Skip to content

Commit

Permalink
Close dense-analysis#4397 - Add human-readable values for g:ale_virtu…
Browse files Browse the repository at this point in the history
…altext_cursor
  • Loading branch information
w0rp authored and mnikulin committed Nov 12, 2023
1 parent 3743196 commit 3d68043
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions autoload/ale/engine.vim
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function! ale#engine#SetResults(buffer, loclist) abort
call ale#highlight#SetHighlights(a:buffer, a:loclist)
endif

if g:ale_virtualtext_cursor == 2
if g:ale_virtualtext_cursor is# 'all' || g:ale_virtualtext_cursor == 2
call ale#virtualtext#SetTexts(a:buffer, a:loclist)
endif

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

if g:ale_virtualtext_cursor == 1
if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor == 1
" Try and show the warning now.
" This will only do something meaningful if we're in normal mode.
call ale#virtualtext#ShowCursorWarning()
Expand Down
2 changes: 1 addition & 1 deletion autoload/ale/events.vim
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function! ale#events#Init() abort
autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#cursor#EchoCursorWarning() | endif
endif

if g:ale_virtualtext_cursor == 1
if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor is# 1 || g:ale_virtualtext_cursor is# '1'
autocmd CursorMoved,CursorHold * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarningWithDelay() | endif
" Look for a warning to echo as soon as we leave Insert mode.
" The script's position variable used when moving the cursor will
Expand Down
2 changes: 1 addition & 1 deletion autoload/ale/toggle.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function! s:DisablePostamble() abort
call ale#highlight#UpdateHighlights()
endif

if g:ale_virtualtext_cursor == 1
if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor == 1
call ale#virtualtext#Clear(bufnr(''))
endif
endfunction
Expand Down
4 changes: 2 additions & 2 deletions autoload/ale/virtualtext.vim
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function! ale#virtualtext#GetHlGroup(type, style) abort
endfunction

function! ale#virtualtext#ShowCursorWarning(...) abort
if g:ale_virtualtext_cursor != 1
if g:ale_virtualtext_cursor isnot# 'current' && g:ale_virtualtext_cursor != 1
return
endif

Expand Down Expand Up @@ -142,7 +142,7 @@ endfunction
function! ale#virtualtext#ShowCursorWarningWithDelay() abort
let l:buffer = bufnr('')

if g:ale_virtualtext_cursor != 1
if g:ale_virtualtext_cursor isnot# 'current' && g:ale_virtualtext_cursor != 1
return
endif

Expand Down
16 changes: 7 additions & 9 deletions doc/ale.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2290,16 +2290,14 @@ g:ale_use_global_executables *g:ale_use_global_executables*
g:ale_virtualtext_cursor *g:ale_virtualtext_cursor*

Type: |Number|
Default: `0`
Default: `'disabled'`

This option controls how ALE will display problems using |virtual-text|.
The following values can be used.

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

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

Expand Down
4 changes: 2 additions & 2 deletions plugin/ale.vim
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1)
" This flag can be set to 1 to automatically show errors in the preview window.
let g:ale_cursor_detail = get(g:, 'ale_cursor_detail', 0)

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

" This flag can be set to 1 to enable LSP hover messages at the cursor.
let g:ale_hover_cursor = get(g:, 'ale_hover_cursor', 1)
Expand Down
4 changes: 2 additions & 2 deletions test/test_ale_info.vader
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Before:
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_virtualtext_cursor = 'disabled'
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1

Expand Down Expand Up @@ -190,7 +190,7 @@ Before:
\ 'let g:ale_statusline_format = [''%d error(s)'', ''%d warning(s)'', ''OK'']',
\ 'let g:ale_type_map = {}',
\ 'let g:ale_use_global_executables = v:null',
\ 'let g:ale_virtualtext_cursor = 0',
\ 'let g:ale_virtualtext_cursor = ''disabled''',
\ 'let g:ale_warn_about_trailing_blank_lines = 1',
\ 'let g:ale_warn_about_trailing_whitespace = 1',
\]
Expand Down

0 comments on commit 3d68043

Please sign in to comment.