nvim: Add workaround for completion-nvim bug

completion-nvim chaining seems to not allow multiple `triggered_only`
definitions in the same linked chain of various completion options. In
other words, when in pandoc files there is no possibility to have
completion for lsp and buffer words by default and for paths on pressing
`/`, as well as bib-citekeys on pressing `@`.

Doing so requires automatically switching sources, which in turn is of
little use when writing pandoc normally and it hangs every couple of
seconds to recompile the bibtex list as soon as it runs out of buffer
words to complete.

Ideally, the completion-nvim bug should be looked at, but also the
bibtex completion possibly completely turned into a lua parsed
completer, so it does not depend on `vim-pandoc` and its (presumably)
slower vimscript implementation.
This commit is contained in:
Marty Oehme 2020-10-08 10:34:45 +02:00
parent 5dde9db2e4
commit cd52e47e22
Signed by: Marty
GPG key ID: B7538B8F50A1C800
3 changed files with 37 additions and 28 deletions

View file

@ -7,7 +7,7 @@ imap <silent> <c-p> <Plug>(completion_smart_s_tab)
" switch between completion sources manually with c-j/c-k
" only do so if popupmenu is visible, otherwise normal function
imap <silent> <c-j> <Plug>(completion_next_source)
imap <silent> <c-k> <Plug>(completion_previous_source)
imap <silent> <c-k> <Plug>(completion_prev_source)
" Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect
@ -47,23 +47,27 @@ endfun
" the completion chains for different filetypes
" see https://github.com/nvim-lua/completion-nvim/wiki/chain-complete-support
" BUG for triggered only bibcite completion, see: https://github.com/nvim-lua/completion-nvim/issues/158
let g:completion_chain_complete_list = {
\ 'pandoc': [
\ { 'complete_items': ['buffer', 'lsp', 'snippet']},
\ { 'complete_items': ['bibcite'] },
\ { 'mode': '<c-p>'},
\ { 'mode': '<c-n>'}
\],
\ 'tex': [
\ { 'complete_items': ['buffer', 'lsp', 'snippet']},
\ { 'complete_items': ['bibcite'] },
\ { 'mode': '<c-p>'},
\ { 'mode': '<c-n>'}
\],
\ 'default': [
\ { 'complete_items': ['lsp', 'snippet']},
\ { 'complete_items': [ 'buffers' ] },
\ { 'mode': '<c-p>'},
\ { 'mode': '<c-n>'}
\]
\}
\ 'pandoc': [
\ { 'complete_items': ['buffer', 'lsp', 'snippet']},
\ { 'complete_items': ['path'], 'triggered_only': ['/']},
\ { 'complete_items': ['bibcite']},
\ { 'mode': '<c-p>'},
\ { 'mode': '<c-n>'}
\],
\ 'tex': [
\ { 'complete_items': ['buffer', 'lsp', 'snippet']},
\ { 'complete_items': ['path'], 'triggered_only': ['/']},
\ { 'complete_items': ['bibcite'] },
\ { 'mode': '<c-p>'},
\ { 'mode': '<c-n>'}
\],
\ 'default': [
\ { 'complete_items': [ 'lsp', 'snippet' ]},
\ { 'complete_items': [ 'buffers' ] },
\ { 'complete_items': [ 'path' ], 'triggered_only': ['/'] },
\ { 'mode': '<c-p>'},
\ { 'mode': '<c-n>'}
\]
\}

View file

@ -1,9 +1,12 @@
" enable python language servers
lua require'nvim_lsp'.pyls.setup{}
lua require'nvim_lsp'.vimls.setup{}
lua require'nvim_lsp'.bashls.setup{}
lua require'nvim_lsp'.gopls.setup{}
lua require'nvim_lsp'.texlab.setup{}
lua << END
" requires manual `:LspInstall sumneko_lua`
lua require'nvim_lsp'.sumneko_lua.setup{}
require'nvim_lsp'.pyls.setup{}
require'nvim_lsp'.vimls.setup{}
require'nvim_lsp'.bashls.setup{}
require'nvim_lsp'.gopls.setup{}
require'nvim_lsp'.texlab.setup{}
-- requires manual `:LspInstall sumneko_lua`
require'nvim_lsp'.sumneko_lua.setup{}
END

View file

@ -67,3 +67,5 @@ glyphosate
Monstanto
univseralism
universalisms
CSO
dialogue