yegappan / lsp

Language Server Protocol (LSP) plugin for Vim9
MIT License
458 stars 49 forks source link

omnicompletion of function after opening parentheses #462

Closed Konfekt closed 6 months ago

Konfekt commented 6 months ago

After having passed autoComplete: v:false to LspOptionsSet(), then in Python (or any other language using functions whose arguments are passed inside parentheses), omni-completing

print(

gives

Error found executing function LspOmniFunc:
line   42:
E716: Key not present in Dictionary: "completeItems"

If instead print is completed to print(, then completing print( completes to print(print

yegappan commented 6 months ago

I committed 0f774f942d8dc351661d1609ada97e6e826d71b4 to address this issue. Can you try the latest plugin?

Konfekt commented 6 months ago

Thank you! Now we advanced one line as it spits out

Error found executing function LspOmniFunc:
line   43:
E716: Key missing in Dictionary: "omniCompleteKeyword"
Konfekt commented 6 months ago
# autoload/lsp/completion.vim (line 513)
var prefix = lspserver->get('omniCompleteKeyword', '')

indeed fixes the error

Error found executing function LspOmniFunc:
line   42:
E716: Key not present in Dictionary: "completeItems"

Still, instead of completing print( to print(print rather the popup window of the function arguments could still be shown.

yegappan commented 6 months ago

I am not able to reproduce this issue with a python file and the pylsp language server. Can you attach the language server configuration, LSP plugin configuration, a sample python file and the sequence of steps to reproduce this problem?

Konfekt commented 6 months ago

Calling

vim --clean -u ~/.vim/viminrc

with ~/.vim/viminrc reading

set nocompatible
language messages en_US  " To avoid scrambled non english letters.

let &rtp = '~/.vim/plugged/lsp/' . ',' . &rtp

autocmd VimEnter * source ~/.vim/after/settings/lsp.vim

filetype plugin indent on
syntax on

" options go here
set hidden

with ~/.vim/after/settings/lsp.vim reading

let lspOpts = #{
  \   autoComplete: v:false,
  \ }
call LspOptionsSet(lspOpts)

let lspServers = []
if filereadable($HOME . '/.local/bin/pylsp')
  call add(lspServers, #{name: 'pylsp',
                      \  filetype: 'python',
                      \  path: $HOME . '/.local/bin/pylsp',
                      \  args: ['--check-parent-process', '--verbose']
                      \ })
endif
call LspAddServer(lspServers)

and typing print(<c-x><c-o> inside a *.py file shows the error message

Trovato errore eseguendo function LspOmniFunc:
riga   43:
E716: Chiave assente dal Dizionario: "omniCompleteKeyword"

If instead print<c-x><c-o>(<c-x><c-o> then print( is completed to print(print

yegappan commented 6 months ago

Thanks for the detailed steps. I am able to reproduce the problem now. This is a regression caused by the PR #418. I have committed 0b9bba0ee4eaa84a75d88a0775b3b34dbf42b12d to address this issue. Can you try the latest plugin?

Konfekt commented 6 months ago

Thank you! Now it works without errors and does not insert text when there's nothing to complete.