fix(nvim): test dev.enable = false
All checks were successful
/ check (push) Successful in 28s
/ build (audiomenu) (push) Successful in 1s
/ build (docs) (push) Successful in 1s
/ build (jpassmenu) (push) Successful in 1s
/ build (nixosConfigurations.vm.config.system.build.toplevel) (push) Successful in 1s
/ build (nvim) (push) Successful in 1s

This caught a bug where we don't disable `conform` keymaps when
`dev.enable = false` (which disables `conform`).
This commit is contained in:
Jalil David Salamé Messina 2024-11-06 22:26:21 +01:00
parent 54c4343567
commit 84387f2597
Signed by: jalil
GPG key ID: F016B9E770737A0B
3 changed files with 277 additions and 249 deletions

View file

@ -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;
};
}

View file

@ -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
'';
}
];
};
};
}

View file

@ -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 = "<leader>qo";
action = "<cmd>Copen<CR>";
options.desc = "Quickfix Open";
}
{
mode = "n";
key = "<leader>qq";
action = "<cmd>cclose<CR>";
options.desc = "Quickfix Quit";
}
{
mode = "n";
key = "<leader>qj";
action = "<cmd>cnext<CR>";
options.desc = "Quickfix next [J]";
}
{
mode = "n";
key = "<leader>qk";
action = "<cmd>cprev<CR>";
options.desc = "Quickfix previous [K]";
}
# Open or create file
{
mode = "n";
key = "<leader>gf";
action = "<cmd>e <cfile><CR>";
options.desc = "Go to File";
}
# Keep Selection when indenting
{
mode = "x";
key = ">";
action = ">gv";
options.desc = "Indent Selection";
}
{
mode = "x";
key = "<";
action = "<gv";
options.desc = "Deindent Selection";
}
# Diagnostics
{
mode = "n";
key = "<leader>dj";
action =
mkRaw
# lua
''
vim.diagnostic.goto_next
'';
options.desc = "Diagnostics next [J]";
}
{
mode = "n";
key = "<leader>dk";
action =
mkRaw
# lua
''
vim.diagnostic.goto_prev
'';
options.desc = "Diagnostics previous [K]";
}
{
mode = "n";
key = "<leader>xs";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('symbols') end
'';
options.desc = "Toggle Diagnostics trouble";
}
{
mode = "n";
key = "<leader>xd";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('diagnostics') end
'';
options.desc = "Toggle Diagnostics trouble";
}
{
mode = "n";
key = "<leader>xq";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('quickfix') end
'';
options.desc = "Toggle Quickfix trouble";
}
{
mode = "n";
key = "<leader>xl";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('loclist') end
'';
options.desc = "Toggle Loclist trouble";
}
{
mode = "n";
key = "gR";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('lsp_references') end
'';
options.desc = "Toggle lsp References trouble";
}
# Telescope
{
mode = "n";
key = "<leader>ff";
action =
mkRaw
# lua
''
require('telescope.builtin').find_files
'';
options.desc = "Find Files";
}
{
mode = "n";
key = "<leader>fg";
action =
mkRaw
# lua
''
require('telescope.builtin').live_grep
'';
options.desc = "Find Grep";
}
{
mode = "n";
key = "<leader>fh";
action =
mkRaw
# lua
''
require('telescope.builtin').help_tags
'';
options.desc = "Find Help";
}
{
mode = "n";
key = "<leader>fb";
action =
mkRaw
# lua
''
require('telescope.builtin').buffers
'';
options.desc = "Find Buffer";
}
{
mode = "n";
key = "<leader>fd";
action =
mkRaw
# lua
''
require('telescope.builtin').diagnostics
'';
options.desc = "Find Diagnostics";
}
{
mode = "n";
key = "<leader>fq";
action =
mkRaw
# lua
''
require('telescope.builtin').quickfix
'';
options.desc = "Find Quickfix";
}
{
config.keymaps =
[
# Quickfix
{
mode = "n";
key = "<leader>qo";
action = "<cmd>Copen<CR>";
options.desc = "Quickfix Open";
}
{
mode = "n";
key = "<leader>qq";
action = "<cmd>cclose<CR>";
options.desc = "Quickfix Quit";
}
{
mode = "n";
key = "<leader>qj";
action = "<cmd>cnext<CR>";
options.desc = "Quickfix next [J]";
}
{
mode = "n";
key = "<leader>qk";
action = "<cmd>cprev<CR>";
options.desc = "Quickfix previous [K]";
}
# Open or create file
{
mode = "n";
key = "<leader>gf";
action = "<cmd>e <cfile><CR>";
options.desc = "Go to File";
}
# Keep Selection when indenting
{
mode = "x";
key = ">";
action = ">gv";
options.desc = "Indent Selection";
}
{
mode = "x";
key = "<";
action = "<gv";
options.desc = "Deindent Selection";
}
# Diagnostics
{
mode = "n";
key = "<leader>dj";
action =
mkRaw
# lua
''
vim.diagnostic.goto_next
'';
options.desc = "Diagnostics next [J]";
}
{
mode = "n";
key = "<leader>dk";
action =
mkRaw
# lua
''
vim.diagnostic.goto_prev
'';
options.desc = "Diagnostics previous [K]";
}
{
mode = "n";
key = "<leader>xs";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('symbols') end
'';
options.desc = "Toggle Diagnostics trouble";
}
{
mode = "n";
key = "<leader>xd";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('diagnostics') end
'';
options.desc = "Toggle Diagnostics trouble";
}
{
mode = "n";
key = "<leader>xq";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('quickfix') end
'';
options.desc = "Toggle Quickfix trouble";
}
{
mode = "n";
key = "<leader>xl";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('loclist') end
'';
options.desc = "Toggle Loclist trouble";
}
{
mode = "n";
key = "gR";
action =
mkRaw
# lua
''
function() require('trouble').toggle_preview('lsp_references') end
'';
options.desc = "Toggle lsp References trouble";
}
# Telescope
{
mode = "n";
key = "<leader>ff";
action =
mkRaw
# lua
''
require('telescope.builtin').find_files
'';
options.desc = "Find Files";
}
{
mode = "n";
key = "<leader>fg";
action =
mkRaw
# lua
''
require('telescope.builtin').live_grep
'';
options.desc = "Find Grep";
}
{
mode = "n";
key = "<leader>fh";
action =
mkRaw
# lua
''
require('telescope.builtin').help_tags
'';
options.desc = "Find Help";
}
{
mode = "n";
key = "<leader>fb";
action =
mkRaw
# lua
''
require('telescope.builtin').buffers
'';
options.desc = "Find Buffer";
}
{
mode = "n";
key = "<leader>fd";
action =
mkRaw
# lua
''
require('telescope.builtin').diagnostics
'';
options.desc = "Find Diagnostics";
}
{
mode = "n";
key = "<leader>fq";
action =
mkRaw
# lua
''
require('telescope.builtin').quickfix
'';
options.desc = "Find Quickfix";
}
# Nvim Silicon
{
mode = "v";
key = "<leader>sc";
action =
mkRaw
# lua
''
require('nvim-silicon').clip
'';
options.desc = "Snap Code (to clipboard)";
}
]
++ lib.optional dev {
mode = "n";
key = "<leader>w";
action =
@ -204,19 +226,5 @@ in
require('conform').format
'';
options.desc = "Format buffer";
}
# Nvim Silicon
{
mode = "v";
key = "<leader>sc";
action =
mkRaw
# lua
''
require('nvim-silicon').clip
'';
options.desc = "Snap Code (to clipboard)";
}
];
};
}