### This line is here so the file shows up in a grep for `inputrc` LMFAO.  I was
### so confused trying to find this module.
{ config, lib, pkgs, ... }:

let
  cfg = config.sydnix.users.crumb.readline;
in {
  options.sydnix.users.crumb.readline.enable
    = lib.mkEnableOption "Readline, à la crumb";

  config = lib.mkIf cfg.enable {
    programs.readline = {
      enable = true;
      extraConfig = ''
        # Unfortunately, the Vi mode is... bad.
        set editing-mode emacs

        # Mimmic Comint/Eshell binds.
        C-k: history-substring-search-backward
        C-j: history-substring-search-forward
        C-s: reverse-search-history

        set history-preserve-point on

        set bell-style none

        set blink-matching-paren on

        # Inhibit that god-awful double-tab bullshit.
        set show-all-if-ambiguous on
        set show-all-if-unmodified on
        set completion-ignore-case on
        set completion-map-case on

        # Append a '/' when completing the full name of a symlink to a
        # directory.  This mirrors the behaviour when completing real
        # directories.
        set mark-symlinked-directories on

        # Visually hint at a file's type in completions.
        set visible-stats on
        set colored-stats on
      '';
    };
  };
}

