{
  pkgs,
  lib,
  theme,
  ...
}:

{
  catppuccin.helix = {
    enable = true;
    flavor = theme.flavor;
  };

  programs = {
    fish.shellAliases.edit = "hx";
    helix =
      let
        prettier = format: {
          command = lib.getExe pkgs.nodePackages.prettier;
          args = [
            "--stdin-filepath"
            "file.${format}"
          ];
        };
        biome = format: {
          command = lib.getExe pkgs.biome;
          args = [
            "check"
            "--stdin-file-path=file.${format}"
            "--write"
          ];
        };
      in
      {
        enable = true;
        defaultEditor = true;
        extraPackages = with pkgs; [
          # Markdown
          marksman
          markdown-oxide
          # Html, css, Json, Eslint
          vscode-langservers-extracted
          # Yaml
          ansible-language-server
          yaml-language-server
        ];
        settings = {
          editor = {
            auto-save = {
              after-delay.enable = true;
              focus-lost = true;
            };
            cursor-shape = {
              normal = "block";
              insert = "bar";
              select = "underline";
            };
            lsp = {
              display-inlay-hints = true;
              display-messages = true;
            };
          };
          keys.normal = {
            C-f = ":format";
          };
        };

        languages.language = [
          {
            name = "css";
            formatter = biome "css";
            auto-format = true;
          }
          {
            name = "json";
            language-servers = [
              "vscode-json-language-server"
            ];
            formatter = biome "json";
            auto-format = true;
          }
          {
            name = "jsonc";
            language-servers = [
            ];
            formatter = biome "jsonc";
            file-types = [
              "jsonc"
            ];
            auto-format = true;
          }
          {
            name = "markdown";
            formatter = prettier "md";
            auto-format = true;
          }
          {
            name = "nix";
            formatter.command = lib.getExe pkgs.nixfmt-rfc-style;
            auto-format = true;
          }
          {
            name = "yaml";
            formatter = prettier "yaml";
            auto-format = true;
          }
        ];

      };
  };
}
