mirror of
https://github.com/dense-analysis/ale
synced 2024-12-25 07:32:24 +00:00
Add zig fmt support (#4198)
* Add zig fmt support * Review changes * Fix linter errors
This commit is contained in:
parent
e343148e80
commit
3d7b3a6541
@ -540,6 +540,11 @@ let s:default_registry = {
|
||||
\ 'function': 'ale#fixers#vfmt#Fix',
|
||||
\ 'suggested_filetypes': ['v'],
|
||||
\ 'description': 'A formatter for V source code.',
|
||||
\ },
|
||||
\ 'zigfmt': {
|
||||
\ 'function': 'ale#fixers#zigfmt#Fix',
|
||||
\ 'suggested_filetypes': ['zig'],
|
||||
\ 'description': 'Official formatter for Zig',
|
||||
\ }
|
||||
\}
|
||||
|
||||
|
14
autoload/ale/fixers/zigfmt.vim
Normal file
14
autoload/ale/fixers/zigfmt.vim
Normal file
@ -0,0 +1,14 @@
|
||||
scriptencoding utf-8
|
||||
" Author: Arash Mousavi <arash-m>
|
||||
" Description: Official formatter for Zig.
|
||||
|
||||
call ale#Set('zig_zigfmt_executable', 'zig')
|
||||
|
||||
function! ale#fixers#zigfmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'zig_zigfmt_executable')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . ' fmt %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
@ -668,6 +668,7 @@ Notes:
|
||||
* Zeek
|
||||
* `zeek`!!
|
||||
* Zig
|
||||
* `zigfmt`
|
||||
* `zls`
|
||||
|
||||
===============================================================================
|
||||
|
@ -7,6 +7,18 @@ Integration Information
|
||||
|
||||
Currently, the only supported linter for zig is zls.
|
||||
|
||||
|
||||
===============================================================================
|
||||
zigfmt *ale-zig-zigfmt*
|
||||
|
||||
g:ale_zig_zigfmt_executable *g:ale_zig_zigfmt_executable*
|
||||
*b:ale_zig_zigfmt_executable*
|
||||
Type: |String|
|
||||
Default: `'zig'`
|
||||
|
||||
The executable that will be run for the `zig fmt` fixer.
|
||||
|
||||
|
||||
===============================================================================
|
||||
zls *ale-zig-zls*
|
||||
|
||||
|
@ -3294,6 +3294,7 @@ documented in additional help files.
|
||||
zeek....................................|ale-zeek-options|
|
||||
zeek..................................|ale-zeek-zeek|
|
||||
zig.....................................|ale-zig-options|
|
||||
zigfmt................................|ale-zig-zigfmt|
|
||||
zls...................................|ale-zig-zls|
|
||||
|
||||
|
||||
|
@ -677,4 +677,5 @@ formatting.
|
||||
* Zeek
|
||||
* [zeek](http://zeek.org) :floppy_disk:
|
||||
* Zig
|
||||
* [zigfmt](https://github.com/ziglang/zig)
|
||||
* [zls](https://github.com/zigtools/zls)
|
||||
|
20
test/fixers/test_zigfmt_fixer_callback.vader
Normal file
20
test/fixers/test_zigfmt_fixer_callback.vader
Normal file
@ -0,0 +1,20 @@
|
||||
Before:
|
||||
call ale#assert#SetUpFixerTest('zig', 'zigfmt')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
Execute(The zig callback should return the correct default values):
|
||||
AssertFixer {
|
||||
\ 'command': ale#Escape('zig') . ' fmt %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
|
||||
Execute(The zig callback should allow custom zig executables):
|
||||
let g:ale_zig_zigfmt_executable = 'foo/bar'
|
||||
|
||||
AssertFixer {
|
||||
\ 'command': ale#Escape('foo/bar') . ' fmt %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
|
Loading…
Reference in New Issue
Block a user