Skip to content

Latest commit

 

History

History
68 lines (57 loc) · 2.5 KB

README.md

File metadata and controls

68 lines (57 loc) · 2.5 KB

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