From 4ed520a2192cfee9b93f329e46a0a57c2bd2e771 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 2 Jan 2021 15:42:38 +0900 Subject: [PATCH 01/20] add initial files --- ale_linters/vala/vala_lint.vim | 44 +++++++++++++++++++++++ test/handler/test_vala_lint_handler.vader | 37 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 ale_linters/vala/vala_lint.vim create mode 100644 test/handler/test_vala_lint_handler.vader diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim new file mode 100644 index 00000000..4aad4dcd --- /dev/null +++ b/ale_linters/vala/vala_lint.vim @@ -0,0 +1,44 @@ +" Author: Atsuya Takagi +" Description: A linter for Vala using Vala-Lint. + +function! ale_linters#vala#vala_lint#GetCommand(buffer) abort + return 'io.elementary.vala-lint' +endfunction + +function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort + let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(\w\+\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:line = l:match[1] + 0 + let l:column = l:match[2] + 0 + let l:type = 'E' + let l:text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') + let l:code = l:match[5] + + call add(l:output, { + \ 'lnum': l:line, + \ 'col': l:column, + \ 'text': l:text, + \ 'type': l:type, + \ 'code': l:code, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('vala', { +\ 'name': 'vala-lint', +\ 'output_stream': 'both', +\ 'executable': 'io.elementary.vala-lint', +\ 'command': function('ale_linters#vala#vala_lint#GetCommand'), +\ 'callback': 'ale_linters#vala#vala_lint#Handle', +\ 'lint_file': 1, +\}) diff --git a/test/handler/test_vala_lint_handler.vader b/test/handler/test_vala_lint_handler.vader new file mode 100644 index 00000000..cee8674a --- /dev/null +++ b/test/handler/test_vala_lint_handler.vader @@ -0,0 +1,37 @@ +Before: + runtime ale_linters/vala/vala_lint.vim + +After: + call ale#linter#Reset() + +Execute(The Vala-Lint handler should parse lines correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 18, + \ 'col': 18, + \ 'text': 'Expected space before paren', + \ 'code': 'space-before-paren', + \ 'type': 'E', + \ }, + \ { + \ 'lnum': 64, + \ 'col': 37, + \ 'text': 'Expected space before paren', + \ 'code': 'space-before-paren', + \ 'type': 'E', + \ }, + \ { + \ 'lnum': 73, + \ 'col': 37, + \ 'text': 'Expected space before paren', + \ 'code': 'space-before-paren', + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#vala#vala_lint#Handle(bufnr(''), [ + \ 'Application.vala', + \ ' 18.18 error Expected space before paren space-before-paren', + \ ' 64.37 error Expected space before paren space-before-paren', + \ ' 73.37 error Expected space before paren space-before-paren', + \ ]) From 3e820207e7d637a86a16dfce3e2d4fa698b0811d Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 2 Jan 2021 15:52:10 +0900 Subject: [PATCH 02/20] be precise about output_stream --- ale_linters/vala/vala_lint.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 4aad4dcd..42434651 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -36,7 +36,7 @@ endfunction call ale#linter#Define('vala', { \ 'name': 'vala-lint', -\ 'output_stream': 'both', +\ 'output_stream': 'stdout', \ 'executable': 'io.elementary.vala-lint', \ 'command': function('ale_linters#vala#vala_lint#GetCommand'), \ 'callback': 'ale_linters#vala#vala_lint#Handle', From 7f1dd5f66ab207676baf79e22edc5e42309306ec Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 2 Jan 2021 16:02:35 +0900 Subject: [PATCH 03/20] specify a filename of the current buffer --- ale_linters/vala/vala_lint.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 42434651..8658c17c 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -2,7 +2,7 @@ " Description: A linter for Vala using Vala-Lint. function! ale_linters#vala#vala_lint#GetCommand(buffer) abort - return 'io.elementary.vala-lint' + return 'io.elementary.vala-lint %s' endfunction function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort From e94d23b1d906df77453f111f7e7984385c20eaa2 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 2 Jan 2021 16:38:45 +0900 Subject: [PATCH 04/20] test my hypotethis --- ale_linters/vala/vala_lint.vim | 44 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 8658c17c..5b512ad0 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -9,27 +9,35 @@ function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(\w\+\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)' let l:output = [] - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) + call add(l:output, { + \ 'lnum': 12, + \ 'col': 30, + \ 'text': 'bad', + \ 'type': 'E', + \ 'code': 'testcode', + \}) - if len(l:match) == 0 - continue - endif + "for l:line in a:lines + " let l:match = matchlist(l:line, l:pattern) - let l:line = l:match[1] + 0 - let l:column = l:match[2] + 0 - let l:type = 'E' - let l:text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') - let l:code = l:match[5] + " if len(l:match) == 0 + " continue + " endif - call add(l:output, { - \ 'lnum': l:line, - \ 'col': l:column, - \ 'text': l:text, - \ 'type': l:type, - \ 'code': l:code, - \}) - endfor + " let l:line = l:match[1] + 0 + " let l:column = l:match[2] + 0 + " let l:type = 'E' + " let l:text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') + " let l:code = l:match[5] + + " call add(l:output, { + " \ 'lnum': l:line, + " \ 'col': l:column, + " \ 'text': l:text, + " \ 'type': l:type, + " \ 'code': l:code, + " \}) + "endfor return l:output endfunction From 9eb6dace889174c61fbaa13ed3c59d91172b5c60 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 2 Jan 2021 16:48:54 +0900 Subject: [PATCH 05/20] escape color sequences --- ale_linters/vala/vala_lint.vim | 49 ++++++++++++++++------------------ 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 5b512ad0..f102d567 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -9,35 +9,32 @@ function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(\w\+\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)' let l:output = [] - call add(l:output, { - \ 'lnum': 12, - \ 'col': 30, - \ 'text': 'bad', - \ 'type': 'E', - \ 'code': 'testcode', - \}) + for l:line in a:lines + " remove color escape sequences since vala-lint doesn't support + " output without colors + let l:cleaned_line = substitute(l:line, '\x1b\[[0-9;]*m', '', 'g') + execute 'echo l:line' + execute 'echo l:cleaned_line' + let l:match = matchlist(l:cleaned, l:pattern) - "for l:line in a:lines - " let l:match = matchlist(l:line, l:pattern) + if len(l:match) == 0 + continue + endif - " if len(l:match) == 0 - " continue - " endif + let l:lnum = l:match[1] + 0 + let l:column = l:match[2] + 0 + let l:type = 'E' + let l:text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') + let l:code = l:match[5] - " let l:line = l:match[1] + 0 - " let l:column = l:match[2] + 0 - " let l:type = 'E' - " let l:text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') - " let l:code = l:match[5] - - " call add(l:output, { - " \ 'lnum': l:line, - " \ 'col': l:column, - " \ 'text': l:text, - " \ 'type': l:type, - " \ 'code': l:code, - " \}) - "endfor + call add(l:output, { + \ 'lnum': l:lnum, + \ 'col': l:column, + \ 'text': l:text, + \ 'type': l:type, + \ 'code': l:code, + \}) + endfor return l:output endfunction From b3010ad7930344a06163a99182c21e4c768f8a23 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 2 Jan 2021 16:54:06 +0900 Subject: [PATCH 06/20] fix the wrong variable name --- ale_linters/vala/vala_lint.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index f102d567..0940f294 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -15,7 +15,7 @@ function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort let l:cleaned_line = substitute(l:line, '\x1b\[[0-9;]*m', '', 'g') execute 'echo l:line' execute 'echo l:cleaned_line' - let l:match = matchlist(l:cleaned, l:pattern) + let l:match = matchlist(l:cleaned_line, l:pattern) if len(l:match) == 0 continue From c15d9538cda6ac4bc7cd258b2a0a271ed22ac350 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 2 Jan 2021 17:28:06 +0900 Subject: [PATCH 07/20] use the correct regex to match the escape sequences... --- ale_linters/vala/vala_lint.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 0940f294..b0c86fcc 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -12,9 +12,7 @@ function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort for l:line in a:lines " remove color escape sequences since vala-lint doesn't support " output without colors - let l:cleaned_line = substitute(l:line, '\x1b\[[0-9;]*m', '', 'g') - execute 'echo l:line' - execute 'echo l:cleaned_line' + let l:cleaned_line = substitute(l:line, '\e\[[0-9;]\+[mK]', '', 'g') let l:match = matchlist(l:cleaned_line, l:pattern) if len(l:match) == 0 From 280d2dedaeba09aad139e9b2c6ea37e3213083b4 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Mon, 4 Jan 2021 15:49:29 +0900 Subject: [PATCH 08/20] find and use vala-lint config if exists --- ale_linters/vala/vala_lint.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index b0c86fcc..b53e9b86 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -2,7 +2,14 @@ " Description: A linter for Vala using Vala-Lint. function! ale_linters#vala#vala_lint#GetCommand(buffer) abort - return 'io.elementary.vala-lint %s' + let l:command = 'io.elementary.vala-lint ' + + let l:config_path = ale#path#FindNearestFile(a:buffer, 'vala-lint.conf') + if !empty(l:config_path) + let l:command .= '-c ' . l:config_path . ' ' + endif + + return l:command . '%s' endfunction function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort From 89403b4a0600011ad94d51a7aef9e26afe284fd6 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Mon, 4 Jan 2021 16:00:30 +0900 Subject: [PATCH 09/20] expect warn or error --- ale_linters/vala/vala_lint.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index b53e9b86..a38bf9bf 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -13,7 +13,7 @@ function! ale_linters#vala#vala_lint#GetCommand(buffer) abort endfunction function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort - let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(\w\+\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)' + let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(error\|warn\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)' let l:output = [] for l:line in a:lines @@ -26,10 +26,13 @@ function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort continue endif + let l:refined_type = l:match[3] is# 'warn' ? 'W' : 'E' + let l:cleaned_text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') + let l:lnum = l:match[1] + 0 let l:column = l:match[2] + 0 - let l:type = 'E' - let l:text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') + let l:type = l:refined_type + let l:text = l:cleaned_text let l:code = l:match[5] call add(l:output, { From 823b094f5618c9dd53a0a56bbf131ed077f4105b Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Mon, 4 Jan 2021 16:17:33 +0900 Subject: [PATCH 10/20] support flags for enable/disable config --- ale_linters/vala/vala_lint.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index a38bf9bf..24ade378 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -1,12 +1,18 @@ " Author: Atsuya Takagi " Description: A linter for Vala using Vala-Lint. +let g:ale_vala_vala_lint_enable_config = get(g:, 'ale_vala_vala_lint_enable_config', 0) +let g:ale_vala_vala_lint_config_filename = get(g:, 'ale_vala_vala_lint_config_filename', 'vala-lint.conf') + function! ale_linters#vala#vala_lint#GetCommand(buffer) abort let l:command = 'io.elementary.vala-lint ' - let l:config_path = ale#path#FindNearestFile(a:buffer, 'vala-lint.conf') - if !empty(l:config_path) - let l:command .= '-c ' . l:config_path . ' ' + if ale#Var(a:buffer, 'vala_vala_lint_enable_config') + let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename') + let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename) + if !empty(l:config_path) + let l:command .= '-c ' . l:config_path . ' ' + endif endif return l:command . '%s' From ed2afafd621503f684c31a5e6e75e358f7ccb6ef Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Mon, 4 Jan 2021 16:28:51 +0900 Subject: [PATCH 11/20] use ale#Set for setting default config variable values --- ale_linters/vala/vala_lint.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 24ade378..d540323c 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -1,8 +1,8 @@ " Author: Atsuya Takagi " Description: A linter for Vala using Vala-Lint. -let g:ale_vala_vala_lint_enable_config = get(g:, 'ale_vala_vala_lint_enable_config', 0) -let g:ale_vala_vala_lint_config_filename = get(g:, 'ale_vala_vala_lint_config_filename', 'vala-lint.conf') +call ale#Set('vala_vala_lint_enable_config', 0) +call ale#Set('vala_vala_lint_config_filename', 'vala-lint.conf') function! ale_linters#vala#vala_lint#GetCommand(buffer) abort let l:command = 'io.elementary.vala-lint ' From 67c3fa9001c28ea19e1ac09bd733680fb8df4c24 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Mon, 4 Jan 2021 16:44:32 +0900 Subject: [PATCH 12/20] add documentation for vala-lint --- doc/ale-vala.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/ale-vala.txt b/doc/ale-vala.txt index ca24bcf4..94bf5400 100644 --- a/doc/ale-vala.txt +++ b/doc/ale-vala.txt @@ -8,5 +8,24 @@ uncrustify *ale-vala-uncrustify* See |ale-c-uncrustify| for information about the available options. +=============================================================================== +Vala-Lint *ale-vala-vala-lint* + +g:ale_vala_vala_lint_enable_config *g:vala_vala_lint_enable_config* + *b:vala_vala_lint_enable_config* + Type: |Number| + Default: `'0'` + + This variable can be set to enable or diable the use of Vala-Lint config file. + + +g:vala_vala_lint_config_filename *g:vala_vala_lint_config_filename* + *b:vala_vala_lint_config_filename* + Type: |String| + Default: `'vala-lint.conf'` + + This variable can be set to specify a Vala-Lint config filename. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: From 2dbf4ee271600a7e243a6d475c57bf54958e904e Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Mon, 4 Jan 2021 16:45:12 +0900 Subject: [PATCH 13/20] add test to check if it properly ignores outputs with unknown error types --- test/handler/test_vala_lint_handler.vader | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/handler/test_vala_lint_handler.vader b/test/handler/test_vala_lint_handler.vader index cee8674a..b8a4fbfa 100644 --- a/test/handler/test_vala_lint_handler.vader +++ b/test/handler/test_vala_lint_handler.vader @@ -19,7 +19,7 @@ Execute(The Vala-Lint handler should parse lines correctly): \ 'col': 37, \ 'text': 'Expected space before paren', \ 'code': 'space-before-paren', - \ 'type': 'E', + \ 'type': 'W', \ }, \ { \ 'lnum': 73, @@ -32,6 +32,23 @@ Execute(The Vala-Lint handler should parse lines correctly): \ ale_linters#vala#vala_lint#Handle(bufnr(''), [ \ 'Application.vala', \ ' 18.18 error Expected space before paren space-before-paren', - \ ' 64.37 error Expected space before paren space-before-paren', + \ ' 64.37 warn Expected space before paren space-before-paren', + \ ' 73.37 error Expected space before paren space-before-paren', + \ ]) + +Execute(The Vala-Lint handler should ignore unknown error types): + AssertEqual + \ [ + \ { + \ 'lnum': 73, + \ 'col': 37, + \ 'text': 'Expected space before paren', + \ 'code': 'space-before-paren', + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#vala#vala_lint#Handle(bufnr(''), [ + \ 'Application.vala', + \ ' 18.18 test Expected space before paren space-before-paren', \ ' 73.37 error Expected space before paren space-before-paren', \ ]) From 04550717bf023db549c67510c7df429d154f3934 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Tue, 5 Jan 2021 17:49:43 +0900 Subject: [PATCH 14/20] add Vala-Lint as supported linter --- doc/ale-supported-languages-and-tools.txt | 1 + supported-tools.md | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 5476be47..d8d10379 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -501,6 +501,7 @@ Notes: * `typecheck` * VALA * `uncrustify` + * `vala-lint`!! * Verilog * `hdl-checker` * `iverilog` diff --git a/supported-tools.md b/supported-tools.md index b07f6acf..21035ffb 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -510,6 +510,7 @@ formatting. * typecheck * VALA * [uncrustify](https://github.com/uncrustify/uncrustify) + * [vala-lint](https://github.com/vala-lang/vala-lint) :floppy_disk: * Verilog * [hdl-checker](https://pypi.org/project/hdl-checker) * [iverilog](https://github.com/steveicarus/iverilog) From 4328fe7dca248266a5cbaa0546581f37d0cf4c64 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Tue, 5 Jan 2021 17:51:59 +0900 Subject: [PATCH 15/20] add a blank line before if statement --- ale_linters/vala/vala_lint.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index d540323c..45e9b7d8 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -10,6 +10,7 @@ function! ale_linters#vala#vala_lint#GetCommand(buffer) abort if ale#Var(a:buffer, 'vala_vala_lint_enable_config') let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename') let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename) + if !empty(l:config_path) let l:command .= '-c ' . l:config_path . ' ' endif From e3e1ddce9558ddad360f1109d48ff9c7c66e4e19 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Thu, 14 Jan 2021 09:52:36 +0900 Subject: [PATCH 16/20] allow setting vala-lint executable --- ale_linters/vala/vala_lint.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 45e9b7d8..39879303 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -3,9 +3,14 @@ call ale#Set('vala_vala_lint_enable_config', 0) call ale#Set('vala_vala_lint_config_filename', 'vala-lint.conf') +call ale#Set('vala_vala_lint_executable', 'io.elementary.vala-lint') + +function! ale_linters#vala#vala_lint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'vala_vala_lint_executable') +endfunction function! ale_linters#vala#vala_lint#GetCommand(buffer) abort - let l:command = 'io.elementary.vala-lint ' + let l:command = ale_linters#vala#vala_lint#GetExecutable(a:buffer) if ale#Var(a:buffer, 'vala_vala_lint_enable_config') let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename') @@ -57,7 +62,7 @@ endfunction call ale#linter#Define('vala', { \ 'name': 'vala-lint', \ 'output_stream': 'stdout', -\ 'executable': 'io.elementary.vala-lint', +\ 'executable': function('ale_linters#vala#vala_lint#GetExecutable'), \ 'command': function('ale_linters#vala#vala_lint#GetCommand'), \ 'callback': 'ale_linters#vala#vala_lint#Handle', \ 'lint_file': 1, From 8d5b3e827df3fa21de32cd367dca95b76f9b0199 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Thu, 14 Jan 2021 09:54:01 +0900 Subject: [PATCH 17/20] decide whether or not to run with config file based on the presence of config filename value --- ale_linters/vala/vala_lint.vim | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 39879303..4c39ba42 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -1,7 +1,6 @@ " Author: Atsuya Takagi " Description: A linter for Vala using Vala-Lint. -call ale#Set('vala_vala_lint_enable_config', 0) call ale#Set('vala_vala_lint_config_filename', 'vala-lint.conf') call ale#Set('vala_vala_lint_executable', 'io.elementary.vala-lint') @@ -12,16 +11,14 @@ endfunction function! ale_linters#vala#vala_lint#GetCommand(buffer) abort let l:command = ale_linters#vala#vala_lint#GetExecutable(a:buffer) - if ale#Var(a:buffer, 'vala_vala_lint_enable_config') - let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename') - let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename) + let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename') + let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename) - if !empty(l:config_path) - let l:command .= '-c ' . l:config_path . ' ' - endif + if !empty(l:config_path) + let l:command .= ' -c ' . l:config_path endif - return l:command . '%s' + return l:command . ' %s' endfunction function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort From 33485ffb92e3718978793d24850d2adb2b08dbc2 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Thu, 14 Jan 2021 09:54:26 +0900 Subject: [PATCH 18/20] document the variables can be set for the linter --- doc/ale-vala.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/ale-vala.txt b/doc/ale-vala.txt index 94bf5400..d48f68bb 100644 --- a/doc/ale-vala.txt +++ b/doc/ale-vala.txt @@ -11,12 +11,12 @@ See |ale-c-uncrustify| for information about the available options. =============================================================================== Vala-Lint *ale-vala-vala-lint* -g:ale_vala_vala_lint_enable_config *g:vala_vala_lint_enable_config* - *b:vala_vala_lint_enable_config* - Type: |Number| - Default: `'0'` +g:vala_vala_lint_executable *g:vala_vala_lint_executable* + *b:vala_vala_lint_executable* + Type: |String| + Default: `'io.elementary.vala-lint'` - This variable can be set to enable or diable the use of Vala-Lint config file. + This variable can be set to specify a Vala-Lint executable file. g:vala_vala_lint_config_filename *g:vala_vala_lint_config_filename* @@ -24,7 +24,9 @@ g:vala_vala_lint_config_filename *g:vala_vala_lint_config_filename* Type: |String| Default: `'vala-lint.conf'` - This variable can be set to specify a Vala-Lint config filename. + This variable can be set to specify a Vala-Lint config filename. When a file + with the specified name was not found or this variable was set to empty, + Vala-Lint will be executed without specifying a config filename. =============================================================================== From 897f6b2b235f7ed7a6b0df7f228d18b74a7407e0 Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 23 Jan 2021 00:20:11 +0900 Subject: [PATCH 19/20] use snake case for linter name --- ale_linters/vala/vala_lint.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim index 4c39ba42..7f8a566a 100644 --- a/ale_linters/vala/vala_lint.vim +++ b/ale_linters/vala/vala_lint.vim @@ -57,7 +57,7 @@ function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort endfunction call ale#linter#Define('vala', { -\ 'name': 'vala-lint', +\ 'name': 'vala_lint', \ 'output_stream': 'stdout', \ 'executable': function('ale_linters#vala#vala_lint#GetExecutable'), \ 'command': function('ale_linters#vala#vala_lint#GetCommand'), From 6b0b8cec79d6805f57ff925923d7157ffb119a5a Mon Sep 17 00:00:00 2001 From: Atsuya Takagi Date: Sat, 23 Jan 2021 00:20:36 +0900 Subject: [PATCH 20/20] update doc with snake cased linter name --- doc/ale-supported-languages-and-tools.txt | 2 +- supported-tools.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index d8d10379..6fb17594 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -501,7 +501,7 @@ Notes: * `typecheck` * VALA * `uncrustify` - * `vala-lint`!! + * `vala_lint`!! * Verilog * `hdl-checker` * `iverilog` diff --git a/supported-tools.md b/supported-tools.md index 21035ffb..289c20e8 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -510,7 +510,7 @@ formatting. * typecheck * VALA * [uncrustify](https://github.com/uncrustify/uncrustify) - * [vala-lint](https://github.com/vala-lang/vala-lint) :floppy_disk: + * [vala_lint](https://github.com/vala-lang/vala-lint) :floppy_disk: * Verilog * [hdl-checker](https://pypi.org/project/hdl-checker) * [iverilog](https://github.com/steveicarus/iverilog)