Open ModProg opened 1 year ago
POC:
function string:endswith(suffix)
return self:sub(- #suffix) == suffix
end
local fwatch = require 'fwatch'
fwatch.watch(".", {
on_event = function(filename)
if filename:endswith("Cargo.toml") then
vim.schedule(function()
require 'lspconfig'["rust_analyzer"].commands["CargoReload"][1]()
end)
end
end
})
I created a new issue with the specific request for ra to listen for changes on its own: https://github.com/rust-lang/rust-analyzer/issues/14669.
I could imagine using something like https://github.com/rktjmp/fwatch.nvim (the code is very short, so probably makes sense to just copy it instead of creating a dependency).
This would ensure changes with e.g.
cargo add
are also registered.IMO, this could also be something ra does itself, but apparently they want the editor to do it (https://github.com/rust-lang/rust-analyzer/issues/9546)