Fixed source completion, so it automatically changes to turn source switching *off* for pandoc files (to not automatically invoke bibcite generation), and *on* for the rest of files. This was accidentally switched the wrong way round before.
69 lines
2.3 KiB
VimL
69 lines
2.3 KiB
VimL
" 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-n> <Plug>(completion_smart_tab)
|
|
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)
|
|
|
|
" 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
|
|
|
|
" switch between different completion changes when no completions found for
|
|
" current one
|
|
let g:completion_auto_change_source = 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)
|
|
|
|
" in pandoc files, normal completion should only come from buffer sources and
|
|
" bibcite only invoked manually, since it takes long to parse
|
|
augroup pandocCompletion
|
|
autocmd!
|
|
autocmd BufEnter * call SetupPandocCompletion()
|
|
augroup end
|
|
fun! SetupPandocCompletion()
|
|
if &ft =~ 'pandoc'
|
|
let g:completion_auto_change_source = 0
|
|
return
|
|
endif
|
|
let g:completion_auto_change_source = 1
|
|
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': ['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>'}
|
|
\]
|
|
\}
|