feat(nvim): add Rust LSP support

This commit was merged in pull request #32.
This commit is contained in:
2026-09-08 22:56:49 -04:00
parent 8855b6d379
commit 4f0512832b
2 changed files with 73 additions and 0 deletions

View File

@@ -6,6 +6,31 @@ require("nord").setup({
})
vim.cmd.colorscheme("nord")
-- Keep floating windows distinct from the current line highlight.
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#2e3440" })
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "#88c0d0", bg = "#2e3440" })
local open_floating_preview = vim.lsp.util.open_floating_preview
vim.lsp.util.open_floating_preview = function(contents, syntax, opts, ...)
opts = opts or {}
opts.border = opts.border or "rounded"
return open_floating_preview(contents, syntax, opts, ...)
end
-- Format Rust buffers before writing them.
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.rs",
callback = function(args)
vim.lsp.buf.format({
bufnr = args.buf,
timeout_ms = 2000,
filter = function(client)
return client.name == "rust_analyzer"
end,
})
end,
})
-- Conceal markdown syntax in markdown buffers.
-- conceallevel is window-local, so it is set with opt_local when the filetype
-- is applied to the buffer's window.

View File

@@ -142,6 +142,54 @@ in
];
plugins = {
blink-cmp = {
enable = true;
setupLspCapabilities = true;
settings = {
keymap = {
preset = "default";
"<M-Space>" = [
"show"
"show_documentation"
"hide_documentation"
];
};
completion.documentation.auto_show = true;
signature.enabled = true;
sources.default = [
"lsp"
"path"
"snippets"
"buffer"
];
};
};
lsp = {
enable = true;
inlayHints = true;
keymaps = {
silent = true;
diagnostic = {
"[d" = "goto_prev";
"]d" = "goto_next";
};
lspBuf = {
gd = "definition";
gD = "references";
K = "hover";
"<leader>ca" = "code_action";
"<leader>rn" = "rename";
};
};
servers.rust_analyzer = lib.mkIf config.modules.shell.rust.enable {
enable = true;
installCargo = false;
installRustc = false;
installRustfmt = false;
};
};
gitsigns = {
enable = true;
settings.current_line_blame = false;