nichts/packages/helix/default.nix

158 lines
3.6 KiB
Nix

{
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,
nil,
nixd,
ruff,
rust-analyzer,
rustfmt,
shellcheck,
shfmt,
superhtml,
kdePackages,
taplo,
tinymist,
typescript-language-server,
vscode-langservers-extracted,
simple-completion-language-server,
zls,
helix,
...
}: let
inherit (lib.meta) getExe;
toml = formats.toml {};
helix-languages = callPackage ./languages.nix {inherit lib;};
colorscheme = toml.generate "colorscheme.toml" (import ./colorscheme.nix);
helix-config = {
theme = "theme_transparent";
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";};
};
};
};
wrapped-helix = symlinkJoin {
name = "helix-wrapped";
paths = [
helix
# Bash
bash-language-server
# C/C++
clang-tools
clippy
golangci-lint-langserver
gopls
lldb_19
# Markdown
taplo
# Nix
nil
nixd
rust-analyzer
rustfmt
# Shell
shellcheck
superhtml
# toml
taplo
# typst
tinymist
# typst lsp
vscode-langservers-extracted
# zig language server
zls
];
nativeBuildInputs = [makeWrapper];
postBuild = ''
mkdir -p $out/config/helix/themes
cp "${toml.generate "config.toml" helix-config}" $out/config/helix/config.toml
cp "${helix-languages}" $out/config/helix/languages.toml
cp "${colorscheme}" $out/config/helix/themes/theme_transparent.toml
wrapProgram $out/bin/hx --set \
XDG_CONFIG_HOME $out/config
'';
};
in
wrapped-helix