Ⅰ. 插件描述
Language Server Protocol snippets in vim using vim-lsp and UltiSnipsⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'thomasfaingnaert/vim-lsp-ultisnips'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'thomasfaingnaert/vim-lsp-ultisnips'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'thomasfaingnaert/vim-lsp-ultisnips'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/thomasfaingnaert/vim-lsp-ultisnips
Ⅳ. 文档说明
# vim-lsp-ultisnips
This plugin integrates UltiSnips in vim-lsp to provide Language Server Protocol snippets.
You can use both Vim's built-in omnifunc or asyncomplete.vim for completion.
Demo

Quick Start
This plugin requires UltiSnips, vim-lsp and their dependencies.
If these are already installed and you are using vim-plug, you can simply add this to your vimrc:
Plug 'thomasfaingnaert/vim-lsp-snippets'
Plug 'thomasfaingnaert/vim-lsp-ultisnips'Otherwise, you can install these using vim-plug as well:
Plug 'SirVer/ultisnips'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'thomasfaingnaert/vim-lsp-snippets'
Plug 'thomasfaingnaert/vim-lsp-ultisnips'Disable for specific language servers
By default, snippet integration is enabled for all language servers. You can disable snippets for one or more servers manually as follows:
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp', 'cc'],
\ 'config': { 'snippets': 0 }
\ })Example Configuration (using omnifunc)
call plug#begin()
Plug 'SirVer/ultisnips'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'thomasfaingnaert/vim-lsp-snippets'
Plug 'thomasfaingnaert/vim-lsp-ultisnips'
call plug#end()
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
if executable('clangd')
augroup vim_lsp_cpp
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp', 'cc'],
\ })
autocmd FileType c,cpp,objc,objcpp,cc setlocal omnifunc=lsp#complete
augroup end
endif
set completeopt+=menuone