summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/elm/elm_ls.vim11
-rw-r--r--ale_linters/php/psalm.vim6
-rw-r--r--ale_linters/ruby/debride.vim42
-rw-r--r--ale_linters/scala/metals.vim48
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/nixpkgsfmt.vim12
-rw-r--r--doc/ale-elm.txt14
-rw-r--r--doc/ale-nix.txt24
-rw-r--r--doc/ale-ruby.txt26
-rw-r--r--doc/ale-scala.txt26
-rw-r--r--doc/ale-supported-languages-and-tools.txt3
-rw-r--r--doc/ale.txt4
-rw-r--r--supported-tools.md3
-rwxr-xr-xtest/command_callback/psalm-project/vendor/bin/psalm (renamed from test/command_callback/psalm-project/vendor/bin/psalm-language-server)0
-rw-r--r--test/command_callback/test_psalm_command_callbacks.vader10
-rw-r--r--test/command_callback/test_scala_metals.vader20
-rw-r--r--test/fixers/test_nixpkgsfmt_fixer_callback.vader24
-rw-r--r--test/handler/test_debride_handler.vader27
18 files changed, 287 insertions, 18 deletions
diff --git a/ale_linters/elm/elm_ls.vim b/ale_linters/elm/elm_ls.vim
index 374ef8de..2fa71adb 100644
--- a/ale_linters/elm/elm_ls.vim
+++ b/ale_linters/elm/elm_ls.vim
@@ -3,9 +3,12 @@
call ale#Set('elm_ls_executable', 'elm-language-server')
call ale#Set('elm_ls_use_global', get(g:, 'ale_use_global_executables', 1))
-call ale#Set('elm_ls_elm_path', 'elm')
-call ale#Set('elm_ls_elm_format_path', 'elm-format')
-call ale#Set('elm_ls_elm_test_path', 'elm-test')
+
+" elm-language-server will search for local and global binaries, if empty
+call ale#Set('elm_ls_elm_path', '')
+call ale#Set('elm_ls_elm_format_path', '')
+call ale#Set('elm_ls_elm_test_path', '')
+call ale#Set('elm_ls_elm_analyse_trigger', 'change')
function! elm_ls#GetRootDir(buffer) abort
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
@@ -15,10 +18,10 @@ endfunction
function! elm_ls#GetOptions(buffer) abort
return {
- \ 'runtime': 'node',
\ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'),
\ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'),
\ 'elmTestPath': ale#Var(a:buffer, 'elm_ls_elm_test_path'),
+ \ 'elmAnalyseTrigger': ale#Var(a:buffer, 'elm_ls_elm_analyse_trigger'),
\}
endfunction
diff --git a/ale_linters/php/psalm.vim b/ale_linters/php/psalm.vim
index 3cdb026a..834d0993 100644
--- a/ale_linters/php/psalm.vim
+++ b/ale_linters/php/psalm.vim
@@ -1,7 +1,7 @@
" Author: Matt Brown <https://github.com/muglug>
" Description: plugin for Psalm, static analyzer for PHP
-call ale#Set('psalm_langserver_executable', 'psalm-language-server')
+call ale#Set('psalm_langserver_executable', 'psalm')
call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
@@ -14,8 +14,8 @@ call ale#linter#Define('php', {
\ 'name': 'psalm',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [
-\ 'vendor/bin/psalm-language-server',
+\ 'vendor/bin/psalm',
\ ])},
-\ 'command': '%e',
+\ 'command': '%e --language-server',
\ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'),
\})
diff --git a/ale_linters/ruby/debride.vim b/ale_linters/ruby/debride.vim
new file mode 100644
index 00000000..0a45644e
--- /dev/null
+++ b/ale_linters/ruby/debride.vim
@@ -0,0 +1,42 @@
+" Author: Eddie Lebow https://github.com/elebow
+" Description: debride, a dead method detector for Ruby files
+
+call ale#Set('ruby_debride_executable', 'debride')
+call ale#Set('ruby_debride_options', '')
+
+function! ale_linters#ruby#debride#GetCommand(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'ruby_debride_executable')
+
+ return ale#handlers#ruby#EscapeExecutable(l:executable, 'debride')
+ \ . ale#Var(a:buffer, 'ruby_debride_options')
+ \ . ' %s'
+endfunction
+
+function! ale_linters#ruby#debride#HandleOutput(buffer, lines) abort
+ let l:output = []
+
+ for l:line in a:lines
+ if l:line !~# '^ '
+ continue
+ endif
+
+ let l:elements = split(l:line)
+ let l:method_name = l:elements[0]
+ let l:lnum = split(l:elements[1], ':')[1]
+
+ call add(l:output, {
+ \ 'lnum': 0 + l:lnum,
+ \ 'text': 'Possible unused method: ' . l:method_name,
+ \ 'type': 'W',
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('ruby', {
+\ 'name': 'debride',
+\ 'executable': {b -> ale#Var(b, 'ruby_debride_executable')},
+\ 'command': function('ale_linters#ruby#debride#GetCommand'),
+\ 'callback': 'ale_linters#ruby#debride#HandleOutput',
+\})
diff --git a/ale_linters/scala/metals.vim b/ale_linters/scala/metals.vim
new file mode 100644
index 00000000..f78c7119
--- /dev/null
+++ b/ale_linters/scala/metals.vim
@@ -0,0 +1,48 @@
+" Author: Jeffrey Lau - https://github.com/zoonfafer
+" Description: Metals Language Server for Scala https://scalameta.org/metals/
+
+call ale#Set('scala_metals_executable', 'metals-vim')
+call ale#Set('scala_metals_project_root', '')
+
+function! ale_linters#scala#metals#GetProjectRoot(buffer) abort
+ let l:project_root = ale#Var(a:buffer, 'scala_metals_project_root')
+
+ if !empty(l:project_root)
+ return l:project_root
+ endif
+
+ let l:potential_roots = [
+ \ 'build.sc',
+ \ 'build.sbt',
+ \ '.bloop',
+ \ '.metals',
+ \]
+
+ for l:root in l:potential_roots
+ let l:project_root = ale#path#ResolveLocalPath(
+ \ a:buffer,
+ \ l:root,
+ \ ''
+ \)
+
+ if !empty(l:project_root)
+ return fnamemodify(
+ \ l:project_root,
+ \ ':h',
+ \)
+ endif
+ endfor
+endfunction
+
+function! ale_linters#scala#metals#GetCommand(buffer) abort
+ return '%e' . ale#Pad('stdio')
+endfunction
+
+call ale#linter#Define('scala', {
+\ 'name': 'metals',
+\ 'lsp': 'stdio',
+\ 'language': 'scala',
+\ 'executable': {b -> ale#Var(b, 'scala_metals_executable')},
+\ 'command': function('ale_linters#scala#metals#GetCommand'),
+\ 'project_root': function('ale_linters#scala#metals#GetProjectRoot'),
+\})
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 750d2196..2a96a7d6 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -345,6 +345,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['ada'],
\ 'description': 'Format Ada files with gnatpp.',
\ },
+\ 'nixpkgs-fmt': {
+\ 'function': 'ale#fixers#nixpkgsfmt#Fix',
+\ 'suggested_filetypes': ['nix'],
+\ 'description': 'A formatter for Nix code',
+\ },
\}
" Reset the function registry to the default entries.
diff --git a/autoload/ale/fixers/nixpkgsfmt.vim b/autoload/ale/fixers/nixpkgsfmt.vim
new file mode 100644
index 00000000..403ce798
--- /dev/null
+++ b/autoload/ale/fixers/nixpkgsfmt.vim
@@ -0,0 +1,12 @@
+call ale#Set('nix_nixpkgsfmt_executable', 'nixpkgs-fmt')
+call ale#Set('nix_nixpkgsfmt_options', '')
+
+function! ale#fixers#nixpkgsfmt#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'nix_nixpkgsfmt_executable')
+ let l:options = ale#Var(a:buffer, 'nix_nixpkgsfmt_options')
+
+ return {
+ \ 'command': ale#Escape(l:executable)
+ \ . (empty(l:options) ? '' : ' ' . l:options),
+ \}
+endfunction
diff --git a/doc/ale-elm.txt b/doc/ale-elm.txt
index 823b53e1..b1510241 100644
--- a/doc/ale-elm.txt
+++ b/doc/ale-elm.txt
@@ -50,7 +50,7 @@ g:ale_elm_ls_use_global *g:ale_elm_ls_use_global*
g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path*
*b:ale_elm_ls_elm_path*
Type: |String|
- Default: `'elm'`
+ Default: `''`
See |ale-integrations-local-executables|
@@ -58,7 +58,7 @@ g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path*
g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path*
*b:ale_elm_ls_elm_format_path*
Type: |String|
- Default: `'elm-format'`
+ Default: `''`
See |ale-integrations-local-executables|
@@ -66,10 +66,18 @@ g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path*
g:ale_elm_ls_elm_test_path *g:ale_elm_ls_elm_test_path*
*b:ale_elm_ls_elm_test_path*
Type: |String|
- Default: `'elm-test'`
+ Default: `''`
See |ale-integrations-local-executables|
+
+g:ale_elm_ls_elm_analyse_trigger *g:ale_elm_ls_elm_analyse_trigger*
+ *b:ale_elm_ls_elm_analyse_trigger*
+ Type: |String|
+ Default: `'change'`
+
+ One of 'change', 'save' or 'never'
+
===============================================================================
elm-make *ale-elm-elm-make*
diff --git a/doc/ale-nix.txt b/doc/ale-nix.txt
new file mode 100644
index 00000000..5b2bd6cb
--- /dev/null
+++ b/doc/ale-nix.txt
@@ -0,0 +1,24 @@
+===============================================================================
+ALE Nix Integration *ale-nix-options*
+
+
+===============================================================================
+nixpkgs-fmt *ale-nix-nixpkgs-fmt*
+
+g:ale_nix_nixpkgsfmt_executable *g:ale_nix_nixpkgsfmt_executable*
+ *b:ale_nix_nixpkgsfmt_executable*
+ Type: |String|
+ Default: `'nixpkgs-fmt'`
+
+ This variable sets executable used for nixpkgs-fmt.
+
+g:ale_nix_nixpkgsfmt_options *g:ale_nix_nixpkgsfmt_options*
+ *b:ale_nix_nixpkgsfmt_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be set to pass additional options to the nixpkgs-fmt fixer.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt
index e373ab8e..a27a20b2 100644
--- a/doc/ale-ruby.txt
+++ b/doc/ale-ruby.txt
@@ -21,6 +21,26 @@ g:ale_ruby_brakeman_options *g:ale_ruby_brakeman_options*
The contents of this variable will be passed through to brakeman.
+===============================================================================
+debride *ale-ruby-debride*
+
+g:ale_ruby_debride_executable *g:ale_ruby_debride_executable*
+ *b:ale_ruby_debride_executable*
+ Type: String
+ Default: `'debride'`
+
+ Override the invoked debride binary. Set this to `'bundle'` to invoke
+ `'bundle` `exec` debride'.
+
+
+g:ale_ruby_debride_options *g:ale_ruby_debride_options*
+ *b:ale_ruby_debride_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be changed to modify flags given to debride.
+
+
===============================================================================
rails_best_practices *ale-ruby-rails_best_practices*
@@ -91,7 +111,7 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options*
Type: |String|
Default: `''`
- This variable can be change to modify flags given to rubocop.
+ This variable can be changed to modify flags given to rubocop.
===============================================================================
@@ -146,7 +166,7 @@ g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options*
Type: |String|
Default: `''`
- This variable can be change to modify flags given to sorbet.
+ This variable can be changed to modify flags given to sorbet.
===============================================================================
@@ -166,7 +186,7 @@ g:ale_ruby_standardrb_options *g:ale_ruby_standardrb_options*
Type: |String|
Default: `''`
- This variable can be change to modify flags given to standardrb.
+ This variable can be changed to modify flags given to standardrb.
===============================================================================
diff --git a/doc/ale-scala.txt b/doc/ale-scala.txt
index ff43cd6c..c9638baf 100644
--- a/doc/ale-scala.txt
+++ b/doc/ale-scala.txt
@@ -3,6 +3,32 @@ ALE Scala Integration *ale-scala-options*
===============================================================================
+metals *ale-scala-metals*
+
+`metals` requires either an SBT project, a Mill project, or a running Bloop
+server.
+
+
+g:ale_scala_metals_executable *g:ale_scala_metals_executable*
+ *b:ale_scala_metals_executable*
+ Type: |String|
+ Default: `'metals-vim'`
+
+ Override the invoked `metals` binary.
+
+
+g:ale_scala_metals_project_root *g:ale_scala_metals_project_root*
+ *b:ale_scala_metals_project_root*
+ Type: |String|
+ Default: `''`
+
+ By default the project root is found by searching upwards for `build.sbt`,
+ `build.sc`, `.bloop` or `.metals`.
+ If the project root is elsewhere, you can override the project root
+ directory.
+
+
+===============================================================================
sbtserver *ale-scala-sbtserver*
`sbtserver` requires a running ^1.1.x sbt shell to connect to. It will attempt
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index aa4f659c..a5b7c35e 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -284,6 +284,7 @@ Notes:
* `nim check`!!
* nix
* `nix-instantiate`
+ * `nixpkgs-fmt`
* nroff
* `alex`!!
* `proselint`
@@ -391,6 +392,7 @@ Notes:
* `rpmlint`
* Ruby
* `brakeman`
+ * `debride`
* `rails_best_practices`!!
* `reek`
* `rubocop`
@@ -409,6 +411,7 @@ Notes:
* `stylelint`
* Scala
* `fsc`
+ * `metals`
* `sbtserver`
* `scalac`
* `scalafmt`
diff --git a/doc/ale.txt b/doc/ale.txt
index b368afd3..3282cbfd 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2305,6 +2305,8 @@ documented in additional help files.
mmc...................................|ale-mercury-mmc|
nasm....................................|ale-nasm-options|
nasm..................................|ale-nasm-nasm|
+ nix.....................................|ale-nix-options|
+ nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
nroff...................................|ale-nroff-options|
write-good............................|ale-nroff-write-good|
objc....................................|ale-objc-options|
@@ -2395,6 +2397,7 @@ documented in additional help files.
write-good............................|ale-restructuredtext-write-good|
ruby....................................|ale-ruby-options|
brakeman..............................|ale-ruby-brakeman|
+ debride...............................|ale-ruby-debride|
rails_best_practices..................|ale-ruby-rails_best_practices|
reek..................................|ale-ruby-reek|
rubocop...............................|ale-ruby-rubocop|
@@ -2412,6 +2415,7 @@ documented in additional help files.
sasslint..............................|ale-sass-sasslint|
stylelint.............................|ale-sass-stylelint|
scala...................................|ale-scala-options|
+ metals................................|ale-scala-metals|
sbtserver.............................|ale-scala-sbtserver|
scalafmt..............................|ale-scala-scalafmt|
scalastyle............................|ale-scala-scalastyle|
diff --git a/supported-tools.md b/supported-tools.md
index a133edac..e392f282 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -293,6 +293,7 @@ formatting.
* [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk:
* nix
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
+ * [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
* nroff
* [alex](https://github.com/wooorm/alex) :floppy_disk:
* [proselint](http://proselint.com/)
@@ -400,6 +401,7 @@ formatting.
* [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`)
* Ruby
* [brakeman](http://brakemanscanner.org/) :floppy_disk:
+ * [debride](https://github.com/seattlerb/debride) :floppy_disk:
* [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) :floppy_disk:
* [reek](https://github.com/troessner/reek)
* [rubocop](https://github.com/bbatsov/rubocop)
@@ -418,6 +420,7 @@ formatting.
* [stylelint](https://github.com/stylelint/stylelint)
* Scala
* [fsc](https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html)
+ * [metals](https://scalameta.org/metals/)
* [sbtserver](https://www.scala-sbt.org/1.x/docs/sbt-server.html)
* [scalac](http://scala-lang.org)
* [scalafmt](https://scalameta.org/scalafmt/)
diff --git a/test/command_callback/psalm-project/vendor/bin/psalm-language-server b/test/command_callback/psalm-project/vendor/bin/psalm
index e69de29b..e69de29b 100755
--- a/test/command_callback/psalm-project/vendor/bin/psalm-language-server
+++ b/test/command_callback/psalm-project/vendor/bin/psalm
diff --git a/test/command_callback/test_psalm_command_callbacks.vader b/test/command_callback/test_psalm_command_callbacks.vader
index 33d770c2..74c68d43 100644
--- a/test/command_callback/test_psalm_command_callbacks.vader
+++ b/test/command_callback/test_psalm_command_callbacks.vader
@@ -9,18 +9,18 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default executable path should be correct):
- AssertLinter 'psalm-language-server',
- \ ale#Escape('psalm-language-server')
+ AssertLinter 'psalm',
+ \ ale#Escape('psalm') . ' --language-server'
Execute(Vendor executables should be detected):
call ale#test#SetFilename('psalm-project/test.php')
AssertLinter
- \ ale#path#Simplify(g:dir . '/psalm-project/vendor/bin/psalm-language-server'),
+ \ ale#path#Simplify(g:dir . '/psalm-project/vendor/bin/psalm'),
\ ale#Escape(ale#path#Simplify(
\ g:dir
- \ . '/psalm-project/vendor/bin/psalm-language-server'
- \ ))
+ \ . '/psalm-project/vendor/bin/psalm'
+ \ )) . ' --language-server'
Execute(The project path should be correct for .git directories):
call ale#test#SetFilename('psalm-project/test.php')
diff --git a/test/command_callback/test_scala_metals.vader b/test/command_callback/test_scala_metals.vader
new file mode 100644
index 00000000..70e14c1a
--- /dev/null
+++ b/test/command_callback/test_scala_metals.vader
@@ -0,0 +1,20 @@
+" Author: Jeffrey Lau https://github.com/zoonfafer
+" Description: Tests for the Scala Metals linter
+
+Before:
+ call ale#assert#SetUpLinterTest('scala', 'metals')
+
+After:
+ call ale#assert#TearDownLinterTest()
+Execute(should set metals for sbt project with build.sbt):
+ call ale#test#SetFilename('../scala_fixtures/valid_sbt_project/Main.scala')
+ AssertLSPLanguage 'scala'
+ AssertLSPOptions {}
+ AssertLSPConfig {}
+ AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../scala_fixtures/valid_sbt_project')
+Execute(should not set metals for sbt project without build.sbt):
+ call ale#test#SetFilename('../scala_fixtures/invalid_sbt_project/Main.scala')
+ AssertLSPLanguage 'scala'
+ AssertLSPOptions {}
+ AssertLSPConfig {}
+ AssertLSPProject ''
diff --git a/test/fixers/test_nixpkgsfmt_fixer_callback.vader b/test/fixers/test_nixpkgsfmt_fixer_callback.vader
new file mode 100644
index 00000000..0065f77b
--- /dev/null
+++ b/test/fixers/test_nixpkgsfmt_fixer_callback.vader
@@ -0,0 +1,24 @@
+Before:
+ Save g:ale_nix_nixpkgsfmt_executable
+ Save g:ale_nix_nixpkgsfmt_options
+
+After:
+ Restore
+
+Execute(The nixpkgs-fmt callback should return the correct default values):
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('nixpkgs-fmt')
+ \ },
+ \ ale#fixers#nixpkgsfmt#Fix(bufnr(''))
+
+Execute(The nixpkgs-fmt executable and options should be configurable):
+ let g:ale_nix_nixpkgsfmt_executable = '/path/to/nixpkgs-fmt'
+ let g:ale_nix_nixpkgsfmt_options = '-h'
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('/path/to/nixpkgs-fmt')
+ \ . ' -h',
+ \ },
+ \ ale#fixers#nixpkgsfmt#Fix(bufnr(''))
diff --git a/test/handler/test_debride_handler.vader b/test/handler/test_debride_handler.vader
new file mode 100644
index 00000000..62851468
--- /dev/null
+++ b/test/handler/test_debride_handler.vader
@@ -0,0 +1,27 @@
+Before:
+ runtime ale_linters/ruby/debride.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The debride linter parses output correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 2,
+ \ 'text': 'Possible unused method: image_tags',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 7,
+ \ 'text': 'Possible unused method: not_deleted',
+ \ 'type': 'W',
+ \ }
+ \ ],
+ \ ale_linters#ruby#debride#HandleOutput(0, [
+ \ 'These methods MIGHT not be called:',
+ \ '',
+ \ 'Image',
+ \ ' image_tags app/models/image.rb:2',
+ \ ' not_deleted app/models/image.rb:7'
+ \])