summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--ale_linters/go/gobuild.vim5
-rw-r--r--ale_linters/go/govet.vim7
-rw-r--r--ale_linters/julia/languageserver.vim2
-rw-r--r--ale_linters/python/flake8.vim6
-rw-r--r--ale_linters/python/mypy.vim6
-rw-r--r--ale_linters/python/prospector.vim7
-rw-r--r--ale_linters/python/pycodestyle.vim6
-rw-r--r--ale_linters/python/pyflakes.vim6
-rw-r--r--ale_linters/python/pylint.vim6
-rw-r--r--ale_linters/python/pyls.vim6
-rw-r--r--ale_linters/python/pyre.vim6
-rw-r--r--ale_linters/ruby/solargraph.vim20
-rw-r--r--autoload/ale/c.vim2
-rw-r--r--autoload/ale/engine.vim16
-rw-r--r--autoload/ale/fix.vim9
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/gomod.vim10
-rw-r--r--autoload/ale/lsp_linter.vim16
-rw-r--r--autoload/ale/python.vim7
-rw-r--r--autoload/ale/toggle.vim19
-rw-r--r--autoload/ale/util.vim2
-rw-r--r--doc/ale-go.txt9
-rw-r--r--doc/ale-python.txt80
-rw-r--r--doc/ale-ruby.txt16
-rw-r--r--doc/ale.txt2
-rw-r--r--plugin/ale.vim7
-rw-r--r--test/command_callback/test_flake8_command_callback.vader11
-rw-r--r--test/command_callback/test_gobuild_command_callback.vader12
-rw-r--r--test/command_callback/test_govet_command_callback.vader11
-rw-r--r--test/command_callback/test_julia_languageserver_callbacks.vader4
-rw-r--r--test/command_callback/test_mypy_command_callback.vader8
-rw-r--r--test/command_callback/test_prospector_command_callback.vader8
-rw-r--r--test/command_callback/test_pycodestyle_command_callback.vader7
-rw-r--r--test/command_callback/test_pyflakes_command_callback.vader7
-rw-r--r--test/command_callback/test_pylint_command_callback.vader9
-rw-r--r--test/command_callback/test_pyls_command_callback.vader7
-rw-r--r--test/command_callback/test_pyre_command_callback.vader7
-rw-r--r--test/command_callback/test_ruby_solargraph.vader11
-rw-r--r--test/fixers/test_gomod_fixer_callback.vader24
-rw-r--r--test/go_files/go.mod1
-rw-r--r--test/python_fixtures/pipenv/Pipfile.lock0
-rw-r--r--test/test_autocmd_commands.vader17
-rw-r--r--test/test_c_flag_parsing.vader2
-rw-r--r--test/test_python_pipenv.vader13
-rw-r--r--test/test_redundant_tsserver_rendering_avoided.vader136
-rw-r--r--test/test_writefile_function.vader21
47 files changed, 538 insertions, 65 deletions
diff --git a/README.md b/README.md
index 06575e35..b225c9c3 100644
--- a/README.md
+++ b/README.md
@@ -124,7 +124,7 @@ formatting.
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
| Git Commit Messages | [gitlint](https://github.com/jorisroovers/gitlint) |
| GLSL | [glslang](https://github.com/KhronosGroup/glslang), [glslls](https://github.com/svenstaro/glsl-language-server) |
-| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go vet](https://golang.org/cmd/vet/) !!, [golint](https://godoc.org/github.com/golang/lint), [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) !!, [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !!, [golangserver](https://github.com/sourcegraph/go-langserver), [golangci-lint](https://github.com/golangci/golangci-lint) !! |
+| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go mod](https://golang.org/cmd/go/) !!, [go vet](https://golang.org/cmd/vet/) !!, [golint](https://godoc.org/github.com/golang/lint), [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) !!, [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !!, [golangserver](https://github.com/sourcegraph/go-langserver), [golangci-lint](https://github.com/golangci/golangci-lint) !! |
| GraphQL | [eslint](http://eslint.org/), [gqlint](https://github.com/happylinks/gqlint), [prettier](https://github.com/prettier/prettier) |
| Hack | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/hhvm/tree/master/hphp/hack/hackfmt), [hhast](https://github.com/hhvm/hhast) (disabled by default; see `:help ale-integration-hack`) |
| Haml | [haml-lint](https://github.com/brigade/haml-lint) |
@@ -162,7 +162,7 @@ formatting.
| proto | [protoc-gen-lint](https://github.com/ckaznocha/protoc-gen-lint) |
| Pug | [pug-lint](https://github.com/pugjs/pug-lint) |
| Puppet | [languageserver](https://github.com/lingua-pupuli/puppet-editor-services), [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
-| Python | [autopep8](https://github.com/hhatto/autopep8), [black](https://github.com/ambv/black), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [prospector](http://github.com/landscapeio/prospector), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pyls](https://github.com/palantir/python-language-server), [pyre](https://github.com/facebook/pyre-check), [pylint](https://www.pylint.org/) !!, [vulture](https://github.com/jendrikseipp/vulture) !!, [yapf](https://github.com/google/yapf) |
+| Python | [autopep8](https://github.com/hhatto/autopep8), [black](https://github.com/ambv/black), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [prospector](https://github.com/PyCQA/prospector), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pyls](https://github.com/palantir/python-language-server), [pyre](https://github.com/facebook/pyre-check), [pylint](https://www.pylint.org/) !!, [vulture](https://github.com/jendrikseipp/vulture) !!, [yapf](https://github.com/google/yapf) |
| QML | [qmlfmt](https://github.com/jesperhh/qmlfmt), [qmllint](https://github.com/qt/qtdeclarative/tree/5.11/tools/qmllint) |
| R | [lintr](https://github.com/jimhester/lintr) |
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server), [refmt](https://github.com/reasonml/reason-cli) |
diff --git a/ale_linters/go/gobuild.vim b/ale_linters/go/gobuild.vim
index a44449f1..cef1ff88 100644
--- a/ale_linters/go/gobuild.vim
+++ b/ale_linters/go/gobuild.vim
@@ -3,6 +3,7 @@
" Description: go build for Go files
" inspired by work from dzhou121 <dzhou121@gmail.com>
+call ale#Set('go_go_executable', 'go')
call ale#Set('go_gobuild_options', '')
function! ale_linters#go#gobuild#GetCommand(buffer) abort
@@ -10,7 +11,7 @@ function! ale_linters#go#gobuild#GetCommand(buffer) abort
" Run go test in local directory with relative path
return ale#path#BufferCdString(a:buffer)
- \ . 'go test'
+ \ . ale#Var(a:buffer, 'go_go_executable') . ' test'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' -c -o /dev/null ./'
endfunction
@@ -47,7 +48,7 @@ endfunction
call ale#linter#Define('go', {
\ 'name': 'gobuild',
\ 'aliases': ['go build'],
-\ 'executable': 'go',
+\ 'executable_callback': ale#VarFunc('go_go_executable'),
\ 'command_callback': 'ale_linters#go#gobuild#GetCommand',
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#go#gobuild#Handler',
diff --git a/ale_linters/go/govet.vim b/ale_linters/go/govet.vim
index 84c23236..3d0d2adf 100644
--- a/ale_linters/go/govet.vim
+++ b/ale_linters/go/govet.vim
@@ -4,20 +4,23 @@
" Author: John Eikenberry <jae@zhar.net>
" Description: updated to work with go1.10
+call ale#Set('go_go_executable', 'go')
call ale#Set('go_govet_options', '')
function! ale_linters#go#govet#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'go_govet_options')
- return ale#path#BufferCdString(a:buffer) . ' go vet .'
+ return ale#path#BufferCdString(a:buffer) . ' '
+ \ . ale#Var(a:buffer, 'go_go_executable') . ' vet '
\ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' .'
endfunction
call ale#linter#Define('go', {
\ 'name': 'govet',
\ 'aliases': ['go vet'],
\ 'output_stream': 'stderr',
-\ 'executable': 'go',
+\ 'executable_callback': ale#VarFunc('go_go_executable'),
\ 'command_callback': 'ale_linters#go#govet#GetCommand',
\ 'callback': 'ale#handlers#go#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/julia/languageserver.vim b/ale_linters/julia/languageserver.vim
index b5d90bff..cd2000de 100644
--- a/ale_linters/julia/languageserver.vim
+++ b/ale_linters/julia/languageserver.vim
@@ -6,7 +6,7 @@ call ale#Set('julia_executable', 'julia')
function! ale_linters#julia#languageserver#GetCommand(buffer) abort
let l:julia_executable = ale#Var(a:buffer, 'julia_executable')
- let l:cmd_string = 'using LanguageServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, false); server.runlinter = true; run(server);'
+ let l:cmd_string = 'using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);'
return ale#Escape(l:julia_executable) . ' --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string)
endfunction
diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim
index 358f51a4..9dcdacc6 100644
--- a/ale_linters/python/flake8.vim
+++ b/ale_linters/python/flake8.vim
@@ -5,12 +5,18 @@ call ale#Set('python_flake8_executable', 'flake8')
call ale#Set('python_flake8_options', '')
call ale#Set('python_flake8_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_flake8_change_directory', 1)
+call ale#Set('python_flake8_auto_pipenv', 0)
function! s:UsingModule(buffer) abort
return ale#Var(a:buffer, 'python_flake8_options') =~# ' *-m flake8'
endfunction
function! ale_linters#python#flake8#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_flake8_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
if !s:UsingModule(a:buffer)
return ale#python#FindExecutable(a:buffer, 'python_flake8', ['flake8'])
endif
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index b38ccdeb..0c90a3c7 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -5,8 +5,14 @@ call ale#Set('python_mypy_executable', 'mypy')
call ale#Set('python_mypy_ignore_invalid_syntax', 0)
call ale#Set('python_mypy_options', '')
call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('python_mypy_auto_pipenv', 0)
function! ale_linters#python#mypy#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_mypy_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy'])
endfunction
diff --git a/ale_linters/python/prospector.vim b/ale_linters/python/prospector.vim
index fff37147..b01cec87 100644
--- a/ale_linters/python/prospector.vim
+++ b/ale_linters/python/prospector.vim
@@ -1,6 +1,8 @@
" Author: chocoelho <carlospecter@gmail.com>
" Description: prospector linter python files
+call ale#Set('python_prospector_auto_pipenv', 0)
+
let g:ale_python_prospector_executable =
\ get(g:, 'ale_python_prospector_executable', 'prospector')
@@ -10,6 +12,11 @@ let g:ale_python_prospector_options =
let g:ale_python_prospector_use_global = get(g:, 'ale_python_prospector_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#python#prospector#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_prospector_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
return ale#python#FindExecutable(a:buffer, 'python_prospector', ['prospector'])
endfunction
diff --git a/ale_linters/python/pycodestyle.vim b/ale_linters/python/pycodestyle.vim
index de96363f..f0269585 100644
--- a/ale_linters/python/pycodestyle.vim
+++ b/ale_linters/python/pycodestyle.vim
@@ -4,8 +4,14 @@
call ale#Set('python_pycodestyle_executable', 'pycodestyle')
call ale#Set('python_pycodestyle_options', '')
call ale#Set('python_pycodestyle_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('python_pycodestyle_auto_pipenv', 0)
function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycodestyle_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
return ale#python#FindExecutable(a:buffer, 'python_pycodestyle', ['pycodestyle'])
endfunction
diff --git a/ale_linters/python/pyflakes.vim b/ale_linters/python/pyflakes.vim
index 86ff8773..091408d5 100644
--- a/ale_linters/python/pyflakes.vim
+++ b/ale_linters/python/pyflakes.vim
@@ -3,8 +3,14 @@
call ale#Set('python_pyflakes_executable', 'pyflakes')
call ale#Set('python_pyflakes_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('python_pyflakes_auto_pipenv', 0)
function! ale_linters#python#pyflakes#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflakes_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
return ale#python#FindExecutable(a:buffer, 'python_pyflakes', ['pyflakes'])
endfunction
diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim
index 9239f835..01c3cb37 100644
--- a/ale_linters/python/pylint.vim
+++ b/ale_linters/python/pylint.vim
@@ -5,8 +5,14 @@ call ale#Set('python_pylint_executable', 'pylint')
call ale#Set('python_pylint_options', '')
call ale#Set('python_pylint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pylint_change_directory', 1)
+call ale#Set('python_pylint_auto_pipenv', 0)
function! ale_linters#python#pylint#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylint_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint'])
endfunction
diff --git a/ale_linters/python/pyls.vim b/ale_linters/python/pyls.vim
index ae71f022..83fe8066 100644
--- a/ale_linters/python/pyls.vim
+++ b/ale_linters/python/pyls.vim
@@ -3,8 +3,14 @@
call ale#Set('python_pyls_executable', 'pyls')
call ale#Set('python_pyls_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('python_pyls_auto_pipenv', 0)
function! ale_linters#python#pyls#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyls_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
return ale#python#FindExecutable(a:buffer, 'python_pyls', ['pyls'])
endfunction
diff --git a/ale_linters/python/pyre.vim b/ale_linters/python/pyre.vim
index 5efef409..adc185f2 100644
--- a/ale_linters/python/pyre.vim
+++ b/ale_linters/python/pyre.vim
@@ -3,8 +3,14 @@
call ale#Set('python_pyre_executable', 'pyre')
call ale#Set('python_pyre_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('python_pyre_auto_pipenv', 0)
function! ale_linters#python#pyre#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyre_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
return ale#python#FindExecutable(a:buffer, 'python_pyre', ['pyre'])
endfunction
diff --git a/ale_linters/ruby/solargraph.vim b/ale_linters/ruby/solargraph.vim
index 2aad3af6..7ca0399f 100644
--- a/ale_linters/ruby/solargraph.vim
+++ b/ale_linters/ruby/solargraph.vim
@@ -1,20 +1,20 @@
" Author: Horacio Sanson - https://github.com/hsanson
" Description: Solargraph Language Server https://solargraph.org/
+"
+" Author: Devon Meunier <devon.meunier@gmail.com>
+" Description: updated to use stdio
-call ale#Set('ruby_solargraph_host', '127.0.0.1')
-call ale#Set('ruby_solargraph_port', '7658')
+call ale#Set('ruby_solargraph_executable', 'solargraph')
-function! ale_linters#ruby#solargraph#GetAddress(buffer) abort
- let l:host = ale#Var(a:buffer, 'ruby_solargraph_host')
- let l:port = ale#Var(a:buffer, 'ruby_solargraph_port')
-
- return l:host . ':' . l:port
+function! ale_linters#ruby#solargraph#GetCommand(buffer) abort
+ return '%e' . ale#Pad('stdio')
endfunction
call ale#linter#Define('ruby', {
\ 'name': 'solargraph',
-\ 'lsp': 'socket',
-\ 'address_callback': 'ale_linters#ruby#solargraph#GetAddress',
+\ 'lsp': 'stdio',
\ 'language': 'ruby',
-\ 'project_root_callback': 'ale#ruby#FindProjectRoot'
+\ 'executable_callback': ale#VarFunc('ruby_solargraph_executable'),
+\ 'command_callback': 'ale_linters#ruby#solargraph#GetCommand',
+\ 'project_root_callback': 'ale#ruby#FindProjectRoot',
\})
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index e7b43d88..ce59ae31 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -55,7 +55,7 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
" Check if cflag contained a '-' and should not have been splitted
let l:option_list = split(l:option, '\zs')
- if l:option_list[-1] isnot# ' '
+ if len(l:option_list) > 0 && l:option_list[-1] isnot# ' '
continue
endif
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index b6c2d3c9..05db0e49 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -18,6 +18,22 @@ if !has_key(s:, 'executable_cache_map')
let s:executable_cache_map = {}
endif
+
+function! ale#engine#CleanupEveryBuffer() abort
+ for l:key in keys(g:ale_buffer_info)
+ " The key could be a filename or a buffer number, so try and
+ " convert it to a number. We need a number for the other
+ " functions.
+ let l:buffer = str2nr(l:key)
+
+ if l:buffer > 0
+ " Stop all jobs and clear the results for everything, and delete
+ " all of the data we stored for the buffer.
+ call ale#engine#Cleanup(l:buffer)
+ endif
+ endfor
+endfunction
+
function! ale#engine#ResetExecutableCache() abort
let s:executable_cache_map = {}
endfunction
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 1ae1a4a1..03652ecf 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -30,7 +30,14 @@ function! ale#fix#ApplyQueuedFixes() abort
call winrestview(l:save)
endif
- call setline(1, l:data.output)
+ " If the file is in DOS mode, we have to remove carriage returns from
+ " the ends of lines before calling setline(), or we will see them
+ " twice.
+ let l:lines_to_set = getbufvar(l:buffer, '&fileformat') is# 'dos'
+ \ ? map(copy(l:data.output), 'substitute(v:val, ''\r\+$'', '''', '''')')
+ \ : l:data.output
+
+ call setline(1, l:lines_to_set)
if l:data.should_save
if empty(&buftype)
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index eb12f22d..76cce87f 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -145,6 +145,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['go'],
\ 'description': 'Fix Go files imports with goimports.',
\ },
+\ 'gomod': {
+\ 'function': 'ale#fixers#gomod#Fix',
+\ 'suggested_filetypes': ['gomod'],
+\ 'description': 'Fix Go module files with go mod edit -fmt.',
+\ },
\ 'tslint': {
\ 'function': 'ale#fixers#tslint#Fix',
\ 'suggested_filetypes': ['typescript'],
diff --git a/autoload/ale/fixers/gomod.vim b/autoload/ale/fixers/gomod.vim
new file mode 100644
index 00000000..68895f9b
--- /dev/null
+++ b/autoload/ale/fixers/gomod.vim
@@ -0,0 +1,10 @@
+call ale#Set('go_go_executable', 'go')
+
+function! ale#fixers#gomod#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'go_go_executable')
+
+ return {
+ \ 'command': ale#Escape(l:executable) . ' mod edit -fmt %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim
index 8fbad12f..a11c76bc 100644
--- a/autoload/ale/lsp_linter.vim
+++ b/autoload/ale/lsp_linter.vim
@@ -55,16 +55,29 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
endif
let l:thislist = ale#lsp#response#ReadTSServerDiagnostics(a:response)
+ let l:no_changes = 0
" tsserver sends syntax and semantic errors in separate messages, so we
" have to collect the messages separately for each buffer and join them
" back together again.
if a:error_type is# 'syntax'
+ if len(l:thislist) is 0 && len(get(l:info, 'syntax_loclist', [])) is 0
+ let l:no_changes = 1
+ endif
+
let l:info.syntax_loclist = l:thislist
else
+ if len(l:thislist) is 0 && len(get(l:info, 'semantic_loclist', [])) is 0
+ let l:no_changes = 1
+ endif
+
let l:info.semantic_loclist = l:thislist
endif
+ if l:no_changes
+ return
+ endif
+
let l:loclist = get(l:info, 'semantic_loclist', [])
\ + get(l:info, 'syntax_loclist', [])
@@ -99,9 +112,10 @@ endfunction
function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
let l:method = get(a:response, 'method', '')
- let l:linter_name = get(s:lsp_linter_map, a:conn_id, '')
if get(a:response, 'jsonrpc', '') is# '2.0' && has_key(a:response, 'error')
+ let l:linter_name = get(s:lsp_linter_map, a:conn_id, '')
+
call s:HandleLSPErrorMessage(l:linter_name, a:response)
elseif l:method is# 'textDocument/publishDiagnostics'
call s:HandleLSPDiagnostics(a:conn_id, a:response)
diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim
index 1f963431..8d6bf1f0 100644
--- a/autoload/ale/python.vim
+++ b/autoload/ale/python.vim
@@ -1,6 +1,8 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Functions for integrating with Python linters.
+call ale#Set('python_auto_pipenv', '0')
+
let s:sep = has('win32') ? '\' : '/'
" bin is used for Unix virtualenv directories, and Scripts is for Windows.
let s:bin_dir = has('unix') ? 'bin' : 'Scripts'
@@ -107,3 +109,8 @@ function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort
return ale#Var(a:buffer, a:base_var_name . '_executable')
endfunction
+
+" Detects whether a pipenv environment is present.
+function! ale#python#PipenvPresent(buffer) abort
+ return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# ''
+endfunction
diff --git a/autoload/ale/toggle.vim b/autoload/ale/toggle.vim
index 1d052b4f..8e642b3f 100644
--- a/autoload/ale/toggle.vim
+++ b/autoload/ale/toggle.vim
@@ -15,21 +15,6 @@ function! s:DisablePostamble() abort
endif
endfunction
-function! s:CleanupEveryBuffer() abort
- for l:key in keys(g:ale_buffer_info)
- " The key could be a filename or a buffer number, so try and
- " convert it to a number. We need a number for the other
- " functions.
- let l:buffer = str2nr(l:key)
-
- if l:buffer > 0
- " Stop all jobs and clear the results for everything, and delete
- " all of the data we stored for the buffer.
- call ale#engine#Cleanup(l:buffer)
- endif
- endfor
-endfunction
-
function! ale#toggle#Toggle() abort
let g:ale_enabled = !get(g:, 'ale_enabled')
@@ -40,7 +25,7 @@ function! ale#toggle#Toggle() abort
call ale#balloon#Enable()
endif
else
- call s:CleanupEveryBuffer()
+ call ale#engine#CleanupEveryBuffer()
call s:DisablePostamble()
if exists('*ale#balloon#Disable')
@@ -64,7 +49,7 @@ function! ale#toggle#Disable() abort
endfunction
function! ale#toggle#Reset() abort
- call s:CleanupEveryBuffer()
+ call ale#engine#CleanupEveryBuffer()
call ale#highlight#UpdateHighlights()
endfunction
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index 58a2065e..e0491653 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -405,7 +405,7 @@ endfunction
" the buffer.
function! ale#util#Writefile(buffer, lines, filename) abort
let l:corrected_lines = getbufvar(a:buffer, '&fileformat') is# 'dos'
- \ ? map(copy(a:lines), 'v:val . "\r"')
+ \ ? map(copy(a:lines), 'substitute(v:val, ''\r*$'', ''\r'', '''')')
\ : a:lines
call writefile(l:corrected_lines, a:filename) " no-custom-checks
diff --git a/doc/ale-go.txt b/doc/ale-go.txt
index 1d55763e..71b248ee 100644
--- a/doc/ale-go.txt
+++ b/doc/ale-go.txt
@@ -20,6 +20,15 @@ the benefit of running a number of linters, more than ALE would by default,
while ensuring it doesn't run any linters known to be slow or resource
intensive.
+g:ale_go_go_executable *g:ale_go_go_options*
+ *b:ale_go_go_options*
+
+ Type: |String|
+ Default: `'go'`
+
+ The executable that will be run for the `gobuild` and `govet` linters, and
+ the gomod` fixer.
+
===============================================================================
gobuild *ale-go-gobuild*
diff --git a/doc/ale-python.txt b/doc/ale-python.txt
index b5c469b1..0b8e1746 100644
--- a/doc/ale-python.txt
+++ b/doc/ale-python.txt
@@ -2,6 +2,14 @@
ALE Python Integration *ale-python-options*
+g:ale_python_auto_pipenv *g:ale_python_auto_pipenv*
+ *b:ale_python_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.
+
===============================================================================
ALE Python Project Root Behavior *ale-python-root*
@@ -137,6 +145,15 @@ g:ale_python_flake8_use_global *g:ale_python_flake8_use_global*
Both variables can be set with `b:` buffer variables instead.
+g:ale_python_flake8_auto_pipenv *g:ale_python_flake8_auto_pipenv*
+ *b:ale_python_flake8_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.
+
+
===============================================================================
isort *ale-python-isort*
@@ -211,6 +228,15 @@ g:ale_python_mypy_use_global *g:ale_python_mypy_use_global*
See |ale-integrations-local-executables|
+g:ale_python_mypy_auto_pipenv *g:ale_python_mypy_auto_pipenv*
+ *b:ale_python_mypy_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.
+
+
===============================================================================
prospector *ale-python-prospector*
@@ -253,6 +279,15 @@ g:ale_python_prospector_use_global *g:ale_python_prospector_use_global*
See |ale-integrations-local-executables|
+g:ale_python_prospector_auto_pipenv *g:ale_python_prospector_auto_pipenv*
+ *b:ale_python_prospector_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.
+
+
===============================================================================
pycodestyle *ale-python-pycodestyle*
@@ -284,6 +319,15 @@ g:ale_python_pycodestyle_use_global *g:ale_python_pycodestyle_use_global*
See |ale-integrations-local-executables|
+g:ale_python_pycodestyle_auto_pipenv *g:ale_python_pycodestyle_auto_pipenv*
+ *b:ale_python_pycodestyle_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.
+
+
===============================================================================
pyflakes *ale-python-pyflakes*
@@ -298,6 +342,15 @@ g:ale_python_pyflakes_executable *g:ale_python_pyflakes_executable*
Set this to `'pipenv'` to invoke `'pipenv` `run` `pyflakes'`.
+g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv*
+ *b:ale_python_pyflakes_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.
+
+
===============================================================================
pylint *ale-python-pylint*
@@ -350,6 +403,15 @@ g:ale_python_pylint_use_global *g:ale_python_pylint_use_global*
See |ale-integrations-local-executables|
+g:ale_python_pylint_auto_pipenv *g:ale_python_pylint_auto_pipenv*
+ *b:ale_python_pylint_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.
+
+
===============================================================================
pyls *ale-python-pyls*
@@ -374,6 +436,15 @@ g:ale_python_pyls_use_global *g:ale_python_pyls_use_global*
See |ale-integrations-local-executables|
+g:ale_python_pyls_auto_pipenv *g:ale_python_pyls_auto_pipenv*
+ *b:ale_python_pyls_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.
+
+
===============================================================================
pyre *ale-python-pyre*
@@ -398,6 +469,15 @@ g:ale_python_pyre_use_global *g:ale_python_pyre_use_global*
See |ale-integrations-local-executables|
+g:ale_python_pyre_auto_pipenv *g:ale_python_pyre_auto_pipenv*
+ *b:ale_python_pyre_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.
+
+
===============================================================================
vulture *ale-python-vulture*
diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt
index 810a1d45..f8a41999 100644
--- a/doc/ale-ruby.txt
+++ b/doc/ale-ruby.txt
@@ -120,19 +120,13 @@ g:ale_ruby_rufo_executable *g:ale_ruby_rufo_executable*
===============================================================================
solargraph *ale-ruby-solargraph*
-g:ale_ruby_solargraph_host *g:ale_ruby_solargraph_host*
- *b:ale_ruby_solargraph_host*
+g:ale_ruby_solargraph_executable *g:ale_ruby_solargraph_executable*
+ *b:ale_ruby_solargraph_executable*
Type: String
- Default: `'127.0.0.1'`
+ Default: `'solargraph'`
- The host/ip where the solargraph language server is running.
-
-g:ale_ruby_solargraph_port *g:ale_ruby_solargraph_port*
- *b:ale_ruby_solargraph_port*
- Type: String
- Default: `'7658'`
-
- The listening port where the solargraph language server is running.
+ Override the invoked solargraph binary. This is useful for running solargraph
+ from binstubs or a bundle.
===============================================================================
diff --git a/doc/ale.txt b/doc/ale.txt
index 9a81b237..46ff08b0 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -402,7 +402,7 @@ Notes:
* FusionScript: `fusion-lint`
* Git Commit Messages: `gitlint`
* GLSL: glslang, `glslls`
-* Go: `gofmt`, `goimports`, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!!
+* Go: `gofmt`, `goimports`, `go mod`!!, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!!
* GraphQL: `eslint`, `gqlint`, `prettier`
* Hack: `hack`, `hackfmt`, `hhast`
* Haml: `haml-lint`
diff --git a/plugin/ale.vim b/plugin/ale.vim
index 36edb48c..41da7c74 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -133,6 +133,9 @@ let g:ale_history_log_output = get(g:, 'ale_history_log_output', 1)
" Enable automatic completion with LSP servers and tsserver
let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0)
+" Enable automatic detection of pipenv for Python linters.
+let g:ale_python_auto_pipenv = get(g:, 'ale_python_auto_pipenv', 0)
+
if g:ale_set_balloons
call ale#balloon#Enable()
endif
@@ -224,4 +227,8 @@ augroup ALECleanupGroup
" Clean up buffers automatically when they are unloaded.
autocmd BufDelete * if exists('*ale#engine#Cleanup') | call ale#engine#Cleanup(str2nr(expand('<abuf>'))) | endif
autocmd QuitPre * call ale#events#QuitEvent(str2nr(expand('<abuf>')))
+
+ if exists('##VimSuspend')
+ autocmd VimSuspend * if exists('*ale#engine#CleanupEveryBuffer') | call ale#engine#CleanupEveryBuffer() | endif
+ endif
augroup END
diff --git a/test/command_callback/test_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader
index f12b6747..ede511e0 100644
--- a/test/command_callback/test_flake8_command_callback.vader
+++ b/test/command_callback/test_flake8_command_callback.vader
@@ -1,5 +1,6 @@
Before:
call ale#assert#SetUpLinterTest('python', 'flake8')
+
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
WithChainResults ['3.0.0']
@@ -152,8 +153,16 @@ Execute(Using `python -m flake8` should be supported for running flake8):
Execute(Setting executable to 'pipenv' should append 'run flake8'):
let g:ale_python_flake8_executable = 'path/to/pipenv'
- " FIXME: pipenv should check the vresion with flake8.
+ " FIXME: pipenv should check the version with flake8.
WithChainResults []
AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run flake8 --format=default -'
+
+Execute(Pipenv is detected when python_flake8_auto_pipenv is set):
+ let g:ale_python_flake8_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('pipenv') . ' run flake8 --format=default --stdin-display-name %s -'
diff --git a/test/command_callback/test_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader
index f9673213..8acbec56 100644
--- a/test/command_callback/test_gobuild_command_callback.vader
+++ b/test/command_callback/test_gobuild_command_callback.vader
@@ -1,9 +1,12 @@
Before:
+ Save g:ale_go_go_executable
+
call ale#assert#SetUpLinterTest('go', 'gobuild')
WithChainResults ['/foo/bar', '/foo/baz']
After:
+ Restore
call ale#assert#TearDownLinterTest()
Execute(The default commands should be correct):
@@ -17,3 +20,12 @@ Execute(Extra options should be supported):
AssertLinter 'go',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'go test --foo-bar -c -o /dev/null ./'
+
+ let g:ale_go_gobuild_options = ''
+
+Execute(The executable should be configurable):
+ let g:ale_go_go_executable = 'foobar'
+
+ AssertLinter 'foobar',
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . 'foobar test -c -o /dev/null ./'
diff --git a/test/command_callback/test_govet_command_callback.vader b/test/command_callback/test_govet_command_callback.vader
index 3718e0a7..ab93a5cb 100644
--- a/test/command_callback/test_govet_command_callback.vader
+++ b/test/command_callback/test_govet_command_callback.vader
@@ -1,12 +1,19 @@
Before:
+ Save g:ale_go_go_executable
+ Save g:ale_go_govet_options
call ale#assert#SetUpLinterTest('go', 'govet')
After:
+ Restore
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet .'
+ AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet .'
Execute(Extra options should be supported):
let g:ale_go_govet_options = '--foo-bar'
- AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet . --foo-bar'
+ AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet --foo-bar .'
+
+Execute(The executable should be configurable):
+ let g:ale_go_go_executable = 'foobar'
+ AssertLinter 'foobar', 'cd ' . ale#Escape(expand('%:p:h')) . ' && foobar vet .'
diff --git a/test/command_callback/test_julia_languageserver_callbacks.vader b/test/command_callback/test_julia_languageserver_callbacks.vader
index 22c6cefe..3bc46e3d 100644
--- a/test/command_callback/test_julia_languageserver_callbacks.vader
+++ b/test/command_callback/test_julia_languageserver_callbacks.vader
@@ -12,7 +12,7 @@ Execute(The default executable path should be correct):
AssertLinter 'julia',
\ ale#Escape('julia') .
\' --startup-file=no --history-file=no -e ' .
- \ ale#Escape('using LanguageServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, false); server.runlinter = true; run(server);')
+ \ ale#Escape('using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);')
Execute(The executable should be configurable):
let g:ale_julia_executable = 'julia-new'
@@ -20,7 +20,7 @@ Execute(The executable should be configurable):
AssertLinter 'julia-new',
\ ale#Escape('julia-new') .
\' --startup-file=no --history-file=no -e ' .
- \ ale#Escape('using LanguageServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, false); server.runlinter = true; run(server);')
+ \ ale#Escape('using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);')
Execute(The project root should be detected correctly):
AssertLSPProject ''
diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader
index 988dfb1b..037d8176 100644
--- a/test/command_callback/test_mypy_command_callback.vader
+++ b/test/command_callback/test_mypy_command_callback.vader
@@ -69,3 +69,11 @@ Execute(Setting executable to 'pipenv' appends 'run mypy'):
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run mypy'
\ . ' --show-column-numbers --shadow-file %s %t %s'
+
+Execute(Pipenv is detected when python_mypy_auto_pipenv is set):
+ let g:ale_python_mypy_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('pipenv') . ' run mypy --show-column-numbers --shadow-file %s %t %s'
diff --git a/test/command_callback/test_prospector_command_callback.vader b/test/command_callback/test_prospector_command_callback.vader
index 316b9883..0d692bde 100644
--- a/test/command_callback/test_prospector_command_callback.vader
+++ b/test/command_callback/test_prospector_command_callback.vader
@@ -10,3 +10,11 @@ Execute(Setting executable to 'pipenv' appends 'run prospector'):
AssertLinter 'path/to/pipenv',
\ ale#Escape('path/to/pipenv') . ' run prospector'
\ . ' --messages-only --absolute-paths --zero-exit --output-format json %s'
+
+Execute(Pipenv is detected when python_prospector_auto_pipenv is set):
+ let g:ale_python_prospector_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#Escape('pipenv') . ' run prospector'
+ \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s'
diff --git a/test/command_callback/test_pycodestyle_command_callback.vader b/test/command_callback/test_pycodestyle_command_callback.vader
index 851eede9..a3a338a9 100644
--- a/test/command_callback/test_pycodestyle_command_callback.vader
+++ b/test/command_callback/test_pycodestyle_command_callback.vader
@@ -24,3 +24,10 @@ Execute(Setting executable to 'pipenv' appends 'run pycodestyle'):
AssertLinter 'path/to/pipenv',
\ ale#Escape('path/to/pipenv') . ' run pycodestyle -'
+
+Execute(Pipenv is detected when python_pycodestyle_auto_pipenv is set):
+ let g:ale_python_pycodestyle_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#Escape('pipenv') . ' run pycodestyle -'
diff --git a/test/command_callback/test_pyflakes_command_callback.vader b/test/command_callback/test_pyflakes_command_callback.vader
index efc925fe..92f83820 100644
--- a/test/command_callback/test_pyflakes_command_callback.vader
+++ b/test/command_callback/test_pyflakes_command_callback.vader
@@ -37,3 +37,10 @@ Execute(Setting executable to 'pipenv' appends 'run pyflakes'):
AssertLinter 'path/to/pipenv',
\ ale#Escape('path/to/pipenv') . ' run pyflakes %t',
+
+Execute(Pipenv is detected when python_pyflakes_auto_pipenv is set):
+ let g:ale_python_pyflakes_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#Escape('pipenv') . ' run pyflakes %t'
diff --git a/test/command_callback/test_pylint_command_callback.vader b/test/command_callback/test_pylint_command_callback.vader
index be2908f9..6b21b127 100644
--- a/test/command_callback/test_pylint_command_callback.vader
+++ b/test/command_callback/test_pylint_command_callback.vader
@@ -68,3 +68,12 @@ Execute(Setting executable to 'pipenv' appends 'run pylint'):
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run pylint'
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
+
+Execute(Pipenv is detected when python_pylint_auto_pipenv is set):
+ let g:ale_python_pylint_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('pipenv') . ' run pylint'
+ \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
diff --git a/test/command_callback/test_pyls_command_callback.vader b/test/command_callback/test_pyls_command_callback.vader
index 53bf3000..531b5b3b 100644
--- a/test/command_callback/test_pyls_command_callback.vader
+++ b/test/command_callback/test_pyls_command_callback.vader
@@ -38,3 +38,10 @@ Execute(Setting executable to 'pipenv' appends 'run pyls'):
let g:ale_python_pyls_executable = 'path/to/pipenv'
AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run pyls'
+
+Execute(Pipenv is detected when python_pyls_auto_pipenv is set):
+ let g:ale_python_pyls_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#Escape('pipenv') . ' run pyls'
diff --git a/test/command_callback/test_pyre_command_callback.vader b/test/command_callback/test_pyre_command_callback.vader
index 6ad19b56..ba57c117 100644
--- a/test/command_callback/test_pyre_command_callback.vader
+++ b/test/command_callback/test_pyre_command_callback.vader
@@ -37,3 +37,10 @@ Execute(Setting executable to 'pipenv' appends 'run pyre'):
AssertLinter 'path/to/pipenv',
\ ale#Escape('path/to/pipenv') . ' run pyre persistent'
+
+Execute(Pipenv is detected when python_pyre_auto_pipenv is set):
+ let g:ale_python_pyre_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#Escape('pipenv') . ' run pyre persistent'
diff --git a/test/command_callback/test_ruby_solargraph.vader b/test/command_callback/test_ruby_solargraph.vader
index b9dd46d8..b39f686e 100644
--- a/test/command_callback/test_ruby_solargraph.vader
+++ b/test/command_callback/test_ruby_solargraph.vader
@@ -7,30 +7,33 @@ Before:
After:
call ale#assert#TearDownLinterTest()
+Execute(command callback should return default string):
+ AssertLinter 'solargraph', ale#Escape('solargraph') . ' stdio'
+
+Execute(command callback executable can be overridden):
+ let g:ale_ruby_solargraph_executable = 'foobar'
+ AssertLinter 'foobar', ale#Escape('foobar') . ' stdio'
+
Execute(should set solargraph for rails app):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/models/thing.rb')
AssertLSPLanguage 'ruby'
AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_rails_app')
- AssertLSPAddress '127.0.0.1:7658'
Execute(should set solargraph for ruby app1):
call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app1/lib/file.rb')
AssertLSPLanguage 'ruby'
AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app1')
- AssertLSPAddress '127.0.0.1:7658'
Execute(should set solargraph for ruby app2):
call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app2/lib/file.rb')
AssertLSPLanguage 'ruby'
AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app2')
- AssertLSPAddress '127.0.0.1:7658'
Execute(should set solargraph for ruby app3):
call ale#test#SetFilename('../ruby_fixtures/valid_ruby_app3/lib/file.rb')
AssertLSPLanguage 'ruby'
AssertLSPOptions {}
AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../ruby_fixtures/valid_ruby_app3')
- AssertLSPAddress '127.0.0.1:7658'
diff --git a/test/fixers/test_gomod_fixer_callback.vader b/test/fixers/test_gomod_fixer_callback.vader
new file mode 100644
index 00000000..a378e961
--- /dev/null
+++ b/test/fixers/test_gomod_fixer_callback.vader
@@ -0,0 +1,24 @@
+Before:
+ Save g:ale_go_go_executable
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_go_go_executable = 'xxxinvalid'
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The gomod callback should return the correct default values):
+ call ale#test#SetFilename('../go_files/go.mod')
+ setl ft=gomod
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' mod edit -fmt'
+ \ . ' %t',
+ \ },
+ \ ale#fixers#gomod#Fix(bufnr(''))
diff --git a/test/go_files/go.mod b/test/go_files/go.mod
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/test/go_files/go.mod
@@ -0,0 +1 @@
+
diff --git a/test/python_fixtures/pipenv/Pipfile.lock b/test/python_fixtures/pipenv/Pipfile.lock
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/python_fixtures/pipenv/Pipfile.lock
diff --git a/test/test_autocmd_commands.vader b/test/test_autocmd_commands.vader
index 8d5048f0..4bb894ba 100644
--- a/test/test_autocmd_commands.vader
+++ b/test/test_autocmd_commands.vader
@@ -175,10 +175,19 @@ Execute (g:ale_lint_on_filetype_changed = 1 should bind the FileType event):
\ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''\v^FileType''')
Execute (ALECleanupGroup should include the right commands):
- AssertEqual [
- \ 'BufDelete * if exists(''*ale#engine#Cleanup'') | call ale#engine#Cleanup(str2nr(expand(''<abuf>''))) | endif',
- \ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))',
- \], CheckAutocmd('ALECleanupGroup')
+ if exists('##VimSuspend')
+ AssertEqual [
+ \ 'BufDelete * if exists(''*ale#engine#Cleanup'') | call ale#engine#Cleanup(str2nr(expand(''<abuf>''))) | endif',
+ \ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))',
+ \ 'VimSuspend * if exists(''*ale#engine#CleanupEveryBuffer'') | call ale#engine#CleanupEveryBuffer() | endif',
+ \], CheckAutocmd('ALECleanupGroup')
+ else
+ AssertEqual [
+ \ 'BufDelete * if exists(''*ale#engine#Cleanup'') | call ale#engine#Cleanup(str2nr(expand(''<abuf>''))) | endif',
+ \ 'QuitPre * call ale#events#QuitEvent(str2nr(expand(''<abuf>'')))',
+ \], CheckAutocmd('ALECleanupGroup')
+ endif
+
Execute(Enabling completion should set up autocmd events correctly):
let g:ale_completion_enabled = 0
diff --git a/test/test_c_flag_parsing.vader b/test/test_c_flag_parsing.vader
index a4e00452..f7bfaa04 100644
--- a/test/test_c_flag_parsing.vader
+++ b/test/test_c_flag_parsing.vader
@@ -74,7 +74,7 @@ Execute(ParseCFlags should ignore -T and other arguments):
\ . ' -DTEST=`date +%s`',
\ ale#c#ParseCFlags(
\ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ 'gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir '
+ \ 'gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir --sysroot=subdir '
\ . '-I'. ale#path#Simplify('kernel/include')
\ . ' -DTEST=`date +%s` -c file.c'
\ )
diff --git a/test/test_python_pipenv.vader b/test/test_python_pipenv.vader
new file mode 100644
index 00000000..91d957f8
--- /dev/null
+++ b/test/test_python_pipenv.vader
@@ -0,0 +1,13 @@
+Execute(ale#python#PipenvPresent is true when a pipenv environment is present):
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertEqual
+ \ ale#python#PipenvPresent(bufnr('%')),
+ \ 1
+
+Execute(ale#python#PipenvPresent is false true when no pipenv environment is present):
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/no_pipenv/whatever.py')
+
+ AssertEqual
+ \ ale#python#PipenvPresent(bufnr('%')),
+ \ 0
diff --git a/test/test_redundant_tsserver_rendering_avoided.vader b/test/test_redundant_tsserver_rendering_avoided.vader
new file mode 100644
index 00000000..41cbe5e0
--- /dev/null
+++ b/test/test_redundant_tsserver_rendering_avoided.vader
@@ -0,0 +1,136 @@
+Before:
+ Save g:ale_buffer_info
+
+ function! CreateError(type, message) abort
+ let l:diagnostics = []
+
+ if !empty(a:message)
+ let l:diagnostics = [{
+ \ 'start': {'line': 1, 'offset': 1},
+ \ 'end': {'line': 1, 'offset':1},
+ \ 'text': a:message,
+ \ 'code': 1005,
+ \}]
+ endif
+
+ return {
+ \ 'seq': 0,
+ \ 'type': 'event',
+ \ 'event': a:type,
+ \ 'body': {'file': expand('%:p'), 'diagnostics': l:diagnostics},
+ \}
+ endfunction
+
+ function! CreateLoclist(message) abort
+ let l:list = []
+
+ if !empty(a:message)
+ let l:list = [{
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'end_lnum': 1,
+ \ 'end_col': 1,
+ \ 'text': a:message,
+ \}]
+ endif
+
+ return l:list
+ endfunction
+
+ call ale#test#SetDirectory('/testplugin/test')
+ call ale#test#SetFilename('filename.ts')
+
+ runtime autoload/ale/engine.vim
+
+ let g:ale_buffer_info = {bufnr(''): {'loclist': []}}
+ let g:ale_handle_loclist_called = 0
+
+ function! ale#engine#HandleLoclist(linter_name, buffer, loclist) abort
+ let g:ale_handle_loclist_called = 1
+ endfunction
+
+After:
+ Restore
+
+ delfunction CreateError
+ delfunction CreateLoclist
+
+ call ale#test#RestoreDirectory()
+
+ runtime autoload/ale/engine.vim
+
+Execute(An initial empty list of syntax errors should be ignored):
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('syntaxDiag', ''))
+
+ Assert !g:ale_handle_loclist_called
+
+Execute(An initial list of syntax errors should be handled):
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('syntaxDiag', 'x'))
+
+ Assert g:ale_handle_loclist_called
+
+Execute(Subsequent empty lists should be ignored):
+ let g:ale_buffer_info[bufnr('')].syntax_loclist = []
+
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('syntaxDiag', ''))
+
+ Assert !g:ale_handle_loclist_called
+
+Execute(Empty then non-empty syntax errors should be handled):
+ let g:ale_buffer_info[bufnr('')].syntax_loclist = []
+
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('syntaxDiag', 'x'))
+
+ Assert g:ale_handle_loclist_called
+
+Execute(Non-empty then empty syntax errors should be handled):
+ let g:ale_buffer_info[bufnr('')].syntax_loclist = CreateLoclist('x')
+
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('syntaxDiag', ''))
+
+ Assert g:ale_handle_loclist_called
+
+Execute(Non-empty then non-empty syntax errors should be handled):
+ let g:ale_buffer_info[bufnr('')].syntax_loclist = CreateLoclist('x')
+
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('syntaxDiag', 'x'))
+
+ Assert g:ale_handle_loclist_called
+
+Execute(An initial empty list of semantic errors should be ignored):
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('semanticDiag', ''))
+
+ Assert !g:ale_handle_loclist_called
+
+Execute(An initial list of semantic errors should be handled):
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('semanticDiag', 'x'))
+
+ Assert g:ale_handle_loclist_called
+
+Execute(Subsequent empty lists should be ignored):
+ let g:ale_buffer_info[bufnr('')].semantic_loclist = []
+
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('semanticDiag', ''))
+
+ Assert !g:ale_handle_loclist_called
+
+Execute(Empty then non-empty semantic errors should be handled):
+ let g:ale_buffer_info[bufnr('')].semantic_loclist = []
+
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('semanticDiag', 'x'))
+
+ Assert g:ale_handle_loclist_called
+
+Execute(Non-empty then empty semantic errors should be handled):
+ let g:ale_buffer_info[bufnr('')].semantic_loclist = CreateLoclist('x')
+
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('semanticDiag', ''))
+
+ Assert g:ale_handle_loclist_called
+
+Execute(Non-empty then non-empty semantic errors should be handled):
+ let g:ale_buffer_info[bufnr('')].semantic_loclist = CreateLoclist('x')
+
+ call ale#lsp_linter#HandleLSPResponse(1, CreateError('semanticDiag', 'x'))
+
+ Assert g:ale_handle_loclist_called
diff --git a/test/test_writefile_function.vader b/test/test_writefile_function.vader
index 4e4aab53..8c8a6f17 100644
--- a/test/test_writefile_function.vader
+++ b/test/test_writefile_function.vader
@@ -28,7 +28,26 @@ Execute(Carriage returns should be included for ale#util#Writefile):
AssertEqual
\ ["first\r", "second\r", "third\r", ''],
\ readfile('.newline-test', 'b')
- \
+
+Given(A file with extra carriage returns):
+ first
+ second
+ third
+ fourth
+
+Execute(Carriage returns should be de-depulicated):
+ call ale#test#SetFilename('.newline-test')
+
+ setlocal buftype=
+ noautocmd :w
+ noautocmd :e! ++ff=dos
+
+ call ale#util#Writefile(bufnr(''), getline(1, '$'), '.newline-test')
+
+ AssertEqual
+ \ ["first\r", "second\r", "third\r", "fourth\r", ''],
+ \ readfile('.newline-test', 'b')
+
Given(A file with Unix line ending characters):
first
second