{ lib, path }: { pkgs, config, ... }: let setPath = if path == [ ] then [ "config" ] else path; in lib.setAttrByPath setPath ( let cfg = lib.getAttrFromPath path config; in { vimAlias = true; enableMan = false; # Basic editing / QoL editorconfig.enable = true; colorschemes.kanagawa.enable = true; plugins = { nix.enable = true; fugitive.enable = true; gitgutter.enable = true; instant.enable = true; lualine.enable = true; typst-vim.enable = true; telescope = { enable = true; keymaps = { "tgf" = "git_files"; "tb" = "buffers"; "tl" = "live_grep"; "ts" = "grep_string"; "tf" = "find_files"; "tt" = "builtin"; "tz" = "spell_suggest"; 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-flatbuffers vim-nftables vim-protobuf vim-toml ]; opts = { hidden = true; backup = false; writebackup = false; cmdheight = 2; shortmess = "filnxtToOFc"; signcolumn = "yes"; number = true; }; # LSP plugins.rust-tools = { enable = cfg.plugins.lsp.enable; server.standalone = false; }; plugins.clangd-extensions.enable = cfg.plugins.lsp.enable; plugins.lsp = { enable = lib.mkDefault true; servers = { clangd.enable = cfg.plugins.lsp.enable; java-language-server.enable = cfg.plugins.lsp.enable; jsonls.enable = cfg.plugins.lsp.enable; nil-ls.enable = cfg.plugins.lsp.enable; omnisharp.enable = cfg.plugins.lsp.enable; pylsp.enable = cfg.plugins.lsp.enable; texlab.enable = cfg.plugins.lsp.enable; tsserver.enable = cfg.plugins.lsp.enable; typst-lsp.enable = cfg.plugins.lsp.enable; }; 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 = { luasnip.enable = true; cmp-cmdline.enable = true; cmp-git.enable = true; cmp-buffer.enable = true; cmp = { enable = true; settings = { snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; sources = [ { name = "luasnip"; } { name = "nvim_lsp"; } { name = "path"; } { name = "calc"; } { name = "emoji"; } ]; mapping = { "" = "cmp.mapping.confirm({ select = true })"; "" = "cmp.mapping.scroll_docs(-4)"; "" = "cmp.mapping.scroll_docs(4)"; "" = "cmp.mapping.complete()"; "" = "cmp.mapping.abort()"; "" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; }; }; }; }; # 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 ''; } )