Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can install plugin, but autocompletion does not work. #175

Open
nurzhanizbassov opened this issue Aug 25, 2017 · 8 comments
Open

Can install plugin, but autocompletion does not work. #175

nurzhanizbassov opened this issue Aug 25, 2017 · 8 comments

Comments

@nurzhanizbassov
Copy link

I installed the plugin tern_for_vim. Followed all the instructions from readme but it doesn't work. I don't have any autocompletion for javascript, the commands :TernDef and :TernDoc are not recognized in vim. I installed the tern server globally using npm and I can launch it in the terminal.

However, if I launch :call tern#Enable() it seems that the plugin gets loaded and I can see :TernDef and :TernDoc commands but still no autcompletion for javascript.

I tried to launch tern with the --verbose option but it did not output anything when I tried to use autocompletion in javascript files.

It seems that there is no communication between vim and the tern server if I understand it correctly.

Here are my plugins in .vimrc file:

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'tmhedberg/SimpylFold'
Plugin 'vim-syntastic/syntastic'
Plugin 'scrooloose/nerdtree'
" Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'kien/ctrlp.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tpope/vim-fugitive'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'nvie/vim-flake8'
" Plugin 'Valloric/YouCompleteMe'
Plugin 'davidhalter/jedi-vim'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'alvan/vim-closetag'
Plugin 'Valloric/MatchTagAlways'
Plugin 'ternjs/tern_for_vim'
Plugin 'lervag/vimtex'

I also setup a .tern-config file in the home directory:

{
    "libs": [
	"ecmascript",
	"browser",
	"jquery"
    ],
    "plugins": {
        "es_modules": {},
	"node": {}
    }
}

I could run ternjs when I set up YouCompleteMe for python autocompletion, but I didn't like it and chose jedi-vim (which is really nice). Now I want to setup javascript autocompletion but without no luck.

Is it possible that the plugin is in conflict with some of my other plugins?

OS: Xubuntu 16.04 LTS

@akkerman
Copy link

I had something similar. Tried adding loadEagerly?
http://ternjs.net/doc/manual.html#configuration

@nurzhanizbassov
Copy link
Author

nurzhanizbassov commented Aug 25, 2017

@akkerman Thanks, for the response. How do you trigger autocompletion. What shortcut?

@chemzqm
Copy link

chemzqm commented Aug 25, 2017

tern hook into omni completition, but your completion plugin may not, you can test whether your omni completion works by use <c-x><c-o>

@EdmundsEcho
Copy link

EdmundsEcho commented Sep 12, 2017

In hopefully what is considered a related note: I can't seem to confirm if the instance of tern started by the vim/nvim plugin is reading the defs files. I cannot find the defs directory for the tern instance the plugin starts. I'm motivated to do so because I have confirmed that tern does not find the third party libraries (react and ecma6) defs when I start the tern server from my z-shell.

Where should I expect to find the defs and plugins directories referenced in the terndocs when I installed tern using tern_for_vim?

Thank you!

@marijnh
Copy link
Member

marijnh commented Sep 12, 2017

Where should I expect to find the defs and plugins directories referenced in the terndocs when I installed tern using tern_for_vim?

They are part of the tern package -- i.e. node_modules/tern/plugin/ under your tern_for_vim if you installed normally.

@EdmundsEcho
Copy link

Perfect. In my case (Mac OS, installing tern the normal, npm i -g tern way that is run by your config spec) the location for both the plugin and defs directories was /usr/local/lib/node_modules/tern/.

I was able to confirm that the globally installed tern server was accessing the required files. To do so, I manually fired up tern in the shell and got rid of any errors by manually copying the required files.

Specifically, I copied from the ternjs/tern github repo the required lib and plugin sources referenced in my .tern-config file.

Knowing what you shared was helpful because while this plugin takes care of the install, I still wanted to know where to put the extra source files that I'm referencing in the .tern-config file.

Am I defeating some project specific capacity/feature? I do know that my set-up is now working at a useful baseline level.

Thank you for your help.

@marijnh
Copy link
Member

marijnh commented Sep 12, 2017

You can also put definition files and plugins in your project—if their name, interpreted as a filename relative to the .tern-project file, exists, that'll be used.

@nurzhanizbassov
Copy link
Author

Sorry for the late reply. My issue was resolved. Here is a link to vim stackexchange - https://vi.stackexchange.com/questions/13348/cannot-setup-tern-for-vim-plugin/13359#13359.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants