Skip to content

Commit

Permalink
feat(config): add close counterparts to jump split actions (#584)
Browse files Browse the repository at this point in the history
## Description
Adds `jump_split_close` and `jump_vsplit_close` actions.
  • Loading branch information
alex35mil authored Oct 2, 2024
1 parent 9297d81 commit 928e6d0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,21 @@ require("trouble").jump_only(opts)
---@return trouble.View
require("trouble").jump_split(opts)

-- Open the item in a split and close the trouble window
---@param opts? trouble.Mode | { new? : boolean } | string
---@return trouble.View
require("trouble").jump_split_close(opts)

-- Open the item in a vsplit
---@param opts? trouble.Mode | { new? : boolean } | string
---@return trouble.View
require("trouble").jump_vsplit(opts)

-- Open the item in a vsplit and close the trouble window
---@param opts? trouble.Mode | { new? : boolean } | string
---@return trouble.View
require("trouble").jump_vsplit_close(opts)

-- Go to the last item
---@param opts? trouble.Mode | { new? : boolean } | string
---@return trouble.View
Expand Down
14 changes: 14 additions & 0 deletions lua/trouble/config/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,26 @@ local M = {
self:jump(ctx.item, { split = true })
end
end,
-- Open the item in a split and close the trouble window
jump_split_close = function(self, ctx)
if ctx.item then
self:jump(ctx.item, { split = true })
self:close()
end
end,
-- Open the item in a vsplit
jump_vsplit = function(self, ctx)
if ctx.item then
self:jump(ctx.item, { vsplit = true })
end
end,
-- Open the item in a vsplit and close the trouble window
jump_vsplit_close = function(self, ctx)
if ctx.item then
self:jump(ctx.item, { vsplit = true })
self:close()
end
end,
-- Dump the item to the console
inspect = function(_, ctx)
vim.print(ctx.item or (ctx.node and ctx.node.item))
Expand Down

0 comments on commit 928e6d0

Please sign in to comment.