On demand generation of workspace diagnostics for your .NET project.
-- lazy.nvim
{
"bosvik/roslyn-diagnostics.nvim",
-- lazy load on filetype
ft = { "cs", "fs" },
opts = { },
}
Important
For large solutions roslyn.nvim
needs to be setup with
dotnet_analyzer_diagnostics_scope = "openFiles"
to avoid
roslyn crashing.
{
"seblj/roslyn.nvim",
ft = { "cs", "csproj" },
opts = {
config = {
settings = {
-- ...
["csharp|background_analysis"] = {
dotnet_analyzer_diagnostics_scope = "openFiles",
dotnet_compiler_diagnostics_scope = "fullSolution",
},
-- ...
},
},
-- ...
}
}
You can configure a different function to filter which files should be processed.
-- lazy.nvim
{
"bosvik/roslyn-diagnostics.nvim",
ft = { "cs", "fs" },
opts = {,
-- Optional filter function to filter out files that should not be processed
-- This is equivalent to the default filter.
filter = function(filename)
return (filename:match("%.cs$") or filename:match("%.fs$")) and not filename:match("/[ob][ij][bn]/")
end,
-- set custom diagnostic opts
-- refer :h vim.diagnostic.Opts
diagnostic_opts = {
virtual_text = {
prefix = "●",
},
severity_sort = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "",
},
},
},
},
keys = {
{ "<leader>cD", "<cmd>RequestDiagnostics<cr>", desc = "Request diagnostics", ft = { "cs", "fs" } },
}
}
Function | Description |
---|---|
RequestDiagnostics | Get diagnostics, include ERROR, WARNING |
RequestDiagnosticErrors | Only errors. |
Adds autocmd on "LspAttach" and "InsertLeave" to refresh diagnostics of the buffer and refresh codelens.
- GustavEikaas: For one of the most vital plugins for .NET development. Also I stole your spinner module 😎