feat: improve nvim

This commit is contained in:
2025-04-08 12:16:13 +02:00
parent c020c969d0
commit 6eb4b228ff
7 changed files with 203 additions and 25 deletions

View File

@@ -38,9 +38,11 @@
mergetool.enable = true; mergetool.enable = true;
trouble.enable = true; trouble.enable = true;
undotree.enable = true; undotree.enable = true;
aerial.enable = true;
base = { base = {
completion.enable = true; completion.enable = true;
diagnostics.enable = true; diagnostics.enable = true;
coverage.enable = true;
find.enable = true; find.enable = true;
formatting = { formatting = {
enable = true; enable = true;

View File

@@ -0,0 +1,64 @@
{
lib,
config,
...
}:
let
cfg = config.presets.aerial;
in
{
options.presets.aerial = {
enable = lib.mkEnableOption "aerial";
};
config = lib.mkIf cfg.enable {
keymaps = [
{
key = "<C-Up>";
action = # vim
":AerialPrev<CR>";
}
{
key = "<C-Down>";
action = # vim
":AerialNext<CR>";
}
{
key = "fs";
mode = "n";
action = # vim
":Telescope aerial<CR>";
}
];
plugins = {
aerial = {
enable = true;
settings = {
autojump = true;
highlight_on_jump = false;
filter_kind = false;
open_automatic = true;
show_guides = true;
backends = [
"lsp"
"treesitter"
"markdown"
"asciidoc"
"man"
];
layout = {
placement = "edge";
direction = "right";
};
};
};
which-key.settings.spec = [
{
__unkeyed-1 = "fs";
group = "Symbols";
icon = "󰡱";
}
];
};
};
}

View File

@@ -0,0 +1,99 @@
{
lib,
config,
...
}:
let
cfg = config.presets.base.coverage;
in
{
options.presets.base.coverage = {
enable = lib.mkEnableOption "coverage";
};
config = lib.mkIf cfg.enable {
keymaps = [
{
key = "<leader>cs";
action = # vim
":CoverageSummary<CR>";
}
{
key = "<leader>cr";
action = # vim
":CoverageClear<CR>:CoverageLoad<CR>:CoverageShow<CR>";
}
{
key = "<leader>ch";
action = # vim
":CoverageHide<CR>";
}
{
key = "<leader>cc";
action = # vim
":CoverageShow<CR>";
}
];
autoCmd = [
{
event = [ "BufEnter" ];
callback.__raw = # lua
''
function()
local ftype = vim.bo.filetype
local ok, lang = pcall(require, "coverage.languages." .. ftype)
if not ok then
return
end
local config = require("coverage.config")
local util = require("coverage.util")
local Path = require("plenary.path")
local ft_config = config.opts.lang[ftype]
if ft_config == nil then
return
end
local p = Path:new(util.get_coverage_file(ft_config.coverage_file))
if not p:exists() then
return
end
require("coverage").load(true)
end
'';
}
];
plugins = {
coverage = {
enable = true;
autoReload = true;
};
which-key.settings.spec = [
{
__unkeyed-1 = "<leader>c";
desc = "Coverage";
icon = "󰠞";
}
{
__unkeyed-1 = "<leader>cs";
desc = "Summary";
icon = "";
}
{
__unkeyed-1 = "<leader>cr";
desc = "Reload";
icon = "󰑓";
}
{
__unkeyed-1 = "<leader>ch";
desc = "Hide";
icon = "󱨃";
}
{
__unkeyed-1 = "<leader>cc";
desc = "Show";
icon = "󱨂";
}
];
};
};
}

View File

@@ -13,36 +13,48 @@ in
telescope = { telescope = {
enable = true; enable = true;
keymaps = { keymaps = {
"<leader>ff" = "git_files"; "ff" = {
"<leader>fa" = "find_files"; action = "git_files";
"<leader>fg" = "live_grep"; mode = "n";
"<leader>fb" = "buffers"; };
"fa" = {
action = "find_files";
mode = "n";
};
"fg" = {
action = "live_grep";
mode = "n";
};
"fc" = {
action = "buffers";
mode = "n";
};
}; };
}; };
which-key.settings.spec = [ which-key.settings.spec = [
{ {
__unkeyed-1 = "<leader>f"; __unkeyed-1 = "f";
group = "Find"; group = "Find";
icon = "󰍉"; icon = "󰍉";
} }
{ {
__unkeyed-1 = "<leader>ff"; __unkeyed-1 = "ff";
desc = "File"; desc = "File";
icon = "󰈢"; icon = "󰈢";
} }
{ {
__unkeyed-1 = "<leader>fa"; __unkeyed-1 = "fa";
desc = "Untracked Files"; desc = "All Files";
icon = "󱪡"; icon = "󱪡";
} }
{ {
__unkeyed-1 = "<leader>fg"; __unkeyed-1 = "fg";
desc = "Grep"; desc = "Grep";
icon = "󰑑"; icon = "󰑑";
} }
{ {
__unkeyed-1 = "<leader>fb"; __unkeyed-1 = "fc";
desc = "Buffer"; desc = "Current";
icon = "󰈙"; icon = "󰈙";
} }
]; ];

View File

@@ -10,12 +10,10 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
keymaps = [ keymaps = [
{ {
key = "<leader>ft"; key = "ft";
action = "<cmd>:Neotree toggle<CR>"; mode = "n";
} action = # vim
{ "<cmd>:Neotree toggle<CR>";
key = "<leader>ss";
action = "<cmd>:Neotree document_symbols right toggle<CR>";
} }
]; ];
plugins = { plugins = {
@@ -27,8 +25,9 @@ in
followCurrentFile.enabled = true; followCurrentFile.enabled = true;
filteredItems.visible = true; filteredItems.visible = true;
}; };
extraSources = [ "document_symbols" ]; popupBorderStyle = "rounded";
popupBorderStyle = "solid"; filesystem.window.mappings.f = "noop";
window.mappings.f = "noop";
eventHandlers.neo_tree_buffer_leave = # lua eventHandlers.neo_tree_buffer_leave = # lua
'' ''
function() function()
@@ -38,15 +37,10 @@ in
}; };
which-key.settings.spec = [ which-key.settings.spec = [
{ {
__unkeyed-1 = "<leader>ft"; __unkeyed-1 = "ft";
desc = "Tree"; desc = "Tree";
icon = "󰙅"; icon = "󰙅";
} }
{
__unkeyed-1 = "<leader>ss";
desc = "Document Symbols";
icon = "󱏒";
}
]; ];
}; };
}; };

