Skip to content

Tern Javascript Completion

Iury O. G. Figueiredo edited this page Oct 6, 2019 · 3 revisions

Autocompletion for javascript using ternjs.

ternjs-screenshot-0

Install

The plugin depends on:

https://github.com/ternjs/tern

You can install it with:

npm -g install tern

Once you have tern installed then place the code in your extra plugins action:

from vyapp.plugins.ternjs.completer import JavascriptCompletion 
JavascriptCompletion.PATH = 'tern'
JavascriptCompletion.PORT = 1234
autocall(JavascriptCompletion)

Notice the class attributes PATH and PORT correspond to where tern is installed and to the port that you want the tern server to run on.

Once it is configured properly then you can press:

<Control-period>

In INSERT mode for getting the dialog with possible completions :)

Note: It will create a .tern-config file in your ~/ directory that can be used for configuring ternjs.

The ~/.tern-config file can be used to configure additional plugins for tern.

{
  "libs": [
    "browser",
    "jquery"
  ],
  "loadEagerly": [
    "importantfile.js"
  ],
  "plugins": {
    "requirejs": {
      "baseURL": "./",
      "paths": {}
    },
    "node": {}
  }
}

Note: In case tern terminates abnormally it leaves a ~/.tern-port even when the daemon is not running. It is necessary to remove such a file otherwise autojs will raise connection error issues then fail to get completions.

Clone this wiki locally