Skip to content

Commit

Permalink
feat(filter): added filetype filter
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 30, 2024
1 parent d7727a5 commit e541444
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/trouble/filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ M.filters = {
end
return item.buf == buf
end,
---@param fts string|string[]
ft = function(item, fts, _)
fts = type(fts) == "table" and fts or { fts }
local ft = item.buf and vim.bo[item.buf].filetype
return ft and vim.tbl_contains(fts, ft) or false
end,
range = function(item, buf, ctx)
local main = ctx.main
local range = item.range --[[@as trouble.Item]]
Expand All @@ -24,7 +30,10 @@ M.filters = {
end,
any = function(item, any, ctx)
---@cast any trouble.Filter[]
for _, f in ipairs(any) do
for k, f in pairs(any) do
if type(k) == "string" then
f = { [k] = f }
end
if M.is(item, f, ctx) then
return true
end
Expand Down

0 comments on commit e541444

Please sign in to comment.