Type inference engine
RequireJS support According to the documentation, this tool can use dependency management system, described in requirejs system.
- Using docblock, this tool with add contextual documentation in a completion list.
Plugin mechanism - plugins extend engine features and give support for hints for popular js libraries. You can find full list of plugins here: https://www.npmjs.com/browse/keyword/tern
Installation and integration with ViM
In case of old good ViM installation is very easy, assuming that you are using pathogen plugin. Whole process is following:
1. If you haven't installed nodejs: sudo apt-get install nodejs
2. In directory ~/.vim/bundle/ download plugin from github: git clone https://github.com/marijnh/tern_for_vim
3. In subdirectory of downloaded plugin (~/.vim/bundle/tern_for_vim/) install tern and its dependencies: npm install
It ends installation of plugin. You need also to create configuration for your project in form of file .tern-project in main directory of project. For example, such file for one of my Drupal projects looks like follow:
In this case, we loaded informations about jQuery, Underscore libraries and browser (built-in API available in modern browsers). We assume, that in addition to those libraries (and file loaded in a editor), we load always files from misc subdirectory (section loadEagerly).
You can find more configuration details here. After setup, code completion in ViM should work flawless. In case of ViM, you have to use CTRL-X CTRL-O shortcut for code completion. You can also can use awesome youcompleteme.
There are few additional features, that are out of scope of this blog post:
- Intelligent re-factorization
- Detection of references to various code elements like, function, methods etc.
- Displaying documentation of selected code element.
If you want to know more details, check vim plugin documentation.