4
4
-- https://github.com/NvChad/NvChad/issues/1907
5
5
(vim .hl or vim .highlight ).priorities .semantic_tokens = 95 -- Or any number lower than 100, treesitter's priority level
6
6
7
+ local virtual_text = {
8
+ prefix = ' ●' ,
9
+ -- Add a custom format function to show error codes
10
+ format = function (diagnostic )
11
+ local code = diagnostic .code and string.format (' [%s]' , diagnostic .code ) or ' '
12
+ return string.format (' %s %s' , code , diagnostic .message )
13
+ end ,
14
+ }
15
+ -- only show current line's diagnostic
16
+ if vim .version .ge (vim .version .parse (tostring (vim .version ())), { 0 , 11 , 0 }) then
17
+ virtual_text .current_line = true
18
+ end
19
+
7
20
-- Appearance of diagnostics
8
21
vim .diagnostic .config {
9
- virtual_text = {
10
- prefix = ' ●' ,
11
- -- Add a custom format function to show error codes
12
- format = function (diagnostic )
13
- local code = diagnostic .code and string.format (' [%s]' , diagnostic .code ) or ' '
14
- return string.format (' %s %s' , code , diagnostic .message )
15
- end ,
16
- },
22
+ virtual_text = virtual_text ,
17
23
underline = false ,
18
24
update_in_insert = true ,
19
25
float = {
@@ -24,6 +30,13 @@ vim.diagnostic.config {
24
30
vim .cmd ' highlight DiagnosticVirtualText guibg=NONE'
25
31
end ,
26
32
}
33
+ vim .keymap .set (' n' , ' <leader>dv' , function ()
34
+ if vim .diagnostic .config ().virtual_text then
35
+ vim .diagnostic .config { virtual_text = false }
36
+ else
37
+ vim .diagnostic .config { virtual_text = virtual_text }
38
+ end
39
+ end , { desc = ' [D]iagnostic [v]irtual_text toggle' })
27
40
28
41
-- Highlight on yank
29
42
local highlight_group = vim .api .nvim_create_augroup (' YankHighlight' , { clear = true })
0 commit comments