Skip to content

Instantly share code, notes, and snippets.

@kylo252
Created October 6, 2021 06:55
Show Gist options
  • Save kylo252/2dc525563ef84b419d0bda4a1c50b7fc to your computer and use it in GitHub Desktop.
Save kylo252/2dc525563ef84b419d0bda4a1c50b7fc to your computer and use it in GitHub Desktop.
basic telescope finder
local M = {}
local function custom_telescope_finder(opts)
opts = opts or {}
local pickers = require "telescope.pickers"
local finders = require "telescope.finders"
local conf = require("telescope.config").values
local custom_action = function()
local action_state = require "telescope.actions.state"
local entry = action_state.get_selected_entry()
if entry ~= nil then
vim.notify("got: " .. entry.value, vim.log.levels.INFO)
end
end
pickers.new(opts, {
prompt_title = "my nice results",
layout_strategy = "flex",
finder = finders.new_table(opts.data),
sorter = conf.generic_sorter(opts),
attach_mappings = function(_, map)
map("i", "<CR>", custom_action)
return true
end,
}):find()
end
function M.test1()
local opts = {
-- data = { "1", "2", "3" },
-- data = vim.tbl_keys(package.loaded),
data = vim.opt.runtimepath:get(),
}
custom_telescope_finder(opts)
end
return M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment