Skip to content

Commit

Permalink
feat: Trouble now shows vim.ui.select to chose a mode
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 23, 2023
1 parent d69200e commit 6e4e2a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions lua/trouble/command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,18 @@ function M.complete(_, line, col)
end

function M.execute(input)
local mode, opts = M.parse(input.args)
if mode and opts then
opts.mode = mode
require("trouble").open(opts)
if input.args:match("^%s*$") then
vim.ui.select(Config.modes(), { prompt = "Select Trouble Mode:" }, function(mode)
if mode then
require("trouble").open({ mode = mode })
end
end)
else
local mode, opts = M.parse(input.args)
if mode and opts then
opts.mode = mode
require("trouble").open(opts)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lua/trouble/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function M.setup(opts)
vim.api.nvim_create_user_command("Trouble", function(input)
require("trouble.command").execute(input)
end, {
nargs = "+",
nargs = "*",
complete = function(...)
return require("trouble.command").complete(...)
end,
Expand Down

0 comments on commit 6e4e2a0

Please sign in to comment.