* feat: replace_map * feat: Add action_set and action_state * fix: Move all actions.get_ to action_state.get_ * fix: replace all internal references of _goto_file_selection_edit * feat: add some docs * fix: lint * feat: actions.select * remove mentions and usage of goto_file_selection APIs * feat: special case attach_mappings to be overridable and defaultable * Having goto_file_selection mappings will cause a error as well as replacing deprecated goto_file_selection methodes For config and replacing use this instead: - actions.select_default - actions.select_horizonal - actions.select_vertical - actions.select_tab Only replacing: - actions.set.edit -- for replacing all select functions * adds actions.state.select_key_to_edit_key Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
93 lines
2.1 KiB
Lua
93 lines
2.1 KiB
Lua
|
|
local make_entry = require('telescope.make_entry')
|
|
local actions = require('telescope.actions')
|
|
local action_state = require('telescope.actions.state')
|
|
local finders = require('telescope.finders')
|
|
local previewers = require('telescope.previewers')
|
|
local pickers = require('telescope.pickers')
|
|
local sorters = require('telescope.sorters')
|
|
|
|
local WIP = {}
|
|
|
|
WIP.git_diff = function()
|
|
local file_picker = pickers.new {
|
|
previewer = previewers.new_termopen {
|
|
command = "git diff %s"
|
|
},
|
|
}
|
|
|
|
file_picker:find {
|
|
prompt = "Git Diff Viewier",
|
|
|
|
finder = finders.new {
|
|
static = true,
|
|
|
|
fn_command = function()
|
|
return {
|
|
command = 'git',
|
|
args = {'ls-files', '-m'}
|
|
}
|
|
end,
|
|
},
|
|
|
|
sorter = sorters.get_norcalli_sorter()
|
|
}
|
|
end
|
|
|
|
-- TODO: Make it so that when you select stuff, it's inserted
|
|
-- TODO: Make it so the previewer shows the help text.
|
|
WIP.completion = function(opts)
|
|
local results = {}
|
|
for k, _ in pairs(vim.api) do
|
|
table.insert(results, k .. "()")
|
|
end
|
|
|
|
local lsp_reference_finder = finders.new {
|
|
results = results
|
|
}
|
|
|
|
-- TODO: Open the help text for the line.
|
|
local reference_picker = pickers.new(opts, {
|
|
prompt = 'vim.api Help Reference',
|
|
finder = lsp_reference_finder,
|
|
sorter = sorters.get_norcalli_sorter(),
|
|
previewer = previewers.help,
|
|
})
|
|
|
|
reference_picker:find {}
|
|
end
|
|
|
|
|
|
WIP.reloader = function(opts)
|
|
opts = opts or {}
|
|
|
|
pickers.new(opts, {
|
|
prompt = 'Packages',
|
|
finder = finders.new_table {
|
|
results = vim.tbl_keys(package.loaded),
|
|
entry_maker = make_entry.gen_from_string(opts),
|
|
},
|
|
sorter = sorters.get_generic_fuzzy_sorter(),
|
|
|
|
attach_mappings = function(prompt_bufnr, map)
|
|
local reload_package = function()
|
|
local selection = action_state.get_selected_entry(prompt_bufnr)
|
|
|
|
actions.close(prompt_bufnr)
|
|
|
|
print(vim.inspect(selection))
|
|
end
|
|
|
|
map('i', '<CR>', reload_package)
|
|
map('n', '<CR>', reload_package)
|
|
|
|
return true
|
|
end
|
|
}):find()
|
|
end
|
|
|
|
-- TODO: Use tree sitter to get "everything" in your current scope / file / etc.
|
|
-- Fuzzy find ofver it, go to its definition.
|
|
|
|
return WIP
|