summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/dafny/dafny.vim2
-rw-r--r--ale_linters/erlang/erlc.vim16
-rw-r--r--ale_linters/inko/inko.vim33
-rw-r--r--ale_linters/java/checkstyle.vim2
-rwxr-xr-x[-rw-r--r--]ale_linters/php/intelephense.vim4
-rw-r--r--ale_linters/ruby/sorbet.vim5
-rw-r--r--ale_linters/salt/salt_lint.vim32
-rw-r--r--autoload/ale/codefix.vim5
-rw-r--r--autoload/ale/cursor.vim22
-rw-r--r--autoload/ale/fix/registry.vim2
-rw-r--r--autoload/ale/fixers/gofmt.vim3
-rw-r--r--autoload/ale/fixers/isort.vim27
-rw-r--r--autoload/ale/floating_preview.vim91
-rw-r--r--autoload/ale/handlers/inko.vim37
-rw-r--r--autoload/ale/hover.vim9
-rw-r--r--autoload/ale/linter.vim1
-rw-r--r--autoload/ale/python.vim2
-rw-r--r--doc/ale-erlang.txt8
-rw-r--r--doc/ale-inko.txt22
-rw-r--r--doc/ale-python.txt11
-rw-r--r--doc/ale-ruby.txt10
-rw-r--r--doc/ale-salt.tmt43
-rw-r--r--doc/ale-supported-languages-and-tools.txt4
-rw-r--r--doc/ale.txt35
-rw-r--r--plugin/ale.vim9
-rw-r--r--supported-tools.md4
-rw-r--r--test/command_callback/inko_paths/test.inko0
-rw-r--r--test/command_callback/inko_paths/tests/test/test_foo.inko0
-rw-r--r--test/command_callback/test_erlang_erlc_command_callback.vader40
-rw-r--r--test/command_callback/test_fecs_command_callback.vader1
-rw-r--r--test/command_callback/test_inko_inko_callbacks.vader20
-rw-r--r--test/command_callback/test_sorbet_command_callback.vader7
-rw-r--r--test/fixers/test_gofmt_fixer_callback.vader14
-rw-r--r--test/fixers/test_isort_fixer_callback.vader10
-rw-r--r--test/handler/test_dafny_handler.vader4
-rw-r--r--test/handler/test_inko_handler.vader54
-rw-r--r--test/handler/test_salt_salt_lint.vader34
-rw-r--r--test/test_floating_preview.vader92
-rw-r--r--test/test_hover.vader83
39 files changed, 756 insertions, 42 deletions
diff --git a/ale_linters/dafny/dafny.vim b/ale_linters/dafny/dafny.vim
index b5b90675..e6021d99 100644
--- a/ale_linters/dafny/dafny.vim
+++ b/ale_linters/dafny/dafny.vim
@@ -6,7 +6,7 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
+ \ 'filename': l:match[1],
\ 'col': l:match[3] + 0,
\ 'lnum': l:match[2] + 0,
\ 'text': l:match[5],
diff --git a/ale_linters/erlang/erlc.vim b/ale_linters/erlang/erlc.vim
index a83bacc3..e78dc341 100644
--- a/ale_linters/erlang/erlc.vim
+++ b/ale_linters/erlang/erlc.vim
@@ -1,14 +1,22 @@
" Author: Magnus Ottenklinger - https://github.com/evnu
+let g:ale_erlang_erlc_executable = get(g:, 'ale_erlang_erlc_executable', 'erlc')
let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '')
+function! ale_linters#erlang#erlc#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'erlang_erlc_executable')
+endfunction
+
function! ale_linters#erlang#erlc#GetCommand(buffer) abort
let l:output_file = ale#util#Tempname()
call ale#command#ManageFile(a:buffer, l:output_file)
- return 'erlc -o ' . ale#Escape(l:output_file)
- \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options')
- \ . ' %t'
+ let l:command = ale#Escape(ale_linters#erlang#erlc#GetExecutable(a:buffer))
+ \ . ' -o ' . ale#Escape(l:output_file)
+ \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options')
+ \ . ' %t'
+
+ return l:command
endfunction
function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
@@ -90,7 +98,7 @@ endfunction
call ale#linter#Define('erlang', {
\ 'name': 'erlc',
-\ 'executable': 'erlc',
+\ 'executable': function('ale_linters#erlang#erlc#GetExecutable'),
\ 'command': function('ale_linters#erlang#erlc#GetCommand'),
\ 'callback': 'ale_linters#erlang#erlc#Handle',
\})
diff --git a/ale_linters/inko/inko.vim b/ale_linters/inko/inko.vim
new file mode 100644
index 00000000..11558897
--- /dev/null
+++ b/ale_linters/inko/inko.vim
@@ -0,0 +1,33 @@
+" Author: Yorick Peterse <yorick@yorickpeterse.com>
+" Description: linting of Inko source code using the Inko compiler
+
+call ale#Set('inko_inko_executable', 'inko')
+
+function! ale_linters#inko#inko#GetCommand(buffer) abort
+ let l:include = ''
+
+ " Include the tests source directory, but only for test files.
+ if expand('#' . a:buffer . ':p') =~? '\vtests[/\\]test[/\\]'
+ let l:test_dir = ale#path#FindNearestDirectory(a:buffer, 'tests')
+
+ if isdirectory(l:test_dir)
+ let l:include = '--include ' . ale#Escape(l:test_dir)
+ endif
+ endif
+
+ " We use %s instead of %t so the compiler determines the correct module
+ " names for the file being edited. Not doing so may lead to errors in
+ " certain cases.
+ return '%e build --check --format=json'
+ \ . ale#Pad(l:include)
+ \ . ' %s'
+endfunction
+
+call ale#linter#Define('inko', {
+\ 'name': 'inko',
+\ 'executable': {b -> ale#Var(b, 'inko_inko_executable')},
+\ 'command': function('ale_linters#inko#inko#GetCommand'),
+\ 'callback': 'ale#handlers#inko#Handle',
+\ 'output_stream': 'stderr',
+\ 'lint_file': 1
+\})
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim
index ec7339d1..f00734e0 100644
--- a/ale_linters/java/checkstyle.vim
+++ b/ale_linters/java/checkstyle.vim
@@ -9,7 +9,7 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
let l:output = []
" modern checkstyle versions
- let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
+ let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
diff --git a/ale_linters/php/intelephense.vim b/ale_linters/php/intelephense.vim
index e9e07d1f..aca619e3 100644..100755
--- a/ale_linters/php/intelephense.vim
+++ b/ale_linters/php/intelephense.vim
@@ -18,8 +18,8 @@ function! ale_linters#php#intelephense#GetProjectRoot(buffer) abort
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
-function! ale_linters#php#intelephense#GetInitializationOptions() abort
- return ale#Get('php_intelephense_config')
+function! ale_linters#php#intelephense#GetInitializationOptions(buffer) abort
+ return ale#Var(a:buffer, 'php_intelephense_config')
endfunction
call ale#linter#Define('php', {
diff --git a/ale_linters/ruby/sorbet.vim b/ale_linters/ruby/sorbet.vim
index cae0683c..c67e20cc 100644
--- a/ale_linters/ruby/sorbet.vim
+++ b/ale_linters/ruby/sorbet.vim
@@ -1,14 +1,17 @@
call ale#Set('ruby_sorbet_executable', 'srb')
call ale#Set('ruby_sorbet_options', '')
+call ale#Set('ruby_sorbet_enable_watchman', 0)
function! ale_linters#ruby#sorbet#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable')
let l:options = ale#Var(a:buffer, 'ruby_sorbet_options')
+ let l:enable_watchman = ale#Var(a:buffer, 'ruby_sorbet_enable_watchman')
return ale#ruby#EscapeExecutable(l:executable, 'srb')
\ . ' tc'
\ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' --lsp --disable-watchman'
+ \ . ' --lsp'
+ \ . (l:enable_watchman ? '' : ' --disable-watchman')
endfunction
call ale#linter#Define('ruby', {
diff --git a/ale_linters/salt/salt_lint.vim b/ale_linters/salt/salt_lint.vim
new file mode 100644
index 00000000..d2027119
--- /dev/null
+++ b/ale_linters/salt/salt_lint.vim
@@ -0,0 +1,32 @@
+" Author: Benjamin BINIER <poulpatine@gmail.com>
+" Description: salt-lint, saltstack linter
+
+call ale#Set('salt_salt_lint_executable', 'salt-lint')
+call ale#Set('salt_salt_lint_options', '')
+
+function! ale_linters#salt#salt_lint#GetCommand(buffer) abort
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'salt_salt_lint_options'))
+ \ . ' --json'
+endfunction
+
+function! ale_linters#salt#salt_lint#Handle(buffer, lines) abort
+ let l:output = []
+
+ for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
+ call add(l:output, {
+ \ 'lnum': l:error.linenumber + 0,
+ \ 'code': l:error.id + 0,
+ \ 'text': l:error.message,
+ \ 'type': l:error.severity is# 'HIGH' ? 'E' : 'W',
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('salt', {
+\ 'name': 'salt-lint',
+\ 'executable': {b -> ale#Var(b, 'salt_salt_lint_executable')},
+\ 'command': function('ale_linters#salt#salt_lint#GetCommand'),
+\ 'callback': 'ale_linters#salt#salt_lint#Handle'
+\})
diff --git a/autoload/ale/codefix.vim b/autoload/ale/codefix.vim
index 69bf36fa..4a78063b 100644
--- a/autoload/ale/codefix.vim
+++ b/autoload/ale/codefix.vim
@@ -261,7 +261,10 @@ function! ale#codefix#HandleLSPResponse(conn_id, response) abort
" Send the results to the menu callback, if set.
if l:MenuCallback isnot v:null
- call l:MenuCallback(map(copy(l:result), '[''lsp'', v:val]'))
+ call l:MenuCallback(
+ \ l:data,
+ \ map(copy(l:result), '[''lsp'', v:val]')
+ \)
return
endif
diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim
index 9ca6fb15..e8478e93 100644
--- a/autoload/ale/cursor.vim
+++ b/autoload/ale/cursor.vim
@@ -9,7 +9,6 @@ let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10)
let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s')
let s:cursor_timer = -1
-let s:last_pos = [0, 0, 0]
function! ale#cursor#TruncatedEcho(original_message) abort
let l:message = a:original_message
@@ -118,14 +117,18 @@ function! ale#cursor#EchoCursorWarningWithDelay() abort
let l:pos = getpos('.')[0:2]
+ if !exists('w:last_pos')
+ let w:last_pos = [0, 0, 0]
+ endif
+
" Check the current buffer, line, and column number against the last
" recorded position. If the position has actually changed, *then*
" we should echo something. Otherwise we can end up doing processing
" the echo message far too frequently.
- if l:pos != s:last_pos
+ if l:pos != w:last_pos
let l:delay = ale#Var(l:buffer, 'echo_delay')
- let s:last_pos = l:pos
+ let w:last_pos = l:pos
let s:cursor_timer = timer_start(
\ l:delay,
\ function('ale#cursor#EchoCursorWarning')
@@ -139,11 +142,16 @@ function! s:ShowCursorDetailForItem(loc, options) abort
let s:last_detailed_line = line('.')
let l:message = get(a:loc, 'detail', a:loc.text)
let l:lines = split(l:message, "\n")
- call ale#preview#Show(l:lines, {'stay_here': l:stay_here})
- " Clear the echo message if we manually displayed details.
- if !l:stay_here
- execute 'echo'
+ if g:ale_floating_preview || g:ale_detail_to_floating_preview
+ call ale#floating_preview#Show(l:lines)
+ else
+ call ale#preview#Show(l:lines, {'stay_here': l:stay_here})
+
+ " Clear the echo message if we manually displayed details.
+ if !l:stay_here
+ execute 'echo'
+ endif
endif
endfunction
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 0f146faa..47f978e8 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -132,7 +132,7 @@ let s:default_registry = {
\ },
\ 'scalafmt': {
\ 'function': 'ale#fixers#scalafmt#Fix',
-\ 'suggested_filetypes': ['scala'],
+\ 'suggested_filetypes': ['sbt', 'scala'],
\ 'description': 'Fix Scala files using scalafmt',
\ },
\ 'sorbet': {
diff --git a/autoload/ale/fixers/gofmt.vim b/autoload/ale/fixers/gofmt.vim
index d5a539b9..b9cfbb58 100644
--- a/autoload/ale/fixers/gofmt.vim
+++ b/autoload/ale/fixers/gofmt.vim
@@ -11,9 +11,6 @@ function! ale#fixers#gofmt#Fix(buffer) abort
return {
\ 'command': l:env . ale#Escape(l:executable)
- \ . ' -l -w'
\ . (empty(l:options) ? '' : ' ' . l:options)
- \ . ' %t',
- \ 'read_temporary_file': 1,
\}
endfunction
diff --git a/autoload/ale/fixers/isort.vim b/autoload/ale/fixers/isort.vim
index 9070fb27..55bb550e 100644
--- a/autoload/ale/fixers/isort.vim
+++ b/autoload/ale/fixers/isort.vim
@@ -2,24 +2,35 @@
" Description: Fixing Python imports with isort.
call ale#Set('python_isort_executable', 'isort')
-call ale#Set('python_isort_options', '')
call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('python_isort_options', '')
+call ale#Set('python_isort_auto_pipenv', 0)
+
+function! ale#fixers#isort#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
+ return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort'])
+endfunction
function! ale#fixers#isort#Fix(buffer) abort
let l:options = ale#Var(a:buffer, 'python_isort_options')
- let l:executable = ale#python#FindExecutable(
- \ a:buffer,
- \ 'python_isort',
- \ ['isort'],
- \)
+ let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
+
+ let l:exec_args = l:executable =~? 'pipenv$'
+ \ ? ' run isort'
+ \ : ''
- if !executable(l:executable)
+ if !executable(l:executable) && l:executable isnot# 'pipenv'
return 0
endif
return {
\ 'command': ale#path#BufferCdString(a:buffer)
- \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
+ \ . ale#Escape(l:executable) . l:exec_args
+ \ . (!empty(l:options) ? ' ' . l:options : '') . ' -',
\}
endfunction
diff --git a/autoload/ale/floating_preview.vim b/autoload/ale/floating_preview.vim
new file mode 100644
index 00000000..e6a75689
--- /dev/null
+++ b/autoload/ale/floating_preview.vim
@@ -0,0 +1,91 @@
+" Author: Jan-Grimo Sobez <jan-grimo.sobez@phys.chem.ethz.ch>
+" Author: Kevin Clark <kevin.clark@gmail.com>
+" Description: Floating preview window for showing whatever information in.
+
+" Precondition: exists('*nvim_open_win')
+
+function! ale#floating_preview#Show(lines, ...) abort
+ if !exists('*nvim_open_win')
+ execute 'echom ''Floating windows not supported in this vim instance.'''
+
+ return
+ endif
+
+ " Remove the close autocmd so it doesn't happen mid update
+ augroup ale_floating_preview_window
+ autocmd!
+ augroup END
+
+ let l:options = get(a:000, 0, {})
+
+ " Only create a new window if we need it
+ if !exists('w:preview') || index(nvim_list_wins(), w:preview['id']) is# -1
+ call s:Create(l:options)
+ else
+ call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:true)
+ endif
+
+ " Execute commands in window context
+ let l:parent_window = nvim_get_current_win()
+
+ call nvim_set_current_win(w:preview['id'])
+
+ for l:command in get(l:options, 'commands', [])
+ call execute(l:command)
+ endfor
+
+ call nvim_set_current_win(l:parent_window)
+
+ " Return to parent context on move
+ augroup ale_floating_preview_window
+ autocmd!
+
+ if g:ale_close_preview_on_insert
+ autocmd CursorMoved,TabLeave,WinLeave,InsertEnter <buffer> ++once call s:Close()
+ else
+ autocmd CursorMoved,TabLeave,WinLeave <buffer> ++once call s:Close()
+ endif
+ augroup END
+
+ let l:width = max(map(copy(a:lines), 'strdisplaywidth(v:val)'))
+ let l:height = min([len(a:lines), 10])
+ call nvim_win_set_width(w:preview['id'], l:width)
+ call nvim_win_set_height(w:preview['id'], l:height)
+
+ call nvim_buf_set_lines(w:preview['buffer'], 0, -1, v:false, a:lines)
+ call nvim_buf_set_option(w:preview['buffer'], 'modified', v:false)
+ call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:false)
+endfunction
+
+function! s:Create(options) abort
+ let l:buffer = nvim_create_buf(v:false, v:false)
+ let l:winid = nvim_open_win(l:buffer, v:false, {
+ \ 'relative': 'cursor',
+ \ 'row': 1,
+ \ 'col': 0,
+ \ 'width': 42,
+ \ 'height': 4,
+ \ 'style': 'minimal'
+ \ })
+ call nvim_buf_set_option(l:buffer, 'buftype', 'acwrite')
+ call nvim_buf_set_option(l:buffer, 'bufhidden', 'delete')
+ call nvim_buf_set_option(l:buffer, 'swapfile', v:false)
+ call nvim_buf_set_option(l:buffer, 'filetype', get(a:options, 'filetype', 'ale-preview'))
+
+ let w:preview = {'id': l:winid, 'buffer': l:buffer}
+endfunction
+
+function! s:Close() abort
+ if !exists('w:preview')
+ return
+ endif
+
+ call setbufvar(w:preview['buffer'], '&modified', 0)
+
+ if win_id2win(w:preview['id']) > 0
+ execute win_id2win(w:preview['id']).'wincmd c'
+ endif
+
+ unlet w:preview
+endfunction
+
diff --git a/autoload/ale/handlers/inko.vim b/autoload/ale/handlers/inko.vim
new file mode 100644
index 00000000..73f06871
--- /dev/null
+++ b/autoload/ale/handlers/inko.vim
@@ -0,0 +1,37 @@
+" Author: Yorick Peterse <yorick@yorickpeterse.com>
+" Description: output handlers for the Inko JSON format
+
+function! ale#handlers#inko#GetType(severity) abort
+ if a:severity is? 'warning'
+ return 'W'
+ endif
+
+ return 'E'
+endfunction
+
+function! ale#handlers#inko#Handle(buffer, lines) abort
+ try
+ let l:errors = json_decode(join(a:lines, ''))
+ catch
+ return []
+ endtry
+
+ if empty(l:errors)
+ return []
+ endif
+
+ let l:output = []
+ let l:dir = expand('#' . a:buffer . ':p:h')
+
+ for l:error in l:errors
+ call add(l:output, {
+ \ 'filename': ale#path#GetAbsPath(l:dir, l:error['file']),
+ \ 'lnum': l:error['line'],
+ \ 'col': l:error['column'],
+ \ 'text': l:error['message'],
+ \ 'type': ale#handlers#inko#GetType(l:error['level']),
+ \})
+ endfor
+
+ return l:output
+endfunction
diff --git a/autoload/ale/hover.vim b/autoload/ale/hover.vim
index 1d38f3b9..cb0379fd 100644
--- a/autoload/ale/hover.vim
+++ b/autoload/ale/hover.vim
@@ -46,6 +46,10 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort
call balloon_show(a:response.body.displayString)
elseif get(l:options, 'truncated_echo', 0)
call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0])
+ elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
+ call ale#floating_preview#Show(split(a:response.body.displayString, "\n"), {
+ \ 'filetype': 'ale-preview.message',
+ \})
elseif g:ale_hover_to_preview
call ale#preview#Show(split(a:response.body.displayString, "\n"), {
\ 'filetype': 'ale-preview.message',
@@ -226,6 +230,11 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort
call balloon_show(join(l:lines, "\n"))
elseif get(l:options, 'truncated_echo', 0)
call ale#cursor#TruncatedEcho(l:lines[0])
+ elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
+ call ale#floating_preview#Show(l:lines, {
+ \ 'filetype': 'ale-preview.message',
+ \ 'commands': l:commands,
+ \})
elseif g:ale_hover_to_preview
call ale#preview#Show(l:lines, {
\ 'filetype': 'ale-preview.message',
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 645c25f9..ba11e1eb 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -43,6 +43,7 @@ let s:default_ale_linters = {
\ 'go': ['gofmt', 'golint', 'go vet'],
\ 'hack': ['hack'],
\ 'help': [],
+\ 'inko': ['inko'],
\ 'perl': ['perlcritic'],
\ 'perl6': [],
\ 'python': ['flake8', 'mypy', 'pylint', 'pyright'],
diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim
index 7ed22367..fc6c1130 100644
--- a/autoload/ale/python.vim
+++ b/autoload/ale/python.vim
@@ -32,6 +32,8 @@ function! ale#python#FindProjectRootIni(buffer) abort
\|| filereadable(l:path . '/.pylintrc')
\|| filereadable(l:path . '/Pipfile')
\|| filereadable(l:path . '/Pipfile.lock')
+ \|| filereadable(l:path . '/poetry.lock')
+ \|| filereadable(l:path . '/pyproject.toml')
return l:path
endif
endfor
diff --git a/doc/ale-erlang.txt b/doc/ale-erlang.txt
index 38762f08..9ee9a51d 100644
--- a/doc/ale-erlang.txt
+++ b/doc/ale-erlang.txt
@@ -46,6 +46,14 @@ g:ale_erlang_elvis_executable *g:ale_erlang_elvis_executable*
-------------------------------------------------------------------------------
erlc *ale-erlang-erlc*
+g:ale_erlang_erlc_executable *g:ale_erlang_erlc_executable*
+ *b:ale_erlang_erlc_executable*
+ Type: |String|
+ Default: `'erlc'`
+
+ This variable can be changed to specify the erlc executable.
+
+
g:ale_erlang_erlc_options *g:ale_erlang_erlc_options*
*b:ale_erlang_erlc_options*
Type: |String|
diff --git a/doc/ale-inko.txt b/doc/ale-inko.txt
new file mode 100644
index 00000000..5ca14af6
--- /dev/null
+++ b/doc/ale-inko.txt
@@ -0,0 +1,22 @@
+===============================================================================
+ALE Inko Integration *ale-inko-options*
+ *ale-integration-inko*
+
+===============================================================================
+Integration Information
+
+ Currently, the only supported linter for Inko is the Inko compiler itself.
+
+===============================================================================
+inko *ale-inko-inko*
+
+g:ale_inko_inko_executable *g:ale_inko_inko_executable*
+ *b:ale_inko_inko_executable*
+ Type: |String|
+ Default: `'inko'`
+
+ This variable can be modified to change the executable path for `inko`.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-python.txt b/doc/ale-python.txt
index f0c8bfb8..1f263e84 100644
--- a/doc/ale-python.txt
+++ b/doc/ale-python.txt
@@ -36,6 +36,8 @@ ALE will look for configuration files with the following filenames. >
.pylintrc
Pipfile
Pipfile.lock
+ poetry.lock
+ pyproject.toml
<
The first directory containing any of the files named above will be used.
@@ -280,6 +282,15 @@ g:ale_python_isort_use_global *g:ale_python_isort_use_global*
See |ale-integrations-local-executables|
+g:ale_python_isort_auto_pipenv *g:ale_python_isort_auto_pipenv*
+ *b:ale_python_isort_auto_pipenv*
+ Type: |Number|
+ Default: `0`
+
+ Detect whether the file is inside a pipenv, and set the executable to `pipenv`
+ if true. This is overridden by a manually-set executable.
+
+
===============================================================================
mypy *ale-python-mypy*
diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt
index 8815404a..edc6144a 100644
--- a/doc/ale-ruby.txt
+++ b/doc/ale-ruby.txt
@@ -177,6 +177,16 @@ g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options*
This variable can be changed to modify flags given to sorbet.
+g:ale_ruby_sorbet_enable_watchman *g:ale_ruby_sorbet_enable_watchman*
+ *b:ale_ruby_sorbet_enable_watchman*
+ Type: |Number|
+ Default: `0`
+
+ Whether or not to use watchman to let the LSP server to know about changes
+ to files from outside of vim. Defaults to disable watchman because it
+ requires watchman to be installed separately from sorbet.
+
+
===============================================================================
standardrb *ale-ruby-standardrb*
diff --git a/doc/ale-salt.tmt b/doc/ale-salt.tmt
new file mode 100644
index 00000000..ac500d37
--- /dev/null
+++ b/doc/ale-salt.tmt
@@ -0,0 +1,43 @@
+===============================================================================
+ALE SALT Integration *ale-salt-options*
+
+===============================================================================
+salt-lint *ale-salt-salt-lint*
+
+Website: https://github.com/warpnet/salt-lint
+
+
+Installation
+-------------------------------------------------------------------------------
+
+Install salt-lint in your a virtualenv directory, locally, or globally: >
+
+ pip install salt-lint # After activating virtualenv
+ pip install --user salt-lint # Install to ~/.local/bin
+ sudo pip install salt-lint # Install globally
+
+See |g:ale_virtualenv_dir_names| for configuring how ALE searches for
+virtualenv directories.
+
+
+Options
+-------------------------------------------------------------------------------
+
+g:ale_salt_salt-lint_executable *g:ale_salt_salt_lint_executable*
+ *b:ale_salt_salt_lint_executable*
+ Type: |String|
+ Default: `'salt-lint'`
+
+ This variable can be set to change the path to salt-lint.
+
+
+g:ale_salt_salt-lint_options *g:ale_salt_salt-lint_options*
+ *b:ale_salt_salt-lint_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be set to pass additional options to salt-lint.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 0a80ef0e..ccedd2ad 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -215,6 +215,8 @@ Notes:
* `idris`
* Ink
* `ink-language-server`
+* Inko
+ * `inko` !!
* ISPC
* `ispc`!!
* Java
@@ -428,6 +430,8 @@ Notes:
* `rust-analyzer`
* `rustc` (see |ale-integration-rust|)
* `rustfmt`
+* Salt
+ * `salt-lint`
* Sass
* `sass-lint`
* `stylelint`
diff --git a/doc/ale.txt b/doc/ale.txt
index 5d59aed4..c5e34c87 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -646,6 +646,9 @@ problem will be displayed in a balloon instead of hover information.
Hover information can be displayed in the preview window instead by setting
|g:ale_hover_to_preview| to `1`.
+When using Neovim, if |g:ale_hover_to_floating_preview| or |g:ale_floating_preview|
+is set to 1, the hover information will show in a floating window.
+
For Vim 8.1+ terminals, mouse hovering is disabled by default. Enabling
|balloonexpr| commands in terminals can cause scrolling issues in terminals,
so ALE will not attempt to show balloons unless |g:ale_set_balloons| is set to
@@ -954,6 +957,15 @@ g:ale_default_navigation *g:ale_default_navigation*
buffer, such as for |ALEFindReferences|, or |ALEGoToDefinition|.
+g:ale_detail_to_floating_preview *g:ale_detail_to_floating_preview*
+ *b:ale_detail_to_floating_preview*
+ Type: |Number|
+ Default: `0`
+
+ When this option is set to `1`, Neovim will use a floating window for
+ ALEDetail output.
+
+
g:ale_disable_lsp *g:ale_disable_lsp*
*b:ale_disable_lsp*
@@ -1177,6 +1189,16 @@ g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore*
let g:ale_fix_on_save_ignore = [g:AddBar]
<
+g:ale_floating_preview *g:ale_floating_preview*
+
+ Type: |Number|
+ Default: `0`
+
+ When set to `1`, Neovim will use a floating window for ale's preview window.
+ This is equivalent to setting |g:ale_hover_to_floating_preview| and
+ |g:ale_detail_to_floating_preview| to `1`.
+
+
g:ale_history_enabled *g:ale_history_enabled*
Type: |Number|
@@ -1235,6 +1257,14 @@ g:ale_hover_to_preview *g:ale_hover_to_preview*
instead of in balloons or the message line.
+g:ale_hover_to_floating_preview *g:ale_hover_to_floating_preview*
+ *b:ale_hover_to_floating_preview*
+ Type: |Number|
+ Default: `0`
+
+ If set to `1`, Neovim will use floating windows for hover messages.
+
+
g:ale_keep_list_window_open *g:ale_keep_list_window_open*
*b:ale_keep_list_window_open*
Type: |Number|
@@ -1531,6 +1561,7 @@ g:ale_linters *g:ale_linters*
\ 'go': ['gofmt', 'golint', 'go vet'],
\ 'hack': ['hack'],
\ 'help': [],
+ \ 'inko': ['inko'],
\ 'perl': ['perlcritic'],
\ 'perl6': [],
\ 'python': ['flake8', 'mypy', 'pylint', 'pyright'],
@@ -2708,6 +2739,8 @@ documented in additional help files.
idris.................................|ale-idris-idris|
ink.....................................|ale-ink-options|
ink-language-server...................|ale-ink-language-server|
+ inko....................................|ale-inko-options|
+ inko..................................|ale-inko-inko|
ispc....................................|ale-ispc-options|
ispc..................................|ale-ispc-ispc|
java....................................|ale-java-options|
@@ -2882,6 +2915,8 @@ documented in additional help files.
rls...................................|ale-rust-rls|
rustc.................................|ale-rust-rustc|
rustfmt...............................|ale-rust-rustfmt|
+ salt....................................|ale-salt-options|
+ salt-lint.............................|ale-salt-salt-lint|
sass....................................|ale-sass-options|
sasslint..............................|ale-sass-sasslint|
stylelint.............................|ale-sass-stylelint|
diff --git a/plugin/ale.vim b/plugin/ale.vim
index 5b7be116..1735715d 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -138,6 +138,15 @@ let g:ale_set_balloons = get(g:, 'ale_set_balloons', has('balloon_eval') && has(
" Use preview window for hover messages.
let g:ale_hover_to_preview = get(g:, 'ale_hover_to_preview', 0)
+" Float preview windows in Neovim
+let g:ale_floating_preview = get(g:, 'ale_floating_preview', 0)
+
+" Hovers use floating windows in Neovim
+let g:ale_hover_to_floating_preview = get(g:, 'ale_hover_to_floating_preview', 0)
+
+" Detail uses floating windows in Neovim
+let g:ale_detail_to_floating_preview = get(g:, 'ale_detail_to_floating_preview', 0)
+
" This flag can be set to 0 to disable warnings for trailing whitespace
let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whitespace', 1)
" This flag can be set to 0 to disable warnings for trailing blank lines
diff --git a/supported-tools.md b/supported-tools.md
index 1c399829..7590e9a4 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -224,6 +224,8 @@ formatting.
* [idris](http://www.idris-lang.org/)
* Ink
* [ink-language-server](https://github.com/ephread/ink-language-server)
+* Inko
+ * [inko](https://inko-lang.org/) :floppy_disk:
* ISPC
* [ispc](https://ispc.github.io/) :floppy_disk:
* Java
@@ -437,6 +439,8 @@ formatting.
* [rust-analyzer](https://github.com/rust-analyzer/rust-analyzer) :warning:
* [rustc](https://www.rust-lang.org/) :warning:
* [rustfmt](https://github.com/rust-lang-nursery/rustfmt)
+* Salt
+ * [salt-lint](https://github.com/warpnet/salt-lint)
* Sass
* [sass-lint](https://www.npmjs.com/package/sass-lint)
* [stylelint](https://github.com/stylelint/stylelint)
diff --git a/test/command_callback/inko_paths/test.inko b/test/command_callback/inko_paths/test.inko
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/inko_paths/test.inko
diff --git a/test/command_callback/inko_paths/tests/test/test_foo.inko b/test/command_callback/inko_paths/tests/test/test_foo.inko
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/inko_paths/tests/test/test_foo.inko
diff --git a/test/command_callback/test_erlang_erlc_command_callback.vader b/test/command_callback/test_erlang_erlc_command_callback.vader
new file mode 100644
index 00000000..7d659a07
--- /dev/null
+++ b/test/command_callback/test_erlang_erlc_command_callback.vader
@@ -0,0 +1,40 @@
+Before:
+ call ale#assert#SetUpLinterTest('erlang', 'erlc')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct.):
+ let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
+ let g:regex = 'erlc.\+-o.\+%t'
+ let g:matched = match(g:cmd, g:regex)
+
+ " match returns -1 if not found
+ AssertNotEqual
+ \ g:matched,
+ \ -1,
+ \ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
+
+Execute(The command should accept configured executable.):
+ let b:ale_erlang_erlc_executable = '/usr/bin/erlc'
+ let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
+ let g:regex = '/usr/bin/erlc.\+-o.\+%t'
+ let g:matched = match(g:cmd, g:regex)
+
+ " match returns -1 if not found
+ AssertNotEqual
+ \ g:matched,
+ \ -1,
+ \ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
+
+Execute(The command should accept configured options.):
+ let b:ale_erlang_erlc_options = '-I include'
+ let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
+ let g:regex = 'erlc.\+-o.\+-I include.\+%t'
+ let g:matched = match(g:cmd, g:regex)
+
+ " match returns -1 if not found
+ AssertNotEqual
+ \ g:matched,
+ \ -1,
+ \ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
diff --git a/test/command_callback/test_fecs_command_callback.vader b/test/command_callback/test_fecs_command_callback.vader
index f70ad084..4287d324 100644
--- a/test/command_callback/test_fecs_command_callback.vader
+++ b/test/command_callback/test_fecs_command_callback.vader
@@ -1,5 +1,6 @@
Before:
call ale#assert#SetUpLinterTest('javascript', 'fecs')
+ runtime autoload/ale/handlers/fecs.vim
After:
call ale#assert#TearDownLinterTest()
diff --git a/test/command_callback/test_inko_inko_callbacks.vader b/test/command_callback/test_inko_inko_callbacks.vader
new file mode 100644
index 00000000..93295c91
--- /dev/null
+++ b/test/command_callback/test_inko_inko_callbacks.vader
@@ -0,0 +1,20 @@
+Before:
+ call ale#assert#SetUpLinterTest('inko', 'inko')
+ call ale#test#SetFilename('inko_paths/test.inko')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default executable path should be correct):
+ AssertLinter 'inko', ale#Escape('inko') . ' build --check --format=json %s'
+
+Execute(The inko callback should include tests/ for test paths):
+ call ale#engine#Cleanup(bufnr(''))
+ noautocmd e! inko_paths/tests/test/test_foo.inko
+ call ale#engine#InitBufferInfo(bufnr(''))
+
+ AssertLinter 'inko',
+ \ ale#Escape('inko')
+ \ . ' build --check --format=json --include '
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/inko_paths/tests/'))
+ \ . ' %s'
diff --git a/test/command_callback/test_sorbet_command_callback.vader b/test/command_callback/test_sorbet_command_callback.vader
index b46e90a4..fe758635 100644
--- a/test/command_callback/test_sorbet_command_callback.vader
+++ b/test/command_callback/test_sorbet_command_callback.vader
@@ -5,6 +5,7 @@ Before:
let g:ale_ruby_sorbet_executable = 'srb'
let g:ale_ruby_sorbet_options = ''
+ let g:ale_ruby_sorbet_enable_watchman = 0
After:
call ale#assert#TearDownLinterTest()
@@ -13,6 +14,12 @@ Execute(Executable should default to srb):
AssertLinter 'srb', ale#Escape('srb')
\ . ' tc --lsp --disable-watchman'
+Execute(Able to enable watchman):
+ let g:ale_ruby_sorbet_enable_watchman = 1
+
+ AssertLinter 'srb', ale#Escape('srb')
+ \ . ' tc --lsp'
+
Execute(Should be able to set a custom executable):
let g:ale_ruby_sorbet_executable = 'bin/srb'
diff --git a/test/fixers/test_gofmt_fixer_callback.vader b/test/fixers/test_gofmt_fixer_callback.vader
index 16659655..99407173 100644
--- a/test/fixers/test_gofmt_fixer_callback.vader
+++ b/test/fixers/test_gofmt_fixer_callback.vader
@@ -21,10 +21,7 @@ Execute(The gofmt callback should return the correct default values):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
- \ 'command': ale#Escape('xxxinvalid')
- \ . ' -l -w'
- \ . ' %t',
+ \ 'command': ale#Escape('xxxinvalid'),
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))
@@ -35,11 +32,8 @@ Execute(The gofmt callback should include custom gofmt options):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
- \ . ' -l -w'
- \ . ' ' . g:ale_go_gofmt_options
- \ . ' %t',
+ \ . ' ' . g:ale_go_gofmt_options,
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))
@@ -50,9 +44,7 @@ Execute(The gofmt callback should support Go environment variables):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
\ 'command': ale#Env('GO111MODULE', 'off')
- \ . ale#Escape('xxxinvalid') . ' -l -w'
- \ . ' %t',
+ \ . ale#Escape('xxxinvalid')
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))
diff --git a/test/fixers/test_isort_fixer_callback.vader b/test/fixers/test_isort_fixer_callback.vader
index 7f389dcf..3941f6dd 100644
--- a/test/fixers/test_isort_fixer_callback.vader
+++ b/test/fixers/test_isort_fixer_callback.vader
@@ -5,6 +5,7 @@ Before:
" Use an invalid global executable, so we don't match it.
let g:ale_python_isort_executable = 'xxxinvalid'
let g:ale_python_isort_options = ''
+ let g:ale_python_isort_auto_pipenv = 0
call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
@@ -48,3 +49,12 @@ Execute(The isort callback should respect custom options):
\ . ' --multi-line=3 --trailing-comma -',
\ },
\ ale#fixers#isort#Fix(bufnr(''))
+
+Execute(Pipenv is detected when python_isort_auto_pipenv is set):
+ let g:ale_python_isort_auto_pipenv = 1
+
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertEqual
+ \ {'command': ale#path#BufferCdString(bufnr('')) . ale#Escape('pipenv') . ' run isort -'},
+ \ ale#fixers#isort#Fix(bufnr(''))
diff --git a/test/handler/test_dafny_handler.vader b/test/handler/test_dafny_handler.vader
index 674f691d..797d348e 100644
--- a/test/handler/test_dafny_handler.vader
+++ b/test/handler/test_dafny_handler.vader
@@ -8,14 +8,14 @@ Execute(The Dafny handler should parse output correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 0,
+ \ 'filename': 'File.dfy',
\ 'col': 45,
\ 'lnum': 123,
\ 'text': 'A precondition for this call might not hold.',
\ 'type': 'E'
\ },
\ {
- \ 'bufnr': 0,
+ \ 'filename': 'File.dfy',
\ 'col': 90,
\ 'lnum': 678,
\ 'text': 'This is the precondition that might not hold.',
diff --git a/test/handler/test_inko_handler.vader b/test/handler/test_inko_handler.vader
new file mode 100644
index 00000000..6621d2d6
--- /dev/null
+++ b/test/handler/test_inko_handler.vader
@@ -0,0 +1,54 @@
+Before:
+ runtime ale_linters/inko/inko.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The inko handler should parse errors correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'filename': ale#path#Simplify('/tmp/foo.inko'),
+ \ 'lnum': 4,
+ \ 'col': 5,
+ \ 'text': 'this is an error',
+ \ 'type': 'E',
+ \ }
+ \ ],
+ \ ale#handlers#inko#Handle(bufnr(''), [
+ \ '[',
+ \ ' {',
+ \ ' "file": "/tmp/foo.inko",',
+ \ ' "line": 4,',
+ \ ' "column": 5,',
+ \ ' "message": "this is an error",',
+ \ ' "level": "error"',
+ \ ' }',
+ \ ']'
+ \ ])
+
+Execute(The inko handler should parse warnings correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'filename': ale#path#Simplify('/tmp/foo.inko'),
+ \ 'lnum': 4,
+ \ 'col': 5,
+ \ 'text': 'this is a warning',
+ \ 'type': 'W',
+ \ }
+ \ ],
+ \ ale#handlers#inko#Handle(bufnr(''), [
+ \ '[',
+ \ ' {',
+ \ ' "file": "/tmp/foo.inko",',
+ \ ' "line": 4,',
+ \ ' "column": 5,',
+ \ ' "message": "this is a warning",',
+ \ ' "level": "warning"',
+ \ ' }',
+ \ ']'
+ \ ])
+
+Execute(The inko handler should handle empty output):
+ AssertEqual [], ale#handlers#inko#Handle(bufnr(''), [])
diff --git a/test/handler/test_salt_salt_lint.vader b/test/handler/test_salt_salt_lint.vader
new file mode 100644
index 00000000..7e234785
--- /dev/null
+++ b/test/handler/test_salt_salt_lint.vader
@@ -0,0 +1,34 @@
+Before:
+ runtime ale_linters/salt/salt_lint.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The salt handler should parse lines correctly and show error in severity HIGH):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 5,
+ \ 'code': 207,
+ \ 'text': 'File modes should always be encapsulated in quotation marks',
+ \ 'type': 'E'
+ \ }
+ \ ],
+ \ ale_linters#salt#salt_lint#Handle(255, [
+ \ '[{"id": "207", "message": "File modes should always be encapsulated in quotation marks", "filename": "test.sls", "linenumber": 5, "line": " - mode: 0755", "severity": "HIGH"}]'
+ \ ])
+
+
+Execute(The salt handler should parse lines correctly and show error in severity not HIGH):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 27,
+ \ 'code': 204,
+ \ 'text': 'Lines should be no longer that 160 chars',
+ \ 'type': 'W'
+ \ }
+ \ ],
+ \ ale_linters#salt#salt_lint#Handle(255, [
+ \ '[{"id": "204", "message": "Lines should be no longer that 160 chars", "filename": "test2.sls", "linenumber": 27, "line": "this line is definitely longer than 160 chars, this line is definitely longer than 160 chars, this line is definitely longer than 160 chars", "severity": "VERY_LOW"}]'
+ \ ])
diff --git a/test/test_floating_preview.vader b/test/test_floating_preview.vader
new file mode 100644
index 00000000..43415556
--- /dev/null
+++ b/test/test_floating_preview.vader
@@ -0,0 +1,92 @@
+Before:
+ let g:ale_floating_preview = 0
+ let g:ale_hover_to_floating_preview = 0
+ let g:ale_detail_to_floating_preview = 0
+
+ runtime autoload/ale/floating_preview.vim
+
+ let g:floated_lines = []
+ let g:floating_preview_show_called = 0
+
+ " Stub out so we can track the call
+ function! ale#floating_preview#Show(lines, ...) abort
+ let g:floating_preview_show_called = 1
+ let g:floated_lines = a:lines
+ endfunction
+
+ let g:ale_buffer_info = {
+ \ bufnr('%'): {
+ \ 'loclist': [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 10,
+ \ 'bufnr': bufnr('%'),
+ \ 'vcol': 0,
+ \ 'linter_name': 'notalinter',
+ \ 'nr': -1,
+ \ 'type': 'E',
+ \ 'code': 'semi',
+ \ 'text': "Missing semicolon.\r",
+ \ 'detail': "Every statement should end with a semicolon\nsecond line",
+ \ },
+ \ ],
+ \ }
+ \}
+
+ call ale#linter#Reset()
+ call ale#linter#PreventLoading('javascript')
+
+After:
+ Restore
+
+ let g:ale_floating_preview = 0
+ let g:ale_hover_to_floating_preview = 0
+ let g:ale_detail_to_floating_preview = 0
+
+ call cursor(1, 1)
+
+ let g:ale_buffer_info = {}
+
+ " Close the preview window if it's open.
+ if &filetype is# 'ale-preview'
+ noautocmd :q!
+ endif
+
+ call ale#linter#Reset()
+
+
+Given javascript(A file with warnings/errors):
+ var x = 3 + 12345678
+ var x = 5*2 + parseInt("10");
+ // comment
+
+Execute(Floating preview is used with ALEDetail when g:ale_floating_preview set):
+ let g:ale_floating_preview = 1
+
+ call cursor(1, 10)
+
+ ALEDetail
+
+ let expected = ["Every statement should end with a semicolon", "second line"]
+
+ AssertEqual 1, g:floating_preview_show_called
+ AssertEqual expected, g:floated_lines
+
+Execute(Floating preview is used with ALEDetail when g:ale_detail_to_floating_preview set):
+ let g:ale_detail_to_floating_preview = 1
+
+ call cursor(1, 10)
+
+ ALEDetail
+
+ let expected = ["Every statement should end with a semicolon", "second line"]
+
+ AssertEqual 1, g:floating_preview_show_called
+ AssertEqual expected, g:floated_lines
+
+Execute(Floating preview is not used with ALEDetail by default):
+ call cursor(1, 10)
+
+ ALEDetail
+
+ AssertEqual 0, g:floating_preview_show_called
diff --git a/test/test_hover.vader b/test/test_hover.vader
index ed756396..7a9c8d91 100644
--- a/test/test_hover.vader
+++ b/test/test_hover.vader
@@ -7,9 +7,25 @@ Before:
let g:item_list = []
let g:show_message_arg_list = []
+ let g:ale_floating_preview = 0
+ let g:ale_hover_to_floating_preview = 0
+ let g:ale_detail_to_floating_preview = 0
+
runtime autoload/ale/linter.vim
runtime autoload/ale/lsp.vim
+ runtime autoload/ale/lsp_linter.vim
runtime autoload/ale/util.vim
+ runtime autoload/ale/floating_preview.vim
+ runtime autoload/ale/hover.vim
+
+ let g:floated_lines = []
+ let g:floating_preview_show_called = 0
+
+ " Stub out so we can track the call
+ function! ale#floating_preview#Show(lines, ...) abort
+ let g:floating_preview_show_called = 1
+ let g:floated_lines = a:lines
+ endfunction
function! ale#lsp_linter#StartLSP(buffer, linter, callback) abort
let g:Callback = a:callback
@@ -50,6 +66,7 @@ Before:
\)
endfunction
+
After:
call ale#hover#SetMap({})
call ale#test#RestoreDirectory()
@@ -65,6 +82,7 @@ After:
runtime autoload/ale/lsp_linter.vim
runtime autoload/ale/lsp.vim
runtime autoload/ale/util.vim
+ runtime autoload/ale/floating_preview.vim
Given python(Some Python file):
foo
@@ -168,6 +186,28 @@ Execute(LSP hover response with lists of strings and marked strings should be ha
\], g:show_message_arg_list
AssertEqual {}, ale#hover#GetMap()
+Execute(LSP hover with ale_floating_preview should float):
+ let g:ale_floating_preview = 1
+
+ call HandleValidLSPResult({'contents': "the message\ncontinuing"})
+
+ AssertEqual 1, g:floating_preview_show_called
+ AssertEqual ["the message", "continuing"], g:floated_lines
+
+Execute(LSP hover ale_hover_to_floating_preview should float):
+ let g:ale_hover_to_floating_preview = 1
+
+ call HandleValidLSPResult({'contents': "the message\ncontinuing"})
+
+ AssertEqual 1, g:floating_preview_show_called
+ AssertEqual ["the message", "continuing"], g:floated_lines
+
+
+Execute(LSP hover by default should not float):
+ call HandleValidLSPResult({'contents': "the message\ncontinuing"})
+
+ AssertEqual 0, g:floating_preview_show_called
+
Execute(tsserver responses for documentation requests should be handled):
call ale#hover#SetMap({3: {'show_documentation': 1, 'buffer': bufnr('')}})
@@ -187,3 +227,46 @@ Execute(tsserver responses for documentation requests should be handled):
" The preview window should show the text.
AssertEqual ['foo is a very good method'], ale#test#GetPreviewWindowText()
silent! pclose
+
+Execute(hover with show_documentation should be in the preview window, not floating):
+ let g:ale_hover_to_floating_preview = 1
+ let g:ale_floating_preview = 1
+
+ call ale#hover#SetMap({3: {'show_documentation': 1, 'buffer': bufnr('')}})
+
+ call ale#hover#HandleTSServerResponse(
+ \ 1,
+ \ {
+ \ 'command': 'quickinfo',
+ \ 'request_seq': 3,
+ \ 'success': v:true,
+ \ 'body': {
+ \ 'documentation': 'foo is a very good method',
+ \ 'displayString': 'foo bar ',
+ \ },
+ \ }
+ \)
+
+ let expected = ["Every statement should end with a semicolon", "second line"]
+
+ AssertEqual 0, g:floating_preview_show_called
+
+Execute(TSServer hover without show_documentation and ale_floating_preview should float):
+ let g:ale_floating_preview = 1
+
+ call ale#hover#SetMap({3: {'buffer': bufnr('')}})
+
+ call ale#hover#HandleTSServerResponse(
+ \ 1,
+ \ {
+ \ 'command': 'quickinfo',
+ \ 'request_seq': 3,
+ \ 'success': v:true,
+ \ 'body': {
+ \ 'displayString': "the message\ncontinuing",
+ \ },
+ \ }
+ \)
+
+ AssertEqual 1, g:floating_preview_show_called
+ AssertEqual ["the message", "continuing"], g:floated_lines