Skip to content

Instantly share code, notes, and snippets.

@tjdevries
Created July 21, 2022 15:04
Show Gist options
  • Save tjdevries/8968cadee0bcaed5aa85bd18961029da to your computer and use it in GitHub Desktop.
Save tjdevries/8968cadee0bcaed5aa85bd18961029da to your computer and use it in GitHub Desktop.
local sorter = require("telescope").extensions.fzf.native_fzf_sorter()
-- Save original scoring function to get the score
local fzf_scoring_function = sorter.scoring_function
-- Override function to do whatever you want.
-- Telescope is just functions
sorter.scoring_function = function(self, prompt, line)
local score = fzf_scoring_function(self, prompt, line)
-- line is the file entry, you could get the full line filename, etc.
if vim.startswith(line, "/home/tjdevries/example") then
score = score * 2
end
return score
end
require("telescope.builtin").find_files {
sorter = sorter,
-- ... other options here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment