Handle disabled code action (#1115)

* handle disabled code action

* enable disabledSupport capability

Co-authored-by: hrsh7th <hrsh7th@gmail.com>
This commit is contained in:
Linda_pp
2021-03-21 22:17:51 +09:00
committed by GitHub
parent e889f80f0f
commit a3b58eb7c4
2 changed files with 9 additions and 1 deletions

View File

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

View File

@@ -116,6 +116,13 @@ function! s:handle_code_action(ctx, server_name, command_id, sync, query, bufnr,
" Execute code action.
if 0 < l:index && l:index <= len(l:total_code_actions)
let l:selected = l:total_code_actions[l:index - 1]
if has_key(l:selected, 'disabled')
let l:reason = l:selected['disabled']['reason']
" Avoid the message is overwritten by inputlist() call
redraw
echo 'This action is disabled: ' . l:reason
return
endif
call s:handle_one_code_action(l:selected['server_name'], a:sync, a:bufnr, l:selected['code_action'])
endif
endfunction