nixos/users/malte/helix.nix

160 lines
4.3 KiB
Nix
Raw Normal View History

2022-09-12 13:00:29 +02:00
{
pkgs,
lib,
2022-09-12 16:35:17 +02:00
config,
2022-09-12 13:00:29 +02:00
...
}: let
2022-09-12 16:35:17 +02:00
tomlFormat = pkgs.formats.toml {};
configFilePath = "~/.config/helix/config.toml";
installConfig = file: ''
2022-10-13 16:58:23 +02:00
${pkgs.coreutils}/bin/ln -sf ${file} ${configFilePath}
2022-09-12 16:35:17 +02:00
'';
lightConfig = {
2022-09-12 13:00:29 +02:00
theme = "gruvbox_light";
editor = {
line-number = "relative";
mouse = true;
#cursorline = true;
#color-modes = true;
cursor-shape = {
insert = "bar";
};
2022-09-21 12:02:49 +02:00
idle-timeout = 50;
2022-09-12 13:00:29 +02:00
};
};
2022-09-12 16:35:17 +02:00
lightConfigFile = tomlFormat.generate "config.toml" lightConfig;
darkConfig = lib.recursiveUpdate lightConfig {
theme = "gruvbox";
};
darkConfigFile = tomlFormat.generate "config.toml" darkConfig;
2022-09-12 13:00:29 +02:00
2022-09-12 15:27:25 +02:00
extraLanguages = (pkgs.formats.toml {}).generate "languages.toml" {
language = [
{
name = "json";
scope = "source.json";
injection-regex = "json";
file-types = ["json"];
roots = [];
language-server = {
command = "${pkgs.nodePackages.vscode-json-languageserver}/bin/vscode-json-languageserver";
args = ["--stdio"];
};
auto-format = true;
config = {"provideFormatter" = true;};
indent = {
tab-width = 2;
unit = " ";
};
}
{
name = "html";
language-server = {
command = "${pkgs.nodePackages.vscode-html-languageserver-bin}/bin/html-languageserver";
args = ["--stdio"];
};
}
{
name = "css";
language-server = {
command = "${pkgs.nodePackages.vscode-css-languageserver-bin}/bin/css-languageserver";
args = ["--stdio"];
};
}
{
name = "beancount";
language-server = {
command = "${pkgs.beancount-language-server}/bin/beancount-language-server";
args = ["--stdio"];
};
config.journal_file = "/home/malte/repos/accounting/main.bean";
}
{
name = "vue";
file-types = ["vue"];
language-server = {
command = "vue-language-server";
args = ["--stdio"];
};
scope = "text.html.vue";
roots = ["package.json"];
injection-regex = "vue";
auto-format = false;
indent = {
tab-width = 4;
unit = " ";
};
config = {
typescript.serverPath = "${pkgs.nodePackages.typescript}/lib/node_modules/typescript/lib/tsserverlibrary.js";
languageFeatures = {
semanticTokens = true;
references = true;
definition = true;
typeDefinition = true;
callHierarchy = true;
hover = true;
rename = true;
renameFileRefactoring = true;
signatureHelp = true;
codeAction = true;
completion = {
defaultTagNameCase = "both";
defaultAttrNameCase = "kebabCase";
};
schemaRequestService = true;
documentHighlight = true;
documentLink = true;
codeLens = true;
diagnostics = true;
};
documentFeatures = {
documentColor = false;
selectionRange = true;
foldingRange = true;
linkedEditingRange = true;
documentSymbol = true;
documentFormatting.defaultPrintWidth = 100;
};
};
}
2022-09-12 15:27:25 +02:00
];
};
2022-09-12 13:00:29 +02:00
in {
2022-09-12 15:27:25 +02:00
home.packages = with pkgs; [
(pkgs.callPackage ../../pkgs/helix.nix {})
2022-09-12 15:27:25 +02:00
# Some helpful language servers
rnix-lsp
yaml-language-server
python-language-server
nodePackages.bash-language-server
taplo-lsp
beancount
2022-09-12 15:27:25 +02:00
];
2022-09-12 13:00:29 +02:00
2022-09-12 16:35:17 +02:00
home.sessionVariables = {
EDITOR = "${pkgs.helix}/bin/hx";
VISUAL = "${pkgs.kitty}/bin/kitty ${pkgs.helix}/bin/hx";
};
2022-09-12 13:00:29 +02:00
xdg.configFile."helix/languages.toml".source = extraLanguages;
2022-09-12 16:35:17 +02:00
services.darkman.scripts."helix.sh" = {
onLight = pkgs.writeScript "helix-light" ''
#!${pkgs.runtimeShell}
${installConfig lightConfigFile}
'';
onDark = pkgs.writeScript "helix-dark" ''
#!${pkgs.runtimeShell}
${installConfig darkConfigFile}
'';
initialize = pkgs.writeScript "helix-initialize" ''
mkdir -p $(dirname ${configFilePath})
if [[ ! -e ${configFilePath} ]]; then
${installConfig lightConfigFile}
fi
'';
};
2022-09-12 13:00:29 +02:00
}