ale/test/lsp/test_other_initialize_messa...

217 lines
5.5 KiB
Plaintext
Raw Permalink Normal View History

Before:
runtime autoload/ale/lsp.vim
let g:message_list = []
2018-08-24 12:16:58 +00:00
let b:conn = {
\ 'id': 1,
2018-08-24 12:16:58 +00:00
\ 'is_tsserver': 0,
\ 'data': '',
\ 'root': '/foo/bar',
\ 'open_documents': {},
\ 'initialized': 0,
2018-08-24 12:16:58 +00:00
\ 'init_request_id': 0,
\ 'init_options': {},
\ 'config': {},
2018-08-24 12:16:58 +00:00
\ 'callback_list': [],
\ 'message_queue': [],
\ 'init_queue': [],
\ 'capabilities': {
\ 'hover': 0,
\ 'rename': 0,
\ 'references': 0,
\ 'completion': 0,
\ 'completion_trigger_characters': [],
\ 'definition': 0,
2018-10-31 16:13:22 +00:00
\ 'symbol_search': 0,
\ 'code_actions': 0,
\ },
\}
function! ale#lsp#Send(conn_id, message) abort
call add(g:message_list, a:message)
return 42
endfunction
After:
unlet! b:conn
unlet! g:message_list
runtime autoload/ale/lsp.vim
Execute(Messages with no method and capabilities should initialize projects):
2018-08-24 12:16:58 +00:00
call ale#lsp#HandleInitResponse(b:conn, {
\ 'result': {'capabilities': {}},
\})
2018-08-24 12:16:58 +00:00
AssertEqual 1, b:conn.initialized
AssertEqual [[1, 'initialized', {}]], g:message_list
Execute(Other messages should not initialize projects):
2018-08-24 12:16:58 +00:00
call ale#lsp#HandleInitResponse(b:conn, {'method': 'lolwat'})
2018-08-24 12:16:58 +00:00
AssertEqual 0, b:conn.initialized
AssertEqual [], g:message_list
2018-08-24 12:16:58 +00:00
call ale#lsp#HandleInitResponse(b:conn, {'result': {'x': {}}})
2018-08-24 12:16:58 +00:00
AssertEqual 0, b:conn.initialized
AssertEqual [], g:message_list
Execute(Capabilities should bet set up correctly):
2018-08-24 12:16:58 +00:00
call ale#lsp#HandleInitResponse(b:conn, {
\ '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-08-24 12:16:58 +00:00
AssertEqual 1, b:conn.initialized
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,
\ 'rename': 1,
\ 'code_actions': 1,
\ },
2018-08-24 12:16:58 +00:00
\ b:conn.capabilities
AssertEqual [[1, 'initialized', {}]], g:message_list
Execute(Disabled capabilities should be recognised correctly):
2018-08-24 12:16:58 +00:00
call ale#lsp#HandleInitResponse(b:conn, {
\ 'jsonrpc': '2.0',
\ 'id': 1,
\ 'result': {
\ 'capabilities': {
\ 'renameProvider': v:false,
\ 'executeCommandProvider': {
\ 'commands': [],
\ },
\ 'hoverProvider': v:false,
\ 'documentSymbolProvider': v:true,
\ 'documentRangeFormattingProvider': v:true,
\ 'codeLensProvider': {
\ 'resolveProvider': v:false
\ },
\ 'referencesProvider': v:false,
\ 'textDocumentSync': 2,
\ 'documentFormattingProvider': v:true,
\ 'codeActionProvider': v:false,
\ 'signatureHelpProvider': {
\ 'triggerCharacters': ['(', ','],
\ },
\ 'definitionProvider': v:false,
\ 'experimental': {},
\ 'documentHighlightProvider': v:true,
\ },
\ },
\})
2018-08-24 12:16:58 +00:00
AssertEqual 1, b:conn.initialized
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,
\ 'rename': 0,
\ 'code_actions': 0,
\ },
2018-08-24 12:16:58 +00:00
\ b:conn.capabilities
AssertEqual [[1, 'initialized', {}]], g:message_list
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': {},
\ 'implementationProvider': {},
\ 'experimental': {},
\ 'documentHighlightProvider': v:true,
\ 'workspaceSymbolProvider': {}
\ },
\ },
\})
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,
\ },
\ b:conn.capabilities
AssertEqual [[1, 'initialized', {}]], g:message_list
Execute(Results that are not dictionaries should be handled correctly):
2018-08-24 12:16:58 +00:00
call ale#lsp#HandleInitResponse(b:conn, {
\ 'jsonrpc': '2.0',
\ 'id': 1,
\ 'result': v:null,
\})
AssertEqual [], g:message_list