summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-04-24 21:03:06 +0100
committerw0rp <devw0rp@gmail.com>2018-04-24 21:03:06 +0100
commitebbf7d0353d9d5d3ecc42bddd50e270ba60e5243 (patch)
tree6e31f73ca717103a0e99943b90358b6574665049 /autoload
parent93a046a78f0ab20af54812f28784d555fda2d38d (diff)
downloadale-ebbf7d0353d9d5d3ecc42bddd50e270ba60e5243.zip
#1428 Show multiline hover messages, and document the new command
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/hover.vim7
-rw-r--r--autoload/ale/util.vim15
2 files changed, 13 insertions, 9 deletions
diff --git a/autoload/ale/hover.vim b/autoload/ale/hover.vim
index fdae350e..2ccc4ff0 100644
--- a/autoload/ale/hover.vim
+++ b/autoload/ale/hover.vim
@@ -62,12 +62,7 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort
let l:str = substitute(l:str, '^\s*\(.\{-}\)\s*$', '\1', '')
if !empty(l:str)
- " Compress multi-line hover messages into one line.
- let l:str = substitute(l:str, "\n", ' ', 'g')
- let l:str = substitute(l:str, ' \+', ' ', 'g')
- let l:str = substitute(l:str, '^\s*\(.\{-}\)\s*$', '\1', '')
-
- call ale#util#Echo(l:str)
+ call ale#util#ShowMessage(l:str)
endif
endif
endif
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index d0dbec65..4e789b72 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -11,9 +11,18 @@ function! ale#util#FeedKeys(...) abort
return call('feedkeys', a:000)
endfunction
-" A wrapper function for echo so we can test calls for it.
-function! ale#util#Echo(string) abort
- execute 'echo a:string'
+" Show a message in as small a window as possible.
+"
+" Vim 8 does not support echoing long messages from asynchronous callbacks,
+" but NeoVim does. Small messages can be echoed in Vim 8, and larger messages
+" have to be shown in preview windows.
+function! ale#util#ShowMessage(string) abort
+ " We have to assume the user is using a monospace font.
+ if has('nvim') || (a:string !~? "\n" && len(a:string) < &columns)
+ execute 'echo a:string'
+ else
+ call ale#preview#Show(split(a:string, "\n"))
+ endif
endfunction
" A wrapper function for execute, so we can test executing some commands.