{ pkgs, ... }:
{
  plugins.telescope = {
    enable = true;
    extensions.file-browser = {
      enable = true;
      # explanation: see :help expand
      # % is current file path, :p is full, :h is head (last component removed)
      settings.cwd.__raw = "'%:p:h'";
    };
    settings.defaults.mappings = {
      i = {
        # close telescope when escape pressed in insert mode
        "<esc>" = "close";
      };
    };
    keymaps = {
      # files
      "<leader><space>" = {
        action = "find_files";
        options = {
          desc = "Find files in current directory";
        };
      };
      "<leader>ff" = {
        action = "file_browser";
        options = {
          desc = "Find files in current directory";
        };
      };
      "<leader>fr" = {
        action = "oldfiles";
        options = {
          desc = "Recent files";
        };
      };

      # search
      "<leader>/" = {
        action = "live_grep";
        options = {
          desc = "Grep (root dir)";
        };
      };

      # buffers
      "<leader>b" = {
        action = "buffers";
        options = {
          desc = "Buffer list";
        };
      };

      # lsp
      "<leader>sD" = {
        action = "diagnostics";
        options = {
          desc = "Workspace diagnostics";
        };
      };
    };
  };
  extraPlugins = [
    # frecency ranking
    (pkgs.vimUtils.buildVimPlugin {
      name = "telescope-all-recent";
      src = pkgs.fetchFromGitHub {
        owner = "prochri";
        repo = "telescope-all-recent.nvim";
        rev = "267e9e5fd13a6e9a4cc6ffe00452d446d040401d";
        hash = "sha256-EYU7HazKcABAGnJ3iqGqM2n+XTo64L1uqoopL/XuLFg=";
      };
    })
    # dependency for telescope-all-recent: sqlite
    pkgs.vimPlugins.sqlite-lua
  ];
  extraConfigLua = (builtins.readFile ./extra_config.lua);
  # use telescope in more places
  plugins.dressing = {
    enable = true;
  };
}
