diff --git a/configs/nixos/modules/shell/nvim/config.lua b/configs/nixos/modules/shell/nvim/config.lua index e157a7f..4ba8221 100644 --- a/configs/nixos/modules/shell/nvim/config.lua +++ b/configs/nixos/modules/shell/nvim/config.lua @@ -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. diff --git a/configs/nixos/modules/shell/nvim/default.nix b/configs/nixos/modules/shell/nvim/default.nix index fbd5a50..ac1a1eb 100644 --- a/configs/nixos/modules/shell/nvim/default.nix +++ b/configs/nixos/modules/shell/nvim/default.nix @@ -142,6 +142,54 @@ in ]; plugins = { + blink-cmp = { + enable = true; + setupLspCapabilities = true; + settings = { + keymap = { + preset = "default"; + "" = [ + "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"; + "ca" = "code_action"; + "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;