select preferred action by default in quickpick (#1126)

spec: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction
This commit is contained in:
Linda_pp
2021-03-30 02:30:38 +09:00
committed by GitHub
parent 882376cc66
commit 4d4a908224
2 changed files with 10 additions and 4 deletions

View File

@@ -472,6 +472,7 @@ function! lsp#default_get_supported_capabilities(server_info) abort
\ 'valueSet': ['', 'quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source', 'source.organizeImports'],
\ }
\ },
\ 'isPreferredSupport': v:true,
\ 'disabledSupport': v:true,
\ },
\ 'codeLens': {

View File

@@ -94,10 +94,15 @@ function! s:handle_code_action(ctx, server_name, command_id, sync, query, bufnr,
endif
for l:code_action in l:code_actions
call add(l:total_code_actions, {
\ 'server_name': l:server_name,
\ 'code_action': l:code_action,
\})
let l:item = {
\ 'server_name': l:server_name,
\ 'code_action': l:code_action,
\ }
if get(l:code_action, 'isPreferred', v:false)
let l:total_code_actions = [l:item] + l:total_code_actions
else
call add(l:total_code_actions, l:item)
endif
endfor
endfor