Skip to content

Language Server Protocol snippets in vim using vim-lsp and UltiSnips

License

Notifications You must be signed in to change notification settings

thomasfaingnaert/vim-lsp-ultisnips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

GIF 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

About

Language Server Protocol snippets in vim using vim-lsp and UltiSnips

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages