mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 21:25:04 -07:00
fix(lsp): always return boolean in lsp.buf_client_attach (#24077)
Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
This commit is contained in:
parent
1f0b2dc6cd
commit
3bf887f6e0
@ -678,6 +678,10 @@ buf_attach_client({bufnr}, {client_id}) *vim.lsp.buf_attach_client()*
|
|||||||
• {bufnr} (integer) Buffer handle, or 0 for current
|
• {bufnr} (integer) Buffer handle, or 0 for current
|
||||||
• {client_id} (integer) Client id
|
• {client_id} (integer) Client id
|
||||||
|
|
||||||
|
Return: ~
|
||||||
|
(boolean) success `true` if client was attached successfully; `false`
|
||||||
|
otherwise
|
||||||
|
|
||||||
buf_detach_client({bufnr}, {client_id}) *vim.lsp.buf_detach_client()*
|
buf_detach_client({bufnr}, {client_id}) *vim.lsp.buf_detach_client()*
|
||||||
Detaches client from the specified buffer. Note: While the server is
|
Detaches client from the specified buffer. Note: While the server is
|
||||||
notified that the text document (buffer) was closed, it is still able to
|
notified that the text document (buffer) was closed, it is still able to
|
||||||
|
@ -1799,6 +1799,7 @@ end
|
|||||||
---
|
---
|
||||||
---@param bufnr (integer) Buffer handle, or 0 for current
|
---@param bufnr (integer) Buffer handle, or 0 for current
|
||||||
---@param client_id (integer) Client id
|
---@param client_id (integer) Client id
|
||||||
|
---@return boolean success `true` if client was attached successfully; `false` otherwise
|
||||||
function lsp.buf_attach_client(bufnr, client_id)
|
function lsp.buf_attach_client(bufnr, client_id)
|
||||||
validate({
|
validate({
|
||||||
bufnr = { bufnr, 'n', true },
|
bufnr = { bufnr, 'n', true },
|
||||||
@ -1887,7 +1888,7 @@ function lsp.buf_attach_client(bufnr, client_id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if buffer_client_ids[client_id] then
|
if buffer_client_ids[client_id] then
|
||||||
return
|
return true
|
||||||
end
|
end
|
||||||
-- This is our first time attaching this client to this buffer.
|
-- This is our first time attaching this client to this buffer.
|
||||||
buffer_client_ids[client_id] = true
|
buffer_client_ids[client_id] = true
|
||||||
|
@ -1070,7 +1070,7 @@ describe('LSP', function()
|
|||||||
eq(full_kind, client.server_capabilities().textDocumentSync.change)
|
eq(full_kind, client.server_capabilities().textDocumentSync.change)
|
||||||
eq(true, client.server_capabilities().textDocumentSync.openClose)
|
eq(true, client.server_capabilities().textDocumentSync.openClose)
|
||||||
exec_lua [[
|
exec_lua [[
|
||||||
assert(not lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID), "Shouldn't attach twice")
|
assert(lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID), "Already attached, returns true")
|
||||||
]]
|
]]
|
||||||
end;
|
end;
|
||||||
on_exit = function(code, signal)
|
on_exit = function(code, signal)
|
||||||
|
Loading…
Reference in New Issue
Block a user