Skip to content

Commit

Permalink
fix(commmand): show mode descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Mar 27, 2024
1 parent 0b166df commit c4a89f0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/trouble/command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ function M.execute(input)
---@type {name: string, desc: string}[]
local modes = vim.tbl_map(function(x)
local m = Config.get(x)
return { name = x, desc = m.desc }
local desc = m.desc or x:gsub("^%l", string.upper)
desc = Util.camel(desc, " ")
return { name = x, desc = desc }
end, Config.modes())

vim.ui.select(modes, {
prompt = "Select Trouble Mode:",
format_item = function(x)
return x.desc and (x.name .. " (" .. x.desc .. ")") or x.name
return x.desc and (x.desc .. " (" .. x.name .. ")") or x.name
end,
}, function(mode)
if mode then
require("trouble").open({ mode = mode.mode })
require("trouble").open({ mode = mode.name })
end
end)
else
Expand Down

0 comments on commit c4a89f0

Please sign in to comment.