From 49718e0ec6eb4b9068049048c9373167c19257c9 Mon Sep 17 00:00:00 2001 From: Dmitri Vereshchagin Date: Sun, 1 Sep 2019 17:36:40 +0300 Subject: Add Elvis handler for Erlang [Elvis][1] is an Erlang style reviewer. [1]: https://github.com/inaka/elvis --- ale_linters/erlang/elvis.vim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 ale_linters/erlang/elvis.vim (limited to 'ale_linters') diff --git a/ale_linters/erlang/elvis.vim b/ale_linters/erlang/elvis.vim new file mode 100644 index 00000000..31dea3dd --- /dev/null +++ b/ale_linters/erlang/elvis.vim @@ -0,0 +1,39 @@ +" Author: Dmitri Vereshchagin +" Description: Elvis linter for Erlang files + +call ale#Set('erlang_elvis_executable', 'elvis') + +function! ale_linters#erlang#elvis#Handle(buffer, lines) abort + let l:pattern = '\v:(\d+):[^:]+:(.+)' + let l:loclist = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:loclist, { + \ 'lnum': str2nr(l:match[1]), + \ 'text': s:AbbreviateMessage(l:match[2]), + \ 'type': 'W', + \}) + endfor + + return l:loclist +endfunction + +function! s:AbbreviateMessage(text) abort + let l:pattern = '\v\c^(line \d+ is too long):.*$' + + return substitute(a:text, l:pattern, '\1.', '') +endfunction + +function! s:GetCommand(buffer) abort + let l:file = ale#Escape(expand('#' . a:buffer . ':.')) + + return '%e rock --output-format=parsable ' . l:file +endfunction + +call ale#linter#Define('erlang', { +\ 'name': 'elvis', +\ 'callback': 'ale_linters#erlang#elvis#Handle', +\ 'executable': {b -> ale#Var(b, 'erlang_elvis_executable')}, +\ 'command': function('s:GetCommand'), +\ 'lint_file': 1, +\}) -- cgit v1.2.3 From fec6b63494b4f491279c7a01c0d61e515b8d0f46 Mon Sep 17 00:00:00 2001 From: Arnold Chand Date: Tue, 15 Sep 2020 19:14:12 -0400 Subject: feat: add intelephense support for php --- ale_linters/php/intelephense.vim | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ale_linters/php/intelephense.vim (limited to 'ale_linters') diff --git a/ale_linters/php/intelephense.vim b/ale_linters/php/intelephense.vim new file mode 100644 index 00000000..e9e07d1f --- /dev/null +++ b/ale_linters/php/intelephense.vim @@ -0,0 +1,32 @@ +" Author: Eric Stern , +" Arnold Chand +" Description: Intelephense language server integration for ALE + +call ale#Set('php_intelephense_executable', 'intelephense') +call ale#Set('php_intelephense_use_global', 1) +call ale#Set('php_intelephense_config', {}) + +function! ale_linters#php#intelephense#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + 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') +endfunction + +call ale#linter#Define('php', { +\ 'name': 'intelephense', +\ 'lsp': 'stdio', +\ 'initialization_options': function('ale_linters#php#intelephense#GetInitializationOptions'), +\ 'executable': {b -> ale#node#FindExecutable(b, 'php_intelephense', [])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#php#intelephense#GetProjectRoot'), +\}) -- cgit v1.2.3 From e08996940468ce90616a9704a439652f1ab73e31 Mon Sep 17 00:00:00 2001 From: Marcus Zanona Date: Wed, 12 Aug 2020 11:06:35 +0200 Subject: fix(ale_linters/phpcs): add support for multiline error messages --- ale_linters/php/phpcs.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ale_linters') diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim index 11b81e84..c5a3faa9 100644 --- a/ale_linters/php/phpcs.vim +++ b/ale_linters/php/phpcs.vim @@ -23,7 +23,7 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort " Matches against lines like the following: " " /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact) - let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\))$' + let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\)).*$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) -- cgit v1.2.3 From 01800a23addb52788265e0349f519556dab41301 Mon Sep 17 00:00:00 2001 From: Dalius Dobravolskas Date: Sat, 14 Nov 2020 12:15:17 +0200 Subject: Support for LSP/tsserver Code Actions (#3437) * Added tsserver and LSP code action support. * tsserver refactors support added. * Handling special case when new text is added after new line symbol. * ale#code_action#ApplyChanges simplified. * Initial attempt on LSP Code Actions. * workspace/executeCommand added. * Some null checks added. * Add last column to LSP Code Action message. * Pass diagnostics to LSP code action. Previously ApplyChanges code was applied from top-to-bottom that required extra parameters to track progress and there was bug. I have changed code to bottom-to-top approach as that does not require those extra parameters and solved the bug. Tested with typescript-language-server and it is working. --- ale_linters/python/jedils.vim | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ale_linters/python/jedils.vim (limited to 'ale_linters') diff --git a/ale_linters/python/jedils.vim b/ale_linters/python/jedils.vim new file mode 100644 index 00000000..eae5fb07 --- /dev/null +++ b/ale_linters/python/jedils.vim @@ -0,0 +1,34 @@ +" Author: Dalius Dobravolskas +" Description: https://github.com/pappasam/jedi-language-server + +call ale#Set('python_jedils_executable', 'jedi-language-server') +call ale#Set('python_jedils_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_jedils_auto_pipenv', 0) + +function! ale_linters#python#jedils#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_jedils_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_jedils', ['jedi-language-server']) +endfunction + +function! ale_linters#python#jedils#GetCommand(buffer) abort + let l:executable = ale_linters#python#jedils#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run jedi-language-server' + \ : '' + + return ale#Escape(l:executable) . l:exec_args +endfunction + +call ale#linter#Define('python', { +\ 'name': 'jedils', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#python#jedils#GetExecutable'), +\ 'command': function('ale_linters#python#jedils#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\}) -- cgit v1.2.3 From b74827de99e842dc7698d8d6274486550d90f05a Mon Sep 17 00:00:00 2001 From: Nathan Herald Date: Wed, 29 Jul 2020 18:23:00 +0200 Subject: Look for node packages in .yarn/sdks as well --- ale_linters/typescript/tsserver.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'ale_linters') diff --git a/ale_linters/typescript/tsserver.vim b/ale_linters/typescript/tsserver.vim index 840889f3..4726e40d 100644 --- a/ale_linters/typescript/tsserver.vim +++ b/ale_linters/typescript/tsserver.vim @@ -9,6 +9,7 @@ call ale#linter#Define('typescript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', \ 'executable': {b -> ale#node#FindExecutable(b, 'typescript_tsserver', [ +\ '.yarn/sdks/typescript/bin/tsserver', \ 'node_modules/.bin/tsserver', \ ])}, \ 'command': '%e', -- cgit v1.2.3 From e1184e31f6ed7907b0fdc51eaf4507af6f22d7d9 Mon Sep 17 00:00:00 2001 From: Jose Soto Date: Sat, 21 Nov 2020 12:29:33 -0800 Subject: Adds support for Tlint - A Tighten Opinionated PHP Linter (#3291) Co-authored-by: w0rp --- ale_linters/php/tlint.vim | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 ale_linters/php/tlint.vim (limited to 'ale_linters') diff --git a/ale_linters/php/tlint.vim b/ale_linters/php/tlint.vim new file mode 100644 index 00000000..6bba8def --- /dev/null +++ b/ale_linters/php/tlint.vim @@ -0,0 +1,80 @@ +" Author: Jose Soto +" +" Description: Tighten Opinionated PHP Linting +" Website: https://github.com/tightenco/tlint + +call ale#Set('php_tlint_executable', 'tlint') +call ale#Set('php_tlint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_tlint_options', '') + +function! ale_linters#php#tlint#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if !empty(l:composer_path) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#php#tlint#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'php_tlint', [ + \ 'vendor/bin/tlint', + \ 'tlint', + \]) +endfunction + +function! ale_linters#php#tlint#GetCommand(buffer) abort + let l:executable = ale_linters#php#tlint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'php_tlint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' lint %s' +endfunction + +function! ale_linters#php#tlint#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " ! There should be 1 space around `.` concatenations, and additional lines should always start with a `.` + " 22 : ` $something = 'a'.'name';` + " + let l:loop_count = 0 + let l:messages_pattern = '^\! \(.*\)' + let l:output = [] + let l:pattern = '^\(\d\+\) \:' + let l:temp_messages = [] + + for l:message in ale#util#GetMatches(a:lines, l:messages_pattern) + call add(l:temp_messages, l:message) + endfor + + let l:loop_count = 0 + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:num = l:match[1] + let l:text = l:temp_messages[l:loop_count] + + call add(l:output, { + \ 'lnum': l:num, + \ 'col': 0, + \ 'text': l:text, + \ 'type': 'W', + \ 'sub_type': 'style', + \}) + + let l:loop_count += 1 + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'tlint', +\ 'executable': function('ale_linters#php#tlint#GetExecutable'), +\ 'command': function('ale_linters#php#tlint#GetCommand'), +\ 'callback': 'ale_linters#php#tlint#Handle', +\ 'project_root': function('ale_linters#php#tlint#GetProjectRoot'), +\}) -- cgit v1.2.3 From 9692c0c64c83bb8f67962cf35e7dc3f1757aa8cc Mon Sep 17 00:00:00 2001 From: Eric Zhao <21zhaoe@protonmail.com> Date: Sat, 21 Nov 2020 15:56:38 -0500 Subject: Add support for R languageserver (#3370) --- ale_linters/r/languageserver.vim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ale_linters/r/languageserver.vim (limited to 'ale_linters') diff --git a/ale_linters/r/languageserver.vim b/ale_linters/r/languageserver.vim new file mode 100644 index 00000000..c625d8b4 --- /dev/null +++ b/ale_linters/r/languageserver.vim @@ -0,0 +1,26 @@ +" Author: Eric Zhao <21zhaoe@protonmail.com> +" Description: Implementation of the Language Server Protocol for R. + +call ale#Set('r_languageserver_cmd', 'languageserver::run()') +call ale#Set('r_languageserver_options', {}) + +function! ale_linters#r#languageserver#GetCommand(buffer) abort + let l:cmd_string = ale#Var(a:buffer, 'r_languageserver_cmd') + + return 'Rscript --vanilla -e ' . ale#Escape(l:cmd_string) +endfunction + +function! ale_linters#r#languageserver#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, '.Rprofile') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : fnamemodify(a:buffer, ':h') +endfunction + +call ale#linter#Define('r', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'r_languageserver_options')}, +\ 'executable': 'Rscript', +\ 'command': function('ale_linters#r#languageserver#GetCommand'), +\ 'project_root': function('ale_linters#r#languageserver#GetProjectRoot') +\}) -- cgit v1.2.3 From 681a6e371d02cce9c2414c19f5deeae61aa321fa Mon Sep 17 00:00:00 2001 From: w0rp Date: Sat, 21 Nov 2020 20:58:34 +0000 Subject: Use _config for LSP config options --- ale_linters/r/languageserver.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ale_linters') diff --git a/ale_linters/r/languageserver.vim b/ale_linters/r/languageserver.vim index c625d8b4..febe66bd 100644 --- a/ale_linters/r/languageserver.vim +++ b/ale_linters/r/languageserver.vim @@ -2,7 +2,7 @@ " Description: Implementation of the Language Server Protocol for R. call ale#Set('r_languageserver_cmd', 'languageserver::run()') -call ale#Set('r_languageserver_options', {}) +call ale#Set('r_languageserver_config', {}) function! ale_linters#r#languageserver#GetCommand(buffer) abort let l:cmd_string = ale#Var(a:buffer, 'r_languageserver_cmd') @@ -19,7 +19,7 @@ endfunction call ale#linter#Define('r', { \ 'name': 'languageserver', \ 'lsp': 'stdio', -\ 'lsp_config': {b -> ale#Var(b, 'r_languageserver_options')}, +\ 'lsp_config': {b -> ale#Var(b, 'r_languageserver_config')}, \ 'executable': 'Rscript', \ 'command': function('ale_linters#r#languageserver#GetCommand'), \ 'project_root': function('ale_linters#r#languageserver#GetProjectRoot') -- cgit v1.2.3