Merge pull request #842 from gfontenot/gf-swiftformat
Add support for SwiftFormat as a fixer
This commit is contained in:
@@ -72,6 +72,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['css', 'sass', 'scss', 'stylus'],
|
||||
\ 'description': 'Fix stylesheet files using stylelint --fix.',
|
||||
\ },
|
||||
\ 'swiftformat': {
|
||||
\ 'function': 'ale#fixers#swiftformat#Fix',
|
||||
\ 'suggested_filetypes': ['swift'],
|
||||
\ 'description': 'Apply SwiftFormat to a file.',
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
||||
25
autoload/ale/fixers/swiftformat.vim
Normal file
25
autoload/ale/fixers/swiftformat.vim
Normal file
@@ -0,0 +1,25 @@
|
||||
" Author: gfontenot (Gordon Fontenot) <gordon@fonten.io>
|
||||
" Description: Integration of SwiftFormat with ALE.
|
||||
|
||||
call ale#Set('swift_swiftformat_executable', 'swiftformat')
|
||||
call ale#Set('swift_swiftformat_use_global', 0)
|
||||
call ale#Set('swift_swiftformat_options', '')
|
||||
|
||||
function! ale#fixers#swiftformat#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'swift_swiftformat', [
|
||||
\ 'Pods/SwiftFormat/CommandLineTool/swiftformat',
|
||||
\ 'ios/Pods/SwiftFormat/CommandLineTool/swiftformat',
|
||||
\ 'swiftformat',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#swiftformat#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'swift_swiftformat_options')
|
||||
|
||||
return {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape(ale#fixers#swiftformat#GetExecutable(a:buffer))
|
||||
\ . ' %t'
|
||||
\ . ' ' . l:options,
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user