2017-02-10 19:34:44 +00:00
|
|
|
Before:
|
2017-09-08 20:38:51 +00:00
|
|
|
Save g:ale_set_lists_synchronously
|
|
|
|
Save g:ale_buffer_info
|
2018-01-17 18:08:17 +00:00
|
|
|
Save &shell
|
2017-09-08 20:38:51 +00:00
|
|
|
|
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
let g:ale_set_lists_synchronously = 1
|
|
|
|
|
2017-02-10 19:34:44 +00:00
|
|
|
function! TestCallback(buffer, output)
|
2017-09-08 20:38:51 +00:00
|
|
|
" Windows adds extra spaces to the text from echo.
|
2017-02-10 19:34:44 +00:00
|
|
|
return [{
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'col': 3,
|
2017-09-08 20:38:51 +00:00
|
|
|
\ 'text': substitute(a:output[0], ' *$', '', ''),
|
2017-06-07 22:12:45 +00:00
|
|
|
\}]
|
|
|
|
endfunction
|
|
|
|
function! TestCallback2(buffer, output)
|
|
|
|
return [{
|
|
|
|
\ 'lnum': 3,
|
|
|
|
\ 'col': 4,
|
2017-09-08 20:38:51 +00:00
|
|
|
\ 'text': substitute(a:output[0], ' *$', '', ''),
|
2017-02-10 19:34:44 +00:00
|
|
|
\}]
|
|
|
|
endfunction
|
|
|
|
|
2017-05-12 20:16:15 +00:00
|
|
|
" Running the command in another subshell seems to help here.
|
2017-02-10 19:34:44 +00:00
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'TestCallback',
|
2017-09-08 20:38:51 +00:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'echo',
|
|
|
|
\ 'command': has('win32') ? 'echo foo bar' : '/bin/sh -c ''echo foo bar''',
|
2017-02-10 19:34:44 +00:00
|
|
|
\})
|
|
|
|
|
|
|
|
After:
|
2017-09-08 20:38:51 +00:00
|
|
|
Restore
|
|
|
|
|
2018-07-11 12:46:13 +00:00
|
|
|
unlet! g:i
|
|
|
|
unlet! g:results
|
|
|
|
unlet! g:expected_results
|
|
|
|
|
2017-02-10 19:34:44 +00:00
|
|
|
delfunction TestCallback
|
2017-06-07 22:12:45 +00:00
|
|
|
delfunction TestCallback2
|
2018-06-28 12:53:49 +00:00
|
|
|
call ale#engine#Cleanup(bufnr(''))
|
2017-02-10 19:34:44 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
Given foobar (Some imaginary filetype):
|
|
|
|
foo
|
|
|
|
bar
|
|
|
|
baz
|
|
|
|
|
|
|
|
Execute(Linters should run with the default options):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
|
|
|
call ale#Lint()
|
|
|
|
call ale#engine#WaitForJobs(2000)
|
|
|
|
|
|
|
|
AssertEqual [{
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': 'foo bar',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
|
|
|
\ }], getloclist(0)
|
2017-06-07 22:12:45 +00:00
|
|
|
|
2018-01-17 18:08:17 +00:00
|
|
|
Execute(Linters should run in PowerShell too):
|
|
|
|
if has('win32')
|
|
|
|
set shell=powershell
|
|
|
|
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
|
|
|
" Replace the callback to handle two lines.
|
|
|
|
function! TestCallback(buffer, output)
|
|
|
|
" Windows adds extra spaces to the text from echo.
|
|
|
|
return [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': substitute(a:output[0], ' *$', '', ''),
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': substitute(a:output[1], ' *$', '', ''),
|
|
|
|
\ },
|
|
|
|
\]
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Recreate the command string to use &&, which PowerShell does not support.
|
|
|
|
call ale#linter#Reset()
|
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'TestCallback',
|
|
|
|
\ 'executable': 'cmd',
|
|
|
|
\ 'command': 'echo foo && echo bar',
|
|
|
|
\})
|
|
|
|
|
|
|
|
call ale#Lint()
|
TUI / GUI tooltip with content from ALEHover (#1556)
* Guard the ballooneval settings
* Mark main objectives to do to get nice Hover
* Make tweaks to make the tooltip work - See " XXX: comments
* Guard balloon_show call
* Use return instead of finish for functions
* ale#hover#show : Add optional arguments to specify arbtirary position
This change is requested to be able to call the function with mouse
position to enable hover information in vim's balloon
* ale#ballon#Disable : Remove feature guards
* ale#balloon : Show 'ALEHover' output on balloon if no diagnostic found
* ale#hover#HandleLSPResponse : remove the check for cursor position
This check prevented the 'ALEHover in balloon' feature, since mouse
position is almost never cursor position.
* ale#balloon#MessageForPos : Change the return of balloonexpr
balloonexpr evaluation now works even without balloon_show for basic
diagnostics, leaving the balloon_show call to ale#hover#Show, which can
then feature guard the call to avoid errors
* ale#hover#Response : Feature guard balloon_show calls
* ale#hover : always display 'Hover' information in messages
Also add a small comment to warn readers the different outputs the
ale#hover#Show will write to
* {LSP,TS}Response : use only variables from the Response
It is clearer that we only rely on l:options to get the relevant data to
build the LSP Response string
* hover#ShowDetails : fix an issue where not having focus broke balloons
The issue was caused by not using a buffer-specific version of getline()
to cap the value of the column sent in the message to LSP. Therefore a
cursor on column 10 in an inactive window could send a message with
column=0, if the active window had a buffer with too few lines
* {LSP,TS}Response : Remove redundant checks for balloon_show call
With the upcoming change in ale_set_balloons default value (see Pull
Request w0rp/ale#1565), this check will be useless
* balloonexpr? : Add a flag to separate hover#Show() calls
The goal of this flag is to make `:ALEHover` calls not pop a balloon
under the cursor, since the user has probably no interest in their
cursor while typing the command
The flag is a default argument which is overridden only in ballonexpr
call of ale#hover#Show, and stays set in the hover_map until the
callback for the LSP handles it.
There are no automated tests for this feature right now, and the nature
of the addition (one optional argument in the API) should make it
transparent to existing tests.
Since the differentiation is now possible, the check for moved cursor
has been put back in ale#hover#HandleLSPResponse
* ale#hover#hover_map : Protect accesses to hover_map
Using get() is safer than trying to access directly with ., as the tests
show.
* Raise timeout to try to get Appveyor happy
* Review : Fix comments
* Review : pass the optional argument 'called_from_balloonexpr' in a Dict
This optional dictionary has documentation just before the function
using it, ale#hover#Show, and allows easier extension in the future.
2018-05-16 20:23:48 +00:00
|
|
|
call ale#engine#WaitForJobs(4000)
|
2018-01-17 18:08:17 +00:00
|
|
|
|
|
|
|
AssertEqual [
|
|
|
|
\ {
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': 'foo',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 3,
|
|
|
|
\ 'text': 'bar',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
|
|
|
\ },
|
|
|
|
\], getloclist(0)
|
|
|
|
endif
|
|
|
|
|
2017-06-07 22:12:45 +00:00
|
|
|
Execute(Previous errors should be removed when linters change):
|
|
|
|
call ale#Lint()
|
|
|
|
call ale#engine#WaitForJobs(2000)
|
|
|
|
|
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter2',
|
|
|
|
\ 'callback': 'TestCallback2',
|
2017-09-08 20:38:51 +00:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'echo',
|
|
|
|
\ 'command': has('win32') ? 'echo baz boz' : '/bin/sh -c ''echo baz boz''',
|
2017-06-07 22:12:45 +00:00
|
|
|
\})
|
|
|
|
|
2018-07-11 12:46:13 +00:00
|
|
|
let g:expected_results = [{
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'lnum': 3,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'col': 4,
|
|
|
|
\ 'text': 'baz boz',
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'pattern': '',
|
|
|
|
\ 'valid': 1,
|
|
|
|
\}]
|
|
|
|
|
2018-07-13 08:53:07 +00:00
|
|
|
" Try the test a few times over in NeoVim 0.3 or Windows,
|
|
|
|
" where tests fail randomly.
|
|
|
|
for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
|
2018-07-11 12:46:13 +00:00
|
|
|
call ale#Lint()
|
|
|
|
call ale#engine#WaitForJobs(2000)
|
2017-06-07 22:12:45 +00:00
|
|
|
|
2018-07-11 12:46:13 +00:00
|
|
|
let g:results = getloclist(0)
|
|
|
|
|
|
|
|
if g:results == g:expected_results
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
AssertEqual g:expected_results, g:results
|