Add zig fmt support (#4198)

* Add zig fmt support

* Review changes

* Fix linter errors
This commit is contained in:
Arash Mousavi
2022-05-16 23:38:54 +01:00
committed by GitHub
parent e343148e80
commit 3d7b3a6541
7 changed files with 54 additions and 0 deletions

View File

@@ -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',
\ }
\}

View 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