diff options
| author | Ryan Koval <ryan@ryankoval.com> | 2022-09-04 14:47:25 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-04 21:47:25 +0200 |
| commit | 2b5060362bc6821faacc346a3069812446a14d68 (patch) | |
| tree | 0745e589256a2b2d94085f6118112770b78a56bc /lua | |
| parent | 19047b6b3c804ac65350fea7e432e1e46ec9770b (diff) | |
feat: added support for tabdrop (#2143)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/actions/init.lua | 32 | ||||
| -rw-r--r-- | lua/telescope/actions/set.lua | 3 | ||||
| -rw-r--r-- | lua/telescope/actions/state.lua | 2 |
3 files changed, 36 insertions, 1 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index 1f047e2..3384b54 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -299,6 +299,38 @@ actions.select_tab = { end, } +--- Perform 'drop' action on selection, usually something like<br> +---`:drop <selection>` +--- +--- i.e. open the selection in a window +---@param prompt_bufnr number: The prompt bufnr +actions.select_drop = { + pre = function(prompt_bufnr) + action_state + .get_current_history() + :append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr)) + end, + action = function(prompt_bufnr) + return action_set.select(prompt_bufnr, "drop") + end, +} + +--- Perform 'tab drop' action on selection, usually something like<br> +---`:tab drop <selection>` +--- +--- i.e. open the selection in a new tab +---@param prompt_bufnr number: The prompt bufnr +actions.select_tab_drop = { + pre = function(prompt_bufnr) + action_state + .get_current_history() + :append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr)) + end, + action = function(prompt_bufnr) + return action_set.select(prompt_bufnr, "tab drop") + end, +} + -- TODO: consider adding float! -- https://github.com/nvim-telescope/telescope.nvim/issues/365 diff --git a/lua/telescope/actions/set.lua b/lua/telescope/actions/set.lua index 6177c9b..7861bb2 100644 --- a/lua/telescope/actions/set.lua +++ b/lua/telescope/actions/set.lua @@ -68,6 +68,7 @@ local edit_buffer do local map = { drop = "drop", + ["tab drop"] = "tab drop", edit = "buffer", new = "sbuffer", vnew = "vert sbuffer", @@ -79,7 +80,7 @@ do if command == nil then error "There was no associated buffer command" end - if command ~= "drop" then + if command ~= "drop" and command ~= "tab drop" then vim.cmd(string.format("%s %d", command, bufnr)) else vim.cmd(string.format("%s %s", command, vim.api.nvim_buf_get_name(bufnr))) diff --git a/lua/telescope/actions/state.lua b/lua/telescope/actions/state.lua index b07248a..d5109ed 100644 --- a/lua/telescope/actions/state.lua +++ b/lua/telescope/actions/state.lua @@ -33,6 +33,8 @@ local select_to_edit_map = { horizontal = "new", vertical = "vnew", tab = "tabedit", + drop = "drop", + ["tab drop"] = "tab drop", } function action_state.select_key_to_edit_key(type) return select_to_edit_map[type] |
