Skip to content

Commit b1839ec

Browse files
committed
fix(keymap.helpers): hide or show virtual text and lines instead of diagnostics itself.
1 parent 7fdbbaf commit b1839ec

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

lua/keymap/helpers.lua

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,24 @@ _G._toggle_inlayhint = function()
5555
)
5656
end
5757

58-
local _vt_enabled = require("core.settings").diagnostics_virtual_text
5958
_G._toggle_virtualtext = function()
60-
if vim.diagnostic.is_enabled() then
61-
_vt_enabled = not _vt_enabled
62-
vim.diagnostic[_vt_enabled and "show" or "hide"]()
59+
local _vt_enabled = require("core.settings").diagnostics_virtual_text
60+
if _vt_enabled then
61+
local vt_config = not vim.diagnostic.config().virtual_text
62+
vim.diagnostic.config({ virtual_text = vt_config })
6363
vim.notify(
64-
(_vt_enabled and "Virtual text is now displayed" or "Virtual text is now hidden"),
64+
(vt_config and "Virtual text is now displayed" or "Virtual text is now hidden"),
65+
vim.log.levels.INFO,
66+
{ title = "LSP Diagnostic" }
67+
)
68+
end
69+
70+
local _vl_enabled = require("core.settings").diagnostics_virtual_lines
71+
if _vl_enabled then
72+
local vl_config = not vim.diagnostic.config().virtual_lines
73+
vim.diagnostic.config({ virtual_lines = vl_config })
74+
vim.notify(
75+
(vl_config and "Virtual lines is now displayed" or "Virtual lines is now hidden"),
6576
vim.log.levels.INFO,
6677
{ title = "LSP Diagnostic" }
6778
)

0 commit comments

Comments
 (0)