Giter VIP home page Giter VIP logo

tern_for_sublime's Introduction

Tern for Sublime Text

This is a Sublime Text (version 2 and 3) package that provides Tern-based JavaScript editing support.

NOTE: This project is not being actively maintained right now. If you'd be interested in becoming a maintainer, write me or open an issue.

In JavaScript files, the package will handle autocompletion.

The following keys will be bound (in JavaScript files):

alt+.
Jump to the definition of the thing that the cursor is pointing at. If there is no known code location, but it has a documentation URL associated with, this will open the documentation in your browser instead.

alt+,
Jump back to where you were when executing the previous alt+. command.

alt+space
When on a variable, select all references to that variable in the current file.

alt+o
Show quick documentation for the thing that the cursor is pointing at. Documentation includes the type, a description (if available), and documentation url (if available).

Installation

Check out the code in this repository into a subdirectory of your Sublime Text's Packages directory.

cd /path/to/sublime-text-N/Packages
git clone https://github.com/ternjs/tern_for_sublime.git

Next, make sure node.js and npm are installed (Tern is a JavaScript program), and install the depedencies of the package.

cd tern_for_sublime
npm install

On OS X, you might also need to install the Fix Mac Path Sublime plugin to help ST actually find your node binary.

You should be all set now.

Configuration

The plugin will load its settings from Tern.sublime-settings (found in Preferences > Package Settings > Tern), and recognized the following settings:

tern_argument_hints (boolean, defaults to false)
Whether to show argument hints (May impact responsiveness on slow machines or big projects).

tern_output_style (status, panel, tooltip, defaults to tooltip when available, otherwise status)
status - When status is enabled, the status bar be used to display argument hints for the function call that the cursor is inside, and documentation. Unfortunately, the status bar is tiny and Sublime Text 2 provides no saner way to show these hints.
panel - When panel is enabled, a new panel window opens to show arguments and documentation.
tooltip - (only available on SublimeText build 3070+) When tooltip is enabled, a tooltip below the cursor is used.

tern_argument_completion (boolean, default to false)
Auto complete function arguments (similar to eclipse).
e.g. document.addEv will show completion for addEventListener (fn/2) which completes to document.addEventListener(type, listener). The first argument will be selected. Use tab to select the next argument.

Completions for smaller number arguments are supported.
e.g. in the extreme case, THREE.SphereGeometry has 7 arguments, most of which are optional. THREE.SphG will show completions for SphereGeometry (fn/7), SphereGeometry (fn/6), ... , SphereGeometry (fn/0). Typing 3 (i.e. THREE.SphG3) will select the completion THREE.SphereGeometry (fn/3) which completes to THREE.SphereGeometry(a, b, c).

tern_command (list of strings) The command to execute to start a Tern server. The default is ["node", "/path/to/Packages/tern_for_sublime/node_modules/tern/bin/tern"]. If your node installation lives somewhere that's not in the default path, or your Tern checkout is not where the module expects it to be, you'll want to manually set this option.

tern_arguments (list of strings) An extra set of arguments to pass to the Tern server. For example --no-port-file to suppress the creation of .tern-port files.

Tern uses .tern-project files to configure loading libraries and plugins for a project. See the Tern docs for details.

tern_inhibit_word_completions (boolean, default to false) If true, Prevents Sublime Text from adding its word completions to the completion list after all plugins have been processed. This consists of any word in the current document that is longer than 3 characters.

Automatically Showing Completions

Add {"selector": "source.js", "characters": "."} to your auto_complete_triggers array in the Sublime Text preferences (found in Sublime Text > Preferences > Settings - User) to automatically show completions after a dot is typed following an object name.

Example:

"auto_complete_triggers": [ {"selector": "text.html", "characters": "<"}, {"selector": "source.js", "characters": "."} ]

If you don't have already an item named auto_complete_triggers, just add it after the last one (after adding a comma) like so:

