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

fix(lsp): not reuse lsp client for standalone file #189

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions ftplugin/rust.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
if vim.b.did_ftplugin_rustacean then
return
end

vim.b.did_ftplugin_rustacean = 1

Comment on lines +1 to +6
Copy link
Owner

@mrcjkb mrcjkb Jan 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented a fix for setting up the vim.lsp.commands for rust-analyzer only once in a24df27

and a fix for doing ftplugin stuff in a503d05

---@type RustaceanConfig
local config = require('rustaceanvim.config.internal')
local types = require('rustaceanvim.types.internal')
Expand Down
9 changes: 9 additions & 0 deletions lua/rustaceanvim/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ M.start = function(bufnr)
end
end

if not root_dir and vim.tbl_isempty(rust_analyzer.get_active_rustaceanvim_clients(bufnr)) then
return vim.lsp.start(lsp_start_opts, {
reuse_client = function()
return false
end,
bufnr = bufnr,
})
end

return vim.lsp.start(lsp_start_opts)
end

Expand Down