-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update telescope actions #92
Conversation
actions.select_default:replace(open(opts.repo, "issue", "edit"))
actions.select_horizontal:replace(open(opts.repo, "issue", "split"))
actions.select_vertical:replace(open(opts.repo, "issue", "vsplit"))
actions.select_tab:replace(open(opts.repo, "issue", "tabedit")) @Conni2461 do we still need all of the above, or is there a way of to replace all actions with one line? |
There never was a need to do that 😆 local action_set = require('telescope.actions.set')
local action_state = require('telescope.actions.state')
action_set.select:replace(function(_, type)
open(opts.repo, "issue", action_state.select_key_to_edit_key(type))
end should work |
@Conni2461 it does not seem to work 🤔 any ideas? |
Because i haven't looked at your code sorry :)
or you can do what i did :) diff --git a/lua/octo/menu.lua b/lua/octo/menu.lua
index 6a0bd3f..818542d 100644
--- a/lua/octo/menu.lua
+++ b/lua/octo/menu.lua
@@ -1,5 +1,6 @@
local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"
+local action_set = require('telescope.actions.set')
local finders = require "telescope.finders"
local pickers = require "telescope.pickers"
local utils = require "telescope.utils"
@@ -67,11 +68,13 @@ local function open(repo, what, command)
return function(prompt_bufnr)
local selection = action_state.get_selected_entry(prompt_bufnr)
actions.close(prompt_bufnr)
- if command == 'split' then
+ if command == 'default' then
+ vim.cmd [[:buffer %]]
+ elseif command == 'horizontal' then
vim.cmd [[:sbuffer %]]
- elseif command == 'vsplit' then
+ elseif command == 'vertical' then
vim.cmd [[:vert sbuffer %]]
- elseif command == 'tabedit' then
+ elseif command == 'tab' then
vim.cmd [[:tab sb %]]
end
vim.cmd(string.format([[ lua require'octo.commands'.get_%s('%s', '%s') ]], what, repo, selection.value))
@@ -155,10 +158,9 @@ function M.issues(opts)
sorter = conf.generic_sorter(opts),
previewer = previewers.issue.new(opts),
attach_mappings = function(_, map)
- actions.select_default:replace(open(opts.repo, "issue", "edit"))
- actions.select_horizontal:replace(open(opts.repo, "issue", "split"))
- actions.select_vertical:replace(open(opts.repo, "issue", "vsplit"))
- actions.select_tab:replace(open(opts.repo, "issue", "tabedit"))
+ action_set.select:replace(function(prompt_bufnr, type)
+ open(opts.repo, "issue", type)(prompt_bufnr)
+ end)
map("i", "<c-b>", open_in_browser("issue", opts.repo))
return true
end |
Awesome, that worked, thanks! |
Glad i could help :) |
according to nvim-telescope/telescope.nvim#472