{ pkgs, lib, config, ... }: let tomlFormat = pkgs.formats.toml {}; configFilePath = "~/.config/helix/config.toml"; installConfig = file: '' ${pkgs.coreutils}/bin/ln -sf ${file} ${configFilePath} ''; lightConfig = { theme = "gruvbox_light"; editor = { line-number = "relative"; mouse = true; #cursorline = true; #color-modes = true; cursor-shape = { insert = "bar"; }; idle-timeout = 50; }; }; lightConfigFile = tomlFormat.generate "config.toml" lightConfig; darkConfig = lib.recursiveUpdate lightConfig { theme = "gruvbox"; }; darkConfigFile = tomlFormat.generate "config.toml" darkConfig; 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; }; }; } ]; }; in { home.packages = with pkgs; [ (pkgs.callPackage ../../pkgs/helix.nix {}) # Some helpful language servers rnix-lsp yaml-language-server python-language-server nodePackages.bash-language-server taplo-lsp beancount ]; home.sessionVariables = { EDITOR = "${pkgs.helix}/bin/hx"; VISUAL = "${pkgs.kitty}/bin/kitty ${pkgs.helix}/bin/hx"; }; xdg.configFile."helix/languages.toml".source = extraLanguages; 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 ''; }; }