mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-04 12:55:46 +08:00
4709e67627
SwiftFormat is a tool that can be used to format Swift files. This commit adds support for using SwiftFormat as a fixer from ALE. It looks for executables in the Pods directory, then the Pods directory for a React Native project, then finally falls back to the globally installed instance if neither of those were found. https://github.com/nicklockwood/SwiftFormat
26 lines
868 B
VimL
26 lines
868 B
VimL
" 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
|