Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go through lsp.start in wipe_data_and_restart, to avoid double start #651

Merged
merged 1 commit into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lua/jdtls/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ local function maybe_implicit_save()
end


---@return string?, lsp.Client?
---@return string?, vim.lsp.Client?
local function extract_data_dir(bufnr)
-- Prefer client from current buffer, in case there are multiple jdtls clients (multiple projects)
local client = get_clients({ name = "jdtls", bufnr = bufnr })[1]
Expand Down Expand Up @@ -264,7 +264,7 @@ end
---
---@param config table<string, any> configuration. See |vim.lsp.start_client|
---@param opts? jdtls.start.opts
---@param start_opts? lsp.StartOpts options passed to vim.lsp.start
---@param start_opts? vim.lsp.start.Opts? options passed to vim.lsp.start
---@return integer? client_id
function M.start_or_attach(config, opts, start_opts)
opts = opts or {}
Expand Down Expand Up @@ -370,7 +370,12 @@ function M.wipe_data_and_restart()
return vim.lsp.get_client_by_id(client.id) == nil
end)
vim.fn.delete(data_dir, 'rf')
local client_id = lsp.start_client(client.config)
local client_id
if vim.bo.filetype == "java" then
client_id = lsp.start(client.config)
else
client_id = vim.lsp.start_client(client.config)
end
if client_id then
for _, buf in ipairs(bufs) do
lsp.buf_attach_client(buf, client_id)
Expand Down
Loading