2017-07-30 22:53:46 +00:00
|
|
|
Before:
|
2019-02-15 08:54:53 +00:00
|
|
|
runtime autoload/ale/lsp.vim
|
|
|
|
|
|
|
|
let g:message_list = []
|
2018-08-24 12:16:58 +00:00
|
|
|
let b:conn = {
|
2019-02-15 08:54:53 +00:00
|
|
|
\ 'id': 1,
|
2018-08-24 12:16:58 +00:00
|
|
|
\ 'is_tsserver': 0,
|
|
|
|
\ 'data': '',
|
|
|
|
\ 'root': '/foo/bar',
|
|
|
|
\ 'open_documents': {},
|
2017-07-30 22:53:46 +00:00
|
|
|
\ 'initialized': 0,
|
2018-08-24 12:16:58 +00:00
|
|
|
\ 'init_request_id': 0,
|
|
|
|
\ 'init_options': {},
|
2018-10-30 22:47:19 +00:00
|
|
|
\ 'config': {},
|
2018-08-24 12:16:58 +00:00
|
|
|
\ 'callback_list': [],
|
2017-07-30 22:53:46 +00:00
|
|
|
\ 'message_queue': [],
|
2019-02-13 00:31:33 +00:00
|
|
|
\ 'init_queue': [],
|
2018-07-19 20:15:05 +00:00
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'hover': 0,
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'rename': 0,
|
2018-07-19 20:15:05 +00:00
|
|
|
\ 'references': 0,
|
|
|
|
\ 'completion': 0,
|
|
|
|
\ 'completion_trigger_characters': [],
|
|
|
|
\ 'definition': 0,
|
2018-10-31 16:13:22 +00:00
|
|
|
\ 'symbol_search': 0,
|
2020-11-14 10:15:17 +00:00
|
|
|
\ 'code_actions': 0,
|
2018-07-19 20:15:05 +00:00
|
|
|
\ },
|
2017-07-30 22:53:46 +00:00
|
|
|
\}
|
|
|
|
|
2019-02-15 08:54:53 +00:00
|
|
|
function! ale#lsp#Send(conn_id, message) abort
|
|
|
|
call add(g:message_list, a:message)
|
|
|
|
|
|
|
|
return 42
|
|
|
|
endfunction
|
|
|
|
|
2017-07-30 22:53:46 +00:00
|
|
|
After:
|
|
|
|
unlet! b:conn
|
2019-02-15 08:54:53 +00:00
|
|
|
unlet! g:message_list
|
|
|
|
|
|
|
|
runtime autoload/ale/lsp.vim
|
2017-07-30 22:53:46 +00:00
|
|
|
|
|
|
|
Execute(Messages with no method and capabilities should initialize projects):
|
2018-08-24 12:16:58 +00:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
2017-07-30 22:53:46 +00:00
|
|
|
\ 'result': {'capabilities': {}},
|
|
|
|
\})
|
|
|
|
|
2018-08-24 12:16:58 +00:00
|
|
|
AssertEqual 1, b:conn.initialized
|
2019-02-15 10:42:34 +00:00
|
|
|
AssertEqual [[1, 'initialized', {}]], g:message_list
|
2017-07-30 22:53:46 +00:00
|
|
|
|
|
|
|
Execute(Other messages should not initialize projects):
|
2018-08-24 12:16:58 +00:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {'method': 'lolwat'})
|
2017-07-30 22:53:46 +00:00
|
|
|
|
2018-08-24 12:16:58 +00:00
|
|
|
AssertEqual 0, b:conn.initialized
|
2019-02-15 08:54:53 +00:00
|
|
|
AssertEqual [], g:message_list
|
2017-07-30 22:53:46 +00:00
|
|
|
|
2018-08-24 12:16:58 +00:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {'result': {'x': {}}})
|
2017-07-30 22:53:46 +00:00
|
|
|
|
2018-08-24 12:16:58 +00:00
|
|
|
AssertEqual 0, b:conn.initialized
|
2019-02-15 08:54:53 +00:00
|
|
|
AssertEqual [], g:message_list
|
2018-07-19 20:15:05 +00:00
|
|
|
|
|
|
|
Execute(Capabilities should bet set up correctly):
|
2018-08-24 12:16:58 +00:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
2018-07-19 20:15:05 +00:00
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': {
|
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'renameProvider': v:true,
|
|
|
|
\ 'executeCommandProvider': {
|
|
|
|
\ 'commands': [],
|
|
|
|
\ },
|
|
|
|
\ 'hoverProvider': v:true,
|
|
|
|
\ 'documentSymbolProvider': v:true,
|
|
|
|
\ 'documentRangeFormattingProvider': v:true,
|
|
|
|
\ 'codeLensProvider': {
|
|
|
|
\ 'resolveProvider': v:false
|
|
|
|
\ },
|
|
|
|
\ 'referencesProvider': v:true,
|
|
|
|
\ 'textDocumentSync': 2,
|
|
|
|
\ 'documentFormattingProvider': v:true,
|
|
|
|
\ 'codeActionProvider': v:true,
|
|
|
|
\ 'signatureHelpProvider': {
|
|
|
|
\ 'triggerCharacters': ['(', ','],
|
|
|
|
\ },
|
|
|
|
\ 'completionProvider': {
|
|
|
|
\ 'triggerCharacters': ['.'],
|
|
|
|
\ 'resolveProvider': v:false
|
|
|
|
\ },
|
|
|
|
\ 'definitionProvider': v:true,
|
|
|
|
\ 'experimental': {},
|
2018-10-31 16:13:22 +00:00
|
|
|
\ 'documentHighlightProvider': v:true,
|
|
|
|
\ 'workspaceSymbolProvider': v:true
|
2018-07-19 20:15:05 +00:00
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\})
|
|
|
|
|
2018-08-24 12:16:58 +00:00
|
|
|
AssertEqual 1, b:conn.initialized
|
2018-07-19 20:15:05 +00:00
|
|
|
AssertEqual
|
|
|
|
\ {
|
2018-08-24 12:16:58 +00:00
|
|
|
\ 'completion_trigger_characters': ['.'],
|
|
|
|
\ 'completion': 1,
|
|
|
|
\ 'references': 1,
|
|
|
|
\ 'hover': 1,
|
|
|
|
\ 'definition': 1,
|
2018-10-31 16:13:22 +00:00
|
|
|
\ 'symbol_search': 1,
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'rename': 1,
|
2020-11-14 10:15:17 +00:00
|
|
|
\ 'code_actions': 1,
|
2018-07-19 20:15:05 +00:00
|
|
|
\ },
|
2018-08-24 12:16:58 +00:00
|
|
|
\ b:conn.capabilities
|
2019-02-15 10:42:34 +00:00
|
|
|
AssertEqual [[1, 'initialized', {}]], g:message_list
|
2018-07-19 20:15:05 +00:00
|
|
|
|
|
|
|
Execute(Disabled capabilities should be recognised correctly):
|
2018-08-24 12:16:58 +00:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
2018-07-19 20:15:05 +00:00
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': {
|
|
|
|
\ 'capabilities': {
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'renameProvider': v:false,
|
2018-07-19 20:15:05 +00:00
|
|
|
\ 'executeCommandProvider': {
|
|
|
|
\ 'commands': [],
|
|
|
|
\ },
|
|
|
|
\ 'hoverProvider': v:false,
|
|
|
|
\ 'documentSymbolProvider': v:true,
|
|
|
|
\ 'documentRangeFormattingProvider': v:true,
|
|
|
|
\ 'codeLensProvider': {
|
|
|
|
\ 'resolveProvider': v:false
|
|
|
|
\ },
|
|
|
|
\ 'referencesProvider': v:false,
|
|
|
|
\ 'textDocumentSync': 2,
|
|
|
|
\ 'documentFormattingProvider': v:true,
|
2020-11-14 10:15:17 +00:00
|
|
|
\ 'codeActionProvider': v:false,
|
2018-07-19 20:15:05 +00:00
|
|
|
\ 'signatureHelpProvider': {
|
|
|
|
\ 'triggerCharacters': ['(', ','],
|
|
|
|
\ },
|
|
|
|
\ 'definitionProvider': v:false,
|
|
|
|
\ 'experimental': {},
|
2020-08-07 09:54:38 +00:00
|
|
|
\ 'documentHighlightProvider': v:true,
|
2018-07-19 20:15:05 +00:00
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\})
|
|
|
|
|
2018-08-24 12:16:58 +00:00
|
|
|
AssertEqual 1, b:conn.initialized
|
2018-07-19 20:15:05 +00:00
|
|
|
AssertEqual
|
|
|
|
\ {
|
2018-08-24 12:16:58 +00:00
|
|
|
\ 'completion_trigger_characters': [],
|
|
|
|
\ 'completion': 0,
|
|
|
|
\ 'references': 0,
|
|
|
|
\ 'hover': 0,
|
|
|
|
\ 'definition': 0,
|
2018-10-31 16:13:22 +00:00
|
|
|
\ 'symbol_search': 0,
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'rename': 0,
|
2020-11-14 10:15:17 +00:00
|
|
|
\ 'code_actions': 0,
|
2018-07-19 20:15:05 +00:00
|
|
|
\ },
|
2018-08-24 12:16:58 +00:00
|
|
|
\ b:conn.capabilities
|
2019-02-15 10:42:34 +00:00
|
|
|
AssertEqual [[1, 'initialized', {}]], g:message_list
|
2018-08-16 13:19:12 +00:00
|
|
|
|
2020-08-07 09:54:38 +00:00
|
|
|
Execute(Capabilities should be enabled when send as Dictionaries):
|
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': {
|
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'renameProvider': {},
|
|
|
|
\ 'executeCommandProvider': {
|
|
|
|
\ 'commands': [],
|
|
|
|
\ },
|
|
|
|
\ 'hoverProvider': {},
|
|
|
|
\ 'documentSymbolProvider': v:true,
|
|
|
|
\ 'documentRangeFormattingProvider': v:true,
|
|
|
|
\ 'codeLensProvider': {
|
|
|
|
\ 'resolveProvider': v:false
|
|
|
|
\ },
|
|
|
|
\ 'completionProvider': {
|
|
|
|
\ 'triggerCharacters': ['.'],
|
|
|
|
\ 'resolveProvider': v:false
|
|
|
|
\ },
|
|
|
|
\ 'referencesProvider': {},
|
|
|
|
\ 'textDocumentSync': 2,
|
|
|
|
\ 'documentFormattingProvider': v:true,
|
|
|
|
\ 'codeActionProvider': v:true,
|
|
|
|
\ 'signatureHelpProvider': {
|
|
|
|
\ 'triggerCharacters': ['(', ','],
|
|
|
|
\ },
|
|
|
|
\ 'definitionProvider': {},
|
|
|
|
\ 'typeDefinitionProvider': {},
|
2022-04-30 03:28:26 +00:00
|
|
|
\ 'implementationProvider': {},
|
2020-08-07 09:54:38 +00:00
|
|
|
\ 'experimental': {},
|
|
|
|
\ 'documentHighlightProvider': v:true,
|
|
|
|
\ 'workspaceSymbolProvider': {}
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\})
|
|
|
|
|
|
|
|
AssertEqual 1, b:conn.initialized
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'completion_trigger_characters': ['.'],
|
|
|
|
\ 'completion': 1,
|
|
|
|
\ 'references': 1,
|
|
|
|
\ 'hover': 1,
|
|
|
|
\ 'definition': 1,
|
|
|
|
\ 'typeDefinition': 1,
|
2022-04-30 03:28:26 +00:00
|
|
|
\ 'implementation': 1,
|
2020-08-07 09:54:38 +00:00
|
|
|
\ 'symbol_search': 1,
|
|
|
|
\ 'rename': 1,
|
2020-11-14 10:15:17 +00:00
|
|
|
\ 'code_actions': 1,
|
2020-08-07 09:54:38 +00:00
|
|
|
\ },
|
|
|
|
\ b:conn.capabilities
|
|
|
|
AssertEqual [[1, 'initialized', {}]], g:message_list
|
|
|
|
|
2018-08-16 13:19:12 +00:00
|
|
|
Execute(Results that are not dictionaries should be handled correctly):
|
2018-08-24 12:16:58 +00:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
2018-08-16 13:19:12 +00:00
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': v:null,
|
|
|
|
\})
|
2019-02-15 08:54:53 +00:00
|
|
|
AssertEqual [], g:message_list
|