summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authoranott03 <amitav_nott@ryecountryday.org>2021-01-25 13:20:01 -0500
committerGitHub <noreply@github.com>2021-01-25 19:20:01 +0100
commitccbb7f56384921a81813f0f9ebc85cdba0b7c255 (patch)
tree107739be676bda2e004e191e6a7c114aa172e399 /lua
parent5bf9e14f10023d5ab8182b33a80fca68cd174f79 (diff)
fix: move to actions.select as default action (#465)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/actions/init.lua25
-rw-r--r--lua/telescope/builtin/files.lua4
-rw-r--r--lua/telescope/builtin/git.lua6
-rw-r--r--lua/telescope/builtin/internal.lua30
-rw-r--r--lua/telescope/builtin/lsp.lua2
-rw-r--r--lua/telescope/config.lua2
-rw-r--r--lua/telescope/mappings.lua16
7 files changed, 46 insertions, 39 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua
index 50c7f37..34cfede 100644
--- a/lua/telescope/actions/init.lua
+++ b/lua/telescope/actions/init.lua
@@ -66,7 +66,7 @@ function actions.preview_scrolling_down(prompt_bufnr)
end
-- TODO: It seems sometimes we get bad styling.
-function actions._goto_file_selection(prompt_bufnr, command)
+function actions._select(prompt_bufnr, command)
local entry = actions.get_selected_entry(prompt_bufnr)
if not entry then
@@ -144,22 +144,29 @@ function actions.center(_)
vim.cmd(':normal! zz')
end
-function actions.goto_file_selection_edit(prompt_bufnr)
- actions._goto_file_selection(prompt_bufnr, "edit")
+function actions.select(prompt_bufnr)
+ actions._select(prompt_bufnr, "edit")
end
-function actions.goto_file_selection_split(prompt_bufnr)
- actions._goto_file_selection(prompt_bufnr, "new")
+function actions.hselect(prompt_bufnr)
+ actions._select(prompt_bufnr, "new")
end
-function actions.goto_file_selection_vsplit(prompt_bufnr)
- actions._goto_file_selection(prompt_bufnr, "vnew")
+function actions.vselect(prompt_bufnr)
+ actions._select(prompt_bufnr, "vnew")
end
-function actions.goto_file_selection_tabedit(prompt_bufnr)
- actions._goto_file_selection(prompt_bufnr, "tabedit")
+function actions.tabselect(prompt_bufnr)
+ actions._select(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)
diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua
index b450eab..cdb758a 100644
--- a/lua/telescope/builtin/files.lua
+++ b/lua/telescope/builtin/files.lua
@@ -251,7 +251,7 @@ files.current_buffer_fuzzy_find = function(opts)
},
sorter = conf.generic_sorter(opts),
attach_mappings = function()
- actions._goto_file_selection:enhance {
+ actions._select: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._goto_file_selection:enhance {
+ actions._select:enhance {
post = function()
local selection = actions.get_selected_entry()
diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua
index a33e76b..2374a5d 100644
--- a/lua/telescope/builtin/git.lua
+++ b/lua/telescope/builtin/git.lua
@@ -47,7 +47,7 @@ git.commits = function(opts)
previewer = previewers.git_commit_diff.new(opts),
sorter = conf.file_sorter(opts),
attach_mappings = function()
- actions.goto_file_selection_edit:replace(actions.git_checkout)
+ actions.select: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.goto_file_selection_edit:replace(actions.git_checkout)
+ actions.select: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.goto_file_selection_edit:replace(actions.git_checkout)
+ actions.select:replace(actions.git_checkout)
return true
end
}):find()
diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua
index 3c34b8b..d09f554 100644
--- a/lua/telescope/builtin/internal.lua
+++ b/lua/telescope/builtin/internal.lua
@@ -47,7 +47,7 @@ internal.builtin = function(opts)
previewer = previewers.builtin.new(opts),
sorter = conf.generic_sorter(opts),
attach_mappings = function(_)
- actions.goto_file_selection_edit:replace(actions.run_builtin)
+ actions.select: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.goto_file_selection_edit:replace(function()
+ actions.select: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.goto_file_selection_edit:replace(actions.insert_symbol)
+ actions.select: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.goto_file_selection_edit:replace(function()
+ actions.select: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.goto_file_selection_edit:replace(function()
+ actions.select: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._goto_file_selection:replace(function(_, cmd)
+ actions._select: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._goto_file_selection:replace(function(_, cmd)
+ actions._select: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.goto_file_selection_edit:replace(function()
+ actions.select: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.goto_file_selection_edit:replace(function()
+ actions.select: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.goto_file_selection_edit:replace(actions.paste_register)
+ actions.select: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.goto_file_selection_edit:replace(function()
+ actions.select: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.goto_file_selection_edit:replace(function()
+ actions.select: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.goto_file_selection_edit:replace(function()
+ actions.select: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._goto_file_selection:replace(function(_, vim_cmd)
+ actions._select: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.goto_file_selection_edit:replace(function()
+ actions.select:replace(function()
local selection = actions.get_selected_entry()
actions.close(prompt_bufnr)
vim.cmd('normal! ciw' .. selection[1])
diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua
index 4a373b1..6c31839 100644
--- a/lua/telescope/builtin/lsp.lua
+++ b/lua/telescope/builtin/lsp.lua
@@ -116,7 +116,7 @@ lsp.code_actions = function(opts)
end
},
attach_mappings = function(prompt_bufnr)
- actions.goto_file_selection_edit:replace(function()
+ actions.select:replace(function()
local selection = actions.get_selected_entry()
actions.close(prompt_bufnr)
local val = selection.value
diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua
index bfe8a6e..8af6b31 100644
--- a/lua/telescope/config.lua
+++ b/lua/telescope/config.lua
@@ -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.goto_file_selection_split
+ -- ["<C-i>"] = actions.hselect
-- ...,
--
set("mappings", {})
diff --git a/lua/telescope/mappings.lua b/lua/telescope/mappings.lua
index 499be3e..38f238c 100644
--- a/lua/telescope/mappings.lua
+++ b/lua/telescope/mappings.lua
@@ -16,10 +16,10 @@ mappings.default_mappings = config.values.default_mappings or {
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
- ["<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,
+ ["<CR>"] = actions.select + actions.center,
+ ["<C-x>"] = actions.hselect,
+ ["<C-v>"] = actions.vselect,
+ ["<C-t>"] = actions.tabselect,
["<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.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,
+ ["<CR>"] = actions.select + actions.center,
+ ["<C-x>"] = actions.hselect,
+ ["<C-v>"] = actions.vselect,
+ ["<C-t>"] = actions.tabselect,
-- TODO: This would be weird if we switch the ordering.
["j"] = actions.move_selection_next,