scr*_*apy 9 javascript vim autocomplete
我以这种方式为js完成安装了tern_for_vim和YouCompleteMe.
1安装节点
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
source ~/.nvm/nvm.sh
nvm install node
Run Code Online (Sandbox Code Playgroud)
2安装tern_for_vim
$ cd ~/.vim/bundle
git clone https://github.com/marijnh/tern_for_vim
Run Code Online (Sandbox Code Playgroud)
3安装YouCompleteMe
cd ~/.vim/bundle/YouCompleteMe
$ ./install.sh --clang-completer --tern-completer
Run Code Online (Sandbox Code Playgroud)
4编辑.tern-project
vim .tern-project
{
"libs": [
"browser",
"underscore",
"jquery"
],
"plugins": {
"node": {}
}
}
Run Code Online (Sandbox Code Playgroud)
现在来vim test.js.
输入document.test.js文件后弹出js完成.

然后vim test.html 在test.html文件中
输入后弹出没有js完成document..
怎么解决?
不幸的是,tern没有正式支持.您可以在已关闭的问题中查看响应
https://github.com/ternjs/tern_for_vim/issues/170
因为用于分离HTML和脚本的解析逻辑尚未实现.这可以作为插件完成,如果你想拍摄它,但它超出了这个存储库的范围.
但是在SO上还有另一个线程可以帮助你
最好的方法是通过JS文件将代码包含在html中,然后编辑JS文件.另外看看其他一些插件/ IDE环境.我也会探讨以下选项
https://github.com/Shougo/deoplete.nvim#install