Skip to content

Commit

Permalink
feat: added actions for opening in new tab, split and vsplit. Fixes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 26, 2021
1 parent 52f18fd commit c94cc59
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ Trouble comes with the following defaults:
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
refresh = "r", -- manually refresh
jump = {"<cr>", "<tab>"}, -- jump to the diagnostic or open / close folds
open_split = { "<c-x>" }, -- open buffer in new split
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
open_tab = { "<c-t>" }, -- open buffer in new tab
jump_close = {"o"}, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
toggle_preview = "P", -- toggle auto_preview
Expand Down
3 changes: 3 additions & 0 deletions lua/trouble/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ local defaults = {
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
refresh = "r", -- manually refresh
jump = { "<cr>", "<tab>" }, -- jump to the diagnostic or open / close folds
open_split = { "<c-x>" }, -- open buffer in new split
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
open_tab = { "<c-t>" }, -- open buffer in new tab
jump_close = { "o" }, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" mode
toggle_preview = "P", -- toggle auto_preview
Expand Down
6 changes: 6 additions & 0 deletions lua/trouble/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ function Trouble.action(action)
end
if action == "jump" then
view:jump()
elseif action == "open_split" then
view:jump({ precmd = "split" })
elseif action == "open_vsplit" then
view:jump({ precmd = "vsplit" })
elseif action == "open_tab" then
view:jump({ precmd = "tabe" })
end
if action == "jump_close" then
view:jump()
Expand Down
3 changes: 3 additions & 0 deletions lua/trouble/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ function View:jump(opts)
self:update()
else
View.switch_to(opts.win or self.parent)
if opts.precmd then
vim.cmd(opts.precmd)
end
if vim.api.nvim_buf_get_option(item.bufnr, "buflisted") == false then
vim.cmd("edit #" .. item.bufnr)
else
Expand Down

0 comments on commit c94cc59

Please sign in to comment.