mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-24 12:14:32 +01:00
Handle disabled code action (#1115)
* handle disabled code action * enable disabledSupport capability Co-authored-by: hrsh7th <hrsh7th@gmail.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user