nvim: Improve lsp source chaining
Lsp will by default invoke most of its sources simultaneously (one after the other if no completions are found for the first), but this is disabled for pandoc. In pandoc, only the buffer and lsp sources are invoked (the first chain), since bibcite will take a while to compile the cite keys. To invoke bibcite in pandoc, use c-j/c-k when in the completion menu, and they will be calculated. This may be removed if a faster compilation for bibtex citekeys is found.
This commit is contained in:
parent
a79bef6c4d
commit
eaec90379d
5 changed files with 49 additions and 24 deletions
|
@ -9,6 +9,7 @@ aspell-de
|
|||
aspell-en
|
||||
atool
|
||||
barrier
|
||||
bash-language-server
|
||||
bat
|
||||
bc
|
||||
biber
|
||||
|
@ -34,6 +35,7 @@ glances
|
|||
glow
|
||||
gnome-keyring
|
||||
go
|
||||
gopls
|
||||
grub
|
||||
hugo
|
||||
i3-gaps
|
||||
|
@ -90,6 +92,7 @@ psmisc
|
|||
pulsemixer
|
||||
python-black
|
||||
python-jedi
|
||||
python-language-server
|
||||
python-pdfminer.six
|
||||
python-pipx
|
||||
python-pybtex
|
||||
|
@ -115,6 +118,7 @@ surfraw
|
|||
sxhkd
|
||||
systemd-sysvcompat
|
||||
tdrop-git
|
||||
texlab
|
||||
texlive-bibtexextra
|
||||
texlive-fontsextra
|
||||
texlive-formatsextra
|
||||
|
@ -138,6 +142,7 @@ usbutils
|
|||
vagrant
|
||||
vi
|
||||
vifm
|
||||
vim-language-server
|
||||
xcape
|
||||
xclip
|
||||
xorg-xev
|
||||
|
|
|
@ -53,6 +53,7 @@ Plug 'junegunn/fzf.vim'
|
|||
|
||||
Plug 'neovim/nvim-lspconfig' " some commong language server configurations
|
||||
Plug 'nvim-lua/completion-nvim' " simple completion engine built specifically for nvim and lsp
|
||||
Plug 'steelsojka/completion-buffers' " completion source from words found in current buffers
|
||||
Plug 'desmap/ale-sensible' | Plug 'w0rp/ale' " asynchronous linting - might be superseded by lsp or coc.nvim at some point
|
||||
" statusline
|
||||
Plug 'vim-airline/vim-airline'
|
||||
|
@ -189,6 +190,9 @@ set noequalalways
|
|||
" make sure there's always *some* context below cursor
|
||||
set scrolloff=5
|
||||
|
||||
" in .tex files, default to latex over plaintext/context as syntax
|
||||
let g:tex_flavor = "latex"
|
||||
|
||||
" }}}
|
||||
" KEYBINDINGS {{{
|
||||
" ================================================================================
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
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>"
|
||||
|
||||
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
|
||||
|
@ -22,38 +21,49 @@ 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)
|
||||
|
||||
" only call for specified shortcut, or with completion keys
|
||||
" 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_enable_auto_popup = 0
|
||||
let g:completion_trigger_character = ['@\w*']
|
||||
let g:completion_auto_change_source = 1
|
||||
return
|
||||
endif
|
||||
let g:completion_enable_auto_popup = 1
|
||||
let g:completion_trigger_character = ['.']
|
||||
let g:completion_auto_change_source = 0
|
||||
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>'}
|
||||
\ { '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']},
|
||||
\ {'mode': '<c-p>'},
|
||||
\ {'mode': '<c-n>'}
|
||||
\ { 'complete_items': ['lsp', 'snippet']},
|
||||
\ { 'complete_items': [ 'buffers' ] },
|
||||
\ { 'mode': '<c-p>'},
|
||||
\ { 'mode': '<c-n>'}
|
||||
\]
|
||||
\}
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
|
||||
" 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{}
|
||||
|
||||
" requires manual `:LspInstall sumneko_lua`
|
||||
lua require'nvim_lsp'.sumneko_lua.setup{}
|
||||
|
|
|
@ -14,3 +14,4 @@ function watch_file(fname)
|
|||
end
|
||||
vim.api.nvim_command(
|
||||
"command! -nargs=1 Watch call luaeval('watch_file(_A)', expand('<args>'))")
|
||||
|
||||
|
|
Loading…
Reference in a new issue