From 235d48135c51bfc2f628a24ce324091086890a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Fri, 16 Aug 2024 15:09:11 +0200 Subject: [PATCH] feat(nixvim): use frecency algorithm in telescope searches This gives better results, especially in 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 --- nixos/nixvim/config/extra_config.lua | 7 +++++++ nixos/nixvim/config/telescope.nix | 1 + 2 files changed, 8 insertions(+) create mode 100644 nixos/nixvim/config/extra_config.lua diff --git a/nixos/nixvim/config/extra_config.lua b/nixos/nixvim/config/extra_config.lua new file mode 100644 index 0000000..cc6b422 --- /dev/null +++ b/nixos/nixvim/config/extra_config.lua @@ -0,0 +1,7 @@ +require('telescope-all-recent').setup({ + default = { + disable = false; + use_cwd = true, + sorting = "frecency", + } +}) diff --git a/nixos/nixvim/config/telescope.nix b/nixos/nixvim/config/telescope.nix index 96aa101..6075aaa 100644 --- a/nixos/nixvim/config/telescope.nix +++ b/nixos/nixvim/config/telescope.nix @@ -74,4 +74,5 @@ # dependency for telescope-all-recent: sqlite pkgs.vimPlugins.sqlite-lua ]; + extraConfigLua = (builtins.readFile ./extra_config.lua); }