From 88c73558f4715810f5260ad914d74f433dfd1c5a Mon Sep 17 00:00:00 2001 From: Bloxx12 Date: Fri, 9 May 2025 09:54:11 +0200 Subject: [PATCH] chore: split up helix into multiple packages --- packages/default.nix | 2 +- packages/helix/colorscheme.nix | 0 packages/helix/default.nix | 151 ++++++++++++++++++++ packages/{helix.nix => helix/languages.nix} | 126 +--------------- 4 files changed, 154 insertions(+), 125 deletions(-) create mode 100644 packages/helix/colorscheme.nix create mode 100644 packages/helix/default.nix rename packages/{helix.nix => helix/languages.nix} (66%) diff --git a/packages/default.nix b/packages/default.nix index 4310e5f..4ede96b 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -2,7 +2,7 @@ pkgs, helix, }: let - wrapped-helix = pkgs.callPackage ./helix.nix {inherit helix;}; + wrapped-helix = pkgs.callPackage ./helix {inherit helix;}; kakoune = pkgs.callPackage ./kakoune.nix {}; fish = pkgs.callPackage ./shell {}; in { diff --git a/packages/helix/colorscheme.nix b/packages/helix/colorscheme.nix new file mode 100644 index 0000000..e69de29 diff --git a/packages/helix/default.nix b/packages/helix/default.nix new file mode 100644 index 0000000..930d355 --- /dev/null +++ b/packages/helix/default.nix @@ -0,0 +1,151 @@ +{ + symlinkJoin, + makeWrapper, + callPackage, + alejandra, + basedpyright, + bash-language-server, + clang-tools, + clippy, + cmake-format, + cmake-language-server, + deno, + dprint, + formats, + gdb, + golangci-lint-langserver, + gopls, + lazygit, + lib, + lldb_19, + marksman, + nil, + nixd, + ruff, + rust-analyzer, + rustfmt, + shellcheck, + shfmt, + superhtml, + kdePackages, + taplo, + tinymist, + typescript-language-server, + vscode-langservers-extracted, + simple-completion-language-server, + helix, + ... +}: let + inherit (lib.meta) getExe; + + toml = formats.toml {}; + helix-config = { + theme = "catppuccin_mocha"; + editor = { + cursorline = false; + color-modes = true; + true-color = true; + indent-guides.render = true; + lsp = { + enable = true; + auto-signature-help = true; + display-inlay-hints = false; + display-messages = true; + snippets = true; + }; + file-picker = { + hidden = true; + }; + line-number = "relative"; + auto-format = true; + completion-timeout = 5; + mouse = true; + bufferline = "multiple"; + soft-wrap.enable = true; + cursor-shape = { + insert = "bar"; + normal = "block"; + select = "underline"; + }; + statusline = { + left = ["spinner" "version-control" "diagnostics" "file-name"]; + right = ["file-base-name" "file-type" "position" "file-encoding"]; + }; + gutters.layout = ["diff" "diagnostics" "line-numbers" "spacer"]; + inline-diagnostics = { + cursor-line = "hint"; + other-lines = "error"; + }; + }; + keys = { + normal = { + space = { + g = [":new" ":insert-output XDG_CONFIG_HOME=~/.config ${getExe lazygit}" ":buffer-close!" ":redraw"]; + i = ":toggle lsp.display-inlay-hints"; + }; + esc = ["collapse_selection" "keep_primary_selection" "normal_mode"]; + A-H = "goto_previous_buffer"; + A-L = "goto_next_buffer"; + A-w = ":buffer-close"; + A-f = ":format"; + A-r = ":reload"; + A-x = "extend_to_line_bounds"; + X = ["extend_line_up" "extend_to_line_bounds"]; + ";" = "flip_selections"; + "A-;" = "collapse_selection"; + + # Kakoune-like config + H = "extend_char_left"; + J = "extend_line_down"; + K = "extend_line_up"; + L = "extend_char_right"; + }; + select = { + A-x = "extend_to_line_bounds"; + X = ["extend_line_up" "extend_to_line_bounds"]; + g = {e = "goto_file_end";}; + }; + }; + }; + helix-languages = callPackage ./languages.nix {inherit lib;}; + wrapped-helix = symlinkJoin { + name = "helix-wrapped"; + paths = [ + helix + + # Bash + bash-language-server + # C/C++ + clang-tools + clippy + golangci-lint-langserver + gopls + lldb_19 + # Markdown + marksman + # Nix + nil + nixd + rust-analyzer + rustfmt + # Shell + shellcheck + superhtml + # toml + taplo + # typst + tinymist + # typst lsp + vscode-langservers-extracted + ]; + nativeBuildInputs = [makeWrapper]; + postBuild = '' + mkdir -p $out/config/helix + cp "${toml.generate "config.toml" helix-config}" $out/config/helix/config.toml + cp "${helix-languages}" $out/config/helix/languages.toml + wrapProgram $out/bin/hx --set \ + XDG_CONFIG_HOME $out/config + ''; + }; +in + wrapped-helix diff --git a/packages/helix.nix b/packages/helix/languages.nix similarity index 66% rename from packages/helix.nix rename to packages/helix/languages.nix index 8c80f67..ab57543 100644 --- a/packages/helix.nix +++ b/packages/helix/languages.nix @@ -1,111 +1,28 @@ { - symlinkJoin, - makeWrapper, alejandra, basedpyright, bash-language-server, clang-tools, - clippy, cmake-format, cmake-language-server, deno, dprint, formats, gdb, - golangci-lint-langserver, - gopls, - lazygit, lib, - lldb_19, - marksman, nil, - nixd, ruff, - rust-analyzer, - rustfmt, - shellcheck, shfmt, - superhtml, kdePackages, - taplo, - tinymist, typescript-language-server, vscode-langservers-extracted, simple-completion-language-server, - helix, ... }: let inherit (lib.meta) getExe; toml = formats.toml {}; - helix-config = { - theme = "catppuccin_mocha"; - editor = { - cursorline = false; - color-modes = true; - true-color = true; - indent-guides.render = true; - lsp = { - enable = true; - auto-signature-help = true; - display-inlay-hints = false; - display-messages = true; - snippets = true; - }; - file-picker = { - hidden = true; - }; - line-number = "relative"; - auto-format = true; - completion-timeout = 5; - mouse = true; - bufferline = "multiple"; - soft-wrap.enable = true; - cursor-shape = { - insert = "bar"; - normal = "block"; - select = "underline"; - }; - statusline = { - left = ["spinner" "version-control" "diagnostics" "file-name"]; - right = ["file-base-name" "file-type" "position" "file-encoding"]; - }; - gutters.layout = ["diff" "diagnostics" "line-numbers" "spacer"]; - inline-diagnostics = { - cursor-line = "hint"; - other-lines = "error"; - }; - }; - keys = { - normal = { - space = { - g = [":new" ":insert-output XDG_CONFIG_HOME=~/.config ${getExe lazygit}" ":buffer-close!" ":redraw"]; - i = ":toggle lsp.display-inlay-hints"; - }; - esc = ["collapse_selection" "keep_primary_selection" "normal_mode"]; - A-H = "goto_previous_buffer"; - A-L = "goto_next_buffer"; - A-w = ":buffer-close"; - A-f = ":format"; - A-r = ":reload"; - A-x = "extend_to_line_bounds"; - X = ["extend_line_up" "extend_to_line_bounds"]; - ";" = "flip_selections"; - "A-;" = "collapse_selection"; - # Kakoune-like config - H = "extend_char_left"; - J = "extend_line_down"; - K = "extend_line_up"; - L = "extend_char_right"; - }; - select = { - A-x = "extend_to_line_bounds"; - X = ["extend_line_up" "extend_to_line_bounds"]; - g = {e = "goto_file_end";}; - }; - }; - }; helix-languages = { language = let mark = lang: { @@ -158,7 +75,7 @@ } { name = "nix"; - language-servers = ["nil" "scls"]; + language-servers = ["nil" "scls" "deadnix"]; } { name = "qml"; @@ -318,44 +235,5 @@ }; }; }; - wrapped-helix = symlinkJoin { - name = "helix-wrapped"; - paths = [ - helix - - # Bash - bash-language-server - # C/C++ - clang-tools - clippy - golangci-lint-langserver - gopls - lldb_19 - # Markdown - marksman - # Nix - nil - nixd - rust-analyzer - rustfmt - # Shell - shellcheck - superhtml - # toml - taplo - # typst - tinymist - # typst lsp - vscode-langservers-extracted - ]; - nativeBuildInputs = [makeWrapper]; - postBuild = '' - mkdir -p $out/config/helix - cp "${toml.generate "config.toml" helix-config}" $out/config/helix/config.toml - cp "${toml.generate "languages.toml" helix-languages}" $out/config/helix/languages.toml - wrapProgram $out/bin/hx --set \ - XDG_CONFIG_HOME $out/config - ''; - }; in - wrapped-helix + toml.generate "languages.toml" helix-languages