diff --git a/flake-modules/nvim.nix b/flake-modules/nvim.nix index 00aadc3..5b25b7b 100644 --- a/flake-modules/nvim.nix +++ b/flake-modules/nvim.nix @@ -1,4 +1,4 @@ -{ inputs, ... }: +{ inputs, lib, ... }: { flake.overlays.nixvim = inputs.nixvim.overlays.default; @@ -7,7 +7,7 @@ let nixvimLib = inputs.nixvim.lib.${system}; nixvim = inputs.nixvim.legacyPackages.${system}; - module = { + moduleDev = { inherit pkgs; extraSpecialArgs = { inherit (inputs) unstable; @@ -15,12 +15,24 @@ }; module = import ../nvim/standalone.nix { standalone = true; }; }; + moduleHeadless = { + inherit pkgs; + extraSpecialArgs = { + inherit (inputs) unstable; + inherit system; + }; + module = { + imports = [ (import ../nvim/standalone.nix { standalone = true; }) ]; + config.jhome.nvim.dev.enable = false; + }; + }; in { # Check standalone nvim build - checks.nvim = nixvimLib.check.mkTestDerivationFromNixvimModule module; + checks.nvimDev = nixvimLib.check.mkTestDerivationFromNixvimModule moduleDev; + checks.nvimHeadless = nixvimLib.check.mkTestDerivationFromNixvimModule moduleHeadless; # Nvim standalone module - packages.nvim = nixvim.makeNixvimWithModule module; + packages.nvim = nixvim.makeNixvimWithModule moduleDev; }; } diff --git a/nvim/augroups.nix b/nvim/augroups.nix index 0ff94d5..de18584 100644 --- a/nvim/augroups.nix +++ b/nvim/augroups.nix @@ -1,6 +1,13 @@ -{ helpers, ... }: +{ + config, + helpers, + lib, + ... +}: let inherit (helpers) mkRaw; + cfg = config.jhome.nvim; + dev = cfg.dev.enable; in { config = { @@ -9,41 +16,43 @@ in "lspConfig" = { }; "restoreCursorPosition" = { }; }; - autoCmd = [ - { - group = "highlightOnYank"; - event = "TextYankPost"; - pattern = "*"; - callback = - mkRaw - # lua - '' - function() - vim.highlight.on_yank { - higroup = ( - vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch' - ), - timeout = 200, - } - end - ''; - } - { - group = "restoreCursorPosition"; - event = "BufReadPost"; - pattern = "*"; - callback = - mkRaw - # lua - '' - function() - if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then - vim.cmd [[execute "normal! g'\""]] + autoCmd = + [ + { + group = "highlightOnYank"; + event = "TextYankPost"; + pattern = "*"; + callback = + mkRaw + # lua + '' + function() + vim.highlight.on_yank { + higroup = ( + vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch' + ), + timeout = 200, + } end - end - ''; - } - { + ''; + } + { + group = "restoreCursorPosition"; + event = "BufReadPost"; + pattern = "*"; + callback = + mkRaw + # lua + '' + function() + if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then + vim.cmd [[execute "normal! g'\""]] + end + end + ''; + } + ] + ++ lib.optional dev { group = "lspConfig"; event = "LspAttach"; pattern = "*"; @@ -94,7 +103,6 @@ in vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = '[G]o to [I]mplementation', ${opts} }) end ''; - } - ]; + }; }; } diff --git a/nvim/mappings.nix b/nvim/mappings.nix index ad99182..a7d5c36 100644 --- a/nvim/mappings.nix +++ b/nvim/mappings.nix @@ -1,200 +1,222 @@ -{ helpers, ... }: +{ + lib, + config, + helpers, + ... +}: let inherit (helpers) mkRaw; + cfg = config.jhome.nvim; + dev = cfg.dev.enable; in { - config.keymaps = [ - # Quickfix - { - mode = "n"; - key = "qo"; - action = "Copen"; - options.desc = "Quickfix Open"; - } - { - mode = "n"; - key = "qq"; - action = "cclose"; - options.desc = "Quickfix Quit"; - } - { - mode = "n"; - key = "qj"; - action = "cnext"; - options.desc = "Quickfix next [J]"; - } - { - mode = "n"; - key = "qk"; - action = "cprev"; - options.desc = "Quickfix previous [K]"; - } - # Open or create file - { - mode = "n"; - key = "gf"; - action = "e "; - options.desc = "Go to File"; - } - # Keep Selection when indenting - { - mode = "x"; - key = ">"; - action = ">gv"; - options.desc = "Indent Selection"; - } - { - mode = "x"; - key = "<"; - action = "