Fix #2295 - Respond to initialize with an initialized message
This commit is contained in:
parent
89039187da
commit
0d10653a7c
@ -299,7 +299,11 @@ function! ale#job#SendRaw(job_id, string) abort
|
|||||||
if has('nvim')
|
if has('nvim')
|
||||||
call jobsend(a:job_id, a:string)
|
call jobsend(a:job_id, a:string)
|
||||||
else
|
else
|
||||||
call ch_sendraw(job_getchannel(s:job_map[a:job_id].job), a:string)
|
let l:job = s:job_map[a:job_id].job
|
||||||
|
|
||||||
|
if ch_status(l:job) is# 'open'
|
||||||
|
call ch_sendraw(job_getchannel(l:job), a:string)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -323,6 +327,20 @@ function! ale#job#IsRunning(job_id) abort
|
|||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ale#job#HasOpenChannel(job_id) abort
|
||||||
|
if ale#job#IsRunning(a:job_id)
|
||||||
|
if has('nvim')
|
||||||
|
" TODO: Implement a check for NeoVim.
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Check if the Job's channel can be written to.
|
||||||
|
return ch_status(s:job_map[a:job_id].job) is# 'open'
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Given a Job ID, stop that job.
|
" Given a Job ID, stop that job.
|
||||||
" Invalid job IDs will be ignored.
|
" Invalid job IDs will be ignored.
|
||||||
function! ale#job#Stop(job_id) abort
|
function! ale#job#Stop(job_id) abort
|
||||||
|
@ -21,7 +21,6 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort
|
|||||||
" init_options: Options to send to the server.
|
" init_options: Options to send to the server.
|
||||||
" config: Configuration settings to send to the server.
|
" config: Configuration settings to send to the server.
|
||||||
" callback_list: A list of callbacks for handling LSP responses.
|
" callback_list: A list of callbacks for handling LSP responses.
|
||||||
" message_queue: Messages queued for sending to callbacks.
|
|
||||||
" capabilities_queue: The list of callbacks to call with capabilities.
|
" capabilities_queue: The list of callbacks to call with capabilities.
|
||||||
" capabilities: Features the server supports.
|
" capabilities: Features the server supports.
|
||||||
let s:connections[l:conn_id] = {
|
let s:connections[l:conn_id] = {
|
||||||
@ -35,7 +34,6 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort
|
|||||||
\ 'init_options': a:init_options,
|
\ 'init_options': a:init_options,
|
||||||
\ 'config': {},
|
\ 'config': {},
|
||||||
\ 'callback_list': [],
|
\ 'callback_list': [],
|
||||||
\ 'message_queue': [],
|
|
||||||
\ 'init_queue': [],
|
\ 'init_queue': [],
|
||||||
\ 'capabilities': {
|
\ 'capabilities': {
|
||||||
\ 'hover': 0,
|
\ 'hover': 0,
|
||||||
@ -250,13 +248,8 @@ function! ale#lsp#HandleInitResponse(conn, response) abort
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" After the server starts, send messages we had queued previously.
|
" The initialized message must be sent before everything else.
|
||||||
for l:message_data in a:conn.message_queue
|
call ale#lsp#Send(a:conn.id, ale#lsp#message#Initialized())
|
||||||
call s:SendMessageData(a:conn, l:message_data)
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Remove the messages now.
|
|
||||||
let a:conn.message_queue = []
|
|
||||||
|
|
||||||
" Call capabilities callbacks queued for the project.
|
" Call capabilities callbacks queued for the project.
|
||||||
for l:Callback in a:conn.init_queue
|
for l:Callback in a:conn.init_queue
|
||||||
@ -317,14 +310,23 @@ function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort
|
|||||||
let l:conn.capabilities.symbol_search = 1
|
let l:conn.capabilities.symbol_search = 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:SendInitMessage(conn) abort
|
||||||
|
let [l:init_id, l:init_data] = ale#lsp#CreateMessageData(
|
||||||
|
\ ale#lsp#message#Initialize(a:conn.root, a:conn.init_options),
|
||||||
|
\)
|
||||||
|
let a:conn.init_request_id = l:init_id
|
||||||
|
call s:SendMessageData(a:conn, l:init_data)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Start a program for LSP servers.
|
" Start a program for LSP servers.
|
||||||
"
|
"
|
||||||
" 1 will be returned if the program is running, or 0 if the program could
|
" 1 will be returned if the program is running, or 0 if the program could
|
||||||
" not be started.
|
" not be started.
|
||||||
function! ale#lsp#StartProgram(conn_id, executable, command) abort
|
function! ale#lsp#StartProgram(conn_id, executable, command) abort
|
||||||
let l:conn = s:connections[a:conn_id]
|
let l:conn = s:connections[a:conn_id]
|
||||||
|
let l:started = 0
|
||||||
|
|
||||||
if !has_key(l:conn, 'job_id') || !ale#job#IsRunning(l:conn.job_id)
|
if !has_key(l:conn, 'job_id') || !ale#job#HasOpenChannel(l:conn.job_id)
|
||||||
let l:options = {
|
let l:options = {
|
||||||
\ 'mode': 'raw',
|
\ 'mode': 'raw',
|
||||||
\ 'out_cb': {_, message -> ale#lsp#HandleMessage(a:conn_id, message)},
|
\ 'out_cb': {_, message -> ale#lsp#HandleMessage(a:conn_id, message)},
|
||||||
@ -335,6 +337,8 @@ function! ale#lsp#StartProgram(conn_id, executable, command) abort
|
|||||||
else
|
else
|
||||||
let l:job_id = ale#job#Start(a:command, l:options)
|
let l:job_id = ale#job#Start(a:command, l:options)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:started = 1
|
||||||
else
|
else
|
||||||
let l:job_id = l:conn.job_id
|
let l:job_id = l:conn.job_id
|
||||||
endif
|
endif
|
||||||
@ -343,6 +347,10 @@ function! ale#lsp#StartProgram(conn_id, executable, command) abort
|
|||||||
let l:conn.job_id = l:job_id
|
let l:conn.job_id = l:job_id
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if l:started
|
||||||
|
call s:SendInitMessage(l:conn)
|
||||||
|
endif
|
||||||
|
|
||||||
return l:job_id > 0
|
return l:job_id > 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -352,11 +360,14 @@ endfunction
|
|||||||
" not be opened.
|
" not be opened.
|
||||||
function! ale#lsp#ConnectToAddress(conn_id, address) abort
|
function! ale#lsp#ConnectToAddress(conn_id, address) abort
|
||||||
let l:conn = s:connections[a:conn_id]
|
let l:conn = s:connections[a:conn_id]
|
||||||
|
let l:started = 0
|
||||||
|
|
||||||
if !has_key(l:conn, 'channel_id') || !ale#socket#IsOpen(l:conn.channel_id)
|
if !has_key(l:conn, 'channel_id') || !ale#socket#IsOpen(l:conn.channel_id)
|
||||||
let l:channel_id = ale#socket#Open(a:address, {
|
let l:channel_id = ale#socket#Open(a:address, {
|
||||||
\ 'callback': {_, mess -> ale#lsp#HandleMessage(a:conn_id, mess)},
|
\ 'callback': {_, mess -> ale#lsp#HandleMessage(a:conn_id, mess)},
|
||||||
\})
|
\})
|
||||||
|
|
||||||
|
let l:started = 1
|
||||||
else
|
else
|
||||||
let l:channel_id = l:conn.channel_id
|
let l:channel_id = l:conn.channel_id
|
||||||
endif
|
endif
|
||||||
@ -365,6 +376,10 @@ function! ale#lsp#ConnectToAddress(conn_id, address) abort
|
|||||||
let l:conn.channel_id = l:channel_id
|
let l:conn.channel_id = l:channel_id
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if l:started
|
||||||
|
call s:SendInitMessage(l:conn)
|
||||||
|
endif
|
||||||
|
|
||||||
return l:channel_id >= 0
|
return l:channel_id >= 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -429,26 +444,12 @@ function! ale#lsp#Send(conn_id, message) abort
|
|||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If we haven't initialized the server yet, then send the message for it.
|
if !l:conn.initialized
|
||||||
if !l:conn.initialized && !l:conn.init_request_id
|
throw 'LSP server not initialized yet!'
|
||||||
let [l:init_id, l:init_data] = ale#lsp#CreateMessageData(
|
|
||||||
\ ale#lsp#message#Initialize(l:conn.root, l:conn.init_options),
|
|
||||||
\)
|
|
||||||
|
|
||||||
let l:conn.init_request_id = l:init_id
|
|
||||||
|
|
||||||
call s:SendMessageData(l:conn, l:init_data)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let [l:id, l:data] = ale#lsp#CreateMessageData(a:message)
|
let [l:id, l:data] = ale#lsp#CreateMessageData(a:message)
|
||||||
|
|
||||||
if l:conn.initialized
|
|
||||||
" Send the message now.
|
|
||||||
call s:SendMessageData(l:conn, l:data)
|
call s:SendMessageData(l:conn, l:data)
|
||||||
else
|
|
||||||
" Add the message we wanted to send to a List to send later.
|
|
||||||
call add(l:conn.message_queue, l:data)
|
|
||||||
endif
|
|
||||||
|
|
||||||
return l:id == 0 ? -1 : l:id
|
return l:id == 0 ? -1 : l:id
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -185,6 +185,31 @@ function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort
|
|||||||
return ale#util#GetFunction(a:linter.project_root_callback)(a:buffer)
|
return ale#util#GetFunction(a:linter.project_root_callback)(a:buffer)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" This function is accessible so tests can call it.
|
||||||
|
function! ale#lsp_linter#OnInit(linter, details, Callback) abort
|
||||||
|
let l:buffer = a:details.buffer
|
||||||
|
let l:conn_id = a:details.connection_id
|
||||||
|
let l:command = a:details.command
|
||||||
|
|
||||||
|
let l:config = ale#lsp_linter#GetConfig(l:buffer, a:linter)
|
||||||
|
let l:language_id = ale#util#GetFunction(a:linter.language_callback)(l:buffer)
|
||||||
|
|
||||||
|
call ale#lsp#UpdateConfig(l:conn_id, l:buffer, l:config)
|
||||||
|
|
||||||
|
if ale#lsp#OpenDocument(l:conn_id, l:buffer, l:language_id)
|
||||||
|
if g:ale_history_enabled && !empty(l:command)
|
||||||
|
call ale#history#Add(l:buffer, 'started', l:conn_id, l:command)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" The change message needs to be sent for tsserver before doing anything.
|
||||||
|
if a:linter.lsp is# 'tsserver'
|
||||||
|
call ale#lsp#NotifyForChanges(l:conn_id, l:buffer)
|
||||||
|
endif
|
||||||
|
|
||||||
|
call a:Callback(a:linter, a:details)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Given a buffer, an LSP linter, start up an LSP linter and get ready to
|
" Given a buffer, an LSP linter, start up an LSP linter and get ready to
|
||||||
" receive messages for the document.
|
" receive messages for the document.
|
||||||
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
||||||
@ -207,7 +232,7 @@ function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
|||||||
else
|
else
|
||||||
let l:executable = ale#linter#GetExecutable(a:buffer, a:linter)
|
let l:executable = ale#linter#GetExecutable(a:buffer, a:linter)
|
||||||
|
|
||||||
if empty(l:executable) || !executable(l:executable)
|
if !ale#engine#IsExecutable(a:buffer, l:executable)
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -233,31 +258,16 @@ function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
|||||||
call ale#lsp#MarkConnectionAsTsserver(l:conn_id)
|
call ale#lsp#MarkConnectionAsTsserver(l:conn_id)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:config = ale#lsp_linter#GetConfig(a:buffer, a:linter)
|
|
||||||
let l:language_id = ale#util#GetFunction(a:linter.language_callback)(a:buffer)
|
|
||||||
|
|
||||||
let l:details = {
|
let l:details = {
|
||||||
\ 'buffer': a:buffer,
|
\ 'buffer': a:buffer,
|
||||||
\ 'connection_id': l:conn_id,
|
\ 'connection_id': l:conn_id,
|
||||||
\ 'command': l:command,
|
\ 'command': l:command,
|
||||||
\ 'project_root': l:root,
|
\ 'project_root': l:root,
|
||||||
\ 'language_id': l:language_id,
|
|
||||||
\}
|
\}
|
||||||
|
|
||||||
call ale#lsp#UpdateConfig(l:conn_id, a:buffer, l:config)
|
call ale#lsp#OnInit(l:conn_id, {->
|
||||||
|
\ ale#lsp_linter#OnInit(a:linter, l:details, a:Callback)
|
||||||
if ale#lsp#OpenDocument(l:conn_id, a:buffer, l:language_id)
|
\})
|
||||||
if g:ale_history_enabled && !empty(l:command)
|
|
||||||
call ale#history#Add(a:buffer, 'started', l:conn_id, l:command)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" The change message needs to be sent for tsserver before doing anything.
|
|
||||||
if a:linter.lsp is# 'tsserver'
|
|
||||||
call ale#lsp#NotifyForChanges(l:conn_id, a:buffer)
|
|
||||||
endif
|
|
||||||
|
|
||||||
call ale#lsp#OnInit(l:conn_id, {-> a:Callback(a:linter, l:details)})
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -23,10 +23,10 @@ Before:
|
|||||||
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
||||||
|
|
||||||
let l:details = {
|
let l:details = {
|
||||||
|
\ 'command': 'foobar',
|
||||||
\ 'buffer': a:buffer,
|
\ 'buffer': a:buffer,
|
||||||
\ 'connection_id': g:conn_id,
|
\ 'connection_id': g:conn_id,
|
||||||
\ 'project_root': '/foo/bar',
|
\ 'project_root': '/foo/bar',
|
||||||
\ 'language_id': 'python',
|
|
||||||
\}
|
\}
|
||||||
|
|
||||||
call add(g:init_callback_list, {-> a:Callback(a:linter, l:details)})
|
call add(g:init_callback_list, {-> a:Callback(a:linter, l:details)})
|
||||||
|
@ -38,10 +38,10 @@ Before:
|
|||||||
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
||||||
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
||||||
let l:details = {
|
let l:details = {
|
||||||
|
\ 'command': 'foobar',
|
||||||
\ 'buffer': a:buffer,
|
\ 'buffer': a:buffer,
|
||||||
\ 'connection_id': g:conn_id,
|
\ 'connection_id': g:conn_id,
|
||||||
\ 'project_root': '/foo/bar',
|
\ 'project_root': '/foo/bar',
|
||||||
\ 'language_id': 'foobar',
|
|
||||||
\}
|
\}
|
||||||
|
|
||||||
call a:Callback(a:linter, l:details)
|
call a:Callback(a:linter, l:details)
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
Before:
|
Before:
|
||||||
|
runtime autoload/ale/lsp.vim
|
||||||
|
|
||||||
|
let g:message_list = []
|
||||||
let b:conn = {
|
let b:conn = {
|
||||||
|
\ 'id': 1,
|
||||||
\ 'is_tsserver': 0,
|
\ 'is_tsserver': 0,
|
||||||
\ 'data': '',
|
\ 'data': '',
|
||||||
\ 'root': '/foo/bar',
|
\ 'root': '/foo/bar',
|
||||||
@ -21,8 +25,17 @@ Before:
|
|||||||
\ },
|
\ },
|
||||||
\}
|
\}
|
||||||
|
|
||||||
|
function! ale#lsp#Send(conn_id, message) abort
|
||||||
|
call add(g:message_list, a:message)
|
||||||
|
|
||||||
|
return 42
|
||||||
|
endfunction
|
||||||
|
|
||||||
After:
|
After:
|
||||||
unlet! b:conn
|
unlet! b:conn
|
||||||
|
unlet! g:message_list
|
||||||
|
|
||||||
|
runtime autoload/ale/lsp.vim
|
||||||
|
|
||||||
Execute(Messages with no method and capabilities should initialize projects):
|
Execute(Messages with no method and capabilities should initialize projects):
|
||||||
call ale#lsp#HandleInitResponse(b:conn, {
|
call ale#lsp#HandleInitResponse(b:conn, {
|
||||||
@ -30,15 +43,18 @@ Execute(Messages with no method and capabilities should initialize projects):
|
|||||||
\})
|
\})
|
||||||
|
|
||||||
AssertEqual 1, b:conn.initialized
|
AssertEqual 1, b:conn.initialized
|
||||||
|
AssertEqual [[1, 'initialized']], g:message_list
|
||||||
|
|
||||||
Execute(Other messages should not initialize projects):
|
Execute(Other messages should not initialize projects):
|
||||||
call ale#lsp#HandleInitResponse(b:conn, {'method': 'lolwat'})
|
call ale#lsp#HandleInitResponse(b:conn, {'method': 'lolwat'})
|
||||||
|
|
||||||
AssertEqual 0, b:conn.initialized
|
AssertEqual 0, b:conn.initialized
|
||||||
|
AssertEqual [], g:message_list
|
||||||
|
|
||||||
call ale#lsp#HandleInitResponse(b:conn, {'result': {'x': {}}})
|
call ale#lsp#HandleInitResponse(b:conn, {'result': {'x': {}}})
|
||||||
|
|
||||||
AssertEqual 0, b:conn.initialized
|
AssertEqual 0, b:conn.initialized
|
||||||
|
AssertEqual [], g:message_list
|
||||||
|
|
||||||
Execute(Capabilities should bet set up correctly):
|
Execute(Capabilities should bet set up correctly):
|
||||||
call ale#lsp#HandleInitResponse(b:conn, {
|
call ale#lsp#HandleInitResponse(b:conn, {
|
||||||
@ -86,6 +102,7 @@ Execute(Capabilities should bet set up correctly):
|
|||||||
\ 'symbol_search': 1,
|
\ 'symbol_search': 1,
|
||||||
\ },
|
\ },
|
||||||
\ b:conn.capabilities
|
\ b:conn.capabilities
|
||||||
|
AssertEqual [[1, 'initialized']], g:message_list
|
||||||
|
|
||||||
Execute(Disabled capabilities should be recognised correctly):
|
Execute(Disabled capabilities should be recognised correctly):
|
||||||
call ale#lsp#HandleInitResponse(b:conn, {
|
call ale#lsp#HandleInitResponse(b:conn, {
|
||||||
@ -128,6 +145,7 @@ Execute(Disabled capabilities should be recognised correctly):
|
|||||||
\ 'symbol_search': 0,
|
\ 'symbol_search': 0,
|
||||||
\ },
|
\ },
|
||||||
\ b:conn.capabilities
|
\ b:conn.capabilities
|
||||||
|
AssertEqual [[1, 'initialized']], g:message_list
|
||||||
|
|
||||||
Execute(Results that are not dictionaries should be handled correctly):
|
Execute(Results that are not dictionaries should be handled correctly):
|
||||||
call ale#lsp#HandleInitResponse(b:conn, {
|
call ale#lsp#HandleInitResponse(b:conn, {
|
||||||
@ -135,3 +153,4 @@ Execute(Results that are not dictionaries should be handled correctly):
|
|||||||
\ 'id': 1,
|
\ 'id': 1,
|
||||||
\ 'result': v:null,
|
\ 'result': v:null,
|
||||||
\})
|
\})
|
||||||
|
AssertEqual [], g:message_list
|
||||||
|
@ -3,6 +3,10 @@ Before:
|
|||||||
|
|
||||||
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
||||||
|
|
||||||
|
" Stub out this function, so we test updating configs.
|
||||||
|
function! ale#lsp#Send(conn_id, message) abort
|
||||||
|
endfunction
|
||||||
|
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ Before:
|
|||||||
let g:conn_id = v:null
|
let g:conn_id = v:null
|
||||||
let g:InitCallback = v:null
|
let g:InitCallback = v:null
|
||||||
|
|
||||||
runtime autoload/ale/linter.vim
|
runtime autoload/ale/lsp_linter.vim
|
||||||
runtime autoload/ale/lsp.vim
|
runtime autoload/ale/lsp.vim
|
||||||
runtime autoload/ale/util.vim
|
runtime autoload/ale/util.vim
|
||||||
runtime autoload/ale/preview.vim
|
runtime autoload/ale/preview.vim
|
||||||
@ -21,14 +21,19 @@ Before:
|
|||||||
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
||||||
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
||||||
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
||||||
|
|
||||||
|
if a:linter.lsp is# 'tsserver'
|
||||||
|
call ale#lsp#MarkConnectionAsTsserver(g:conn_id)
|
||||||
|
endif
|
||||||
|
|
||||||
let l:details = {
|
let l:details = {
|
||||||
|
\ 'command': 'foobar',
|
||||||
\ 'buffer': a:buffer,
|
\ 'buffer': a:buffer,
|
||||||
\ 'connection_id': g:conn_id,
|
\ 'connection_id': g:conn_id,
|
||||||
\ 'project_root': '/foo/bar',
|
\ 'project_root': '/foo/bar',
|
||||||
\ 'language_id': 'python',
|
|
||||||
\}
|
\}
|
||||||
|
|
||||||
let g:InitCallback = {-> a:Callback(a:linter, l:details)}
|
let g:InitCallback = {-> ale#lsp_linter#OnInit(a:linter, l:details, a:Callback)}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#lsp#HasCapability(conn_id, capability) abort
|
function! ale#lsp#HasCapability(conn_id, capability) abort
|
||||||
@ -167,6 +172,8 @@ Execute(The preview window should not be opened for empty tsserver responses):
|
|||||||
AssertEqual ['echom ''No references found.'''], g:expr_list
|
AssertEqual ['echom ''No references found.'''], g:expr_list
|
||||||
|
|
||||||
Execute(tsserver reference requests should be sent):
|
Execute(tsserver reference requests should be sent):
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
runtime ale_linters/typescript/tsserver.vim
|
runtime ale_linters/typescript/tsserver.vim
|
||||||
call setpos('.', [bufnr(''), 2, 5, 0])
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||||
|
|
||||||
@ -183,7 +190,10 @@ Execute(tsserver reference requests should be sent):
|
|||||||
\ 'function(''ale#references#HandleTSServerResponse'')',
|
\ 'function(''ale#references#HandleTSServerResponse'')',
|
||||||
\ string(g:Callback)
|
\ string(g:Callback)
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [[0, 'ts@references', {'file': expand('%:p'), 'line': 2, 'offset': 5}]],
|
\ [
|
||||||
|
\ ale#lsp#tsserver_message#Change(bufnr('')),
|
||||||
|
\ [0, 'ts@references', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
||||||
|
\ ],
|
||||||
\ g:message_list
|
\ g:message_list
|
||||||
AssertEqual {'42': {'use_relative_paths': 0}}, ale#references#GetMap()
|
AssertEqual {'42': {'use_relative_paths': 0}}, ale#references#GetMap()
|
||||||
|
|
||||||
|
@ -11,20 +11,26 @@ Before:
|
|||||||
let g:InitCallback = v:null
|
let g:InitCallback = v:null
|
||||||
|
|
||||||
runtime autoload/ale/linter.vim
|
runtime autoload/ale/linter.vim
|
||||||
|
runtime autoload/ale/lsp_linter.vim
|
||||||
runtime autoload/ale/lsp.vim
|
runtime autoload/ale/lsp.vim
|
||||||
runtime autoload/ale/util.vim
|
runtime autoload/ale/util.vim
|
||||||
|
|
||||||
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
||||||
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
||||||
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
||||||
|
|
||||||
|
if a:linter.lsp is# 'tsserver'
|
||||||
|
call ale#lsp#MarkConnectionAsTsserver(g:conn_id)
|
||||||
|
endif
|
||||||
|
|
||||||
let l:details = {
|
let l:details = {
|
||||||
|
\ 'command': 'foobar',
|
||||||
\ 'buffer': a:buffer,
|
\ 'buffer': a:buffer,
|
||||||
\ 'connection_id': g:conn_id,
|
\ 'connection_id': g:conn_id,
|
||||||
\ 'project_root': '/foo/bar',
|
\ 'project_root': '/foo/bar',
|
||||||
\ 'language_id': 'python',
|
|
||||||
\}
|
\}
|
||||||
|
|
||||||
let g:InitCallback = {-> a:Callback(a:linter, l:details)}
|
let g:InitCallback = {-> ale#lsp_linter#OnInit(a:linter, l:details, a:Callback)}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#lsp#HasCapability(conn_id, capability) abort
|
function! ale#lsp#HasCapability(conn_id, capability) abort
|
||||||
@ -215,7 +221,10 @@ Execute(tsserver definition requests should be sent):
|
|||||||
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
||||||
\ string(g:Callback)
|
\ string(g:Callback)
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [[0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]],
|
\ [
|
||||||
|
\ ale#lsp#tsserver_message#Change(bufnr('')),
|
||||||
|
\ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
||||||
|
\ ],
|
||||||
\ g:message_list
|
\ g:message_list
|
||||||
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
||||||
|
|
||||||
@ -236,7 +245,10 @@ Execute(tsserver tab definition requests should be sent):
|
|||||||
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
||||||
\ string(g:Callback)
|
\ string(g:Callback)
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [[0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]],
|
\ [
|
||||||
|
\ ale#lsp#tsserver_message#Change(bufnr('')),
|
||||||
|
\ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
||||||
|
\ ],
|
||||||
\ g:message_list
|
\ g:message_list
|
||||||
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
|
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ Before:
|
|||||||
let g:Callback = a:callback
|
let g:Callback = a:callback
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
\ 'command': 'foobar',
|
||||||
\ 'connection_id': 347,
|
\ 'connection_id': 347,
|
||||||
\ 'project_root': '/foo/bar',
|
\ 'project_root': '/foo/bar',
|
||||||
\}
|
\}
|
||||||
|
Loading…
Reference in New Issue
Block a user