ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

tern_for_sublime

by ternjs ALL

Sublime Text package adding Tern support

Details

  • 2019.11.28.08.50.52
  • github.​com
  • github.​com
  • 3 years ago
  • 3 hours ago
  • 9 years ago

Installs

  • Total 37K
  • Win 15K
  • Mac 15K
  • Linux 7K
Jul 1 Jun 30 Jun 29 Jun 28 Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17
Windows 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 2 0 1 6 3 1 2 0 1 1 0 1 0 0 1 1 1 1 1 0 0 0 0 0 1 2 0
Mac 0 0 0 0 0 0 0 0 0 0 2 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Linux 0 0 0 0 0 0 0 0 2 0 0 1 0 0 0 0 1 2 1 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 3 0 0 1 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

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.