refactor: removing needless module complexity

This commit is contained in:
cnst
2024-10-27 09:14:34 +01:00
parent d8f810ee05
commit 4887feccfd
175 changed files with 920 additions and 1118 deletions

View File

@@ -0,0 +1,139 @@
{
inputs,
pkgs,
lib,
config,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.home.programs.helix;
in {
imports = [
./lang.nix
./theme.nix
];
options = {
home.programs.helix.enable = mkEnableOption "Enable helix";
};
config = mkIf cfg.enable {
programs.helix = {
enable = true;
# package = inputs.helix.packages.${pkgs.system}.default;
package = inputs.helix-flake.packages.${pkgs.system}.default;
settings = {
theme = "gruvbox_custom";
editor = {
color-modes = true;
scrolloff = 0;
cursorline = true;
completion-replace = true;
cursor-shape = {
insert = "bar";
normal = "block";
select = "underline";
};
indent-guides.render = true;
inline-diagnostics = {
cursor-line = "hint";
other-lines = "error";
};
lsp = {
display-messages = true;
display-inlay-hints = true;
};
gutters = ["diagnostics" "line-numbers" "spacer" "diff"];
statusline = {
separator = "of";
left = [
"mode"
"selections"
"file-type"
"register"
"spinner"
"diagnostics"
];
center = ["file-name"];
right = [
"file-encoding"
"file-line-ending"
"position-percentage"
"spacer"
"separator"
"total-line-numbers"
];
mode = {
normal = "NOR";
insert = "INS";
select = "SEL";
};
};
true-color = true;
whitespace.characters = {
newline = "";
tab = "";
};
};
keys = let
spaceMode = {
space = "file_picker";
n = "global_search";
f = ":format";
c = "toggle_comments";
t = {
d = "goto_type_definition";
i = "goto_implementation";
r = "goto_reference";
t = "goto_definition";
w = "trim_selections";
};
x = ":buffer-close";
w = ":w";
q = ":q";
y = "yank";
p = "paste_after";
P = "paste_before";
R = "replace_with_yanked";
};
in {
normal = {
d = {
d = ["extend_to_line_bounds" "yank_main_selection_to_clipboard" "delete_selection"];
s = ["surround_delete"];
};
x = "delete_selection";
y = {
y = ["extend_to_line_bounds" "yank_main_selection_to_clipboard" "normal_mode" "collapse_selection"];
d = ":yank-diagnostic";
};
Y = ["extend_to_line_end" "yank_main_selection_to_clipboard" "collapse_selection"];
P = ["paste_clipboard_before" "collapse_selection"];
p = ["paste_clipboard_after" "collapse_selection"];
C-a = "select_all";
del = "delete_selection";
space = spaceMode;
};
insert = {
C-v = "paste_clipboard_after";
C-c = "yank_to_clipboard";
C-x = "completion";
del = "delete_selection";
esc = ["collapse_selection" "normal_mode"];
};
select = {
space = spaceMode;
d = ["yank_main_selection_to_clipboard" "delete_selection"];
x = ["yank_main_selection_to_clipboard" "delete_selection"];
y = ["yank_main_selection_to_clipboard" "normal_mode" "flip_selections" "collapse_selection"];
Y = ["extend_to_line_bounds" "yank_main_selection_to_clipboard" "goto_line_start" "collapse_selection" "normal_mode"];
p = ["replace_selections_with_clipboard"];
P = ["paste_clipboard_before"];
};
};
};
};
};
}

View File

@@ -0,0 +1,225 @@
{
pkgs,
lib,
...
}: {
programs.helix.languages = {
language = let
deno = lang: {
command = lib.getExe pkgs.deno;
args = ["fmt" "-" "--ext" lang];
};
prettier = lang: {
command = lib.getExe pkgs.nodePackages.prettier;
args = ["--parser" lang];
};
prettierLangs = map (e: {
name = e;
formatter = prettier e;
});
langs = ["css" "scss" "html"];
in
[
{
name = "bash";
auto-format = true;
formatter = {
command = lib.getExe pkgs.shfmt;
args = ["-i" "2"];
};
}
{
name = "clojure";
injection-regex = "(clojure|clj|edn|boot|yuck)";
file-types = ["clj" "cljs" "cljc" "clje" "cljr" "cljx" "edn" "boot" "yuck"];
}
{
name = "cmake";
auto-format = true;
language-servers = ["cmake-language-server"];
formatter = {
command = lib.getExe pkgs.cmake-format;
args = ["-"];
};
}
{
name = "lua";
auto-format = true;
language-servers = ["lua-language-server"];
formatter = {
command = lib.getExe pkgs.stylua;
};
}
{
name = "javascript";
auto-format = true;
language-servers = ["dprint" "typescript-language-server"];
}
{
name = "nix";
auto-format = true;
file-types = ["nix"];
language-servers = ["nil"];
formatter = {
command = lib.getExe pkgs.alejandra;
args = ["-q"];
};
}
{
name = "json";
formatter = deno "json";
}
{
name = "common-lisp";
file-types = ["kbd"];
auto-format = true;
}
{
name = "markdown";
auto-format = true;
formatter = deno "md";
}
{
name = "python";
language-servers = ["pylsp"];
formatter = {
command = lib.getExe pkgs.black;
args = ["-" "--quiet" "--line-length 100"];
};
}
{
name = "typescript";
auto-format = true;
language-servers = ["dprint" "typescript-language-server"];
}
{
name = "php";
auto-format = true;
}
{
name = "css";
auto-format = true;
language-servers = ["vscode-css-language-server"];
}
{
name = "rust";
auto-format = true;
file-types = ["rs"];
language-servers = ["rust-analyzer"];
formatter = {
command = lib.getExe pkgs.rustfmt;
};
}
]
++ prettierLangs langs;
language-server = {
gpt = {
command = "helix-gpt";
args = ["--copilotApiKey" "cat /run/agenix/helix-gpt"];
};
bash-language-server = {
command = lib.getExe pkgs.bash-language-server;
args = ["start"];
};
clangd = {
command = "${pkgs.clang-tools}/bin/clangd";
clangd.fallbackFlags = ["-std=c++2b"];
};
cmake-language-server = {
command = lib.getExe pkgs.cmake-language-server;
};
lua-language-server = {
command = lib.getExe pkgs.lua-language-server;
};
deno-lsp = {
command = lib.getExe pkgs.deno;
args = ["lsp"];
environment.NO_COLOR = "1";
config.deno = {
enable = true;
lint = true;
unstable = true;
suggest = {
completeFunctionCalls = false;
imports = {hosts."https://deno.land" = true;};
};
inlayHints = {
enumMemberValues.enabled = true;
functionLikeReturnTypes.enabled = true;
parameterNames.enabled = "all";
parameterTypes.enabled = true;
propertyDeclarationTypes.enabled = true;
variableTypes.enabled = true;
};
};
};
dprint = {
command = lib.getExe pkgs.dprint;
args = ["lsp"];
};
nil = {
command = lib.getExe pkgs.nil;
};
pyright = {
command = "${pkgs.pyright}/bin/pyright-langserver";
args = ["--stdio"];
config = {
reportMissingTypeStubs = false;
analysis = {
typeCheckingMode = "basic";
autoImportCompletions = true;
};
};
};
typescript-language-server = {
command = lib.getExe pkgs.nodePackages.typescript-language-server;
args = ["--stdio"];
config = let
inlayHints = {
includeInlayEnumMemberValueHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayVariableTypeHints = true;
};
in {
typescript-language-server.source = {
addMissingImports.ts = true;
fixAll.ts = true;
organizeImports.ts = true;
removeUnusedImports.ts = true;
sortImports.ts = true;
};
typescript = {inherit inlayHints;};
javascript = {inherit inlayHints;};
hostInfo = "helix";
};
};
vscode-css-language-server = {
command = "${pkgs.nodePackages.vscode-langservers-extracted}/bin/vscode-css-language-server";
args = ["--stdio"];
config = {
provideFormatter = true;
css.validate.enable = true;
scss.validate.enable = true;
};
};
};
};
}

View File

@@ -0,0 +1,201 @@
{
programs.helix.themes = {
gruvbox_custom = let
bg0 = "#32302f";
bg1 = "#3c3836";
bg2 = "#3c3836";
bg3 = "#504945";
bg4 = "#504945";
fg0 = "#d4be98";
red = "#ea6962";
orange = "#e78a4e";
yellow = "#d8a657";
bg_visual_yellow = "#574833";
green = "#a9b665";
aqua = "#89b482";
blue = "#7daea3";
purple = "#d3869b";
grey0 = "#7c6f64";
grey2 = "#a89984";
in {
"type" = yellow;
"constant" = purple;
"constant.numeric" = purple;
"constant.character.escape" = orange;
"string" = green;
"string.regexp" = blue;
"comment" = grey0;
"variable" = fg0;
"variable.builtin" = blue;
"variable.parameter" = fg0;
"variable.other.member" = fg0;
"label" = aqua;
"punctuation" = grey2;
"punctuation.delimiter" = grey2;
"punctuation.bracket" = fg0;
"keyword" = red;
"keyword.directive" = aqua;
"operator" = orange;
"function" = green;
"function.builtin" = blue;
"function.macro" = aqua;
"tag" = yellow;
"namespace" = aqua;
"attribute" = aqua;
"constructor" = yellow;
"module" = blue;
"special" = orange;
"markup.heading.marker" = grey2;
"markup.heading.1" = {
fg = red;
modifiers = ["bold"];
};
"markup.heading.2" = {
fg = orange;
modifiers = ["bold"];
};
"markup.heading.3" = {
fg = yellow;
modifiers = ["bold"];
};
"markup.heading.4" = {
fg = green;
modifiers = ["bold"];
};
"markup.heading.5" = {
fg = blue;
modifiers = ["bold"];
};
"markup.heading.6" = {
fg = fg0;
modifiers = ["bold"];
};
"markup.list" = red;
"markup.bold" = {modifiers = ["bold"];};
"markup.italic" = {modifiers = ["italic"];};
"markup.link.url" = {
fg = blue;
modifiers = ["underlined"];
};
"markup.link.text" = purple;
"markup.quote" = grey2;
"markup.raw" = green;
"diff.plus" = green;
"diff.delta" = orange;
"diff.minus" = red;
"ui.background" = {bg = bg0;};
"ui.background.separator" = grey0;
"ui.cursor" = {
fg = bg0;
bg = fg0;
};
"ui.cursor.match" = {
fg = orange;
bg = bg_visual_yellow;
};
"ui.cursor.insert" = {
fg = bg0;
bg = grey2;
};
"ui.cursor.select" = {
fg = bg0;
bg = blue;
};
"ui.cursorline.primary" = {bg = bg1;};
"ui.cursorline.secondary" = {bg = bg1;};
"ui.selection" = {bg = bg3;};
"ui.linenr" = grey0;
"ui.linenr.selected" = fg0;
"ui.statusline" = {
fg = fg0;
bg = bg3;
};
"ui.statusline.inactive" = {
fg = grey0;
bg = bg1;
};
"ui.statusline.normal" = {
fg = bg0;
bg = fg0;
modifiers = ["bold"];
};
"ui.statusline.insert" = {
fg = bg0;
bg = yellow;
modifiers = ["bold"];
};
"ui.statusline.select" = {
fg = bg0;
bg = blue;
modifiers = ["bold"];
};
"ui.bufferline" = {
fg = grey0;
bg = bg1;
};
"ui.bufferline.active" = {
fg = fg0;
bg = bg3;
modifiers = ["bold"];
};
"ui.popup" = {
fg = grey2;
bg = bg2;
};
"ui.window" = {
fg = grey0;
bg = bg0;
};
"ui.help" = {
fg = fg0;
bg = bg2;
};
"ui.text" = fg0;
"ui.text.focus" = fg0;
"ui.menu" = {
fg = fg0;
bg = bg3;
};
"ui.menu.selected" = {
fg = bg0;
bg = blue;
modifiers = ["bold"];
};
"ui.virtual.whitespace" = {fg = bg4;};
"ui.virtual.indent-guide" = {fg = bg4;};
"ui.virtual.ruler" = {bg = bg3;};
"hint" = blue;
"info" = aqua;
"warning" = yellow;
"error" = red;
"diagnostic" = {underline = {style = "curl";};};
"diagnostic.hint" = {
underline = {
color = blue;
style = "dotted";
};
};
"diagnostic.info" = {
underline = {
color = aqua;
style = "dotted";
};
};
"diagnostic.warning" = {
underline = {
color = yellow;
style = "curl";
};
};
"diagnostic.error" = {
underline = {
color = red;
style = "curl";
};
};
};
};
}