Skip to content

Language Server Protocol snippets in vim using vim-lsp and neosnippet.vim

License

Notifications You must be signed in to change notification settings

thomasfaingnaert/vim-lsp-neosnippet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vim-lsp-neosnippet

This plugin integrates neosnippet.vim 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 neosnippet.vim, 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-neosnippet'

Otherwise, you can install these using vim-plug as well:

Plug 'Shougo/neosnippet.vim'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'thomasfaingnaert/vim-lsp-snippets'
Plug 'thomasfaingnaert/vim-lsp-neosnippet'

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 'Shougo/neosnippet.vim'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'thomasfaingnaert/vim-lsp-snippets'
Plug 'thomasfaingnaert/vim-lsp-neosnippet'

call plug#end()

imap <expr> <Tab> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<Tab>"
smap <expr> <Tab> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<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

if has('conceal')
    set conceallevel=2 concealcursor=niv
endif

set completeopt+=menuone

About

Language Server Protocol snippets in vim using vim-lsp and neosnippet.vim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •