-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Examples | ||
|
||
## Filtering | ||
|
||
### Diagnostics for the current buffer only | ||
|
||
```lua | ||
{ | ||
modes = { | ||
diagnostics_buffer = { | ||
mode = "diagnostics", -- inherit from diagnostics mode | ||
filter = { buf = 0 }, -- filter diagnostics to the current buffer | ||
}, | ||
} | ||
} | ||
``` | ||
|
||
### Diagnostics for the current buffer and errors from the current project | ||
|
||
```lua | ||
{ | ||
modes = { | ||
mydiags = { | ||
mode = "diagnostics", -- inherit from diagnostics mode | ||
filter = { | ||
any = { | ||
buf = 0, -- current buffer | ||
{ | ||
severity = vim.diagnostic.severity.ERROR, -- errors only | ||
-- limit to files in the current project | ||
function(item) | ||
return item.filename:find(vim.loop.cwd(), 1, true) | ||
end, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
``` | ||
|
||
### Diagnostics Cascade | ||
|
||
The following example shows how to create a new mode that | ||
shows only the most severe diagnostics. | ||
|
||
Once those are resolved, less severe diagnostics will be shown. | ||
|
||
```lua | ||
{ | ||
modes = { | ||
cascade = { | ||
mode = "diagnostics", -- inherit from diagnostics mode | ||
filter = function(items) | ||
local severity = vim.diagnostic.severity.HINT | ||
for _, item in ipairs(items) do | ||
severity = math.min(severity, item.severity) | ||
end | ||
return vim.tbl_filter(function(item) | ||
return item.severity == severity | ||
end, items) | ||
end, | ||
}, | ||
}, | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters