summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/cursor.vim6
-rw-r--r--autoload/ale/preview.vim18
-rw-r--r--ftplugin/ale-preview.vim2
-rw-r--r--test/test_cursor_warnings.vader22
4 files changed, 36 insertions, 12 deletions
diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim
index 1980c194..69076102 100644
--- a/autoload/ale/cursor.vim
+++ b/autoload/ale/cursor.vim
@@ -125,9 +125,7 @@ function! ale#cursor#ShowCursorDetail() abort
if !empty(l:loc)
let l:message = get(l:loc, 'detail', l:loc.text)
- call s:EchoWithShortMess('off', l:message)
-
- " Set the echo marker, so we can clear it by moving the cursor.
- let l:info.echoed = 1
+ call ale#preview#Show(split(l:message, "\n"))
+ echo
endif
endfunction
diff --git a/autoload/ale/preview.vim b/autoload/ale/preview.vim
new file mode 100644
index 00000000..3b1c16a6
--- /dev/null
+++ b/autoload/ale/preview.vim
@@ -0,0 +1,18 @@
+" Author: w0rp <devw0rp@gmail.com>
+" Description: Preview windows for showing whatever information in.
+
+" Open a preview window and show some lines in it.
+function! ale#preview#Show(lines) abort
+ silent pedit ALEPreviewWindow
+ wincmd P
+ setlocal modifiable
+ setlocal noreadonly
+ setlocal nobuflisted
+ setlocal filetype=ale-preview
+ setlocal buftype=nofile
+ setlocal bufhidden=wipe
+ :%d
+ call setline(1, a:lines)
+ setlocal nomodifiable
+ setlocal readonly
+endfunction
diff --git a/ftplugin/ale-preview.vim b/ftplugin/ale-preview.vim
new file mode 100644
index 00000000..ffbffbd5
--- /dev/null
+++ b/ftplugin/ale-preview.vim
@@ -0,0 +1,2 @@
+" Close the ALEPreviewWindow window with the q key.
+noremap <buffer> q :q!<CR>
diff --git a/test/test_cursor_warnings.vader b/test/test_cursor_warnings.vader
index dbcbe66e..c6dc5269 100644
--- a/test/test_cursor_warnings.vader
+++ b/test/test_cursor_warnings.vader
@@ -97,6 +97,11 @@ After:
" carried over between test cases.
echomsg ''
+ " Close the preview window if it's open.
+ if &filetype is# 'ale-preview'
+ noautocmd :q!
+ endif
+
Given javascript(A Javscript file with warnings/errors):
var x = 3 + 12345678
var x = 5*2 + parseInt("10");
@@ -138,20 +143,21 @@ Execute(The message at the cursor should be shown on InsertLeave):
Execute(ALEDetail should print 'detail' attributes):
call cursor(1, 1)
- redir => g:output
- ALEDetail
- redir END
+ ALEDetail
- AssertEqual "\nEvery statement should end with a semicolon\nsecond line", g:output
+ AssertEqual
+ \ ['Every statement should end with a semicolon', 'second line'],
+ \ getline(1, '$')
Execute(ALEDetail should print regular 'text' attributes):
call cursor(2, 10)
- redir => g:output
- ALEDetail
- redir END
+ ALEDetail
- AssertEqual "\nInfix operators must be spaced.", g:output
+ " ALEDetail opens a window, so check the text in it.
+ AssertEqual
+ \ ['Infix operators must be spaced.'],
+ \ getline(1, '$')
Execute(ALEDetail should not capitlise cursor messages):
call cursor(3, 1)