Ensure that your auto_complete preference is set to true. It's enabled by default.

tern_for_sublime's People

Contributors

abester01 avatar akatopo avatar amalj07 avatar atabel avatar bosbyj avatar chigix avatar easyfrog avatar f213 avatar gvn avatar ivovermeer avatar mango1234 avatar marijnh avatar mrusselltombras avatar nickw444 avatar nmaxcom avatar othree avatar pahen avatar subhaze avatar svenheden avatar tansongyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tern_for_sublime's Issues

Sublime 3 crashing with TernJS.

I just installed this package end TernJS following the directions given but Sublime is now crashing.

The console has the following.

SyntaxError: Unexpected token < ( plugin/meteor.js @ 6 : 0 ) ->
error: plugin_host has exited unexpectedly, plugin functionality won't be available until Sublime Text has been restarted

Any ideas??

OK, seems to be a problem with TernJS not this package.. mixed issues by the looks. Removed TernJS and it seems to be good now. Thanks.

Requirejs plugin not working

I'm trying to setup a simple project to test the plugin features, but I'm facing problems to see it working.

I have a simple workspace structure:

.
├── .tern-project
├── main.js
├── myModule.js

My tern configuration is:
.tern-project

{
  "libs": [
    "browser",
    "jquery"
  ],
  "plugins": {
    "requirejs": {
      "baseURL": ".",
      "paths": {}
    }
  }
}

myModule.js

define([], function(){
    return {
        myNumber: 1,
        myString: 'foo'
    };
});

main.js

define(['myModule'],function(myModule){
    myModule.
});

I'm not getting hints from tern, I'm not sure if I'm doing something wrong or this could be a bug.

Thanks

nodeJS autocompletion issues

How to add node modules for auto completion with '.' (dot) as auto completion trigger ? Is there a quick way ?

reverse `Region`s may not get handled properly

The plugin is unaware of the fact that a Region's a is not necessarily a lower number than its b. For reverse selections, a > b holds. (Ignoring the = case here, since it doesn't make a difference.)

Is this worth fixing?

No subprocess.check_output in the Sublime 2.0 subprocess module

The subprocess module in Sublime Text 2.0 build 2217 doesn't have the check_output function.

This causes a problem with the tern.py script, which errors out with an error on line 474 of the tern.py script.

This means that it is not possible to install the plugin using the tern.py script.

It seems that all the plugin python files always run with Python 2.6 in Sublime Text 2. The check_output wasn't introduced until 2.7 according to the Python docs.

Gives error when started typing

I have used the instructions on the readme. npm install passed without errors.

When I try to type in a js file the following pop-up appears:

error: <urlopen error timed out>

No further indications are provided, then again when I start typing this happens again and again.

The following config is used (via .tern-project in the main folder of the project):

{
  "loadEagerly": [
    "/home/peterj/Documents/Projects/closure/library/closure/goog/*/*.js",
    "/home/peterj/Documents/Projects/closure/library/closure/goog/base.js"
  ],
  "dontLoad": [
    "/home/peterj/Documents/Projects/closure/library/closure/goog/*/*_test.js"
  ]
}

No further configuration is used.

De-facto this prevent me from using it at all.

System is Linux with working npm and node.

Support for ES6 object literal shorthand

By using the node require along with esnext and browserify, the engine does not recognise this pattern:

var a = 'a';
var b = 'b';
module.exports = {
a,
b
}

but does recognise this

module.exports = {
a: a,
b: b,
}

I'm guessing there needs to be an overhaul for several ES6 features, with this being one of them.

tern_command doesn't like nvm

I've been trying to get tern_command to work with node installed via npm and it doesn't seem to like it. I get the following in the sublime console:

Traceback (most recent call last):
  File "./sublime_plugin.py", line 210, in on_deactivated
  File "./sublime_plugin.py", line 154, in run_timed_function
  File "./sublime_plugin.py", line 209, in <lambda>
  File "./tern.py", line 25, in on_deactivated
  File "./tern.py", line 290, in send_buffer
  File "./tern.py", line 130, in server_port
  File "./tern.py", line 143, in start_server
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

