nix/nixos/nixvim/config/telescope.nix
Khaïs COLIN 235d48135c feat(nixvim): use frecency algorithm in telescope searches
This gives better results, especially in <leader>b

My first try was to use the frecency telescope plugin, but that seems to
add a new telescope command, while I want frecency sorting in all
commands.

I then found the telescope-all-recent[1] plugin, which seems to do what
I want. This seems best paired with dressing.nvim[2] or
telescope-ui-select[3], to use the telescope ui in all select operations
(kind of like ivy in emacs).

These plugins are not supported by nixvim natively, so I'm following the
guide on how to use these plugins[4].

This now works, but I'm kind of unhappy with the sorting. Emacs-ivy had
this really neat feature where the first ~5 elements of the result were
always the last 5 elements you picked. Maybe I can acheive that by
tweaking the frecency weights? Let's see in another commit.

[1] https://github.com/prochri/telescope-all-recent.nvim
[2] https://github.com/stevearc/dressing.nvim
[3] https://github.com/nvim-telescope/telescope-ui-select.nvim
[4] https://nix-community.github.io/nixvim/user-guide/faq.html
2024-08-16 16:29:22 +02:00

78 lines
1.8 KiB
Nix

{ 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);
}