mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
remove substr_matcher and use the upstreamed version
https://github.com/nvim-telescope/telescope.nvim/pull/443
This commit is contained in:
parent
78bc319f49
commit
8ceaedc4ca
@ -11,10 +11,12 @@ local entry_display = require "telescope.pickers.entry_display"
|
||||
local finders = require "telescope.finders"
|
||||
local path = require('telescope.path')
|
||||
local pickers = require "telescope.pickers"
|
||||
local sorters = require "telescope._extensions.frecency.sorter"
|
||||
local sorters = require "telescope.sorters"
|
||||
local utils = require('telescope.utils')
|
||||
|
||||
local os_path_sep = vim.loop.os_uname().sysname == "Windows" and "\\" or "/"
|
||||
|
||||
-- local os_path_sep = vim.loop.os_uname().sysname == "Windows" and "\\" or "/"
|
||||
local os_path_sep = utils.get_separator()
|
||||
local show_scores = false
|
||||
local db_client
|
||||
|
||||
@ -56,6 +58,9 @@ local frecency = function(opts)
|
||||
|
||||
display_items = show_scores and {{entry.score, "Directory"}} or {}
|
||||
table.insert(display_items, {filename, hl_filename})
|
||||
if frecency_utils.string_ends(filename, '.lua') then
|
||||
table.insert(display_items, create_tag_display("lua"))
|
||||
end
|
||||
|
||||
return displayer(display_items)
|
||||
end
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
local sorters = require "telescope.sorters"
|
||||
local util = require("telescope._extensions.frecency.util")
|
||||
|
||||
local my_sorters = {}
|
||||
|
||||
local substr_highlighter = function(_, prompt, display)
|
||||
local highlights = {}
|
||||
display = display:lower()
|
||||
|
||||
local search_terms = util.split(prompt, "%s")
|
||||
local hl_start, hl_end
|
||||
|
||||
for _, word in pairs(search_terms) do
|
||||
hl_start, hl_end = display:find(word, 1, true)
|
||||
if hl_start then
|
||||
table.insert(highlights, {start = hl_start, finish = hl_end})
|
||||
end
|
||||
end
|
||||
|
||||
return highlights
|
||||
end
|
||||
|
||||
my_sorters.get_substr_matcher = function(opts)
|
||||
opts = opts or {}
|
||||
|
||||
local substr = sorters:new()
|
||||
substr.highlighter = substr_highlighter
|
||||
substr.scoring_function = function(_, prompt, _, entry)
|
||||
local display = entry.ordinal:lower()
|
||||
|
||||
local search_terms = util.split(prompt, "%s")
|
||||
local matched = 0
|
||||
local total_search_terms = 0
|
||||
for _, word in pairs(search_terms) do
|
||||
total_search_terms = total_search_terms + 1
|
||||
if display:find(word, 1, true) then
|
||||
matched = matched + 1
|
||||
end
|
||||
end
|
||||
|
||||
return matched == total_search_terms and entry.index or -1
|
||||
end
|
||||
|
||||
return substr
|
||||
end
|
||||
|
||||
return my_sorters
|
||||
Loading…
Reference in New Issue
Block a user