{ config, lib, ... }: let inherit (lib) mkEnableOption mkMerge mkIf ; basecfg = { enable = true; defaultEditor = true; vimdiffAlias = true; vimAlias = true; viAlias = true; colorschemes.dracula-nvim = { enable = true; settings = { colors = { bg = "#000000"; black = "#000000"; }; transparent_bg = true; overrides.__raw = '' function (colors) return { LineNr = { bg = "#181818", fg = colors.purple }, CursorLine = { }, CursorLineNr = { fg = "#FFFF00", bg = colors.black, bold = true }, StatusLine = { fg = colors.bright_white, bg = colors.black }, } end ''; }; }; opts = { foldlevelstart = 99; number = true; relativenumber = true; cursorline = true; tabstop = 2; shiftwidth = 2; expandtab = true; }; globals.mapleader = ","; autoCmd = [ { command = "set relativenumber"; event = [ "InsertLeave" ]; } { command = "set norelativenumber"; event = [ "InsertEnter" ]; } ]; keymaps = [ { action = ":set number!"; key = ""; } { action = ":set relativenumber!"; key = ""; } { action = ''"*ygv''; key = ""; mode = [ "v" ]; } ]; plugins = { nix.enable = true; treesitter = { enable = true; folding = true; settings.highlight.enable = true; }; telescope = { enable = true; keymaps = { "ff".action = "find_files"; "fg".action = "live_grep"; "fb".action = "buffers"; }; settings.pickers.buffers.mappings = rec { i."".__raw = "require('telescope.actions').delete_buffer"; n = i; }; }; web-devicons.enable = true; which-key = { enable = true; settings.triggers = map (key: { __unkeyed = key; mode = "nxsot"; }) [ "" "f" "c" "d" "y" ]; }; todo-comments = { enable = true; keymaps.todoTelescope.key = "ft"; }; markview.enable = true; nvim-surround.enable = true; }; }; adv-editor = { plugins = { which-key.settings.spec = [ { __unkeyed = "l"; desc = "Lsp keymaps"; } { __unkeyed = "lK"; desc = "Hover information"; } { __unkeyed = "la"; desc = "Apply code action"; } { __unkeyed = "ls"; desc = "Show signature help"; } { __unkeyed = "lg"; desc = "Go to"; } { __unkeyed = "lgD"; desc = "References"; } { __unkeyed = "lgd"; desc = "Definition"; } { __unkeyed = "lgi"; desc = "Implementation"; } { __unkeyed = "lgt"; desc = "Type definition"; } ]; luasnip.enable = true; cmp_luasnip.enable = true; cmp-nvim-lsp.enable = true; cmp-buffer.enable = true; cmp-cmdline.enable = true; cmp-path.enable = true; cmp-latex-symbols.enable = true; cmp = { enable = true; autoEnableSources = false; cmdline = let slash-qu = { mapping.__raw = "cmp.mapping.preset.cmdline()"; sources = [ { name = "buffer"; } ]; }; in { "/" = slash-qu; "?" = slash-qu; ":" = { mapping.__raw = "cmp.mapping.preset.cmdline()"; sources = [ { name = "path"; } { name = "cmdline"; } ]; matching = { disallow_symbol_nonprefix_matching = false; }; }; }; settings = { snippet.expand = '' function(args) require('luasnip').lsp_expand(args.body) end ''; sources = map (name: { inherit name; }) [ "luasnip" "nvim_lsp" "buffer" ] ++ [ { name = "latex_symbols"; option.strategy = 2; } ]; mapping = { "" = "cmp.mapping.complete()"; "" = "cmp.mapping.scroll_docs(-4)"; "" = "cmp.mapping.close()"; "" = "cmp.mapping.scroll_docs(4)"; "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })"; "" = '' cmp.mapping( function(fallback) if cmp.visible() then cmp.select_prev_item() elseif require("luasnip").jumpable(-1) then vim.fn.feedkeys( vim.api.nvim_replace_termcodes( "luasnip-jump-prev", true, true, true), "") else fallback() end end, {'i', 's'})''; "" = '' cmp.mapping( function(fallback) if cmp.visible() then cmp.select_next_item() elseif require("luasnip").expand_or_jumpable() then vim.fn.feedkeys( vim.api.nvim_replace_termcodes( "luasnip-expand-or-jump", true, true, true), "") else fallback() end end, { 'i', 's' }) ''; }; }; }; lsp-lines.enable = true; lsp = { enable = true; keymaps = { diagnostic = { "lj" = "goto_next"; "lk" = "goto_prev"; }; lspBuf = { "lK" = "hover"; "la" = "code_action"; "ls" = "signature_help"; "lgD" = "references"; "lgd" = "definition"; "lgi" = "implementation"; "lgt" = "type_definition"; }; extra = [ { action = "LspStop"; key = "lx"; } { action = "LspStart"; key = "ls"; } { action = "LspRestart"; key = "lr"; } ]; }; servers = { nixd.enable = true; pylsp.enable = true; clangd.enable = true; ltex.enable = true; rust_analyzer = { enable = true; installCargo = true; installRustc = true; }; hls = { enable = true; installGhc = true; }; }; }; }; }; in { options.kat.neovim = { enable = mkEnableOption "neovim configuration" // { default = true; }; lsp = mkEnableOption "neovim LSPs"; }; config = mkIf config.kat.neovim.enable { programs.nixvim = mkMerge [ basecfg (mkIf config.kat.neovim.lsp adv-editor) ]; }; }