mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-19 23:09:58 +08:00
Add 'scalafmt' fixer for Scala files
closes https://github.com/w0rp/ale/issues/1299
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
" Author: Jeffrey Lau https://github.com/zoonfafer
|
||||
" Description: Integration of Scalafmt with ALE.
|
||||
|
||||
call ale#Set('scala_scalafmt_executable', 'scalafmt')
|
||||
call ale#Set('scala_scalafmt_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('scala_scalafmt_options', '')
|
||||
|
||||
function! ale#fixers#scalafmt#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'scala_scalafmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'scala_scalafmt_options')
|
||||
let l:exec_args = l:executable =~? 'ng$'
|
||||
\ ? ' scalafmt'
|
||||
\ : ''
|
||||
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %t'
|
||||
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#scalafmt#Fix(buffer) abort
|
||||
return {
|
||||
\ 'command': ale#fixers#scalafmt#GetCommand(a:buffer),
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user