Skip to content

feat(config): add close counterparts to jump split actions #584

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

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading