Skip to content

Commit

Permalink
Improve checking for 'completionProvider' (#1574)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorenar authored Sep 22, 2024
1 parent 356254d commit 04428c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 4 additions & 0 deletions autoload/lsp/capabilities.vim
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ function! lsp#capabilities#get_code_action_kinds(server_name) abort
return []
endfunction

function! lsp#capabilities#has_completion_provider(server_name) abort
return s:has_provider(a:server_name, 'completionProvider')
endfunction

function! lsp#capabilities#has_completion_resolve_provider(server_name) abort
return s:has_provider(a:server_name, 'completionProvider', 'resolveProvider')
endfunction
Expand Down
3 changes: 1 addition & 2 deletions autoload/lsp/omni.vim
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ endfunction
function! s:find_complete_servers() abort
let l:server_names = []
for l:server_name in lsp#get_allowed_servers()
let l:init_capabilities = lsp#get_server_capabilities(l:server_name)
if has_key(l:init_capabilities, 'completionProvider')
if lsp#capabilities#has_completion_provider(l:server_name)
" TODO: support triggerCharacters
call add(l:server_names, l:server_name)
endif
Expand Down
6 changes: 1 addition & 5 deletions autoload/lsp/ui/vim/completion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ function! s:resolve_completion_item(completion_item, server_name) abort
endif

" check server capabilities.
let l:capabilities = lsp#get_server_capabilities(a:server_name)
if !has_key(l:capabilities, 'completionProvider')
\ || type(l:capabilities['completionProvider']) != v:t_dict
\ || !has_key(l:capabilities['completionProvider'], 'resolveProvider')
\ || !l:capabilities['completionProvider']['resolveProvider']
if !lsp#capabilities#has_completion_resolve_provider(a:server_name)
return a:completion_item
endif

Expand Down

0 comments on commit 04428c9

Please sign in to comment.