I've set 'tern_command' to the following in my Preferences.sublime-settings:

"tern_command": [
    "~/.nvm/v0.8.23/bin/node"
]
"tern_command": [
    "/Users/larrygordon/.nvm/v0.8.23/bin/node"
]
"tern_command": [
    "node"
]

Please note that I've also tried the above 3 configurations adding a 2nd item to the list which is a full path to the tern script:

"tern_command": [
    "/Users/larrygordon/.nvm/v0.8.23/bin/node",
    "/Users/larrygordon/Library/Application Support/Sublime Text 2/Packages/tern_for_sublime/node_modules/tern/bin/tern"
]

At the command prompt in iTerm I get the following:

which node
/Users/larrygordon/.nvm/v0.8.23/bin/node

I'm using oh-my-zsh and my .zshrc has the following to source nvm:

[[ -s "$HOME/.nvm/nvm.sh" ]] && . "$HOME/.nvm/nvm.sh"

I can get it to work by excluding tern_command from my Preferences.sublime-settings if I add a symbolic link to node like so:

ln -s /Users/larrygordon/.nvm/v0.8.23/bin/node /usr/local/bin/node

Error: Could not find a definition

With the following code sample, placing my cursor in the middle of the function doSomething on line 4 foo.doSo[cursor here]mething('one', 'two'); hitting alt+. returns Error: Could not find a definition

function Thing(){}
Thing.prototype.doSomething = function(arg1, arg2) {};
var foo = new Thing();
foo.doSomething('one', 'two');

tern_for_sublime doesn't fully work (ecma5, browser, jquery)

After the install I can't get e.g. browser support to work. These examples do not work:

document.body.
// -> completion (e.g. addEventListener) does not work

$("form").on("click", selector, data, function(e) {
    // -> completion (e.g. event functions) does not work
});

Display tern_argument_hints in the popup

Is it possible to display the argument hints and return values in the popup? Right now, the string that displays on the small bottom panel is not very intuitive.

There are two alternatives to this:
a) Display the arguments and return values at the same time as the function suggestion is being displayed in the tooltip.
b) Display the arguments and return values when the user enters the parenthesis, just like it works now, except that the values are displayed in the status panel.

Advanced example doesn't work in Sublime

Advanced example from the main demo doesn't work in Sublime. That is the following one:

// And a little more advanced code...

(function(exports) {
  exports.randomElt = function(arr) {
    return arr[Math.floor(arr.length * Math.random())];
  };
  exports.strList = "foo".split("");
  exports.intList = exports.strList.map(function(s) { return s.charCodeAt(0); });
})(window.myMod = {});

var randomStr = myMod.randomElt(myMod.strList);
var randomInt = myMod.randomElt(myMod.intList);

