mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-19 00:05:04 +08:00
Add 'scalafmt' fixer for Scala files
closes https://github.com/w0rp/ale/issues/1299
This commit is contained in:
@@ -95,6 +95,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['ruby'],
|
||||
\ 'description': 'Fix ruby files with rufo',
|
||||
\ },
|
||||
\ 'scalafmt': {
|
||||
\ 'function': 'ale#fixers#scalafmt#Fix',
|
||||
\ 'suggested_filetypes': ['scala'],
|
||||
\ 'description': 'Fix Scala files using scalafmt',
|
||||
\ },
|
||||
\ 'standard': {
|
||||
\ 'function': 'ale#fixers#standard#Fix',
|
||||
\ 'suggested_filetypes': ['javascript'],
|
||||
|
||||
26
autoload/ale/fixers/scalafmt.vim
Normal file
26
autoload/ale/fixers/scalafmt.vim
Normal file
@@ -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