summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--nvim/.config/nvim/lua/tobyvin/lsp/configs.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua b/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua
index bed8a3e..7ca8b00 100644
--- a/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua
+++ b/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua
@@ -95,6 +95,24 @@ local M = {
powershell_es = {},
pylsp = {},
rust_analyzer = {
+ root_dir = function(fname)
+ local util = require("lspconfig.util")
+
+ local cargo_home = os.getenv("CARGO_HOME") or util.path.join(vim.env.HOME, ".cargo")
+ local registry = util.path.join(cargo_home, "registry", "src")
+
+ local rustup_home = os.getenv("RUSTUP_HOME") or util.path.join(vim.env.HOME, ".rustup")
+ local toolchains = util.path.join(rustup_home, "toolchains")
+
+ for _, item in ipairs({ toolchains, registry }) do
+ if fname:sub(1, #item) == item then
+ local clients = vim.lsp.get_active_clients({ name = "rust_analyzer" })
+ return clients[#clients].config.root_dir
+ end
+ end
+
+ return require("lspconfig.server_configurations.rust_analyzer").default_config.root_dir(fname)
+ end,
handlers = {
["experimental/externalDocs"] = function(err, result)
if result then