Skip to content

Commit f03fb98

Browse files
committed
feat: support virtual_line and adapt to the latest diagnostics interface
1 parent 8a0db9b commit f03fb98

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lua/core/settings.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ settings["lsp_inlayhints"] = false
5858
-- Set it to false if diagnostics virtual text is annoying.
5959
-- If disabled, you may browse lsp diagnostics using trouble.nvim (press `gt` to toggle it).
6060
---@type boolean
61-
settings["diagnostics_virtual_text"] = true
61+
settings["diagnostics_virtual_text"] = false
62+
63+
-- Set it to false if diagnostics virtual lines is annoying.
64+
-- NOTE: This entry is an alternative form to `diagnostics_virtual_text`.
65+
---@type boolean
66+
settings["diagnostics_virtual_lines"] = true
6267

6368
-- Set it to one of the values below if you want to change the visible severity level of lsp diagnostics.
6469
-- Priority: `Error` > `Warning` > `Information` > `Hint`.

lua/modules/configs/completion/mason-lspconfig.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local M = {}
22

33
M.setup = function()
44
local diagnostics_virtual_text = require("core.settings").diagnostics_virtual_text
5+
local diagnostics_virtual_lines = require("core.settings").diagnostics_virtual_lines
56
local diagnostics_level = require("core.settings").diagnostics_level
67

78
local nvim_lsp = require("lspconfig")
@@ -12,15 +13,19 @@ M.setup = function()
1213
ensure_installed = require("core.settings").lsp_deps,
1314
})
1415

15-
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
16+
vim.diagnostic.config({
1617
signs = true,
1718
underline = true,
1819
virtual_text = diagnostics_virtual_text and {
1920
severity = {
2021
min = vim.diagnostic.severity[diagnostics_level],
2122
},
2223
} or false,
23-
-- set update_in_insert to false because it was enabled by lspsaga
24+
virtual_lines = diagnostics_virtual_lines and {
25+
severity = {
26+
min = vim.diagnostic.severity[diagnostics_level],
27+
},
28+
} or false,
2429
update_in_insert = false,
2530
})
2631

0 commit comments

Comments
 (0)