After typing myMod.^ I'm not getting any Tern's completion (there's the default word completion).

I'm using Tern 0.4.0. Thanks.

Proxy support

Just a heads up...

When I make a new *.js file and press 'a', I get this error message from what looks like my corporate proxy server:

tern_for_sublime-proxy-erro

IIRC, Package Control seems to use the system proxy settings correctly out of the box.

I'm not really sure what is going on here as I can't see the <body> of the error message.

Mysterious error "

I was working on a file when this alert kept popping up:
Mysterious Alert

I tracked it down to tern_for_sublime, and this particular bit of code:

return {
    //
    a: ''
}

Note: That is an invalid return statement, outside of a function.

If you copy that into a sublime js window, any time an autocomplete menu would pop up, you get that alert instead.

If you remove the return, the comment inside the object, or the object's property, it works normally. Also if the property is defined before the comment, there is no issue.

I checked to see if acorn throws an error with the same code but it seemed to parse it without a problem.

Configuration for YUI 3

Hi, I just installed this plugin for SubLime 2, but trying hard to get this work with YUI 3 JavaScript Library. When I press . it just lists the content in the file and not the actual API list of the YUI object.

I'm very new to tern and appreciate if someone please help me on how to configure this plugin to work with YUI3. Thanks in advance!

.tern-port files

If there was a way to not create .tern-port files it would make using this a lot easier.

It's annoying for my git flow to have git status filled with .tern-port files

Insert arguments when calling a function

Is it possible to automatically insert function arguments when entering the parenthesis on a function that is going to be called? Right now there is an implementation that hints of the arguments the moment you enter the parenthesis, but it would be very handy to automatically insert them and jump into the selections of the arguments to directly edit the names. The current implementation that hints of the arguments and the possible types has great functionality, but isn't very useful as the panel is barely visible.

/**
 * @param {number} arg1
 * @param {Object} arg2
 */
fun(${1:arg1}, ${2:arg2}...) {}

I've tried implementing this by hacking render_argument_hints(*args) at line 398 that intends to display the function argument hints. It worked fairly ok, until I realized it needs some sort of context. If a new function is being created, inserting the message that is being hinted is wrong. This is also breaks when you try to edit a functions parameters, it simply inserts them again.

On a side note, would it be possible to implement this auto-insertion for object literals passed to functions (sometimes as optional parameters)? I've tried, and Tern, can read the types of a object literal if annotated with a specific JSDoc format.

Example:

/**
 * This format CANT be read, although it's a little more readible in some situations
 *  @param  {Object} obj
 *  @param  {obj.hello} hello  optional argument to hello
 */
function fn1(obj) {
    // body...
}

/**
 *  This format CAN be read, but it would be great if the arguments could be auto-inserted on a function call
 *  @param  {{a: number, b: string}} obj
 */
function fn2(obj) {
    // body...
}

Not working for Sublime Text 3

Installed this via Packages Control ( Also tried manually ) but it always says "It appears Tern has not been installed...".

I think it's because how ST3 handles packages now.

Node plugin not properly working

I have configured a small Node application to test the Node plugin. Here is my isolated case.

If I try to jump to the definition of a property on a dependency, i.e. require('./test').foo, Tern reports "Could not find a definition."

Autocompletion doesn't seem to work for the required module either (see index.js).

In spite of this, if I do require('util'), autocompletion does appear to work.

"Jump to definition" does not work with RequireJS modules

I am using the RequireJS plugin that comes with Tern. Although autocomplete is working for AMD dependencies, I cannot jump to the AMD definition. It simply takes me to the function parameter that references the dependency in the current module.

Not sure if this is an issue with this package or something more. Please advise.

Non descriptive error with double period

image

Whenever I have something like window.body, and place the cursor after window (and before the period) and then type another period I get the error message in the screenshot. There is no output in the console.

Completion performance

I'm using tern and this plugin on Windows, and I noticed a considerable lag after entering two characters (before completion comes up).

When you start typing a sequence of charactes, the first one appears instantly, but on the second character, the editor freezes momentarily and it takes around 1-2 seconds for the other typed characters and the completion to appear. Re-typing these same two characters again works instantly, probably because of some caching mechanism.

I realize this may be caused by other plugins installed, here's the relevant ones that run alongside tern:

  • SublimeLinter 3 + JSHint
  • BracketHighlighter
  • Color Highlighter
  • Alignment
  • JavaScript & Node.js Snippets

How to setup Tern for sublime for meteor.js

I have been able to download and use tern_for_sublime and for vanilla JavaScript auto-completion and jump to definition works properly. In the tern_for_sublime package directory I've added a folder named plugins and added the meteor.js auto-completion plugin from Slava\tern-meteor.

In my meteor.js project, I have the following .tern-project file

 {
    "libs": ["browser", "underscore", "jquery"],
    "exclude": [".meteor/**", "node_modules/**"],
    "plugins": {
        "meteor": {}
    }
 }

So what I need help with is to check if the contents of this .tern-project file are correct and if what I've done by placing the meteor.js file in the package's folder also correct.

With this I'm able to see auto-completion but I'm unable to use the alt+. to jump to definition. I feel after two day of toiling with IDE's/Texteditors to fit my needs, I'm very close to solving my problem and I need your help to do that.

Thanks.

Taking too long in `on_deactivated`

I've just tried installing this and I keep getting an error that say:

A plugin (tern) may be making Sublime Text unresponsive by taking too long (1s) in its on_deactivated callback

Is there any way the work done in that function could be made asynchronous so as to prevent this problem?

installing using package control generates and error (sublime2/win7)

Installing this with Sublime's package control "install package" by selecting "tern_for_sublime" generates the error "it appears Tern has not been installed, would you like tern_for_sublime to try and install it?". Letting it do so generates the error "installation failed, try doing npm install manually in C:...\Sublime Text 2\packages\tern_for_sublime". However, package control lists two packages when searching for tern: TernJS and tern_for_sublime, and installing the first rather than the second works just fine. Does the installation by term_for_sublime us an alternative installation method? (if so, would it make sense to delegate to package control, since that seems to work fine?)

Customizable scopes for completions

I guess this is more of an enhancement request but it would be nice to allow completions within <script/> when editing HTML files.

Another plus would be having the ability to turn of completions when editing within quotes.

I can send a PR if you're interested.

term_for_sublime does not work on win8.1 x64 FileNotFoundError

ST3 build 3065 (32bit)

DPI scale: 1
startup, version: 3065 windows x32 channel: stable
executable: /D/Programs/SublimeText3/sublime_text.exe
working dir: /D/Programs/SublimeText3
packages path: /D/Programs/SublimeText3/Data/Packages
state path: /D/Programs/SublimeText3/Data/Local
hardware concurrency: 8
zip path: /D/Programs/SublimeText3/Packages
zip path: /D/Programs/SublimeText3/Data/Installed Packages
found 5 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 3 files for base name Main.sublime-menu
loading bindings
loading pointer bindings
found 1 files for base name Default.sublime-theme
theme loaded
app ready
startup cache, total files: 174 cache hits: 174
pre session restore time: 0.0609922
startup time: 0.0799922
first paint time: 0.0809922
launching: /D/Programs/SublimeText3/plugin_host.exe
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin Color Highlighter.ColorHighlighter
reloading plugin Color Highlighter.colors
reloading plugin Package Control.Package Control
reloading plugin tern_for_sublime.tern
loaded 837 snippets
plugins loaded
Traceback (most recent call last):
File "./subprocess.py", line 1112, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Programs\SublimeText3\sublime_plugin.py", line 157, in on_api_ready
m.plugin_loaded()
File "D:\Programs\SublimeText3\Data\Packages\tern_for_sublime\tern.py", line 531, in plugin_loaded
subprocess.check_output(["npm", "install"], cwd=plugin_dir)
File "./subprocess.py", line 576, in check_output
File "./subprocess.py", line 824, in init
File "./subprocess.py", line 1118, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
Package Control: Skipping automatic upgrade, last run at 2014-12-21 08:16:09, next run at 2014-12-21 09:16:09 or after

tern_for_sublime failed to install Tern on Windows 7

Hi

Sublime Text 3 (on Windows 7) keeps complaining that Tern has not been installed even though I have selected the option to install it automatically by tern_for_sublime.

There are some errors shown in the Sublime Text console:

DPI scale: 1.25
startup, version: 3059 windows x64 channel: stable
executable: /C/Program Files/Sublime Text 3/sublime_text.exe
working dir: /C/Program Files/Sublime Text 3
packages path: /C/Users/hezjing/AppData/Roaming/Sublime Text 3/Packages
state path: /C/Users/hezjing/AppData/Roaming/Sublime Text 3/Local
hardware concurrency: 4
zip path: /C/Program Files/Sublime Text 3/Packages
zip path: /C/Users/hezjing/AppData/Roaming/Sublime Text 3/Installed Packages
found 4 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 2 files for base name Main.sublime-menu
loading bindings
loading pointer bindings
found 1 files for base name Default.sublime-theme
theme loaded
app ready
wrote startup cache, added files: 3 orphaned files: 0 total files: 151 cache hits: 148
pre session restore time: 0.149348
using gamma: 1.9 (err: 81.5966)
startup time: 0.189348
first paint time: 0.192348
launching: /C/Program Files/Sublime Text 3/plugin_host.exe
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin Package Control.Package Control
loaded 837 snippets
reloading plugin tern_for_sublime.tern
plugins loaded
Traceback (most recent call last):
File "X/subprocess.py", line 1090, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 157, in on_api_ready
m.plugin_loaded()
File "C:\Users\hezjing\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 495, in plugin_loaded
subprocess.check_output(["npm", "install"], cwd=plugin_dir)
File "X/subprocess.py", line 571, in check_output
File "X/subprocess.py", line 818, in init
File "X/subprocess.py", line 1096, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
Package Control: Skipping automatic upgrade, last run at 2014-04-09 03:26:35, next run at 2014-04-09 04:26:35 or after

Do you have any idea of what is wrong here?

No Code Completion

As an update to my post below, perhaps I'm just misunderstanding what's supposed to work, because TernJS seems to operate the same way.

I'm basing this upon being similar to http://ternjs.net/doc/demo.html .

For example if I type "conso" and hit ctrl-space, I get "No available completion".

I've also tried inside a project that contains hundreds+ files. This is what some of my console output looks like:

Reloading plugin C:\Users\chris.CFWEBTOOLS\AppData\Roaming\Sublime Text 2\Packages\tern_for_sublime\tern.py

When I hit ctrl+. the definitions from MDN do appear on some.

This is on a Windows 7 machine.

I do get a plugin (tern)... taking too long (1s) in its on_deactivated callback as well.

It appears node.js is working okay because the SublimeLinter for javascript is working correctly.

follow require statements

It would be cool if tern followed require statements

In the expression var Quiz = require("placement-quiz/quiz-state")

If I have my cursor over the u in Quiz and hit alt+. it would be more useful if it opened the quiz-state file and then went to the module.exports declaration then if it jumped my cursor to just before Quiz

Type-based auto complete

Hi,
does the plugin support the type based autocomplete of tern? E.g. when I have a string, it shows me all string functions on autocomplete.
I tried it, but it said "no completions available" in the statusbar

Argument hints

Hi,

First of all I want to thank you, @marijnh, for a fantastic job with ternJS, it's awesome (and I can't wait for ES6 support, I will gladly fund it).

