-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Can we use both fuzzy matching & frecency scoring at the same time? #165
Comments
I added naive implementation for fuzzy-matching in #166. It simply converts prompt string, such as |
I've just discovered this project and super-grateful for your effort! The first thing I stumbled across was not matching stuff with fuzzy searches. By now, it's deeply ingrained in my brain to just type 2-4-letter pieces to find the file ( This would be a single most impactful improvement for me. |
I see. I tried #166 and didn't feel much useful. But it is a good idea that users can select “fuzzy” or “unfuzzy” matcher in config. I will implement that. -- such as this way?
telescope.setup {
extensions = {
frecency = {
matcher = "fuzzy" -- acceptable: "default" / "fuzzy"
},
},
} |
Yes. # your input “libsan” matches below.
/path/to/www/src/lib/sanity.ts
# also this matches: `Lib……S……A……N` => “libsan”
/Users/foo/Library/Some/Arbitrary/Nice/project.ts This is why I am hesitating to include this feature into frecency. There is two ways to reduce this inconvenience.
Do you want to use this feature even with these points? |
Just a few thoughts:
|
— edited. Sorry, I’ve mistaken yes/no at the first time because I use yes against negative questions when I agree in my native language, Japanese.;) |
Yes - that would be fine. Plus, once I actually navigate to |
I've updated #166. The current logic calculates scores with recency and fzy implemented by |
It works well in my env. I merged #166 and added |
Awesome, thanks a lot @delphinus! For the reference, here's the config that does what I was looking for: frecency = {
matcher = "fuzzy",
scoring_function = function(recency, fzy_score)
return -recency
end
} It seems to only filter the list while the order still depends ONLY on the recency score. So now I basically use either of two file searches: fuzzy only (default telescope find_files with rg in my case) or frecency only. I found that mixing the two leads to unpredictable sorting on every character I type (at least in my experience, ymmv). Will keep it like that for a week to see if there's more to it. 🙌 |
@kirillrogovoy I also tried your suggested function. I noticed it is difficult to select a candidate which has too small recency score, such as, I have opened it only once. For example, consider a case like this.
But, it might be a matter of taste. I want to test own logic by many users. |
I reopen this just to be sure. |
Thanks for sharing! I think it's definitely a matter of taste or just preferred use cases. I use the frecency search only to navigate among the last ~5-20 opened files while working on a task. When the file is not frecently visited, I look it up with the standard find_files. The biggest time saver here for me is that I can just type something like "controller" and have the most related controller to my current task as the first/second suggested option. Some people handle it differently: e.g. they have a dozen of buffers open with the files they need and they use the buffer search to navigate. For me, the frecency search is like that, but without the need to manage those buffers. :) This tactics definitely doesn't work if you intend to use the frecency search most of the time in place of find_files exactly for the reasons you've mentioned. 👍 |
Fuzzy works great for me, thank you! |
[SOLVED - See bottom]
If I understand the previous comments correctly fuzzy search should let me write "lazyin" and "nvim/lua/bartosz/lazy/init.lua" should show up. But I get an empty list. If I search fot "lazy in" it comes up. But that's not the expected behavior? For more context I'm migrating from VSCode and I work in a very large repository with inconsistent class names, like some files would be called SomeMessageReqSerializer.hpp, but others are AnotherMessageRequestSerializer.hpp. In default Telescope file search I can search for AnotherMessageReqSer and the file will come up anyway. I'd love to have such search algorithm combined with frecency. Here's the relevant part of my config:
UPDATE: |
It's good that the problem is solved. I found you are calling require("lazy").setup {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope-frecency.nvim",
-- and more telescope-* plugins
},
config = function()
local telescope = require "telescope"
telescope.setup {
extensions = {
frecency = {
matcher = "fuzzy",
},
-- other telescope-* plugins' configs
},
}
-- builtin settings
local builtin = require "telescope.builtin"
vim.keymap.set("n", "<C-p>", builtin.git_files)
vim.keymap.set("n", "<leader>pg", function()
builtin.grep_string { search = vim.fn.input "Grep > " }
end)
-- extensions' setting
telescope.load_extension "frecency"
vim.keymap.set("n", "<leader>pf", function()
telescope.extensions.frecency.frecency { workspace = "CWD" }
end)
end,
},
} |
From #163 & some issues, there are some demand that users want to use fuzzy matching for frecency results. The current build allows to use
sorters.get_substr_matcher
only. That is because it is the only “sorter” that does not sort but match candidates.If a “sorter” that fuzzy-matches and does not sort exists, it is maybe useful for them. I want to create it on trial.
The text was updated successfully, but these errors were encountered: