From 84387f25979cfc35519fdffee8ac510b6988b182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Wed, 6 Nov 2024 22:26:21 +0100 Subject: [PATCH] fix(nvim): test dev.enable = false This caught a bug where we don't disable `conform` keymaps when `dev.enable = false` (which disables `conform`). --- flake-modules/nvim.nix | 20 +- nvim/augroups.nix | 82 ++++---- nvim/mappings.nix | 424 +++++++++++++++++++++-------------------- 3 files changed, 277 insertions(+), 249 deletions(-) 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 = "