However, I have some problem to get argument hints for function call, see my gif:

pkvhuzmadc

Do I miss something?
My Preferences.sublime-settings contains the following lines:

"tern_command": [
    "/usr/local/bin/node",
    "/absoult_path_to/Packages/tern_for_sublime/node_modules/tern/bin/tern"
],
"tern_argument_hints": true,

My .tern-project:

{
  "plugins": {
    "doc_comment": {
      "fullDocs": true
    }
  }
}

In brackets I get the following (expected) result:
yrgovnvgs0

Parsing issue.

This is very similar to #36 (Mysterious error ") except it's caused by extra parentheses in regex literals:

var test = /)/

Docs Issue for "tern_command"

tern_command (list of strings) The command to execute to start a Tern server. The default is ["node" "/path/to/Packages/tern_for_sublime/node_modules/tern/bin/tern"].

so, ["node" "/path/to/Packages/tern_for_sublime/node_modules/tern/bin/tern"] is not valid JSON... is this an array and a comma is missing or some other format?

TypeError: coercing to Unicode: need string or buffer, list found

I can't get tern_for_sublime working on Sublime Text 2 (which I think is running Python 2.6?), Windows 7 x64 SP1. I've installed tern through npm install -g tern, and set the paths as necessary in my user settings:

  "tern_command": "c:\\users\\jevon\\appdata\\roaming\\npm\\tern",
  "auto_complete_triggers": [ {"selector": "text.html", "characters": "<"}, {"selector": "source.js", "characters": "."} ]

