Supply language_id values to Neovim LSP API

Change logic so ALE's LSP implementation and the Neovim LSP client
retrieve the language_id for language clients at roughly the same time
via the same means. This makes ALE inform the language server what the
language for the language is for clients.
This commit is contained in:
w0rp
2025-03-18 14:05:58 +00:00
parent 4f4d68f153
commit 73b568b071
19 changed files with 65 additions and 41 deletions

View File

@@ -37,24 +37,24 @@ After:
runtime autoload/ale/lsp.vim
Execute(No errors should be thrown if the connection is not initialized):
call ale#lsp#Register('command', '/foo', {})
call ale#lsp#Register('command', '/foo', '', {})
call MarkDocumentOpened()
call ale#engine#Cleanup(bufnr(''))
AssertEqual [], g:message_list
Execute(No messages should be sent if the document wasn't opened):
call ale#lsp#Register('command', '/foo', {})
call ale#lsp#Register('command', '/foo', '', {})
call MarkAllConnectionsInitialized()
call ale#engine#Cleanup(bufnr(''))
AssertEqual [], g:message_list
Execute(A message should be sent if the document was opened):
call ale#lsp#Register('command', '/foo', {})
call ale#lsp#Register('command', '/foo', 'lang', {})
call MarkAllConnectionsInitialized()
call ale#lsp#OpenDocument('command:/foo', bufnr(''), 'lang')
call ale#lsp#OpenDocument('command:/foo', bufnr(''))
call ale#engine#Cleanup(bufnr(''))
" We should only send the message once.
call ale#engine#Cleanup(bufnr(''))
@@ -78,10 +78,10 @@ Execute(A message should be sent if the document was opened):
\ g:message_list
Execute(A message should be sent if the document was opened for tsserver):
call ale#lsp#Register('command', '/foo', {})
call ale#lsp#Register('command', '/foo', 'lang', {})
call ale#lsp#MarkConnectionAsTsserver('command:/foo')
call ale#lsp#OpenDocument('command:/foo', bufnr(''), 'lang')
call ale#lsp#OpenDocument('command:/foo', bufnr(''))
call ale#engine#Cleanup(bufnr(''))
" We should only send the message once.
call ale#engine#Cleanup(bufnr(''))
@@ -94,12 +94,12 @@ Execute(A message should be sent if the document was opened for tsserver):
\ g:message_list
Execute(Re-opening and closing the documents should work):
call ale#lsp#Register('command', '/foo', {})
call ale#lsp#Register('command', '/foo', 'lang', {})
call MarkAllConnectionsInitialized()
call ale#lsp#OpenDocument('command:/foo', bufnr(''), 'lang')
call ale#lsp#OpenDocument('command:/foo', bufnr(''))
call ale#engine#Cleanup(bufnr(''))
call ale#lsp#OpenDocument('command:/foo', bufnr(''), 'lang')
call ale#lsp#OpenDocument('command:/foo', bufnr(''))
call ale#engine#Cleanup(bufnr(''))
AssertEqual
@@ -134,12 +134,12 @@ Execute(Re-opening and closing the documents should work):
\ g:message_list
Execute(Messages for closing documents should be sent to each server):
call ale#lsp#Register('command', '/foo', {})
call ale#lsp#Register('command', '/bar', {})
call ale#lsp#Register('command', '/foo', 'lang', {})
call ale#lsp#Register('command', '/bar', 'lang', {})
call MarkAllConnectionsInitialized()
call ale#lsp#OpenDocument('command:/foo', bufnr(''), 'lang')
call ale#lsp#OpenDocument('command:/bar', bufnr(''), 'lang')
call ale#lsp#OpenDocument('command:/foo', bufnr(''))
call ale#lsp#OpenDocument('command:/bar', bufnr(''))
call ale#engine#Cleanup(bufnr(''))
" We should only send the message once.
call ale#engine#Cleanup(bufnr(''))