View File

@@ -6,6 +6,7 @@
inherit pkgs; inherit pkgs;
}; };
modules = [ modules = [
./aerial.nix
./auto-save.nix ./auto-save.nix
./auto-format.nix ./auto-format.nix
./harpoon.nix ./harpoon.nix
@@ -15,6 +16,7 @@
./undotree.nix ./undotree.nix
./base/completion.nix ./base/completion.nix
./base/coverage.nix
./base/diagnostics.nix ./base/diagnostics.nix
./base/find.nix ./base/find.nix
./base/formatting.nix ./base/formatting.nix

View File

@@ -82,6 +82,10 @@ hi! ErrorMsg guibg={{colors.danger_container.default.hex}} guifg={{colors.on_dan
hi! WarningMsg guibg={{colors.warning_container.default.hex}} guifg={{colors.on_warning_container.default.hex}} hi! WarningMsg guibg={{colors.warning_container.default.hex}} guifg={{colors.on_warning_container.default.hex}}
hi! NvimInternalError guibg={{colors.danger.default.hex}} guifg={{colors.on_danger.default.hex}} hi! NvimInternalError guibg={{colors.danger.default.hex}} guifg={{colors.on_danger.default.hex}}
hi! CoverageCovered guifg={{colors.success.default.hex}}
hi! CoverageUncovered guifg={{colors.danger.default.hex}}
hi! CoveragePartial guifg={{colors.warning.default.hex}}
hi! DiagnosticError guifg={{colors.danger.default.hex}} hi! DiagnosticError guifg={{colors.danger.default.hex}}
hi! DiagnosticWarn guifg={{colors.warning.default.hex}} hi! DiagnosticWarn guifg={{colors.warning.default.hex}}
hi! DiagnosticInfo guifg={{colors.info.default.hex}} hi! DiagnosticInfo guifg={{colors.info.default.hex}}
@@ -204,6 +208,7 @@ hi! link @keyword.import.cpp PreProc
hi! Type gui=none guifg={{colors.types.default.hex}} hi! Type gui=none guifg={{colors.types.default.hex}}
hi! link @lsp.type.interface Type hi! link @lsp.type.interface Type
hi! link AerialLine CursorLine
hi! IlluminatedWordText gui=none guibg={{colors.surface_container_highest.default.hex}} hi! IlluminatedWordText gui=none guibg={{colors.surface_container_highest.default.hex}}
hi! IlluminatedWordRead gui=none guibg={{colors.surface_container_highest.default.hex}} hi! IlluminatedWordRead gui=none guibg={{colors.surface_container_highest.default.hex}}
hi! IlluminatedWordWrite gui=none guibg={{colors.surface_container_highest.default.hex}} hi! IlluminatedWordWrite gui=none guibg={{colors.surface_container_highest.default.hex}}