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
|
aspell-en
|
||||||
atool
|
atool
|
||||||
barrier
|
barrier
|
||||||
|
bash-language-server
|
||||||
bat
|
bat
|
||||||
bc
|
bc
|
||||||
biber
|
biber
|
||||||
|
@ -34,6 +35,7 @@ glances
|
||||||
glow
|
glow
|
||||||
gnome-keyring
|
gnome-keyring
|
||||||
go
|
go
|
||||||
|
gopls
|
||||||
grub
|
grub
|
||||||
hugo
|
hugo
|
||||||
i3-gaps
|
i3-gaps
|
||||||
|
@ -90,6 +92,7 @@ psmisc
|
||||||
pulsemixer
|
pulsemixer
|
||||||
python-black
|
python-black
|
||||||
python-jedi
|
python-jedi
|
||||||
|
python-language-server
|
||||||
python-pdfminer.six
|
python-pdfminer.six
|
||||||
python-pipx
|
python-pipx
|
||||||
python-pybtex
|
python-pybtex
|
||||||
|
@ -115,6 +118,7 @@ surfraw
|
||||||
sxhkd
|
sxhkd
|
||||||
systemd-sysvcompat
|
systemd-sysvcompat
|
||||||
tdrop-git
|
tdrop-git
|
||||||
|
texlab
|
||||||
texlive-bibtexextra
|
texlive-bibtexextra
|
||||||
texlive-fontsextra
|
texlive-fontsextra
|
||||||
texlive-formatsextra
|
texlive-formatsextra
|
||||||
|
@ -138,6 +142,7 @@ usbutils
|
||||||
vagrant
|
vagrant
|
||||||
vi
|
vi
|
||||||
vifm
|
vifm
|
||||||
|
vim-language-server
|
||||||
xcape
|
xcape
|
||||||
xclip
|
xclip
|
||||||
xorg-xev
|
xorg-xev
|
||||||
|
|
|
@ -53,6 +53,7 @@ Plug 'junegunn/fzf.vim'
|
||||||
|
|
||||||
Plug 'neovim/nvim-lspconfig' " some commong language server configurations
|
Plug 'neovim/nvim-lspconfig' " some commong language server configurations
|
||||||
Plug 'nvim-lua/completion-nvim' " simple completion engine built specifically for nvim and lsp
|
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
|
Plug 'desmap/ale-sensible' | Plug 'w0rp/ale' " asynchronous linting - might be superseded by lsp or coc.nvim at some point
|
||||||
" statusline
|
" statusline
|
||||||
Plug 'vim-airline/vim-airline'
|
Plug 'vim-airline/vim-airline'
|
||||||
|
@ -189,6 +190,9 @@ set noequalalways
|
||||||
" make sure there's always *some* context below cursor
|
" make sure there's always *some* context below cursor
|
||||||
set scrolloff=5
|
set scrolloff=5
|
||||||
|
|
||||||
|
" in .tex files, default to latex over plaintext/context as syntax
|
||||||
|
let g:tex_flavor = "latex"
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
" KEYBINDINGS {{{
|
" KEYBINDINGS {{{
|
||||||
" ================================================================================
|
" ================================================================================
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
autocmd BufEnter * lua require'completion'.on_attach()
|
autocmd BufEnter * lua require'completion'.on_attach()
|
||||||
|
|
||||||
"map <c-p> to manually trigger completion
|
"map <c-p> to manually trigger completion
|
||||||
imap <silent> <c-p> <Plug>(completion_trigger)
|
imap <silent> <c-n> <Plug>(completion_smart_tab)
|
||||||
imap <silent> <c-n> <Plug>(completion_trigger)
|
imap <silent> <c-p> <Plug>(completion_smart_s_tab)
|
||||||
|
" switch between completion sources manually with c-j/c-k
|
||||||
" Add <Tab> and <S-Tab> to navigate through popup menu
|
" only do so if popupmenu is visible, otherwise normal function
|
||||||
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
imap <silent> <c-j> <Plug>(completion_next_source)
|
||||||
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
imap <silent> <c-k> <Plug>(completion_previous_source)
|
||||||
|
|
||||||
|
|
||||||
" Set completeopt to have a better completion experience
|
" Set completeopt to have a better completion experience
|
||||||
set completeopt=menuone,noinsert,noselect
|
set completeopt=menuone,noinsert,noselect
|
||||||
|
@ -22,37 +21,48 @@ let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
|
||||||
" even when backtracking enable completion
|
" even when backtracking enable completion
|
||||||
let g:completion_trigger_on_delete = 1
|
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
|
" register new completion engines
|
||||||
" (set in rtp/lua/*_complete.lua)
|
" (set in rtp/lua/*_complete.lua)
|
||||||
"
|
"
|
||||||
" pandoc citation key completion
|
" pandoc citation key completion
|
||||||
lua require'completion'.addCompletionSource('bibcite', require'pandoc_complete'.complete_item)
|
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
|
augroup pandocCompletion
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufEnter * call SetupPandocCompletion()
|
autocmd BufEnter * call SetupPandocCompletion()
|
||||||
augroup end
|
augroup end
|
||||||
fun! SetupPandocCompletion()
|
fun! SetupPandocCompletion()
|
||||||
if &ft =~ 'pandoc'
|
if &ft =~ 'pandoc'
|
||||||
let g:completion_enable_auto_popup = 0
|
let g:completion_auto_change_source = 1
|
||||||
let g:completion_trigger_character = ['@\w*']
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let g:completion_enable_auto_popup = 1
|
let g:completion_auto_change_source = 0
|
||||||
let g:completion_trigger_character = ['.']
|
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
" the completion chains for different filetypes
|
" the completion chains for different filetypes
|
||||||
" see https://github.com/nvim-lua/completion-nvim/wiki/chain-complete-support
|
" see https://github.com/nvim-lua/completion-nvim/wiki/chain-complete-support
|
||||||
let g:completion_chain_complete_list = {
|
let g:completion_chain_complete_list = {
|
||||||
\ 'pandoc': [
|
\ 'pandoc': [
|
||||||
\ {'complete_items': ['bibcite', 'lsp', 'snippet']},
|
\ { '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-p>'},
|
||||||
\ { 'mode': '<c-n>'}
|
\ { 'mode': '<c-n>'}
|
||||||
\],
|
\],
|
||||||
\ 'default': [
|
\ 'default': [
|
||||||
\ { 'complete_items': ['lsp', 'snippet']},
|
\ { 'complete_items': ['lsp', 'snippet']},
|
||||||
|
\ { 'complete_items': [ 'buffers' ] },
|
||||||
\ { 'mode': '<c-p>'},
|
\ { 'mode': '<c-p>'},
|
||||||
\ { 'mode': '<c-n>'}
|
\ { 'mode': '<c-n>'}
|
||||||
\]
|
\]
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
" enable python language servers
|
" enable python language servers
|
||||||
lua require'nvim_lsp'.pyls.setup{}
|
lua require'nvim_lsp'.pyls.setup{}
|
||||||
lua require'nvim_lsp'.vimls.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
|
end
|
||||||
vim.api.nvim_command(
|
vim.api.nvim_command(
|
||||||
"command! -nargs=1 Watch call luaeval('watch_file(_A)', expand('<args>'))")
|
"command! -nargs=1 Watch call luaeval('watch_file(_A)', expand('<args>'))")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue