From 0ebfee77e61286c47d9e50214e6fd871cafef14e Mon Sep 17 00:00:00 2001 From: Adam0 Date: Wed, 15 Jul 2026 21:10:06 -0400 Subject: [PATCH] Refactor config and improve neovim config --- flake.nix | 6 +- modules/desktop/hyprland/default.nix | 2 +- modules/desktop/hyprland/plugins.nix | 2 +- modules/desktop/hyprland/rules.nix | 10 +- modules/desktop/overzicht/default.nix | 2 +- .../blocklist-gotify-proxy.nix} | 0 .../blocklist-import.nix} | 0 modules/pkgs/default.nix | 2 + modules/pkgs/neovim/dashboard-gh-notify.nix | 17 ++++ modules/pkgs/neovim/dashboard-vcs-status.nix | 75 ++++++++++++++ modules/programs/cli/diffnav.nix | 17 ++-- modules/programs/delta.nix | 2 - modules/programs/gui/zen/chrome.nix | 2 +- .../tui/neovim/components/autocomplete.nix | 2 +- .../tui/neovim/components/dashboard.nix | 97 +------------------ .../tui/neovim/components/debugger.nix | 5 + .../tui/neovim/components/diagnostics.nix | 8 ++ .../tui/neovim/components/statuscolumn.nix | 5 - modules/programs/tui/neovim/keymap.nix | 84 ++++++++++++++++ .../programs/tui/neovim/languages/default.nix | 1 + 20 files changed, 219 insertions(+), 120 deletions(-) rename modules/pkgs/{crowdsec-blocklist-gotify-proxy.nix => crowdsec/blocklist-gotify-proxy.nix} (100%) rename modules/pkgs/{crowdsec-blocklist-import.nix => crowdsec/blocklist-import.nix} (100%) create mode 100644 modules/pkgs/neovim/dashboard-gh-notify.nix create mode 100644 modules/pkgs/neovim/dashboard-vcs-status.nix create mode 100644 modules/programs/tui/neovim/components/debugger.nix create mode 100644 modules/programs/tui/neovim/components/diagnostics.nix delete mode 100644 modules/programs/tui/neovim/components/statuscolumn.nix diff --git a/flake.nix b/flake.nix index a7ccd9d..1f2869b 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; hylix = { - url = "https://tangled.org/adam0.dev/hylix/archive/main?format=tar.gz"; + url = "tarball+https://tangled.org/adam0.dev/hylix/archive/main?format=tar.gz"; inputs = { flake-parts.follows = "flake-parts"; import-tree.follows = "import-tree"; @@ -51,7 +51,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; nix-userstyles = { - url = "https://tangled.org/adam0.dev/nix-userstyles/archive/main?format=tar.gz"; + url = "tarball+https://tangled.org/adam0.dev/nix-userstyles/archive/main?format=tar.gz"; inputs = { flake-parts.follows = "flake-parts"; import-tree.follows = "import-tree"; @@ -89,7 +89,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; overzicht = { - url = "https://tangled.org/adam0.dev/overzicht/archive/main?format=tar.gz"; + url = "tarball+https://tangled.org/adam0.dev/overzicht/archive/main?format=tar.gz"; inputs = { flake-parts.follows = "flake-parts"; import-tree.follows = "import-tree"; diff --git a/modules/desktop/hyprland/default.nix b/modules/desktop/hyprland/default.nix index fd0568b..b604066 100644 --- a/modules/desktop/hyprland/default.nix +++ b/modules/desktop/hyprland/default.nix @@ -3,7 +3,7 @@ hyprland.url = "github:hyprwm/Hyprland?ref=v0.55.4"; hylix = { - url = "https://tangled.org/adam0.dev/hylix/archive/main?format=tar.gz"; + url = "tarball+https://tangled.org/adam0.dev/hylix/archive/main?format=tar.gz"; inputs = { # keep-sorted start flake-parts.follows = "flake-parts"; diff --git a/modules/desktop/hyprland/plugins.nix b/modules/desktop/hyprland/plugins.nix index 0a5f79b..f22dcf0 100644 --- a/modules/desktop/hyprland/plugins.nix +++ b/modules/desktop/hyprland/plugins.nix @@ -45,8 +45,8 @@ in { wayland.windowManager.hyprland.plugins = [ # keep-sorted start - pkgs.hyprlandPlugins.hyprfocus kineticScroll + pkgs.hyprlandPlugins.hyprfocus # keep-sorted end ]; diff --git a/modules/desktop/hyprland/rules.nix b/modules/desktop/hyprland/rules.nix index 248fb73..731d47f 100644 --- a/modules/desktop/hyprland/rules.nix +++ b/modules/desktop/hyprland/rules.nix @@ -31,28 +31,28 @@ in { programs.hylix = { permissions = [ - # Plugnis. + # Plugins # keep-sorted start block=yes newline_separated=yes { - binary = escapeRegex kineticScroll; + binary = ".*/libhyprfocus\\.so$"; mode = "allow"; type = "plugin"; } { - binary = ".*/libhyprfocus\\.so$"; + binary = escapeRegex hyprctl; mode = "allow"; type = "plugin"; } { - binary = escapeRegex hyprctl; + binary = escapeRegex kineticScroll; mode = "allow"; type = "plugin"; } # keep-sorted end - # Screenscopy. + # Screencopy # keep-sorted start block=yes newline_separated=yes { binary = escapeRegex equibop; diff --git a/modules/desktop/overzicht/default.nix b/modules/desktop/overzicht/default.nix index cba49dd..4b560f6 100644 --- a/modules/desktop/overzicht/default.nix +++ b/modules/desktop/overzicht/default.nix @@ -1,6 +1,6 @@ {inputs, ...}: { flake-file.inputs.overzicht = { - url = "https://tangled.org/adam0.dev/overzicht/archive/main?format=tar.gz"; + url = "tarball+https://tangled.org/adam0.dev/overzicht/archive/main?format=tar.gz"; inputs = { # keep-sorted start flake-parts.follows = "flake-parts"; diff --git a/modules/pkgs/crowdsec-blocklist-gotify-proxy.nix b/modules/pkgs/crowdsec/blocklist-gotify-proxy.nix similarity index 100% rename from modules/pkgs/crowdsec-blocklist-gotify-proxy.nix rename to modules/pkgs/crowdsec/blocklist-gotify-proxy.nix diff --git a/modules/pkgs/crowdsec-blocklist-import.nix b/modules/pkgs/crowdsec/blocklist-import.nix similarity index 100% rename from modules/pkgs/crowdsec-blocklist-import.nix rename to modules/pkgs/crowdsec/blocklist-import.nix diff --git a/modules/pkgs/default.nix b/modules/pkgs/default.nix index 1d78169..7d0aa85 100644 --- a/modules/pkgs/default.nix +++ b/modules/pkgs/default.nix @@ -8,6 +8,8 @@ # keep-sorted start crowdsec-blocklist-gotify-proxy crowdsec-blocklist-import + dashboard-gh-notify + dashboard-vcs-status djvutorga-adapter gotify-optimize-images jj-conflict-nvim diff --git a/modules/pkgs/neovim/dashboard-gh-notify.nix b/modules/pkgs/neovim/dashboard-gh-notify.nix new file mode 100644 index 0000000..b53fb8c --- /dev/null +++ b/modules/pkgs/neovim/dashboard-gh-notify.nix @@ -0,0 +1,17 @@ +{ + perSystem = {pkgs, ...}: let + inherit (pkgs) writeShellApplication; + in { + packages.dashboard-gh-notify = writeShellApplication { + name = "dashboard-gh-notify"; + runtimeInputs = [pkgs.coreutils]; + text = '' + : "''${GH_TOKEN_FILE:?GH_TOKEN_FILE is required}" + + GH_TOKEN="$(cat "$GH_TOKEN_FILE")" + export GH_TOKEN + exec "${pkgs.lib.getExe pkgs.gh-notify}" "$@" + ''; + }; + }; +} diff --git a/modules/pkgs/neovim/dashboard-vcs-status.nix b/modules/pkgs/neovim/dashboard-vcs-status.nix new file mode 100644 index 0000000..e5b3e39 --- /dev/null +++ b/modules/pkgs/neovim/dashboard-vcs-status.nix @@ -0,0 +1,75 @@ +{ + perSystem = {pkgs, ...}: let + inherit (pkgs) writeShellApplication writeText; + + dashboardStatusFilter = writeText "dashboard-status-filter.lua" '' + local function truncate_ansi(line, max) + local out = {} + local visible = 0 + local i = 1 + + while i <= #line do + local char = line:sub(i, i) + + if char == "\27" then + local finish = line:find("m", i, true) + if not finish then + break + end + + out[#out + 1] = line:sub(i, finish) + i = finish + 1 + else + if visible >= max then + out[#out + 1] = "...\27[0m" + break + end + + out[#out + 1] = char + visible = visible + 1 + i = i + 1 + end + end + + return table.concat(out) + end + + local seen = 0 + for line in io.lines() do + if seen == 6 then + break + end + + local plain = line:gsub("\27%[[0-9;]*m", "") + print(#plain > 48 and truncate_ansi(line, 45) or line) + seen = seen + 1 + end + + if seen == 0 then + print("No jj changes") + end + ''; + in { + packages.dashboard-vcs-status = writeShellApplication { + name = "dashboard-vcs-status"; + runtimeInputs = with pkgs; [ + # keep-sorted start + gawk + git + jujutsu + lua + # keep-sorted end + ]; + text = '' + if jj root >/dev/null 2>&1; then + jj --color always status | lua ${dashboardStatusFilter} + elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + git -c color.status=always status --short --branch --renames \ + | awk 'NR <= 6 { print; seen = 1 } END { if (!seen) print "No git changes" }' + else + printf '\n\n\n\n\n\n' + fi + ''; + }; + }; +} diff --git a/modules/programs/cli/diffnav.nix b/modules/programs/cli/diffnav.nix index a7e932f..b4c17a6 100644 --- a/modules/programs/cli/diffnav.nix +++ b/modules/programs/cli/diffnav.nix @@ -6,13 +6,7 @@ # keep-sorted end ... }: let - inherit - (lib) - # keep-sorted start - getExe - mkForce - # keep-sorted end - ; + inherit (lib) getExe; inherit (pkgs) writeShellApplication; diffnavPager = writeShellApplication { @@ -33,6 +27,13 @@ in { home.packages = [pkgs.diffnav]; - programs.git.iniContent.pager.diff = mkForce (getExe diffnavPager); + programs = { + git.iniContent.pager.diff = getExe diffnavPager; + + jujutsu.settings.ui = { + diff-formatter = ":git"; + pager = getExe diffnavPager; + }; + }; }; } diff --git a/modules/programs/delta.nix b/modules/programs/delta.nix index 84a14e5..db98c63 100644 --- a/modules/programs/delta.nix +++ b/modules/programs/delta.nix @@ -12,8 +12,6 @@ in { programs.delta = { enable = true; - enableGitIntegration = true; - enableJujutsuIntegration = true; options = with colors; { true-color = "always"; diff --git a/modules/programs/gui/zen/chrome.nix b/modules/programs/gui/zen/chrome.nix index 71466b0..9920c40 100644 --- a/modules/programs/gui/zen/chrome.nix +++ b/modules/programs/gui/zen/chrome.nix @@ -1,7 +1,7 @@ { flake-file.inputs = { nix-userstyles = { - url = "https://tangled.org/adam0.dev/nix-userstyles/archive/main?format=tar.gz"; + url = "tarball+https://tangled.org/adam0.dev/nix-userstyles/archive/main?format=tar.gz"; inputs = { # keep-sorted start flake-parts.follows = "flake-parts"; diff --git a/modules/programs/tui/neovim/components/autocomplete.nix b/modules/programs/tui/neovim/components/autocomplete.nix index e1a63df..650ea1a 100644 --- a/modules/programs/tui/neovim/components/autocomplete.nix +++ b/modules/programs/tui/neovim/components/autocomplete.nix @@ -121,7 +121,7 @@ words.enabled = mkLuaInline '' function() - return vim.bo.filetype == "markdown" + return vim.tbl_contains({ "gitcommit", "jjdescription", "markdown" }, vim.bo.filetype) end ''; }; diff --git a/modules/programs/tui/neovim/components/dashboard.nix b/modules/programs/tui/neovim/components/dashboard.nix index ad10e65..3b64135 100644 --- a/modules/programs/tui/neovim/components/dashboard.nix +++ b/modules/programs/tui/neovim/components/dashboard.nix @@ -7,97 +7,10 @@ # keep-sorted end ... }: let - inherit (lib) getExe; + inherit (lib) escapeShellArg getExe; inherit (lib.generators) mkLuaInline; - inherit - (pkgs) - #keep-sorted start - writeShellApplication - writeText - #keep-sorted end - ; colors = config.lib.stylix.colors.withHashtag; - - dashboardStatusFilter = writeText "dashboard-status-filter.lua" '' - local function truncate_ansi(line, max) - local out = {} - local visible = 0 - local i = 1 - - while i <= #line do - local char = line:sub(i, i) - - if char == "\27" then - local finish = line:find("m", i, true) - if not finish then - break - end - - out[#out + 1] = line:sub(i, finish) - i = finish + 1 - else - if visible >= max then - out[#out + 1] = "...\27[0m" - break - end - - out[#out + 1] = char - visible = visible + 1 - i = i + 1 - end - end - - return table.concat(out) - end - - local seen = 0 - for line in io.lines() do - if seen == 6 then - break - end - - local plain = line:gsub("\27%[[0-9;]*m", "") - print(#plain > 48 and truncate_ansi(line, 45) or line) - seen = seen + 1 - end - - if seen == 0 then - print("No jj changes") - end - ''; - - dashboardGhNotify = writeShellApplication { - name = "dashboard-gh-notify"; - runtimeInputs = [pkgs.coreutils]; - text = '' - GH_TOKEN="$(cat "${config.sops.secrets.github_token.path}")" - export GH_TOKEN - exec "${getExe pkgs.gh-notify}" "$@" - ''; - }; - - dashboardVcsStatus = writeShellApplication { - name = "dashboard-vcs-status"; - runtimeInputs = with pkgs; [ - # keep-sorted start - gawk - git - jujutsu - lua - # keep-sorted end - ]; - text = '' - if jj root >/dev/null 2>&1; then - jj --color always status | lua ${dashboardStatusFilter} - elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then - git -c color.status=always status --short --branch --renames \ - | awk 'NR <= 6 { print; seen = 1 } END { if (!seen) print "No git changes" }' - else - printf '\n\n\n\n\n\n' - fi - ''; - }; in { # keep-sorted start block=yes newline_separated=yes # Capture dashboard metrics once so the footer can read cached values. @@ -212,7 +125,7 @@ # Provide CLI tools consumed by dashboard terminal sections. extraPackages = with pkgs; [ # keep-sorted start - dashboardGhNotify + dashboard-gh-notify dwt1-shell-color-scripts # keep-sorted end ]; @@ -258,7 +171,7 @@ icon = " "; key = "f"; desc = "Find File"; - action = ":lua Snacks.dashboard.pick('files')"; + action = ":Telescope find_files"; text = mkLuaInline '' { { " ", hl = "SnacksDashboardIcon" }, @@ -385,7 +298,7 @@ icon = ""; title = "Notifications"; section = "terminal"; - cmd = "${getExe dashboardGhNotify} -s -a -n4"; + cmd = "GH_TOKEN_FILE=${escapeShellArg config.sops.secrets.github_token.path} ${getExe pkgs.dashboard-gh-notify} -s -a -n4"; height = 4; padding = 1; indent = 3; @@ -396,7 +309,7 @@ icon = ""; title = "VCS Status"; section = "terminal"; - cmd = getExe dashboardVcsStatus; + cmd = getExe pkgs.dashboard-vcs-status; height = 6; padding = 1; indent = 3; diff --git a/modules/programs/tui/neovim/components/debugger.nix b/modules/programs/tui/neovim/components/debugger.nix new file mode 100644 index 0000000..1d280ad --- /dev/null +++ b/modules/programs/tui/neovim/components/debugger.nix @@ -0,0 +1,5 @@ +{ + flake.modules.homeManager.neovim = { + programs.nvf.settings.vim.debugger.nvim-dap.ui.enable = true; + }; +} diff --git a/modules/programs/tui/neovim/components/diagnostics.nix b/modules/programs/tui/neovim/components/diagnostics.nix new file mode 100644 index 0000000..3649dee --- /dev/null +++ b/modules/programs/tui/neovim/components/diagnostics.nix @@ -0,0 +1,8 @@ +{ + flake.modules.homeManager.neovim = { + programs.nvf.settings.vim = { + lsp.trouble.enable = true; + utility.snacks-nvim.setupOpts.statuscolumn.enable = true; + }; + }; +} diff --git a/modules/programs/tui/neovim/components/statuscolumn.nix b/modules/programs/tui/neovim/components/statuscolumn.nix deleted file mode 100644 index 8ebdd66..0000000 --- a/modules/programs/tui/neovim/components/statuscolumn.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - flake.modules.homeManager.neovim = { - programs.nvf.settings.vim.utility.snacks-nvim.setupOpts.statuscolumn.enable = true; - }; -} diff --git a/modules/programs/tui/neovim/keymap.nix b/modules/programs/tui/neovim/keymap.nix index d4d5c01..2a4c7ea 100644 --- a/modules/programs/tui/neovim/keymap.nix +++ b/modules/programs/tui/neovim/keymap.nix @@ -2,6 +2,73 @@ flake.modules.homeManager.neovim = { programs.nvf.settings.vim = { keymaps = [ + # Buffer selection + # keep-sorted start block=yes newline_separated=yes + { + key = "1"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[1]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 1"; + } + + { + key = "2"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[2]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 2"; + } + + { + key = "3"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[3]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 3"; + } + + { + key = "4"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[4]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 4"; + } + + { + key = "5"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[5]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 5"; + } + + { + key = "6"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[6]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 6"; + } + + { + key = "7"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[7]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 7"; + } + + { + key = "8"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[8]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 8"; + } + + { + key = "9"; + mode = "n"; + action = "lua local b = vim.fn.getbufinfo({ buflisted = 1 })[9]; if b then vim.api.nvim_set_current_buf(b.bufnr) end"; + desc = "Select buffer 9"; + } + # keep-sorted end + + # File operations # keep-sorted start block=yes newline_separated=yes { key = "Q"; @@ -31,6 +98,23 @@ desc = "Write and quit"; } # keep-sorted end + + # Buffer navigation + # keep-sorted start block=yes newline_separated=yes + { + key = "["; + mode = "n"; + action = "bprevious"; + desc = "Previous buffer"; + } + + { + key = "]"; + mode = "n"; + action = "bnext"; + desc = "Next buffer"; + } + # keep-sorted end ]; }; }; diff --git a/modules/programs/tui/neovim/languages/default.nix b/modules/programs/tui/neovim/languages/default.nix index 86633e8..ed277f5 100644 --- a/modules/programs/tui/neovim/languages/default.nix +++ b/modules/programs/tui/neovim/languages/default.nix @@ -2,6 +2,7 @@ flake.modules.homeManager.neovim = { programs.nvf.settings.vim.languages = { # keep-sorted start + enableDAP = true; enableExtraDiagnostics = true; enableFormat = true; enableTreesitter = true; -- 2.51.2