File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ # AstroCore - Automatically virtual lines on current line only
2
+
3
+ ** Website:** < https://docs.astronvim.com/recipes/diagnostics/#virtual-line-current-line-only >
4
+
5
+ This plugin specification configures AstroCore to show virtual text except on the current line which shows as virtual lines.
Original file line number Diff line number Diff line change
1
+ local og_virt_text
2
+ local og_virt_line
3
+ return {
4
+ " AstroNvim/astrocore" ,
5
+ --- @type AstroCoreOpts
6
+ opts = {
7
+ features = {
8
+ diagnostics = true ,
9
+ },
10
+ diagnostics = {
11
+ virtual_text = true ,
12
+ virtual_lines = { current_line = true },
13
+ underline = true ,
14
+ update_in_insert = false ,
15
+ },
16
+ autocmds = {
17
+ diagnostic_only_virtlines = {
18
+ {
19
+ event = { " CursorMoved" , " DiagnosticChanged" },
20
+ callback = function ()
21
+ if not require (" astrocore.buffer" ).is_valid () then return end
22
+ if og_virt_line == nil then og_virt_line = vim .diagnostic .config ().virtual_lines end
23
+
24
+ -- ignore if virtual_lines.current_line is disabled
25
+ if not (og_virt_line and og_virt_line .current_line ) then
26
+ if og_virt_text then
27
+ vim .diagnostic .config { virtual_text = og_virt_text }
28
+ og_virt_text = nil
29
+ end
30
+ return
31
+ end
32
+
33
+ if og_virt_text == nil then og_virt_text = vim .diagnostic .config ().virtual_text end
34
+
35
+ local lnum = vim .api .nvim_win_get_cursor (0 )[1 ] - 1
36
+
37
+ if vim .tbl_isempty (vim .diagnostic .get (0 , { lnum = lnum })) then
38
+ vim .diagnostic .config { virtual_text = og_virt_text }
39
+ else
40
+ vim .diagnostic .config { virtual_text = false }
41
+ end
42
+ end ,
43
+ },
44
+ {
45
+ event = " ModeChanged" ,
46
+ callback = function () pcall (vim .diagnostic .show ) end ,
47
+ },
48
+ },
49
+ },
50
+ },
51
+ }
You can’t perform that action at this time.
0 commit comments