Skip to content

Commit

Permalink
fix rust_analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
dundalek committed Mar 13, 2024
1 parent 87305e0 commit e7638bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lua/lazy-lsp/overrides.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,16 @@ return {
perlnavigator = {
cmd = { "perlnavigator", "--stdio" },
},
rust_analyzer = {
root_dir = function(fname)
-- Default lspconfig root_dir detection uses cargo to try to detect workspace directory.
-- It fails if cargo is not available, fallback to a simpler detection.
if not vim.fn.executable("cargo") then
return util.root_pattern("Cargo.toml")(fname)
or util.root_pattern("rust-project.json")(fname)
or util.find_git_ancestor(fname)
end
return lspconfig.jdtls.document_config.default_config.root_dir(fname)
end
},
}
6 changes: 5 additions & 1 deletion lua/lazy-lsp/servers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ return {
ruby_ls = "rubyPackages.ruby-lsp",
ruff_lsp = "ruff-lsp",
rune_languageserver = "rune-languageserver",
rust_analyzer = "rust-analyzer",
rust_analyzer = {
"rust-analyzer",
"cargo",
"rustfmt"
},
salt_ls = "",
scheme_langserver = "",
scry = "scry",
Expand Down

0 comments on commit e7638bd

Please sign in to comment.