When I try to edit a Javascript file or get an autocomplete dialog, the console shows errors:

Traceback (most recent call last):
  File ".\sublime_plugin.py", line 236, in on_query_completions
  File ".\tern.py", line 54, in on_query_completions
  File ".\tern.py", line 356, in ensure_completions_cached
  File ".\tern.py", line 277, in run_command
  File ".\tern.py", line 151, in server_port
  File ".\tern.py", line 163, in start_server
TypeError: coercing to Unicode: need string or buffer, list found
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 210, in on_deactivated
  File ".\sublime_plugin.py", line 154, in run_timed_function
  File ".\sublime_plugin.py", line 209, in <lambda>
  File ".\tern.py", line 33, in on_deactivated
  File ".\tern.py", line 21, in on_deactivated
  File ".\tern.py", line 322, in send_buffer
  File ".\tern.py", line 151, in server_port
  File ".\tern.py", line 163, in start_server
TypeError: coercing to Unicode: need string or buffer, list found

From what I can tell it's trying to convert tern_arguments, which is an empty list (defined on line 16 of tern.py), into a string and failing. Removing the tern_arguments solves the error and Tern works.

Update Readme installation section

The plugin is currently available through package control so the installation part could be updated to include that info.

P.S. I will try to send a PR tomorrow but if somebody would like to proceed with that, feel free!

