Files
nixos-blueprint/modules/home/programs/editor/helix.nix
2025-06-12 22:40:19 +03:00

158 lines
4.6 KiB
Nix

{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption getExe;
cfg = config.editor.helix;
in {
options = {
editor.helix.enable =
mkEnableOption "enable helix editor";
};
config = mkIf cfg.enable {
programs.helix = {
enable = true; # vim-like editor in rust
defaultEditor = true;
settings = {
editor = {
bufferline = "multiple";
cursorline = true;
inline-diagnostics.cursor-line = "warning";
line-number = "relative";
lsp = {
display-messages = true;
display-inlay-hints = true;
};
cursor-shape = {
insert = "bar";
normal = "block";
select = "underline";
};
statusline = {
left = ["mode" "spinner" "version-control"];
center = ["file-name"];
right = ["diagnostics" "selections" "position" "file-encoding" "file-line-ending" "file-type"];
separator = "|";
};
soft-wrap = {
enable = true;
max-wrap = 25;
max-indent-retain = 0;
wrap-indicator = "";
};
};
keys = {
insert.C-c = "normal_mode";
normal = {
esc = ["collapse_selection" "keep_primary_selection"];
space = {
space = "file_picker";
w = ":w";
q = ":q";
x = ":x";
n = ":n";
"," = "goto_previous_buffer";
"." = "goto_next_buffer";
l = ":reflow";
};
};
};
};
languages = {
language-server = {
clangd.command = "${pkgs.clang-tools}/bin/clangd";
# markdown-oxide.command = getExe pkgs.markdown-oxide;
nil.command = getExe pkgs.nil;
# nixd.command = getExe pkgs.nixd;
# pyright.command = getExe pkgs.pyright;
# pyright.args = ["-"];
ruff.command = getExe pkgs.ruff;
ruff.args = ["server"];
# rust-analyzer.command = getExe pkgs.rust-analyzer;
# texlab.command = getExe pkgs.texlab;
tinymist.command = getExe pkgs.tinymist;
zk = {
command = getExe pkgs.zk;
args = ["lsp"];
};
fsac.command = getExe pkgs.fsautocomplete;
fsac.config = {
# editor.formatOnSave = true;
AutomaticWorkspaceInit = true;
FSharp.ExternalAutocomplete = true;
FSharp.linting.fsharplint.enabled = true;
FSharp.linting.fsharplint.configFile = "fsharplint.json";
FSharp.formatting.fantomas.enabled = true;
};
};
language = [
{
name = "nix";
auto-format = true;
formatter.command = getExe pkgs.alejandra;
language-servers = ["nil"];
}
# {
# name = "latex";
# auto-format = true;
# formatter.command = "${pkgs.texlivePackages.latexindent}/bin/latexindent";
# language-servers = ["texlab"];
# }
{
name = "typst";
auto-format = true;
formatter.command = getExe pkgs.typstyle;
language-servers = ["tinymist"];
}
{
name = "markdown";
# auto-format = true;
# formatter.command = "${pkgs.comrak}/bin/comrak";
language-servers = ["zk" "markdown-oxide"];
}
{
name = "c";
auto-format = true;
formatter.command = "${pkgs.clang-tools}/bin/clang-format";
}
{
name = "cpp";
auto-format = true;
formatter.command = "${pkgs.clang-tools}/bin/clang-format";
}
{
name = "fsharp";
auto-format = true;
# formatter.command = getExe pkgs.fantomas;
language-servers = ["fsac"];
scope = "source.fs";
roots = ["fsproj" "sln" ".git"];
}
# {
# name = "rust";
# auto-format = true;
# language-servers = ["rust-analyzer"];
# formatter.command = getExe pkgs.rustfmt;
# }
{
name = "python";
auto-format = true;
language-servers = [
{
name = "ruff";
# only-features = ["format" "diagnostics"];
}
# {
# name = "pyright";
# except-features = ["format" "diagnostics"];
# }
];
}
];
};
};
};
}