{ pkgs, inputs, ... }: { imports = [ inputs.nixvim.nixosModules.nixvim ]; environment.sessionVariables = { EDITOR = "nvim"; VISUAL = "nvim"; }; programs.nixvim = { enable = true; vimAlias = true; # Basic editing / QoL editorconfig.enable = true; colorschemes.kanagawa.enable = true; plugins = { nix.enable = true; fugitive.enable = true; gitgutter.enable = true; lualine.enable = true; telescope = { enable = true; keymaps = { "tgf" = "git_files"; "tb" = "buffers"; "tl" = "live_grep"; "ts" = "grep_string"; "tf" = "find_files"; "tt" = "builtin"; gd = "lsp_definitions"; gt = "lsp_type_definitions"; gr = "lsp_references"; gi = "lsp_implementations"; gcd = "diagnostics"; gsd = "lsp_document_symbols"; gsw = "lsp_workspace_symbols"; gci = "lsp_incoming_calls"; gco = "lsp_outgoing_calls"; "tgs" = "git_status"; "tgb" = "git_branches"; "tgc" = "git_commits"; }; }; }; extraPlugins = with pkgs.vimPlugins; [ vim-fetch vim-fish vim-flatbuffers vim-nftables vim-protobuf vim-toml ]; options = { hidden = true; backup = false; writebackup = false; cmdheight = 2; shortmess = "filnxtToOFc"; signcolumn = "yes"; number = true; }; # LSP plugins.rust-tools = { enable = true; server.standalone = false; }; plugins.clangd-extensions.enable = true; plugins.lsp = { enable = true; servers = { clangd.enable = true; java-language-server.enable = true; nil_ls.enable = true; pylsp.enable = true; texlab.enable = true; jsonls.enable = true; }; keymaps = { silent = true; diagnostic = { "rk" = "goto_prev"; "rj" = "goto_next"; }; lspBuf = { K = "hover"; gD = "declaration"; "ra" = "code_action"; "rn" = "rename"; "rs" = "signature_help"; "f" = "format"; }; }; onAttach = '' if client.server_capabilities.documentHighlightProvider then vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true }) vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" } vim.api.nvim_create_autocmd("CursorHold", { callback = vim.lsp.buf.document_highlight, buffer = bufnr, group = "lsp_document_highlight", desc = "Document Highlight", }) vim.api.nvim_create_autocmd("CursorMoved", { callback = vim.lsp.buf.clear_references, buffer = bufnr, group = "lsp_document_highlight", desc = "Clear All the References", }) end ''; }; # Autocomplete plugins = { cmp-cmdline.enable = true; cmp-git.enable = true; cmp-buffer.enable = true; nvim-cmp = { enable = true; sources = [ { name = "nvim_lsp"; } { name = "path"; } { name = "calc"; } { name = "emoji"; } ]; mappingPresets = [ "insert" "cmdline" ]; mapping = { "" = "cmp.mapping.confirm({ select = true })"; "" = "cmp.mapping.scroll_docs(-4)"; "" = "cmp.mapping.scroll_docs(4)"; "" = "cmp.mapping.complete()"; "" = "cmp.mapping.abort()"; }; }; }; # For some reason you can't do this directly in nix? extraConfigLuaPost = '' do local cmp = require('cmp') cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ { name = 'git' }, }, { { name = 'buffer' }, }) }) cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } } }) cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) }) end ''; }; }