2017-07-30 18:53:46 -04:00
|
|
|
Before:
|
2019-02-15 03:54:53 -05:00
|
|
|
runtime autoload/ale/lsp.vim
|
|
|
|
|
|
|
|
let g:message_list = []
|
2018-08-24 08:16:58 -04:00
|
|
|
let b:conn = {
|
2019-02-15 03:54:53 -05:00
|
|
|
\ 'id': 1,
|
2018-08-24 08:16:58 -04:00
|
|
|
\ 'is_tsserver': 0,
|
|
|
|
\ 'data': '',
|
|
|
|
\ 'root': '/foo/bar',
|
|
|
|
\ 'open_documents': {},
|
2017-07-30 18:53:46 -04:00
|
|
|
\ 'initialized': 0,
|
2018-08-24 08:16:58 -04:00
|
|
|
\ 'init_request_id': 0,
|
|
|
|
\ 'init_options': {},
|
2018-10-30 18:47:19 -04:00
|
|
|
\ 'config': {},
|
2018-08-24 08:16:58 -04:00
|
|
|
\ 'callback_list': [],
|
2017-07-30 18:53:46 -04:00
|
|
|
\ 'message_queue': [],
|
2019-02-12 19:31:33 -05:00
|
|
|
\ 'init_queue': [],
|
2018-07-19 16:15:05 -04:00
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'hover': 0,
|
|
|
|
\ 'references': 0,
|
|
|
|
\ 'completion': 0,
|
|
|
|
\ 'completion_trigger_characters': [],
|
|
|
|
\ 'definition': 0,
|
2018-10-31 12:13:22 -04:00
|
|
|
\ 'symbol_search': 0,
|
2018-07-19 16:15:05 -04:00
|
|
|
\ },
|
2017-07-30 18:53:46 -04:00
|
|
|
\}
|
|
|
|
|
2019-02-15 03:54:53 -05:00
|
|
|
function! ale#lsp#Send(conn_id, message) abort
|
|
|
|
call add(g:message_list, a:message)
|
|
|
|
|
|
|
|
return 42
|
|
|
|
endfunction
|
|
|
|
|
2017-07-30 18:53:46 -04:00
|
|
|
After:
|
|
|
|
unlet! b:conn
|
2019-02-15 03:54:53 -05:00
|
|
|
unlet! g:message_list
|
|
|
|
|
|
|
|
runtime autoload/ale/lsp.vim
|
2017-07-30 18:53:46 -04:00
|
|
|
|
|
|
|
Execute(Messages with no method and capabilities should initialize projects):
|
2018-08-24 08:16:58 -04:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
2017-07-30 18:53:46 -04:00
|
|
|
\ 'result': {'capabilities': {}},
|
|
|
|
\})
|
|
|
|
|
2018-08-24 08:16:58 -04:00
|
|
|
AssertEqual 1, b:conn.initialized
|
2019-02-15 05:42:34 -05:00
|
|
|
AssertEqual [[1, 'initialized', {}]], g:message_list
|
2017-07-30 18:53:46 -04:00
|
|
|
|
|
|
|
Execute(Other messages should not initialize projects):
|
2018-08-24 08:16:58 -04:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {'method': 'lolwat'})
|
2017-07-30 18:53:46 -04:00
|
|
|
|
2018-08-24 08:16:58 -04:00
|
|
|
AssertEqual 0, b:conn.initialized
|
2019-02-15 03:54:53 -05:00
|
|
|
AssertEqual [], g:message_list
|
2017-07-30 18:53:46 -04:00
|
|
|
|
2018-08-24 08:16:58 -04:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {'result': {'x': {}}})
|
2017-07-30 18:53:46 -04:00
|
|
|
|
2018-08-24 08:16:58 -04:00
|
|
|
AssertEqual 0, b:conn.initialized
|
2019-02-15 03:54:53 -05:00
|
|
|
AssertEqual [], g:message_list
|
2018-07-19 16:15:05 -04:00
|
|
|
|
|
|
|
Execute(Capabilities should bet set up correctly):
|
2018-08-24 08:16:58 -04:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
2018-07-19 16:15:05 -04: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 12:13:22 -04:00
|
|
|
\ 'documentHighlightProvider': v:true,
|
|
|
|
\ 'workspaceSymbolProvider': v:true
|
2018-07-19 16:15:05 -04:00
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\})
|
|
|
|
|
2018-08-24 08:16:58 -04:00
|
|
|
AssertEqual 1, b:conn.initialized
|
2018-07-19 16:15:05 -04:00
|
|
|
AssertEqual
|
|
|
|
\ {
|
2018-08-24 08:16:58 -04:00
|
|
|
\ 'completion_trigger_characters': ['.'],
|
|
|
|
\ 'completion': 1,
|
|
|
|
\ 'references': 1,
|
|
|
|
\ 'hover': 1,
|
|
|
|
\ 'definition': 1,
|
2018-10-31 12:13:22 -04:00
|
|
|
\ 'symbol_search': 1,
|
2018-07-19 16:15:05 -04:00
|
|
|
\ },
|
2018-08-24 08:16:58 -04:00
|
|
|
\ b:conn.capabilities
|
2019-02-15 05:42:34 -05:00
|
|
|
AssertEqual [[1, 'initialized', {}]], g:message_list
|
2018-07-19 16:15:05 -04:00
|
|
|
|
|
|
|
Execute(Disabled capabilities should be recognised correctly):
|
2018-08-24 08:16:58 -04:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
2018-07-19 16:15:05 -04:00
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': {
|
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'renameProvider': v:true,
|
|
|
|
\ '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:true,
|
|
|
|
\ 'signatureHelpProvider': {
|
|
|
|
\ 'triggerCharacters': ['(', ','],
|
|
|
|
\ },
|
|
|
|
\ 'definitionProvider': v:false,
|
|
|
|
\ 'experimental': {},
|
|
|
|
\ 'documentHighlightProvider': v:true
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\})
|
|
|
|
|
2018-08-24 08:16:58 -04:00
|
|
|
AssertEqual 1, b:conn.initialized
|
2018-07-19 16:15:05 -04:00
|
|
|
AssertEqual
|
|
|
|
\ {
|
2018-08-24 08:16:58 -04:00
|
|
|
\ 'completion_trigger_characters': [],
|
|
|
|
\ 'completion': 0,
|
|
|
|
\ 'references': 0,
|
|
|
|
\ 'hover': 0,
|
|
|
|
\ 'definition': 0,
|
2018-10-31 12:13:22 -04:00
|
|
|
\ 'symbol_search': 0,
|
2018-07-19 16:15:05 -04:00
|
|
|
\ },
|
2018-08-24 08:16:58 -04:00
|
|
|
\ b:conn.capabilities
|
2019-02-15 05:42:34 -05:00
|
|
|
AssertEqual [[1, 'initialized', {}]], g:message_list
|
2018-08-16 09:19:12 -04:00
|
|
|
|
|
|
|
Execute(Results that are not dictionaries should be handled correctly):
|
2018-08-24 08:16:58 -04:00
|
|
|
call ale#lsp#HandleInitResponse(b:conn, {
|
2018-08-16 09:19:12 -04:00
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': v:null,
|
|
|
|
\})
|
2019-02-15 03:54:53 -05:00
|
|
|
AssertEqual [], g:message_list
|