0

I installed ternjs_for_vim plugin but can't figure out how to use it properly. RTFM didn't help. What I get is list random JS-methods in the omni-completion. But things like completing for Node.JS modules doesn't work. For example if I type:

var fs = require('fs');
fs.

and after . there is no relevant completion (like methods readFile, readFileSync etc.)

Here is my .tern-project file:

{
    "libs": [
        "underscore",
        "jquery"
    ],
    "plugins": {
        "node": {}
    }
}
1
  • 1
    Thanks for removing the duplicate submission on SO! (You can still post there in a few days if there's no progress here, though this beta site gets quite some attention in the moment.) Mar 11, 2015 at 14:18

2 Answers 2

1

The documentation states (emphasis added):

In JavaScript files, the package will hook into omni completion to handle autocompletion

Omni completion doesn't automatically get triggered. It has to be manually invoked using the key sequence <C-x><C-o> in insert mode. Then you can use various keys to navigate the resulting completion menu and select the completion you want. For example, <C-y> will accept the completion and <C-e> aborts the completion leaving you with the original text.

1
  • I asked about other thing. Omni completion worked fine at that moment. But content of popup window was almost useless. Mar 11, 2015 at 15:35
0

Actually, there was a problem in my .vimrc config.
A long time ago I created some settings regarding Omni completion and forgot about them. So I just deleted this lines from my config:

set ofu=syntaxcomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete

and everything works like a charm now.

2
  • 1
    You shouldn't have to manually define those autocmds. If you add filetype plugin on to your vimrc, then they should be automatically set.
    – jamessan
    Mar 11, 2015 at 15:37
  • @jamessan Yes, It is my very old config and there was some junk in it from that time when I started to learn vim. Hope my config without any issues anymore. Thank you for pointing on this. Mar 11, 2015 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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