nixpkgs/home/programs/neovim/configuration/lua/telescope/_extensions/custom_runs.lua
Daniel Siepmann 774e4f8555
Rename Neovim custom telescope
The keyboard shortcut was already in use.
I therefore renamed custom_functions into custom runs.
That way I can add multiple things in the future.
E.g. the items to select can also be a table which defines the name as
well as what to execute. That way I could add functions, commands and
other things.
2022-03-23 16:37:26 +01:00

33 lines
1 KiB
Lua

local telescope = require('telescope')
local pickers = require('telescope.pickers')
local finders = require('telescope.finders')
local actions = require('telescope.actions')
local action_state = require('telescope.actions.state')
local conf = require('telescope.config').values
local custom_runs = function(opts)
opts = opts or {}
local results = { 'CopyFileName', 'CopyRelativeFilePath', 'CopyFullFilePath' }
pickers.new(opts, {
prompt_title = 'Custom Runs',
finder = finders.new_table {
results = results
},
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr, map)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
vim.api.nvim_call_function(selection[1], {})
end)
return true
end,
}):find()
end
return telescope.register_extension({
exports = { custom_runs = custom_runs },
})