Replies: 1 comment
-
|
this is probably a dumb solution to this but i did this local builtin = require'telescope.builtin'
local conf = require'telescope.config'.values
local sorter = conf.file_sorter() -- or generic_sorter
local def_filter_function = sorter.filter_function -- sorter might have a filter_function already
local buf_name = vim.api.nvim_buf_get_name(0) -- get filename
sorter._delimiter = '' -- i don't know what this is but if you remove it it will yell at you
sorter.filter_function = function(self,prompt,entry,cb_add,cb_filter)
-- check if sorter's filter_function already filters this or not
if vim.is_callable(def_filter_function) then
local result = def_filter_function(self, prompt, cb_add, cb_filter)
if result == -1 then
return -1
end
end
-- insert your logic here
-- return -1 if you want it filtered
-- return anything else if you don't
if entry.filename ~= buf_name then
return -1
end
end
builtin.lsp_references({
sorter = sorter
})if you know a better way of doing this please tell me. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
hi, thanks for this amazing plugin
"Find, Filter, Preview, Pick. All lua, all the time."
i have been looking at discussions, commits, issues and searching on the internet for any information regarding filtering results of telescope and have found nothing.
i've also asked a question on gitter and got no answer
so how can i filter results?
shouldn't this be as simple as providing a function like filter in the opts object for builtin pickers like find_files etc.?
as an example right now i want to have lsp_references picker to only show references in the current file. so it came to my mind
to filter to only references that have the current buffer name in their entry.filename or something like that.
is that possible? i've found
sorters.prefilterbut i don't know how to use it or if it's even useful for this case because there is not enough information for it in the docsBeta Was this translation helpful? Give feedback.
All reactions