We have broke all extension that do some sort of goto_file_selection:replace Problem described here: https://github.com/nvim-telescope/telescope.nvim/pull/465#issuecomment-767831897 Possible solution: https://github.com/nvim-telescope/telescope.nvim/pull/465#issuecomment-767808213
This commit is contained in:
26
README.md
26
README.md
@@ -278,11 +278,11 @@ require('telescope').setup{
|
||||
-- So, to not map "<C-n>", just put
|
||||
["<c-x>"] = false,
|
||||
-- Otherwise, just set the mapping to the function that you want it to be.
|
||||
["<C-i>"] = actions.hselect,
|
||||
["<C-i>"] = actions.goto_file_selection_split,
|
||||
-- Add up multiple actions
|
||||
["<CR>"] = actions.select + actions.center,
|
||||
["<CR>"] = actions.goto_file_selection_edit + actions.center,
|
||||
-- You can perform as many actions in a row as you like
|
||||
["<CR>"] = actions.select + actions.center + my_cool_custom_action,
|
||||
["<CR>"] = actions.goto_file_selection_edit + actions.center + my_cool_custom_action,
|
||||
},
|
||||
n = {
|
||||
["<esc>"] = actions.close
|
||||
@@ -303,7 +303,7 @@ local actions = require('telescope.actions')
|
||||
require('telescope.builtin').fd({ -- or new custom picker's attach_mappings field:
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
-- This will replace select no mather on which key it is mapped by default
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local entry = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
print(vim.inspect(entry))
|
||||
@@ -311,17 +311,17 @@ require('telescope.builtin').fd({ -- or new custom picker's attach_mappings fiel
|
||||
end)
|
||||
|
||||
-- You can also enhance an action with pre and post action which will run before of after an action
|
||||
actions.hselect:enhance ({
|
||||
actions.goto_file_selection_split:enhance ({
|
||||
pre = function()
|
||||
-- Will run before actions.hselect
|
||||
-- Will run before actions.goto_file_selection_split
|
||||
end,
|
||||
post = function()
|
||||
-- Will run after actions.hselect
|
||||
-- Will run after actions.goto_file_selection_split
|
||||
end,
|
||||
})
|
||||
|
||||
-- Or replace for all commands: edit, new, vnew and tab
|
||||
actions._select:replace(function(_, cmd)
|
||||
actions._goto_file_selection:replace(function(_, cmd)
|
||||
print(cmd) -- Will print edit, new, vnew or tab depending on your keystroke
|
||||
end)
|
||||
|
||||
@@ -340,20 +340,20 @@ require('telescope.builtin').fd({ -- or new custom picker's attach_mappings fiel
|
||||
<!-- sorter = sorters.fuzzy_with_index_bias(), -->
|
||||
<!-- attach_mappings = function(prompt_bufnr) -->
|
||||
<!-- -- This will replace select no mather on which key it is mapped by default -->
|
||||
<!-- actions.select:replace(function() -->
|
||||
<!-- actions.goto_file_selection_edit:replace(function() -->
|
||||
<!-- -- Code here -->
|
||||
<!-- end) -->
|
||||
<!-- -- You can also enhance an action with post and post action which will run before of after an action -->
|
||||
<!-- actions.hselect:enhance { -->
|
||||
<!-- actions.goto_file_selection_split:enhance { -->
|
||||
<!-- pre = function() -->
|
||||
<!-- -- Will run before actions.hselect -->
|
||||
<!-- -- Will run before actions.goto_file_selection_split -->
|
||||
<!-- end, -->
|
||||
<!-- post = function() -->
|
||||
<!-- -- Will run after actions.hselect -->
|
||||
<!-- -- Will run after actions.goto_file_selection_split -->
|
||||
<!-- end, -->
|
||||
<!-- } -->
|
||||
<!-- -- Or replace for all commands: edit, new, vnew and tab -->
|
||||
<!-- actions._select:replace(function(_, cmd) -->
|
||||
<!-- actions._goto_file_selection:replace(function(_, cmd) -->
|
||||
<!-- print(cmd) -- Will print edit, new, vnew or tab depending on your keystroke -->
|
||||
<!-- end) -->
|
||||
<!-- return true -->
|
||||
|
||||
@@ -66,7 +66,7 @@ function actions.preview_scrolling_down(prompt_bufnr)
|
||||
end
|
||||
|
||||
-- TODO: It seems sometimes we get bad styling.
|
||||
function actions._select(prompt_bufnr, command)
|
||||
function actions._goto_file_selection(prompt_bufnr, command)
|
||||
local entry = actions.get_selected_entry(prompt_bufnr)
|
||||
|
||||
if not entry then
|
||||
@@ -144,29 +144,22 @@ function actions.center(_)
|
||||
vim.cmd(':normal! zz')
|
||||
end
|
||||
|
||||
function actions.select(prompt_bufnr)
|
||||
actions._select(prompt_bufnr, "edit")
|
||||
function actions.goto_file_selection_edit(prompt_bufnr)
|
||||
actions._goto_file_selection(prompt_bufnr, "edit")
|
||||
end
|
||||
|
||||
function actions.hselect(prompt_bufnr)
|
||||
actions._select(prompt_bufnr, "new")
|
||||
function actions.goto_file_selection_split(prompt_bufnr)
|
||||
actions._goto_file_selection(prompt_bufnr, "new")
|
||||
end
|
||||
|
||||
function actions.vselect(prompt_bufnr)
|
||||
actions._select(prompt_bufnr, "vnew")
|
||||
function actions.goto_file_selection_vsplit(prompt_bufnr)
|
||||
actions._goto_file_selection(prompt_bufnr, "vnew")
|
||||
end
|
||||
|
||||
function actions.tabselect(prompt_bufnr)
|
||||
actions._select(prompt_bufnr, "tabedit")
|
||||
function actions.goto_file_selection_tabedit(prompt_bufnr)
|
||||
actions._goto_file_selection(prompt_bufnr, "tabedit")
|
||||
end
|
||||
|
||||
-- aliases
|
||||
actions._goto_file_selection = actions._select
|
||||
actions.goto_file_selection_edit = actions.select
|
||||
actions.goto_file_selection_split = actions.hselect
|
||||
actions.goto_file_selection_vsplit = actions.vselect
|
||||
actions.goto_file_selection_tabedit = actions.tabselect
|
||||
|
||||
function actions.close_pum(_)
|
||||
if 0 ~= vim.fn.pumvisible() then
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<c-y>", true, true, true), 'n', true)
|
||||
|
||||
@@ -251,7 +251,7 @@ files.current_buffer_fuzzy_find = function(opts)
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function()
|
||||
actions._select:enhance {
|
||||
actions._goto_file_selection:enhance {
|
||||
post = function()
|
||||
local selection = actions.get_selected_entry()
|
||||
vim.api.nvim_win_set_cursor(0, {selection.lnum, 0})
|
||||
@@ -287,7 +287,7 @@ files.tags = function(opts)
|
||||
previewer = previewers.ctags.new(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function()
|
||||
actions._select:enhance {
|
||||
actions._goto_file_selection:enhance {
|
||||
post = function()
|
||||
local selection = actions.get_selected_entry()
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ git.commits = function(opts)
|
||||
previewer = previewers.git_commit_diff.new(opts),
|
||||
sorter = conf.file_sorter(opts),
|
||||
attach_mappings = function()
|
||||
actions.select:replace(actions.git_checkout)
|
||||
actions.goto_file_selection_edit:replace(actions.git_checkout)
|
||||
return true
|
||||
end
|
||||
}):find()
|
||||
@@ -67,7 +67,7 @@ git.bcommits = function(opts)
|
||||
previewer = previewers.git_commit_diff.new(opts),
|
||||
sorter = conf.file_sorter(opts),
|
||||
attach_mappings = function()
|
||||
actions.select:replace(actions.git_checkout)
|
||||
actions.goto_file_selection_edit:replace(actions.git_checkout)
|
||||
return true
|
||||
end
|
||||
}):find()
|
||||
@@ -107,7 +107,7 @@ git.branches = function(opts)
|
||||
previewer = previewers.git_branch_log.new(opts),
|
||||
sorter = conf.file_sorter(opts),
|
||||
attach_mappings = function()
|
||||
actions.select:replace(actions.git_checkout)
|
||||
actions.goto_file_selection_edit:replace(actions.git_checkout)
|
||||
return true
|
||||
end
|
||||
}):find()
|
||||
|
||||
@@ -47,7 +47,7 @@ internal.builtin = function(opts)
|
||||
previewer = previewers.builtin.new(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(_)
|
||||
actions.select:replace(actions.run_builtin)
|
||||
actions.goto_file_selection_edit:replace(actions.run_builtin)
|
||||
return true
|
||||
end
|
||||
}):find()
|
||||
@@ -82,7 +82,7 @@ internal.planets = function(opts)
|
||||
previewer = previewers.cat.new(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
|
||||
@@ -137,7 +137,7 @@ internal.symbols = function(opts)
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(_)
|
||||
actions.select:replace(actions.insert_symbol)
|
||||
actions.goto_file_selection_edit:replace(actions.insert_symbol)
|
||||
return true
|
||||
end
|
||||
}):find()
|
||||
@@ -168,7 +168,7 @@ internal.commands = function(opts)
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
local val = selection.value
|
||||
@@ -285,7 +285,7 @@ internal.vim_options = function(opts)
|
||||
-- previewer = previewers.help.new(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function()
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
local esc = ""
|
||||
|
||||
@@ -411,7 +411,7 @@ internal.help_tags = function(opts)
|
||||
previewer = previewers.help.new(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions._select:replace(function(_, cmd)
|
||||
actions._goto_file_selection:replace(function(_, cmd)
|
||||
local selection = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
if cmd == 'edit' or cmd == 'new' then
|
||||
@@ -440,7 +440,7 @@ internal.man_pages = function(opts)
|
||||
previewer = previewers.man.new(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions._select:replace(function(_, cmd)
|
||||
actions._goto_file_selection:replace(function(_, cmd)
|
||||
local selection = actions.get_selected_entry()
|
||||
|
||||
actions.close(prompt_bufnr)
|
||||
@@ -483,7 +483,7 @@ internal.reloader = function(opts)
|
||||
sorter = conf.generic_sorter(opts),
|
||||
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
|
||||
actions.close(prompt_bufnr)
|
||||
@@ -562,7 +562,7 @@ internal.colorscheme = function(opts)
|
||||
-- TODO: better preview?
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
|
||||
actions.close(prompt_bufnr)
|
||||
@@ -614,7 +614,7 @@ internal.registers = function(opts)
|
||||
-- use levenshtein as n-gram doesn't support <2 char matches
|
||||
sorter = sorters.get_levenshtein_sorter(),
|
||||
attach_mappings = function(_, map)
|
||||
actions.select:replace(actions.paste_register)
|
||||
actions.goto_file_selection_edit:replace(actions.paste_register)
|
||||
map('i', '<C-e>', actions.edit_register)
|
||||
|
||||
return true
|
||||
@@ -653,7 +653,7 @@ internal.keymaps = function(opts)
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes(selection.value.lhs, true, false, true),
|
||||
@@ -675,7 +675,7 @@ internal.filetypes = function(opts)
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
vim.cmd('setfiletype ' .. selection[1])
|
||||
@@ -696,7 +696,7 @@ internal.highlights = function(opts)
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
vim.cmd('hi ' .. selection.value)
|
||||
@@ -787,7 +787,7 @@ internal.autocommands = function(opts)
|
||||
previewer = previewers.autocommands.new(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions._select:replace(function(_, vim_cmd)
|
||||
actions._goto_file_selection:replace(function(_, vim_cmd)
|
||||
local selection = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
vim.cmd(vim_cmd .. ' ' .. selection.value)
|
||||
@@ -811,7 +811,7 @@ internal.spell_suggest = function(opts)
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
vim.cmd('normal! ciw' .. selection[1])
|
||||
|
||||
@@ -116,7 +116,7 @@ lsp.code_actions = function(opts)
|
||||
end
|
||||
},
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.select:replace(function()
|
||||
actions.goto_file_selection_edit:replace(function()
|
||||
local selection = actions.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
local val = selection.value
|
||||
|
||||
@@ -83,7 +83,7 @@ function config.set_defaults(defaults)
|
||||
-- Otherwise, just set the mapping to the function that you want it to be.
|
||||
--
|
||||
-- ...,
|
||||
-- ["<C-i>"] = actions.hselect
|
||||
-- ["<C-i>"] = actions.goto_file_selection_split
|
||||
-- ...,
|
||||
--
|
||||
set("mappings", {})
|
||||
|
||||
@@ -16,10 +16,10 @@ mappings.default_mappings = config.values.default_mappings or {
|
||||
["<Down>"] = actions.move_selection_next,
|
||||
["<Up>"] = actions.move_selection_previous,
|
||||
|
||||
["<CR>"] = actions.select + actions.center,
|
||||
["<C-x>"] = actions.hselect,
|
||||
["<C-v>"] = actions.vselect,
|
||||
["<C-t>"] = actions.tabselect,
|
||||
["<CR>"] = actions.goto_file_selection_edit + actions.center,
|
||||
["<C-x>"] = actions.goto_file_selection_split,
|
||||
["<C-v>"] = actions.goto_file_selection_vsplit,
|
||||
["<C-t>"] = actions.goto_file_selection_tabedit,
|
||||
|
||||
["<C-u>"] = actions.preview_scrolling_up,
|
||||
["<C-d>"] = actions.preview_scrolling_down,
|
||||
@@ -30,10 +30,10 @@ mappings.default_mappings = config.values.default_mappings or {
|
||||
|
||||
n = {
|
||||
["<esc>"] = actions.close,
|
||||
["<CR>"] = actions.select + actions.center,
|
||||
["<C-x>"] = actions.hselect,
|
||||
["<C-v>"] = actions.vselect,
|
||||
["<C-t>"] = actions.tabselect,
|
||||
["<CR>"] = actions.goto_file_selection_edit + actions.center,
|
||||
["<C-x>"] = actions.goto_file_selection_split,
|
||||
["<C-v>"] = actions.goto_file_selection_vsplit,
|
||||
["<C-t>"] = actions.goto_file_selection_tabedit,
|
||||
|
||||
-- TODO: This would be weird if we switch the ordering.
|
||||
["j"] = actions.move_selection_next,
|
||||
|
||||
Reference in New Issue
Block a user