File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-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 og_virt_line == nil then og_virt_line = vim .diagnostic .config ().virtual_lines end
22+
23+ -- ignore if virtual_lines.current_line is disabled
24+ if not (og_virt_line and og_virt_line .current_line ) then
25+ if og_virt_text then
26+ vim .diagnostic .config { virtual_text = og_virt_text }
27+ og_virt_text = nil
28+ end
29+ return
30+ end
31+
32+ if og_virt_text == nil then og_virt_text = vim .diagnostic .config ().virtual_text end
33+
34+ local lnum = vim .api .nvim_win_get_cursor (0 )[1 ] - 1
35+
36+ if vim .tbl_isempty (vim .diagnostic .get (0 , { lnum = lnum })) then
37+ vim .diagnostic .config { virtual_text = og_virt_text }
38+ else
39+ vim .diagnostic .config { virtual_text = false }
40+ end
41+ end ,
42+ },
43+ {
44+ event = " ModeChanged" ,
45+ callback = function () pcall (vim .diagnostic .show ) end ,
46+ },
47+ },
48+ },
49+ },
50+ }
You can’t perform that action at this time.
0 commit comments