-
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
Use frecency with git_files #49
Comments
Is it really a workaround if this feature was planed like for the beginning 🤔
|
Hi, Am I correct? |
A sorter is nothing more than a function that gets a entry and the current prompt and returns a score. You maybe can get a list, from But you still need a simple list all my frecency entries because the sorter cant add new things to a picker. PR welcome |
I thought about it a little bit more. I havent this project, just havent seen the creator in months. I think this might actually work. A additional frecency sorter you can set on top of |
Yes, that is what I was thinking - a frecency sorter set on top of I do think that this picker would be obsoleted by that - you could just use the frecency sorter with the |
Hey there! I'm seeing the exact same issue with this project: It's a picker, rather than a sorter. This would also make sense for Are there any news on this issue? |
I think the news are that it will happen if there's someone willing to make it... |
This is what I am using local ext = require("telescope._extensions")
local builtins = require("telescope.builtin")
local frecency_db = require("telescope._extensions.frecency.db_client")
local fzf = ext.manager.fzf
local function frecency_score(self, prompt, line, entry)
if prompt == nil or prompt == "" then
for _, file_entry in ipairs(self.state.frecency) do
local filepath = entry.cwd .. "/" .. entry.value
if file_entry.filename == filepath then
return 9999 - file_entry.score
end
end
return 9999
end
return self.default_scoring_function(self, prompt, line, entry)
end
local function frecency_start(self, prompt)
self.default_start(self, prompt)
if not self.state.frecency then
self.state.frecency = frecency_db.get_file_scores()
end
end
local frecency_sorter = function(opts)
local fzf_sorter = fzf.native_fzf_sorter()
fzf_sorter.default_scoring_function = fzf_sorter.scoring_function
fzf_sorter.default_start = fzf_sorter.start
fzf_sorter.scoring_function = frecency_score
fzf_sorter.start = frecency_start
return fzf_sorter
end
return {
frecency_sorter = frecency_sorter,
}
---
telescope.setup({
defaults = {
file_sorter = mysorter.frecency_sorter,
}, |
I was about to ask the same thing, I would love to use this not only for files, but also for commands |
Is outdated, there are new way to handle this? |
(I have not tried @nikhilkalige's snippets with this change.) |
should such sorter be added to I used to have it under ¯\_(ツ)_/¯ |
Hi,
I would like to use this with
git_files
or ideally with https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#falling-back-to-find_files-if-git_files-cant-find-a-git-directoryIs there any way to do this? I think #13 and #4 are going this way of being able to use frecency with any picker, not just recent files, but the current workaround with the workspaces is not it.
Anyway, thanks for the great work!
The text was updated successfully, but these errors were encountered: