nix-configs/modules/shell/helix.nix
2024-04-03 18:37:15 +02:00

218 lines
5.8 KiB
Nix

{
config,
pkgs-unstable-small,
...
}: {
home-manager.users.jade = {pkgs, ...}: let
typstGrammar = pkgs.fetchFromGitHub {
owner = "uben0";
repo = "tree-sitter-typst";
rev = "baddc325e858afff90501dbefa00ecfa28528931";
sha256 = "sha256-XZAgnpb1B8EZ2WXPj/JYSZGsmpKsnDiBFCDF0XjunOM";
};
in {
home = {
sessionVariables.EDITOR = "hx";
packages = [
pkgs.nil
pkgs.vscode-langservers-extracted
pkgs.nodePackages.typescript-language-server
pkgs.emmet-language-server
pkgs.typst-lsp
];
};
home.file = {
".config/helix/runtime/queries" = {
source = "${typstGrammar}/queries";
};
};
programs.helix = {
enable = true;
package = pkgs-unstable-small.helix;
settings = {
theme = "gruvbox";
editor = {
line-number = "relative";
bufferline = "multiple";
color-modes = true;
cursorline = true;
lsp = {
display-messages = true;
display-inlay-hints = true;
};
shell = ["nu" "-c"];
statusline.left = [
"mode"
"spinner"
"spacer"
"version-control"
"file-name"
"diagnostics"
"read-only-indicator"
"file-modification-indicator"
"spacer"
];
statusline.right = [
"workspace-diagnostics"
"register"
"position"
"selections"
"file-encoding"
"file-type"
];
idle-timeout = 30;
indent-guides = {
render = true;
character = "";
};
whitespace = {
render = {
space = "all";
tab = "all";
newline = "none";
};
characters = {
space = "·";
nbsp = "";
tab = "";
};
};
};
keys = {
normal = {
space."=" = ":fmt";
};
insert = {
up = "no_op";
down = "no_op";
left = "no_op";
right = "no_op";
pageup = "no_op";
pagedown = "no_op";
home = "no_op";
end = "no_op";
};
};
};
languages = {
language-server = {
"nu-builtin-lsp" = {
command = "${config.users.defaultUserShell}/bin/nu";
args = ["--lsp"];
};
"rust-analyzer" = {
config = {
check.command = "clippy";
completion.snippets.custom = {
"pub fn" = {
prefix = ["pfn" "pubfn"];
postfix = ["pfn"];
body = [
"pub fn $\{receiver\}() {"
"\\t$1"
"}"
];
scope = "type";
};
};
completion.termSearch.enable = true;
diagnostics.enable = true;
inlayHints = {
bindingModeHints.enable = true;
closureCaptureHints.enable = true;
closureReturnTypeHints.enable = true;
discriminantHints.enable = true;
expressionAdjustmentHints = {
hideOutsideUnsafe = true;
};
lifetimeElisionHints.enable = "skip_trivial";
};
interpret.tests = true;
lens = {
references = {
adt.enable = true;
trait.enable = true;
};
};
typing.autoClosingAngleBrackets.enable = true;
};
};
"emmet-language-server" = {
command = "emmet-language-server";
args = ["--stdio"];
};
"psalm" = {
command = "psalm";
args = ["--language-server"];
};
"typst-lsp" = {
command = "typst-lsp";
config = {
exportPdf = "onType";
};
};
};
grammar = [
{
name = "typst";
source = {
git = "https://github.com/uben0/tree-sitter-typst";
rev = "baddc325e858afff90501dbefa00ecfa28528931";
# path = "${typstGrammar}";
};
}
];
language = [
{
name = "nu";
language-servers = ["nu-builtin-lsp"];
}
{
name = "php";
language-servers = ["psalm"];
}
{
name = "typst";
scope = "source.typst";
file-types = ["typ" "typst"];
injection-regex = "typ(st)?";
comment-token = "//";
indent = {
tab-width = 2;
unit = " ";
};
roots = ["typst.toml"];
formatter = {
command = "${pkgs.typstfmt}/bin/typstfmt";
};
auto-format = true;
language-servers = ["typst-lsp"];
auto-pairs = {
"(" = ")";
"{" = "}";
"[" = "]";
"$" = "$";
"\"" = "\"";
};
}
{
name = "nix";
formatter = {
command = "${pkgs.alejandra}/bin/alejandra";
args = ["--quiet"];
};
auto-format = true;
}
{
name = "html";
roots = [".git"];
language-servers = ["vscode-html-language-server" "emmet-language-server"];
auto-format = false;
}
];
};
};
};
}