How to force a plugin to retrieve a given's API textual documentation and signature from the Tern server.

I had no luck to find this through the documentation itself, so wonder how I can set up a given plugin, let's angularjs to retrieve a given API documentation. E.g. compare the nice Array.push() textual documentation below from the demo:

screen shot 2014-10-26 at 11 33 23

with the empty $scope.$broadcast() one inside my editor.
screen shot 2014-10-26 at 11 36 26

Also the same question about the libs entries inside .tern-project like ecma5 or browser.

And is it possible to see the signature as well? Something like Array.push(element1, ..., elementN)?

Thanks!

Can not use dollar sign prefix for functions

If you use a $ to prefix functions the completion will not complete just leaving you with the $

Example:

{
  "!name": "mylibrary",
  "!def": {
    "point": {
      "x": "number",
      "y": "number"
    }
  },
  "$MyConstructor": {
    "!type": "fn(arg: string)",
    "staticFunction": "fn() -> bool",
    "prototype": {
      "property": "[number]",
      "clone": "fn() -> +MyConstructor",
      "getPoint": "fn(i: number) -> point"
    }
  },
  "MyConstructor": {
    "!type": "fn(arg: string)",
    "staticFunction": "fn() -> bool",
    "prototype": {
      "property": "[number]",
      "clone": "fn() -> +MyConstructor",
      "getPoint": "fn(i: number) -> point"
    }
  },
  "someOtherGlobal": "string"
}

In the above example MyCon will correctly completed to MyConstructor, however, $MyCon will complete to $

Lazy file loading

I have a test folder with 2 files: a.js and b.js:
a.js contents:

var obj_a = {
    test_a: function() {}
};

b.js contents:

var obj_b = {
    test_b: function() {}
};

I open those two files, enter obj_ in a.js and there's not obj_b: pic. 1

Ok, I switch to b.js. It has obj_a in auto-completion list: pic. 2
Sometimes there are objects from both files in auto-completion list in file a.js, and there's only obj_b in b.js, like b.js was loaded in tern and a.js wasn't. It seems like I have to show some activity in one file for it to load in tern, like entering a text, trigger auto-completion or saving it. I don't know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.