mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-03 16:42:50 +08:00
Use echon over echom for cursor echo (#3888)
* Problem messages no longer clutter `:messages` * Messages are truncated better
This commit is contained in:
@@ -16,6 +16,9 @@ function! ale#cursor#TruncatedEcho(original_message) abort
|
||||
let l:message = substitute(l:message, "\t", ' ', 'g')
|
||||
" Remove any newlines in the message.
|
||||
let l:message = substitute(l:message, "\n", '', 'g')
|
||||
" Convert indentation groups into single spaces for better legibility when
|
||||
" put on a single line
|
||||
let l:message = substitute(l:message, ' \+', ' ', 'g')
|
||||
|
||||
" We need to remember the setting for shortmess and reset it again.
|
||||
let l:shortmess_options = &l:shortmess
|
||||
@@ -27,7 +30,14 @@ function! ale#cursor#TruncatedEcho(original_message) abort
|
||||
silent! setlocal shortmess+=T
|
||||
|
||||
try
|
||||
exec "norm! :echomsg l:message\n"
|
||||
" echon will not display the message if it exceeds the width of
|
||||
" the window
|
||||
if &columns < strdisplaywidth(l:message)
|
||||
" Truncate message longer than window width with trailing '...'
|
||||
let l:message = l:message[:&columns - 5] . '...'
|
||||
endif
|
||||
|
||||
echon l:message
|
||||
catch /^Vim\%((\a\+)\)\=:E523/
|
||||
" Fallback into manual truncate (#1987)
|
||||
let l:winwidth = winwidth(0)
|
||||
|
||||
@@ -46,7 +46,7 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort
|
||||
call balloon_show(a:response.body.displayString)
|
||||
elseif get(l:options, 'truncated_echo', 0)
|
||||
if !empty(a:response.body.displayString)
|
||||
call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0])
|
||||
call ale#cursor#TruncatedEcho(a:response.body.displayString)
|
||||
endif
|
||||
elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
|
||||
call ale#floating_preview#Show(split(a:response.body.displayString, "\n"), {
|
||||
@@ -231,7 +231,7 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort
|
||||
\&& (l:set_balloons is 1 || l:set_balloons is# 'hover')
|
||||
call balloon_show(join(l:lines, "\n"))
|
||||
elseif get(l:options, 'truncated_echo', 0)
|
||||
call ale#cursor#TruncatedEcho(l:lines[0])
|
||||
call ale#cursor#TruncatedEcho(join(l:lines[0], '\n'))
|
||||
elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
|
||||
call ale#floating_preview#Show(l:lines, {
|
||||
\ 'filetype': 'ale-preview.message',
|
||||
|
||||
Reference in New Issue
Block a user