From 3348222abccb8ed9555cafe6983cf04754340362 Mon Sep 17 00:00:00 2001 From: godbless <26397224+sak96@users.noreply.github.com> Date: Fri, 29 Apr 2022 18:47:29 +0530 Subject: [PATCH] Add CodeAction codeActionLiteralSupport Feature (#4163) * Advertise codeActionLiteralSupport to LSP server Without this, rust-analyzer doesn't return any code actions. With it, everything works properly. * linter fixes * test cases fixes * Fix underflow of column in position. Special values like for example -1 to denote the end of a line are not supported. [reference](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position) Co-authored-by: Brian Gernhardt --- autoload/ale/codefix.vim | 2 +- autoload/ale/lsp.vim | 5 +++++ test/lsp/test_lsp_startup.vader | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/ale/codefix.vim b/autoload/ale/codefix.vim index 938d9637..34ce3e15 100644 --- a/autoload/ale/codefix.vim +++ b/autoload/ale/codefix.vim @@ -457,7 +457,7 @@ function! s:ExecuteGetCodeFix(linter, range, MenuCallback) abort let [l:end_line, l:end_column] = getpos("'>")[1:2] endif - let l:column = min([l:column, len(getline(l:line))]) + let l:column = max([min([l:column, len(getline(l:line))]), 1]) let l:end_column = min([l:end_column, len(getline(l:end_line))]) let l:Callback = function( diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim index a5c9dff9..acdcdac3 100644 --- a/autoload/ale/lsp.vim +++ b/autoload/ale/lsp.vim @@ -443,6 +443,11 @@ function! s:SendInitMessage(conn) abort \ }, \ 'codeAction': { \ 'dynamicRegistration': v:false, + \ 'codeActionLiteralSupport': { + \ 'codeActionKind': { + \ 'valueSet': [] + \ } + \ } \ }, \ 'rename': { \ 'dynamicRegistration': v:false, diff --git a/test/lsp/test_lsp_startup.vader b/test/lsp/test_lsp_startup.vader index 21c61e13..1f169266 100644 --- a/test/lsp/test_lsp_startup.vader +++ b/test/lsp/test_lsp_startup.vader @@ -194,6 +194,11 @@ Before: \ }, \ 'codeAction': { \ 'dynamicRegistration': v:false, + \ 'codeActionLiteralSupport': { + \ 'codeActionKind': { + \ 'valueSet': [] + \ } + \ } \ }, \ 'rename': { \ 'dynamicRegistration': v:false,