There isn't much from VS Code I can't reproduce with neovim but working with javascript/node, I am quite jealous of the fact that the autocompletion works with any (or most?) libraries added to the node_modules folder...

Any idea of plugins allowing that? With youcompleteme, deoplete or language server protocol/ternjs based plugins, I've never been able to get it.

Thx!

  • It would be a big win if neovim have the same autocompletion as vscode for javascript (*.js, *.jsx). Surprisingly neovim does excellent job for (TypeScript) *.ts files – Eskinder Nov 12 at 17:41
  • Thx for the info. Can you give me some details on your typescript configuration? Also, I have started testing Language Protocol for Python in neovim (using "ALE" and autozimu's "LanguageClient-neovim"'). The results are much better than for js... – godot Nov 13 at 17:20
  • I tried LanguageClient-neovim. Even though the autocompletion works good for javascript, it takes more than 10 sec for each autocompletion to show up. The only autocompletion that is working for me now in neovim is Typscript and that is by using 'mhartington/nvim-typescript' not for javascript. here is my .vimrc github.com/eskinderg/.rc/blob/master/.vimrc. after you install 'mhartington/nvim-typescript', make sure to invoke :UpdateRemotePlugins. i always forget to do that. Let me know how the "LanguageClient-neovim" is working. – Eskinder Nov 14 at 18:23
  • Also checkout github.com/neoclide/coc.nvim i haven't gotten it to work yet. – Eskinder Nov 14 at 18:23

I have had some success with this plugin: https://github.com/ternjs/tern_for_vim

But it does require some setting up:

  1. After installing the plugin, you need to cd into the plugin folder and run npm install

  2. For each project you work on, you need to create a .tern-project file. (See below)

I also tweak some of the plugin's config in Vim:

" Don't keep locking up Vim (an issue if the codebase is large)
let g:tern_show_argument_hints = 'never'

let g:tern_show_signature_in_pum = 1

I make the K key use Tern to look up documentation:

autocmd BufReadPost  *.js  nnoremap <buffer> K :TernDoc<CR>

Here is an example .tern-project file you can start from:

{
  "ecmaVersion": 7,
  "libs": [],
  "loadEagerly": [
    "app.js",
    "lib/globals.js"
  ],
  "plugins": {
    "node": {
      "dontLoad": "",
      "load": "",
      "modules": ""
    },
    "node_resolve": {},
    "modules": {
      "dontLoad": "",
      "load": "",
      "modules": ""
    },
    "commonjs": {},
    "doc_comment": {}
  },
  "dependencyBudget": 2000
}

The dependencyBudget will stop waiting for a response if Tern cannot provide one quickly. But I have found that the server will continue loading scripts and inferring in the background, so you can wait a while and then try the completion again.

(I have completion on Tab but I can't see where that was configured!)

There are some more examples of .tern-project files here.

  • 1
    Thanks, I have used ternjs in the past, but from what I have seen, it is far from the efficiency and smartness of VS autocompletion... – godot Jun 19 at 22:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.