Skip to content

Commit b251774

Browse files
committed
fix(nvim): refined LSP launching process
1 parent 97dd5a6 commit b251774

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lua/vectorcode/config.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ local lsp_configs = function()
3232
cfg = lspconfig.vectorcode_server.config_def.default_config
3333
end
3434
end
35+
cfg.name = "vectorcode_server"
3536
return cfg
3637
end
3738

lua/vectorcode/jobrunner/lsp.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ local notify_opts = vc_config.notify_opts
1818
---@param ok_to_fail boolean
1919
---@return integer?
2020
function jobrunner.init(ok_to_fail)
21+
local existing_clients = vim.lsp.get_clients({ name = vc_config.lsp_configs().name })
22+
if #existing_clients > 0 then
23+
CLIENT = existing_clients[1]
24+
return CLIENT.id
25+
end
2126
ok_to_fail = ok_to_fail or true
2227
local client_id = vim.lsp.start(vc_config.lsp_configs(), {})
2328
if client_id ~= nil then
@@ -63,8 +68,7 @@ function jobrunner.run(args, timeout_ms, bufnr)
6368
end
6469

6570
function jobrunner.run_async(args, callback, bufnr)
66-
jobrunner.init(false)
67-
assert(CLIENT ~= nil)
71+
assert(jobrunner.init(false))
6872
assert(bufnr ~= nil)
6973

7074
if not CLIENT.attached_buffers[bufnr] then

0 commit comments

Comments
 (0)