mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Fix tests for Neovim LSP integration
This commit is contained in:
@@ -320,19 +320,21 @@ function! ale#lsp#UpdateConfig(conn_id, buffer, config) abort
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#CallInitCallbacks(conn_id) abort
|
||||
let l:conn = s:connections[a:conn_id]
|
||||
let l:conn = get(s:connections, a:conn_id, {})
|
||||
|
||||
" Ensure the connection is marked as initialized.
|
||||
" For integration with Neovim's LSP tooling this ensures immediately
|
||||
" call OnInit functions in Vim after the `on_init` callback is called.
|
||||
let l:conn.initialized = 1
|
||||
if !empty(l:conn)
|
||||
" Ensure the connection is marked as initialized.
|
||||
" For integration with Neovim's LSP tooling this ensures immediately
|
||||
" call OnInit functions in Vim after the `on_init` callback is called.
|
||||
let l:conn.initialized = 1
|
||||
|
||||
" Call capabilities callbacks queued for the project.
|
||||
for l:Callback in l:conn.init_queue
|
||||
call l:Callback()
|
||||
endfor
|
||||
" Call capabilities callbacks queued for the project.
|
||||
for l:Callback in l:conn.init_queue
|
||||
call l:Callback()
|
||||
endfor
|
||||
|
||||
let l:conn.init_queue = []
|
||||
let l:conn.init_queue = []
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#HandleInitResponse(conn, response) abort
|
||||
|
||||
@@ -2,30 +2,10 @@ Before:
|
||||
runtime autoload/ale/lsp.vim
|
||||
|
||||
let g:message_list = []
|
||||
let b:conn = {
|
||||
\ 'id': 1,
|
||||
\ 'is_tsserver': 0,
|
||||
\ 'data': '',
|
||||
\ 'root': '/foo/bar',
|
||||
\ 'open_documents': {},
|
||||
\ 'initialized': 0,
|
||||
\ 'init_request_id': 0,
|
||||
\ 'init_options': {},
|
||||
\ 'config': {},
|
||||
\ 'callback_list': [],
|
||||
\ 'message_queue': [],
|
||||
\ 'init_queue': [],
|
||||
\ 'capabilities': {
|
||||
\ 'hover': 0,
|
||||
\ 'rename': 0,
|
||||
\ 'references': 0,
|
||||
\ 'completion': 0,
|
||||
\ 'completion_trigger_characters': [],
|
||||
\ 'definition': 0,
|
||||
\ 'symbol_search': 0,
|
||||
\ 'code_actions': 0,
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Register a fake connection and get it for tests.
|
||||
call ale#lsp#Register('ale-fake-lsp-server', '/code', {})
|
||||
let b:conn = ale#lsp#GetConnections()['ale-fake-lsp-server:/code']
|
||||
|
||||
function! ale#lsp#Send(conn_id, message) abort
|
||||
call add(g:message_list, a:message)
|
||||
@@ -34,6 +14,9 @@ Before:
|
||||
endfunction
|
||||
|
||||
After:
|
||||
" Remove the connection with the ID.
|
||||
call ale#lsp#RemoveConnectionWithID(b:conn.id)
|
||||
|
||||
unlet! b:conn
|
||||
unlet! g:message_list
|
||||
|
||||
@@ -58,7 +41,7 @@ Execute(Other messages should not initialize projects):
|
||||
AssertEqual 0, b:conn.initialized
|
||||
AssertEqual [], g:message_list
|
||||
|
||||
Execute(Capabilities should bet set up correctly):
|
||||
Execute(Capabilities should be set up correctly):
|
||||
call ale#lsp#HandleInitResponse(b:conn, {
|
||||
\ 'jsonrpc': '2.0',
|
||||
\ 'id': 1,
|
||||
@@ -96,14 +79,19 @@ Execute(Capabilities should bet set up correctly):
|
||||
AssertEqual 1, b:conn.initialized
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'completion_trigger_characters': ['.'],
|
||||
\ 'completion': 1,
|
||||
\ 'references': 1,
|
||||
\ 'hover': 1,
|
||||
\ 'definition': 1,
|
||||
\ 'symbol_search': 1,
|
||||
\ 'rename': 1,
|
||||
\ 'code_actions': 1,
|
||||
\ 'completion': 1,
|
||||
\ 'completion_trigger_characters': ['.'],
|
||||
\ 'definition': 1,
|
||||
\ 'did_save': 0,
|
||||
\ 'filerename': 0,
|
||||
\ 'hover': 1,
|
||||
\ 'implementation': 0,
|
||||
\ 'includeText': 0,
|
||||
\ 'references': 1,
|
||||
\ 'rename': 1,
|
||||
\ 'symbol_search': 1,
|
||||
\ 'typeDefinition': 0,
|
||||
\ },
|
||||
\ b:conn.capabilities
|
||||
AssertEqual [[1, 'initialized', {}]], g:message_list
|
||||
@@ -141,19 +129,24 @@ Execute(Disabled capabilities should be recognised correctly):
|
||||
AssertEqual 1, b:conn.initialized
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'completion_trigger_characters': [],
|
||||
\ 'completion': 0,
|
||||
\ 'references': 0,
|
||||
\ 'hover': 0,
|
||||
\ 'definition': 0,
|
||||
\ 'symbol_search': 0,
|
||||
\ 'rename': 0,
|
||||
\ 'code_actions': 0,
|
||||
\ 'completion': 0,
|
||||
\ 'completion_trigger_characters': [],
|
||||
\ 'definition': 0,
|
||||
\ 'did_save': 0,
|
||||
\ 'filerename': 0,
|
||||
\ 'hover': 0,
|
||||
\ 'implementation': 0,
|
||||
\ 'includeText': 0,
|
||||
\ 'references': 0,
|
||||
\ 'rename': 0,
|
||||
\ 'symbol_search': 0,
|
||||
\ 'typeDefinition': 0,
|
||||
\ },
|
||||
\ b:conn.capabilities
|
||||
AssertEqual [[1, 'initialized', {}]], g:message_list
|
||||
|
||||
Execute(Capabilities should be enabled when send as Dictionaries):
|
||||
Execute(Capabilities should be enabled when sent as Dictionaries):
|
||||
call ale#lsp#HandleInitResponse(b:conn, {
|
||||
\ 'jsonrpc': '2.0',
|
||||
\ 'id': 1,
|
||||
@@ -174,7 +167,11 @@ Execute(Capabilities should be enabled when send as Dictionaries):
|
||||
\ 'resolveProvider': v:false
|
||||
\ },
|
||||
\ 'referencesProvider': {},
|
||||
\ 'textDocumentSync': 2,
|
||||
\ 'textDocumentSync': {
|
||||
\ 'save': {
|
||||
\ 'includeText': v:true
|
||||
\ }
|
||||
\ },
|
||||
\ 'documentFormattingProvider': v:true,
|
||||
\ 'codeActionProvider': v:true,
|
||||
\ 'signatureHelpProvider': {
|
||||
@@ -193,16 +190,19 @@ Execute(Capabilities should be enabled when send as Dictionaries):
|
||||
AssertEqual 1, b:conn.initialized
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'completion_trigger_characters': ['.'],
|
||||
\ 'completion': 1,
|
||||
\ 'references': 1,
|
||||
\ 'hover': 1,
|
||||
\ 'definition': 1,
|
||||
\ 'typeDefinition': 1,
|
||||
\ 'implementation': 1,
|
||||
\ 'symbol_search': 1,
|
||||
\ 'rename': 1,
|
||||
\ 'code_actions': 1,
|
||||
\ 'completion': 1,
|
||||
\ 'completion_trigger_characters': ['.'],
|
||||
\ 'definition': 1,
|
||||
\ 'did_save': 1,
|
||||
\ 'filerename': 0,
|
||||
\ 'hover': 1,
|
||||
\ 'implementation': 1,
|
||||
\ 'includeText': 1,
|
||||
\ 'references': 1,
|
||||
\ 'rename': 1,
|
||||
\ 'symbol_search': 1,
|
||||
\ 'typeDefinition': 1,
|
||||
\ },
|
||||
\ b:conn.capabilities
|
||||
AssertEqual [[1, 'initialized', {}]], g:message_list
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
let g:ale_set_lists_synchronously = 1
|
||||
" Disable Neovim diagnostics by default for CI tests.
|
||||
let g:ale_use_neovim_diagnostics_api = 0
|
||||
" Disable Neovim native LSP API by default for CI tests.
|
||||
let g:ale_use_neovim_lsp_api = 0
|
||||
|
||||
" This lowercase highlight definition is needed for highlight tests.
|
||||
hi link aleerrorline spellbad
|
||||
|
||||
Reference in New Issue
Block a user