Skip to content

Commit

Permalink
fix: diagnostics sections
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 23, 2023
1 parent ef47f7a commit a802477
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
91 changes: 46 additions & 45 deletions lua/trouble/sources/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ M.highlights = {
M.modes = {
diagnostics = {
events = { "DiagnosticChanged", "BufEnter" },
sections = -- {
-- -- Trouble classic for current buffer
-- source = "diagnostics",
-- groups = {
-- { format = "{hl:Title}Diagnostics (current buffer){hl} {filename} {count}" },
-- },
-- sort = { "severity", "filename", "pos" },
-- format = "{severity_icon} {message} {item.source} ({code}) {pos}",
-- filter = {
-- buf = 0,
-- },
-- },
-- filename group sorted by severity
-- items per filename sorted by pos
{
-- Trouble classic for other buffers,
-- but only if they are in the current directory
source = "diagnostics",
groups = {
{ format = "{hl:Special}蟀殺 {hl} {hl:Title}Diagnostics{hl} {count}" },
{ "severity", format = "{severity_icon} {severity} {count}" },
{ "filename", format = "{file_icon} {filename} {count}" },
},
sort = { { buf = 0 }, "severity", "filename", "pos", "message" },
format = "{severity_icon} {message} {item.source} ({code}) {pos}",
filter = {
sections = {
-- -- Trouble classic for current buffer
-- source = "diagnostics",
-- groups = {
-- { format = "{hl:Title}Diagnostics (current buffer){hl} {filename} {count}" },
-- },
-- sort = { "severity", "filename", "pos" },
-- format = "{severity_icon} {message} {item.source} ({code}) {pos}",
-- filter = {
-- buf = 0,
-- },
-- },
-- filename group sorted by severity
-- items per filename sorted by pos
{
-- Trouble classic for other buffers,
-- but only if they are in the current directory
source = "diagnostics",
groups = {
{ format = "{hl:Special}蟀殺 {hl} {hl:Title}Diagnostics{hl} {count}" },
{ "severity", format = "{severity_icon} {severity} {count}" },
{ "filename", format = "{file_icon} {filename} {count}" },
},
sort = { { buf = 0 }, "severity", "filename", "pos", "message" },
format = "{severity_icon} {message} {item.source} ({code}) {pos}",
-- filter = {
-- ["not"] = {
-- any = {
-- { severity = vim.diagnostic.severity.ERROR },
Expand All @@ -48,27 +48,28 @@ M.modes = {
-- function(item)
-- return item.filename:find(vim.loop.cwd(), 1, true)
-- end,
-- },
},
-- {
-- -- error from all files
-- source = "diagnostics",
-- groups = { "severity", "code", "filename" },
-- filter = {
-- -- severity = 1,
-- },
-- sort = { "filename", "pos" },
-- format = "sig {severity_sign} {severity} file: {filename} pos: {pos}",
-- },
-- {
-- -- diagnostics from current buffer
-- source = "diagnostics",
-- groups = { "severity", "filename" },
-- filter = {
-- buf = 0,
-- },
-- sort = { "pos" },
-- },
},
-- {
-- -- error from all files
-- source = "diagnostics",
-- groups = { "severity", "code", "filename" },
-- filter = {
-- -- severity = 1,
-- },
-- sort = { "filename", "pos" },
-- format = "sig {severity_sign} {severity} file: {filename} pos: {pos}",
-- },
-- {
-- -- diagnostics from current buffer
-- source = "diagnostics",
-- groups = { "severity", "filename" },
-- filter = {
-- buf = 0,
-- },
-- sort = { "pos" },
-- },
},
}

Expand Down
2 changes: 1 addition & 1 deletion lua/trouble/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function M:refresh()
self.nodes[s] = Tree.build(items, section)
self.fetching = self.fetching - 1
self:update()
end, { filter = section.filter, view = self })
end, { filter = section.filter or self.opts.filter or nil, view = self })
end
end

Expand Down

0 comments on commit a802477

Please sign in to comment.