Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make live diagnostics level configurable #776

Merged
merged 2 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lua/core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ settings["format_on_save"] = true
settings["format_notify"] = true

-- Set it to false if diagnostics virtual text is annoying.
-- You can still see the diagnostics in the trouble list by pressing `gt` to toggle it.
---@type boolean
settings["diagnostics_virtual_text"] = true
settings["diagnostics_virtual_text"] = false

-- Set it to value below if you want to change the visible severity level of diagnostics.
-- The valid values are: `Error`, `Warning`, `Information`, `Hint`.
-- The priority is: `Error` > `Warning` > `Information` > `Hint`.
-- e.g. if you set it to `Warning`, only `Warning` and `Error` will be shown.
-- NOTE: This setting only works when `diagnostics_virtual_text` is true.
---@type string
settings["diagnostics_severity_limit"] = "Hint"

-- Set the format disabled directories here, files under these dirs won't be formatted on save.
---@type string[]
Expand Down
7 changes: 6 additions & 1 deletion lua/modules/configs/completion/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ return function()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)

local diagnostics_virtual_text = require("core.settings").diagnostics_virtual_text
local diagnostics_severity_limit = require("core.settings").diagnostics_severity_limit
local virtual_text_setting = diagnostics_virtual_text and {
severity_limit = diagnostics_severity_limit,
} or false
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
signs = true,
underline = true,
virtual_text = require("core.settings").diagnostics_virtual_text,
virtual_text = virtual_text_setting,
-- set update_in_insert to false bacause it was enabled by lspsaga
update_in_insert = false,
})
Expand Down