Skip to content

Commit 8995b40

Browse files
committed
Go through lsp.start in wipe_data_and_restart, to avoid double start
1 parent 8eb5f0d commit 8995b40

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lua/jdtls/setup.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ local function maybe_implicit_save()
167167
end
168168

169169

170-
---@return string?, lsp.Client?
170+
---@return string?, vim.lsp.Client?
171171
local function extract_data_dir(bufnr)
172172
-- Prefer client from current buffer, in case there are multiple jdtls clients (multiple projects)
173173
local client = get_clients({ name = "jdtls", bufnr = bufnr })[1]
@@ -264,7 +264,7 @@ end
264264
---
265265
---@param config table<string, any> configuration. See |vim.lsp.start_client|
266266
---@param opts? jdtls.start.opts
267-
---@param start_opts? lsp.StartOpts options passed to vim.lsp.start
267+
---@param start_opts? vim.lsp.start.Opts? options passed to vim.lsp.start
268268
---@return integer? client_id
269269
function M.start_or_attach(config, opts, start_opts)
270270
opts = opts or {}
@@ -370,7 +370,12 @@ function M.wipe_data_and_restart()
370370
return vim.lsp.get_client_by_id(client.id) == nil
371371
end)
372372
vim.fn.delete(data_dir, 'rf')
373-
local client_id = lsp.start_client(client.config)
373+
local client_id
374+
if vim.bo.filetype == "java" then
375+
client_id = lsp.start(client.config)
376+
else
377+
client_id = vim.lsp.start_client(client.config)
378+
end
374379
if client_id then
375380
for _, buf in ipairs(bufs) do
376381
lsp.buf_attach_client(buf, client_id)

0 commit comments

Comments
 (0)