mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
chezmoi: reorganise repo
This commit is contained in:
parent
b391e03c87
commit
67a78879db
278 changed files with 102 additions and 182 deletions
33
home/dot_config/nvim/lsp/rust_analyzer.lua
Normal file
33
home/dot_config/nvim/lsp/rust_analyzer.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
-- Rust
|
||||
--[[ Installation
|
||||
rustup component add rust-src
|
||||
--]]
|
||||
return {
|
||||
cmd = { "rust-analyzer" },
|
||||
filetypes = { "rust" },
|
||||
root_dir = function(bufnr, cb)
|
||||
local root = vim.fs.root(bufnr, { "Cargo.toml" })
|
||||
if root then
|
||||
vim.system({ "cargo", "metadata", "--no-depts", "--format-version", "1" }, { cwd = root }, function(obj)
|
||||
if obj.code ~= 0 then
|
||||
cb(root)
|
||||
else
|
||||
local success, result = pcall(vim.json.decode, obj.stdout)
|
||||
if success and result.workspace_root then
|
||||
cb(result.workspace_root)
|
||||
else
|
||||
cb(root)
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
cb(vim.fs.root(bufnr, { "rust-project.json", ".git" }))
|
||||
end
|
||||
end,
|
||||
before_init = function(init_params, config)
|
||||
-- See https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26
|
||||
if config.settings and config.settings["rust-analyzer"] then
|
||||
init_params.initializationOptions = config.settings["rust-analyzer"]
|
||||
end
|
||||
end,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue