nvim: Switch to nvim-lsp
Enabled lsp within nvim and switched completion engine from deoplete to completion-nvim. The completion will be somewhat more barebones for some filetypes until the language servers are set up, but should then (theoretically) carry a lot more features than before. Additionally, we can, over time, add additional code inspection functionality. One change concerns the calling of bibtex cite key completion in pandoc files: Where before the completion would automatically begin after typing an '@', it will now only start on manual completion invocation (c-p/c-n) -- since the completion from my current bibtex file takes a while to load.
This commit is contained in:
parent
28f7f304c1
commit
a79bef6c4d
7 changed files with 114 additions and 67 deletions
59
nvim/.config/nvim/plugin/completion-nvim.vim
Normal file
59
nvim/.config/nvim/plugin/completion-nvim.vim
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
" use completion-nvim for all buffers (not just lsp)
|
||||
autocmd BufEnter * lua require'completion'.on_attach()
|
||||
|
||||
"map <c-p> to manually trigger completion
|
||||
imap <silent> <c-p> <Plug>(completion_trigger)
|
||||
imap <silent> <c-n> <Plug>(completion_trigger)
|
||||
|
||||
" Add <Tab> and <S-Tab> to navigate through popup menu
|
||||
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
||||
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
||||
|
||||
|
||||
" Set completeopt to have a better completion experience
|
||||
set completeopt=menuone,noinsert,noselect
|
||||
|
||||
" Avoid showing message extra message when using completion
|
||||
set shortmess+=c
|
||||
|
||||
" set loop of strategies in descending order
|
||||
let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
|
||||
|
||||
" even when backtracking enable completion
|
||||
let g:completion_trigger_on_delete = 1
|
||||
|
||||
" register new completion engines
|
||||
" (set in rtp/lua/*_complete.lua)
|
||||
"
|
||||
" pandoc citation key completion
|
||||
lua require'completion'.addCompletionSource('bibcite', require'pandoc_complete'.complete_item)
|
||||
|
||||
" only call for specified shortcut, or with completion keys
|
||||
augroup pandocCompletion
|
||||
autocmd!
|
||||
autocmd BufEnter * call SetupPandocCompletion()
|
||||
augroup end
|
||||
fun! SetupPandocCompletion()
|
||||
if &ft =~ 'pandoc'
|
||||
let g:completion_enable_auto_popup = 0
|
||||
let g:completion_trigger_character = ['@\w*']
|
||||
return
|
||||
endif
|
||||
let g:completion_enable_auto_popup = 1
|
||||
let g:completion_trigger_character = ['.']
|
||||
endfun
|
||||
|
||||
" the completion chains for different filetypes
|
||||
" see https://github.com/nvim-lua/completion-nvim/wiki/chain-complete-support
|
||||
let g:completion_chain_complete_list = {
|
||||
\ 'pandoc': [
|
||||
\ {'complete_items': ['bibcite', 'lsp', 'snippet']},
|
||||
\ {'mode': '<c-p>'},
|
||||
\ {'mode': '<c-n>'}
|
||||
\],
|
||||
\ 'default': [
|
||||
\ {'complete_items': ['lsp', 'snippet']},
|
||||
\ {'mode': '<c-p>'},
|
||||
\ {'mode': '<c-n>'}
|
||||
\]
|
||||
\}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
" PLUGIN: DEOPLETE
|
||||
" For async completion
|
||||
" enable deoplete at startup
|
||||
let g:deoplete#enable_at_startup =1
|
||||
|
||||
call deoplete#custom#option( {
|
||||
\ 'camel_case': v:true,
|
||||
\ 'smart_case': v:true,
|
||||
\ 'ignore_case': v:true,
|
||||
\ 'refresh_always': v:true,
|
||||
\ 'max_abbr_width': 0,
|
||||
\ 'max_menu_width': 0
|
||||
\} )
|
||||
|
||||
call deoplete#custom#var('omni', 'input_patterns', {
|
||||
\'pandoc': '@\w*',
|
||||
\})
|
||||
call deoplete#custom#var('omni', 'functions', {
|
||||
\'pandoc': 'pandoc#completion#Complete',
|
||||
\})
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
" PLUGIN: ECHODOC
|
||||
let g:echodoc#type="virtual"
|
||||
let g:echodoc_enable_at_startup=1
|
||||
set splitbelow
|
||||
set completeopt+=menu,menuone,noinsert,noselect
|
||||
set completeopt-=preview
|
||||
autocmd CompleteDone * pclose
|
||||
4
nvim/.config/nvim/plugin/nvim-lspconfig.vim
Normal file
4
nvim/.config/nvim/plugin/nvim-lspconfig.vim
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
" enable python language servers
|
||||
lua require'nvim_lsp'.pyls.setup{}
|
||||
lua require'nvim_lsp'.vimls.setup{}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
" PLUGIN: vim-polyglot
|
||||
"
|
||||
" we disable markdown so that every markdown file can be given pandoc type
|
||||
let g:polyglot_disabled = ['markdown']
|
||||
" let g:polyglot_disabled = ['markdown']
|
||||
|
||||
au BufNewFile,BufRead *.{md,mdown,mkd,mkdn,markdown,mdwn} set ft=pandoc
|
||||
au BufNewFile,BufRead *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} set ft=pandoc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue