fix expert lsp stdio and register capability (#5113)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled

* pass --stdio flag to expert lsp server

expert requires --stdio to use stdio transport but the linter
definition launched it without the flag, so the server never
entered lsp mode

* handle client/registerCapability requests from lsp servers

some lsp servers like expert send a client/registerCapability
request after initialization to dynamically register capabilities,
if ale does not respond the server blocks and never processes
further messages like textDocument/didOpen
This commit is contained in:
coriocactus
2026-04-10 15:20:22 +01:00
committed by GitHub
parent b1b027d5e6
commit 6ba798d2e7
4 changed files with 29 additions and 3 deletions

View File

@@ -5,12 +5,12 @@ After:
call ale#assert#TearDownLinterTest()
Execute(should set correct defaults):
AssertLinter 'expert', ale#Escape('expert')
AssertLinter 'expert', ale#Escape('expert') . ' --stdio'
Execute(The executable should be configurable):
let b:ale_elixir_expert_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar')
AssertLinter 'foobar', ale#Escape('foobar') . ' --stdio'
Execute(should set correct LSP values):
call ale#test#SetFilename('../test-files/elixir/umbrella_project/apps/app1/lib/app.ex')

View File

@@ -562,6 +562,30 @@ Execute(workspace/configuration requests should be answered with the connection
unlet! g:sent_responses
runtime autoload/ale/lsp.vim
Execute(client/registerCapability requests should be acknowledged):
let g:sent_responses = []
function! ale#lsp#SendResponse(conn_id, id, result) abort
call add(g:sent_responses, [a:conn_id, a:id, a:result])
endfunction
call ale#lsp_linter#SetLSPLinterMap({'1': {'name': 'expert', 'aliases': [], 'lsp': 'stdio'}})
call ale#lsp_linter#HandleLSPResponse(1, {
\ 'jsonrpc': '2.0',
\ 'id': 12,
\ 'method': 'client/registerCapability',
\ 'params': {
\ 'registrations': [{'id': 'abc', 'method': 'textDocument/didSave'}],
\ },
\})
AssertEqual
\ [[1, 12, v:null]],
\ g:sent_responses
unlet! g:sent_responses
runtime autoload/ale/lsp.vim
Execute(LSP errors should be logged in the history):
call ale#lsp_linter#SetLSPLinterMap({'347': {'name': 'foobar', 'aliases': [], 'lsp': 'stdio'}})
call ale#lsp_linter#HandleLSPResponse(347, {