-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lsp): reload cargo workspace broken when opening another buffer (#…
…271)
- Loading branch information
Showing
3 changed files
with
20 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local fname = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ':t') | ||
if fname ~= 'Cargo.toml' then | ||
return | ||
end | ||
|
||
local config = require('rustaceanvim.config.internal') | ||
local ra = require('rustaceanvim.rust_analyzer') | ||
if config.tools.reload_workspace_from_cargo_toml then | ||
vim.api.nvim_create_autocmd('BufWritePost', { | ||
buffer = vim.api.nvim_get_current_buf(), | ||
callback = function() | ||
if #ra.get_active_rustaceanvim_clients(nil) > 0 then | ||
vim.cmd.RustLsp { 'reloadWorkspace', mods = { silent = true } } | ||
end | ||
end, | ||
group = vim.api.nvim_create_augroup('RustaceanCargoReloadWorkspace', { clear = false }), | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Duplicate autocmds will be created on each
FileType
(which is triggered byBufRead
).I suggest
nvim_clear_autocmds
-ing this augroup with the current buffer beforenvim_create_autocmd
.