Skip to content

Commit 300ea23

Browse files
committed
Close #4397 - Add human-readable values for g:ale_virtualtext_cursor
1 parent 522b5d0 commit 300ea23

File tree

7 files changed

+17
-19
lines changed

7 files changed

+17
-19
lines changed

autoload/ale/engine.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ function! ale#engine#SetResults(buffer, loclist) abort
203203
call ale#highlight#SetHighlights(a:buffer, a:loclist)
204204
endif
205205

206-
if g:ale_virtualtext_cursor == 2
206+
if g:ale_virtualtext_cursor is# 'all' || g:ale_virtualtext_cursor == 2
207207
call ale#virtualtext#SetTexts(a:buffer, a:loclist)
208208
endif
209209

@@ -214,7 +214,7 @@ function! ale#engine#SetResults(buffer, loclist) abort
214214
call ale#cursor#EchoCursorWarning()
215215
endif
216216

217-
if g:ale_virtualtext_cursor == 1
217+
if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor == 1
218218
" Try and show the warning now.
219219
" This will only do something meaningful if we're in normal mode.
220220
call ale#virtualtext#ShowCursorWarning()

autoload/ale/events.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function! ale#events#Init() abort
139139
autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#cursor#EchoCursorWarning() | endif
140140
endif
141141

142-
if g:ale_virtualtext_cursor == 1
142+
if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor is# 1 || g:ale_virtualtext_cursor is# '1'
143143
autocmd CursorMoved,CursorHold * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarningWithDelay() | endif
144144
" Look for a warning to echo as soon as we leave Insert mode.
145145
" The script's position variable used when moving the cursor will

autoload/ale/toggle.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function! s:DisablePostamble() abort
1414
call ale#highlight#UpdateHighlights()
1515
endif
1616

17-
if g:ale_virtualtext_cursor == 1
17+
if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor == 1
1818
call ale#virtualtext#Clear(bufnr(''))
1919
endif
2020
endfunction

autoload/ale/virtualtext.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function! ale#virtualtext#GetHlGroup(type, style) abort
112112
endfunction
113113

114114
function! ale#virtualtext#ShowCursorWarning(...) abort
115-
if g:ale_virtualtext_cursor != 1
115+
if g:ale_virtualtext_cursor isnot# 'current' && g:ale_virtualtext_cursor != 1
116116
return
117117
endif
118118

@@ -142,7 +142,7 @@ endfunction
142142
function! ale#virtualtext#ShowCursorWarningWithDelay() abort
143143
let l:buffer = bufnr('')
144144

145-
if g:ale_virtualtext_cursor != 1
145+
if g:ale_virtualtext_cursor isnot# 'current' && g:ale_virtualtext_cursor != 1
146146
return
147147
endif
148148

doc/ale.txt

+7-9
Original file line numberDiff line numberDiff line change
@@ -2290,16 +2290,14 @@ g:ale_use_global_executables *g:ale_use_global_executables*
22902290
g:ale_virtualtext_cursor *g:ale_virtualtext_cursor*
22912291

22922292
Type: |Number|
2293-
Default: `0`
2293+
Default: `'disabled'`
2294+
2295+
This option controls how ALE will display problems using |virtual-text|.
2296+
The following values can be used.
22942297

2295-
When this option is set to `1`, a message will be shown when a cursor is
2296-
near a warning or error. ALE will attempt to find the warning or error at a
2297-
column nearest to the cursor when the cursor is resting on a line which
2298-
contains a warning or error. This option can be set to `0` to disable this
2299-
behavior.
2300-
When this option is set to `2`, then all warnings will be shown for the
2301-
whole buffer, regardless of if the cursor is currently positioned in that
2302-
line.
2298+
`'all'`, `'2'`, or `2` - Show problems for all lines.
2299+
`'current'`, `'1'`, or `1` - Show problems for the current line.
2300+
`'disabled'`, `'0'`, or `0` - Do not show problems with virtual-text.
23032301

23042302
Messages are only displayed after a short delay. See |g:ale_virtualtext_delay|.
23052303

plugin/ale.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1)
127127
" This flag can be set to 1 to automatically show errors in the preview window.
128128
let g:ale_cursor_detail = get(g:, 'ale_cursor_detail', 0)
129129

130-
" This flag can be set to 1 to enable virtual text when the cursor moves.
131-
let g:ale_virtualtext_cursor = get(g:, 'ale_virtualtext_cursor', 0)
130+
" This flag can be changed to disable/enable virtual text.
131+
let g:ale_virtualtext_cursor = get(g:, 'ale_virtualtext_cursor', 'disabled')
132132

133133
" This flag can be set to 1 to enable LSP hover messages at the cursor.
134134
let g:ale_hover_cursor = get(g:, 'ale_hover_cursor', 1)

test/test_ale_info.vader

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Before:
111111
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
112112
let g:ale_type_map = {}
113113
let g:ale_use_global_executables = v:null
114-
let g:ale_virtualtext_cursor = 0
114+
let g:ale_virtualtext_cursor = 'disabled'
115115
let g:ale_warn_about_trailing_blank_lines = 1
116116
let g:ale_warn_about_trailing_whitespace = 1
117117

@@ -190,7 +190,7 @@ Before:
190190
\ 'let g:ale_statusline_format = [''%d error(s)'', ''%d warning(s)'', ''OK'']',
191191
\ 'let g:ale_type_map = {}',
192192
\ 'let g:ale_use_global_executables = v:null',
193-
\ 'let g:ale_virtualtext_cursor = 0',
193+
\ 'let g:ale_virtualtext_cursor = ''disabled''',
194194
\ 'let g:ale_warn_about_trailing_blank_lines = 1',
195195
\ 'let g:ale_warn_about_trailing_whitespace = 1',
196196
\]

0 commit comments

Comments
 (0)