{
  pkgs,
  lib,
  inputs,
  ...
}: {
  programs.helix = {
    enable = true;

    settings = {
      theme = lib.mkForce "stylix_fix";

      keys.normal = {
        "C" = ["collapse_selection" "extend_to_line_end" "change_selection"];
        "D" = ["extend_to_line_end" "delete_selection"];
        "Y" = ["extend_to_line_bounds" "yank_main_selection_to_clipboard" "goto_line_start" "collapse_selection"];
        "V" = ["select_mode" "extend_to_line_bounds"];

        "{" = "goto_prev_paragraph";
        "}" = "goto_next_paragraph";
        "X" = "extend_line_above";
        "esc" = ["collapse_selection" "keep_primary_selection"];
        space.space = "file_picker";
        space.w = ":w";
        # space.q = ":bc";
        "C-q" = ":xa";
        space.u = {
          f = ":format"; # format using LSP formatter
          w = ":set whitespace.render all";
          W = ":set whitespace.render none";
        };
      };
      keys.select = {
        "%" = "match_brackets";
      };
      editor = {
        color-modes = true;
        cursorline = true;
        mouse = false;
        idle-timeout = 1;
        line-number = "relative";
        scrolloff = 5;
        completion-replace = true;
        bufferline = "always";
        true-color = true;
        rulers = [80];
        soft-wrap.enable = true;
        indent-guides = {
          render = true;
        };
        lsp = {
          display-messages = true;
          display-inlay-hints = true;
        };
        statusline = {
          separator = "|";
          left = ["mode" "selections" "spinner" "file-name" "total-line-numbers"];
          center = [];
          right = ["diagnostics" "file-encoding" "file-line-ending" "file-type" "position-percentage" "position"];
          mode = {
            normal = "NORMAL";
            insert = "INSERT";
            select = "SELECT";
          };
        };

        whitespace.characters = {
          space = "·";
          nbsp = "⍽";
          tab = "→";
          newline = "⤶";
        };

        cursor-shape = {
          insert = "bar";
          normal = "block";
          select = "block";
        };
      };
    };

    languages = {
      language = [
        {
          name = "bash";
          auto-format = true;
          formatter = {
            command = "${pkgs.shfmt}/bin/shfmt";
            args = ["-i" "2" "-"];
          };
        }
        {
          name = "html";
          file-types = ["html" "tera"];
        }
        {
          name = "clojure";
          injection-regex = "(clojure|clj|edn|boot|yuck)";
          file-types = ["clj" "cljs" "cljc" "clje" "cljr" "cljx" "edn" "boot" "yuck"];
        }
        {
          name = "latex";
          file-types = ["tex"];
          # config.texlab = {
          #   build = {
          #     forwardSearchAfter = true;
          #     onSave = true;
          #   };
          #   chktex = {
          #     onEdit = true;
          #   };
          #   forwardSearch = {
          #     executable = "zathura";
          #     args = [ "--synctex-forward" "%l:1:%f" "%p" ];
          #   };
          # };
        }
      ];

      language-server = {
        bash-language-server = {
          command = "${pkgs.nodePackages.bash-language-server}/bin/bash-language-server";
          args = ["start"];
        };

        clangd = {
          command = "${pkgs.clang-tools}/bin/clangd";
          clangd.fallbackFlags = ["-std=c++2b"];
        };

        nil = {
          command = lib.getExe pkgs.nil;
          config.nil.formatting.command = ["${lib.getExe pkgs.alejandra}" "-q"];
        };
      };
    };

    themes = {
      # ui.selection = {bg = "white"; modifiers = ["reversed"];};
      # ui.primary = {bg = "light-cyan"; modifiers = ["reversed"];};
      stylix_fix = {
        inherits = "gruvbox";
        ui.selection = { bg = "#304a3d"; };
        ui.selection.primary = { bg = "#2f2f2f"; };
        ui.text = "#ff0000";
        ui.virtual.inlay-hint = "#ff0000";
      };
    };

  };

  home.packages = with pkgs; [
    # some other lsp related packages / dev tools
    typst
    shellcheck
    lldb
    gopls
    clang-tools
    nodejs
    guile
    nim
    zig
    texlab
    zls
    jre8
    gcc
    uncrustify
    black
    shellcheck
    gawk
    haskellPackages.haskell-language-server
    java-language-server
    kotlin-language-server
    nodePackages.vls
    nodePackages.jsonlint
    nodePackages.yarn

    # Nix
    alejandra
    nil

    # Rust
    cargo
    rust-analyzer
  ];
}
