{
  inputs,
  pkgs,
  rice,
  ...
}:
let
  pal = rice.palette.hex;
in
{
  programs.helix = {
    enable = true;
    package = inputs.helix.packages.${pkgs.system}.helix;
    themes = with pal; {
      nix-rice = {
        "attribute" = bright.cyan;
        "keyword" = {
          fg = normal.red;
        };
        "keyword.directive" = normal.red;
        "namespace" = bright.cyan;
        "punctuation" = bright.yellow;
        "punctuation.delimiter" = bright.yellow;
        "operator" = bright.magenta;
        "special" = normal.magenta;
        "variable.other.member" = bright.blue;
        "variable" = util.fg;
        "variable.builtin" = bright.yellow;
        "variable.parameter" = bright.white;
        "type" = normal.yellow;
        "type.builtin" = normal.yellow;
        "constructor" = {
          fg = bright.magenta;
          modifiers = [ "bold" ];
        };
        "function" = {
          fg = normal.green;
          modifiers = [ "bold" ];
        };
        "function.macro" = bright.cyan;
        "function.builtin" = normal.yellow;
        "tag" = normal.red;
        "comment" = {
          fg = normal.magenta;
          modifiers = [ "italic" ];
        };
        "constant" = {
          fg = bright.magenta;
        };
        "constant.builtin" = {
          fg = bright.magenta;
          modifiers = [ "bold" ];
        };
        "string" = normal.green;
        "constant.numeric" = bright.magenta;
        "constant.character.escape" = {
          fg = bright.white;
          modifiers = [ "bold" ];
        };
        "label" = bright.cyan;
        "module" = bright.cyan;
        "diff.plus" = bright.green;
        "diff.delta" = bright.yellow;
        "diff.minus" = bright.red;
        "warning" = bright.yellow;
        "error" = bright.red;
        "info" = bright.cyan;
        "hint" = bright.blue;
        "ui.background" = {
          inherit (util) bg;
        };
        "ui.linenr" = {
          fg = normal.cyan;
        };
        "ui.linenr.selected" = {
          fg = normal.yellow;
          modifiers = [ "bold" ];
        };
        "ui.cursorline" = {
          bg = normal.black;
        };
        "ui.statusline" = {
          inherit (util) fg;
          bg = bright.black;
        };
        "ui.statusline.normal" = {
          inherit (util) fg;
          bg = bright.black;
        };
        "ui.statusline.insert" = {
          inherit (util) fg;
          bg = normal.blue;
        };
        "ui.statusline.select" = {
          inherit (util) fg;
          bg = bright.yellow;
        };
        "ui.statusline.inactive" = {
          fg = normal.white;
          bg = normal.black;
        };
        "ui.popup" = {
          bg = normal.black;
        };
        "ui.window" = {
          bg = normal.black;
        };
        "ui.help" = {
          bg = normal.black;
          inherit (util) fg;
        };
        "ui.text" = {
          inherit (util) fg;
        };
        "ui.text.focus" = {
          inherit (util) fg;
        };
        "ui.selection" = {
          # modifiers = ["reversed"];
          bg = bright.yellow;
        };
        "ui.selection.primary" = {
          modifiers = [ "reversed" ];
        };
        # "ui.selection.primary" = { bg = bright.cyan; };
        "ui.cursor.primary" = {
          bg = normal.white;
          fg = normal.black;
        };
        "ui.cursor.match" = {
          bg = bright.cyan;
        };
        "ui.menu" = {
          inherit (util) fg;
          bg = bright.black;
        };
        "ui.menu.selected" = {
          fg = bright.black;
          bg = bright.blue;
          modifiers = [ "bold" ];
        };
        "ui.virtual.whitespace" = bright.black;
        "ui.virtual.ruler" = {
          bg = normal.black;
        };
        "ui.virtual.inlay-hint" = {
          fg = normal.magenta;
        };
        "diagnostic.warning" = {
          underline = {
            color = bright.yellow;
            style = "curl";
          };
        };
        "diagnostic.error" = {
          underline = {
            color = bright.red;
            style = "curl";
          };
        };
        "diagnostic.info" = {
          underline = {
            color = bright.cyan;
            style = "curl";
          };
        };
        "diagnostic.hint" = {
          underline = {
            color = bright.blue;
            style = "curl";
          };
        };
        "markup.heading" = bright.cyan;
        "markup.bold" = {
          modifiers = [ "bold" ];
        };
        "markup.italic" = {
          modifiers = [ "italic" ];
        };
        "markup.strikethrough" = {
          modifiers = [ "crossed_out" ];
        };
        "markup.link.url" = {
          fg = bright.green;
          modifiers = [ "underlined" ];
        };
        "markup.link.text" = bright.red;
        "markup.raw" = bright.red;
      };
    };

    # theme = "nix-rice"

    settings = {
      theme = "nix-rice";
      editor = {
        bufferline = "multiple";
        cursorline = true;
        true-color = true;
        cursor-shape = {
          insert = "bar";
          normal = "block";
          select = "underline";
        };
        statusline.left = [
          "mode"
          "spinner"
          "version-control"
          "file-name"
          "file-modification-indicator"
        ];
        lsp.display-messages = true;
      };
    };

    languages = {
      language = [
        {
          name = "rust";
          language-servers = [ "rust-analyzer" ];
        }
        {
          name = "nix";
          language-servers = [ "nil" ];
          file-types = [ "nix" ];
          auto-format = true;
          formatter = {
            command = "nixfmt";
          };
        }
      ];

      language-server = {
        qmlls = {
          command = "qmlls";
          args = [ "-E" ];
        };

        nil = {
          command = "nil";
        };

        rust-analyzer = {
          config = {
            cargo.buildScripts.enable = true;
            procMacro.enable = true;
            check.command = "clippy";
          };
        };
      }; # language-server
    }; # languages
  }; # helix config
}
