Compare commits

...
2 Commits
Author SHA1 Message Date
Nikita Korolevandds 2f4a866591 Add initial support for named-checkzone linter (#4961)
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Co-authored-by: ds <ds@local>
2025-05-05 15:05:51 +09:00
Benjamin Block f9de268816 Adding Roc language linters and fixers. (#4966)
* `roc_language_server`

* `roc format`

* `roc format annotate`
2025-05-05 15:01:45 +09:00
16 changed files with 356 additions and 0 deletions

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
" Description: named-checkzone for bindzone
call ale#Set('bindzone_checkzone_executable', 'named-checkzone')
call ale#Set('bindzone_checkzone_options', '-c IN')
function! ale_linters#bindzone#checkzone#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'bindzone_checkzone_options'))
\ . ' example.com %t'
endfunction
function! ale_linters#bindzone#checkzone#Handle(buffer, lines) abort
let l:warning_pattern = '\vzone example.com/IN: (.+)$'
let l:error_pattern = '\v:(\d+): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:error_pattern)
let l:lnum = l:match[1]
let l:text = l:match[2]
call add(l:output, {'text': l:text, 'lnum': l:lnum + 0, 'type': 'E'})
endfor
for l:match in ale#util#GetMatches(a:lines, l:warning_pattern)
let l:text = l:match[1]
" Ignore information messages
let l:scrub_match = matchlist(l:text, '\v(loaded serial|not loaded due to) ')
if empty(l:scrub_match)
call add(l:output, {'text': l:text, 'lnum': 0, 'type': 'W'})
endif
endfor
return l:output
endfunction
call ale#linter#Define('bindzone', {
\ 'name': 'checkzone',
\ 'executable': {b -> ale#Var(b, 'bindzone_checkzone_executable')},
\ 'command': function('ale_linters#bindzone#checkzone#GetCommand'),
\ 'callback': 'ale_linters#bindzone#checkzone#Handle',
\ 'read_buffer': 0,
\})
+25
View File
@@ -0,0 +1,25 @@
" Author: Benjamin Block <https://github.com/benjamindblock>
" Description: A language server for Roc.
function! ale_linters#roc#roc_language_server#GetProjectRoot(buffer) abort
let l:roc_main_file = ale#path#FindNearestFile(a:buffer, 'main.roc')
if !empty(l:roc_main_file)
return fnamemodify(l:roc_main_file, ':p:h')
else
return fnamemodify('', ':h')
endif
endfunction
call ale#Set('roc_roc_language_server_executable', 'roc_language_server')
call ale#Set('roc_roc_language_server_config', {})
call ale#linter#Define('roc', {
\ 'name': 'roc_language_server',
\ 'lsp': 'stdio',
\ 'language': 'roc',
\ 'lsp_config': {b -> ale#Var(b, 'roc_roc_language_server_config')},
\ 'executable': {b -> ale#Var(b, 'roc_roc_language_server_executable')},
\ 'command': '%e',
\ 'project_root': function('ale_linters#roc#roc_language_server#GetProjectRoot'),
\})
+10
View File
@@ -722,6 +722,16 @@ let s:default_registry = {
\ 'suggested_filetypes': ['typst'],
\ 'description': 'A formatter for Typst files',
\ },
\ 'roc_format': {
\ 'function': 'ale#fixers#roc_format#Fix',
\ 'suggested_filetypes': ['roc'],
\ 'description': 'Formats Roc files.',
\ },
\ 'roc_annotate': {
\ 'function': 'ale#fixers#roc_annotate#Fix',
\ 'suggested_filetypes': ['roc'],
\ 'description': 'Annotates all top-level definitions in Roc files.',
\ },
\}
" Reset the function registry to the default entries.
+21
View File
@@ -0,0 +1,21 @@
" Author: Benjamin Block <https://github.com/benjamindblock>
" Description: Official type annotation tool for Roc.
call ale#Set('roc_roc_annotate_executable', 'roc')
call ale#Set('roc_roc_annotate_options', '')
function! ale#fixers#roc_annotate#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'roc_roc_annotate_executable')
let l:command = l:executable . ' format annotate'
let l:options = ale#Var(a:buffer, 'roc_roc_annotate_options')
if l:options isnot# ''
let l:command .= ' ' . l:options
endif
return {
\ 'command': l:command . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction
+20
View File
@@ -0,0 +1,20 @@
" Author: Benjamin Block <https://github.com/benjamindblock>
" Description: Official formatter for Roc.
call ale#Set('roc_roc_format_executable', 'roc')
call ale#Set('roc_roc_format_options', '')
function! ale#fixers#roc_format#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'roc_roc_format_executable')
let l:command = l:executable . ' format'
let l:options = ale#Var(a:buffer, 'roc_roc_format_options')
if l:options isnot# ''
let l:command .= ' ' . l:options
endif
return {
\ 'command': l:command . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction
+32
View File
@@ -0,0 +1,32 @@
===============================================================================
ALE BINDZone Integration *ale-bindzone-options*
===============================================================================
checkzone *ale-bindzone-checkzone*
*ale-options.bindzone_checkzone_executable*
*g:ale_bindzone_checkzone_executable*
*b:ale_bindzone_checkzone_executable*
bindzone_checkzone_executable
g:ale_bindzone_checkzone_executable
Type: |String|
Default: `named-checkzone`
This variable can be changed to set the path to named-checkzone executable.
*ale-options.bindzone_checkzone_options*
*g:ale_bindzone_checkzone_options*
*b:ale_bindzone_checkzone_options*
bindzone_checkzone_options
g:ale_bindzone_checkzone_options
Type: |String|
Default: `-c IN`
This variable can be changed to add additional command-line arguments.
All available options can be found at:
https://bind9.readthedocs.io/en/stable/manpages.html#named-checkzone-zone-file-validation-tool
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
+79
View File
@@ -0,0 +1,79 @@
===============================================================================
ALE Roc Integration *ale-roc-options*
*ale-integration-roc*
===============================================================================
roc_language_server *ale-roc-roc-language-server*
*ale-options.roc_roc_language_server_executable*
*g:ale_roc_roc_language_server_executable*
*b:ale_roc_roc_language_server_executable*
roc_roc_language_server_executable
g:ale_roc_roc_language_server_executable
Type: |String|
Default: `'roc_language_server'`
This variable can be modified to change the executable path for
`roc_language_server`.
*ale-options.roc_roc_language_server_config*
*g:ale_roc_roc_language_server_config*
*b:ale_roc_roc_language_server_config*
roc_roc_language_server_config
g:ale_roc_roc_language_server_config
Type: |Dictionary|
Default: `{}`
Dictionary with configuration settings for roc_language_server.
===============================================================================
roc_format *ale-roc-roc-format*
*ale-options.roc_roc_format_executable*
*g:ale_roc_roc_format_executable*
*b:ale_roc_roc_format_executable*
roc_roc_format_executable
g:ale_roc_roc_format_executable
Type: |String|
Default: `'roc'`
This variable can be modified to change the executable path for `roc`.
*ale-options.roc_roc_format_options*
*g:ale_roc_roc_format_options*
*b:ale_roc_roc_format_options*
roc_roc_format_options
g:ale_roc_roc_format_options
Type: String
Default: `''`
Additional flags for `roc format`.
===============================================================================
roc_annotate *ale-roc-roc-annotate*
*ale-options.roc_roc_annotate_executable*
*g:ale_roc_roc_annotate_executable*
*b:ale_roc_roc_annotate_executable*
roc_roc_annotate_executable
g:ale_roc_roc_annotate_executable
Type: |String|
Default: `'roc'`
This variable can be modified to change the executable path for `roc`.
*ale-options.roc_roc_annotate_options*
*g:ale_roc_roc_annotate_options*
*b:ale_roc_roc_annotate_options*
roc_roc_annotate_options
g:ale_roc_roc_annotate_options
Type: String
Default: `''`
Additional flags for `roc format annotate`.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
@@ -60,6 +60,8 @@ Notes:
* `bibclean`
* Bicep
* `bicep`
* Bindzone
* `checkzone` (named-checkzone)
* BitBake
* `oelint-adv`
* Bourne Shell
@@ -586,6 +588,10 @@ Notes:
* `write-good`
* Robot
* `rflint`
* Roc
* roc_annotate
* roc_format
* roc_language_server
* RPM spec
* `rpmlint`
* Ruby
+6
View File
@@ -3361,6 +3361,8 @@ documented in additional help files.
bicep...................................|ale-bicep-options|
bicep.................................|ale-bicep-bicep|
az_bicep..............................|ale-bicep-az_bicep|
bindzone................................|ale-bindzone-options|
checkzone.............................|ale-bindzone-checkzone|
bitbake.................................|ale-bitbake-options|
oelint-adv............................|ale-bitbake-oelint_adv|
c.......................................|ale-c-options|
@@ -3820,6 +3822,10 @@ documented in additional help files.
write-good............................|ale-restructuredtext-write-good|
robot...................................|ale-robot-options|
rflint................................|ale-robot-rflint|
roc.....................................|ale-roc-options|
roc_language_server...................|ale-roc-roc-language-server|
roc_format............................|ale-roc-roc-format|
roc_annotate..........................|ale-roc-roc-annotate|
ruby....................................|ale-ruby-options|
brakeman..............................|ale-ruby-brakeman|
cspell................................|ale-ruby-cspell|
+6
View File
@@ -69,6 +69,8 @@ formatting.
* [bibclean](http://ftp.math.utah.edu/pub/bibclean/)
* Bicep
* [bicep](https://github.com/Azure/bicep) :floppy_disk:
* Bindzone
* [checkzone](https://bind9.readthedocs.io/en/stable/manpages.html#named-checkzone-zone-file-validation-tool)
* BitBake
* [oelint-adv](https://github.com/priv-kweihmann/oelint-adv)
* Bourne Shell
@@ -595,6 +597,10 @@ formatting.
* [write-good](https://github.com/btford/write-good)
* Robot
* [rflint](https://github.com/boakley/robotframework-lint)
* Roc
* [roc_annotate](https://github.com/roc-lang/roc)
* [roc_format](https://github.com/roc-lang/roc)
* [roc_language_server](https://github.com/roc-lang/roc)
* RPM spec
* [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`)
* Ruby
@@ -0,0 +1,20 @@
Before:
call ale#assert#SetUpFixerTest('roc', 'roc_annotate')
After:
call ale#assert#TearDownFixerTest()
Execute(The roc annotate callback should return the correct default values):
AssertFixer {
\ 'command': 'roc format annotate %t',
\ 'read_temporary_file': 1,
\}
Execute(The roc annotate callback should allow a custom executable):
let g:ale_roc_roc_annotate_executable = 'foo/bar'
AssertFixer {
\ 'command': 'foo/bar format annotate %t',
\ 'read_temporary_file': 1,
\}
@@ -0,0 +1,20 @@
Before:
call ale#assert#SetUpFixerTest('roc', 'roc_format')
After:
call ale#assert#TearDownFixerTest()
Execute(The roc format callback should return the correct default values):
AssertFixer {
\ 'command': 'roc format %t',
\ 'read_temporary_file': 1,
\}
Execute(The roc format callback should allow a custom executable):
let g:ale_roc_roc_format_executable = 'foo/bar'
AssertFixer {
\ 'command': 'foo/bar format %t',
\ 'read_temporary_file': 1,
\}
@@ -0,0 +1,26 @@
Before:
runtime ale_linters/bindzone/checkzone.vim
After:
call ale#linter#Reset()
Execute(The checkzone handler should handle basic warnings):
AssertEqual
\ [
\ {
\ 'lnum': 2,
\ 'type': 'E',
\ 'text': 'unknown RR type ''fasd''',
\ },
\ {
\ 'lnum': 0,
\ 'type': 'W',
\ 'text': '_some_srv._tcp.example.com/SRV ''some.example.com'' (out of zone) has no addresses records (A or AAAA)',
\ },
\ ],
\ ale_linters#bindzone#checkzone#Handle(1, [
\ 'zone example.com/IN: _some_srv._tcp.example.com/SRV ''some.example.com'' (out of zone) has no addresses records (A or AAAA)',
\ 'zone example.com/IN: loaded serial 2025050400',
\ 'zone example.com/IN: not loaded due to errors',
\ '/tmp/vb3wXsu/2/example.com:2: unknown RR type ''fasd''',
\ ])
+19
View File
@@ -0,0 +1,19 @@
Before:
call ale#assert#SetUpLinterTest('bindzone', 'checkzone')
After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
AssertLinter 'named-checkzone',
\ ale#Escape('named-checkzone') . ' -c IN example.com %t'
Execute(The default command should be overridden):
let b:ale_bindzone_checkzone_executable = '/bin/bind9-checkzone'
AssertLinter '/bin/bind9-checkzone',
\ ale#Escape('/bin/bind9-checkzone') . ' -c IN example.com %t'
Execute(The default options should be overridden):
let b:ale_bindzone_checkzone_options = '-c IN -d'
AssertLinter 'named-checkzone',
\ ale#Escape('named-checkzone') . ' -c IN -d example.com %t'
@@ -0,0 +1,23 @@
Before:
call ale#assert#SetUpLinterTest('roc', 'roc_language_server')
After:
call ale#assert#TearDownLinterTest()
Execute(The default executable path should be correct):
AssertLinter 'roc_language_server', ale#Escape('roc_language_server')
Execute(The project root should be detected correctly in empty directory):
AssertLSPProject '.'
Execute(The project root should be detected correctly with main.roc):
call ale#test#SetFilename('../test-files/roc/main.roc')
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/roc')
Execute(The LSP values should be set correctly):
call ale#test#SetFilename('../test-files/roc/main.roc')
AssertLSPLanguage 'roc'
AssertLSPOptions {}
AssertLSPConfig {}
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/roc')
View File
Whitespace-only changes.