mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-09 13:02:28 +08:00
Add support for syntax_tree fixer (#4268)
This is the library that now powers prettier/plugin-ruby but is also stands on its own: https://github.com/ruby-syntax-tree/syntax_tree
This commit is contained in:
@@ -221,6 +221,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['swift'],
|
||||
\ 'description': 'Apply SwiftFormat to a file.',
|
||||
\ },
|
||||
\ 'syntax_tree': {
|
||||
\ 'function': 'ale#fixers#syntax_tree#Fix',
|
||||
\ 'suggested_filetypes': ['ruby'],
|
||||
\ 'description': 'Fix ruby files with stree write',
|
||||
\ },
|
||||
\ 'apple-swift-format': {
|
||||
\ 'function': 'ale#fixers#appleswiftformat#Fix',
|
||||
\ 'suggested_filetypes': ['swift'],
|
||||
|
||||
19
autoload/ale/fixers/syntax_tree.vim
Normal file
19
autoload/ale/fixers/syntax_tree.vim
Normal file
@@ -0,0 +1,19 @@
|
||||
call ale#Set('ruby_syntax_tree_options', '')
|
||||
call ale#Set('ruby_syntax_tree_executable', 'stree')
|
||||
|
||||
function! ale#fixers#syntax_tree#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'ruby_syntax_tree_executable')
|
||||
let l:options = ale#Var(a:buffer, 'ruby_syntax_tree_options')
|
||||
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'stree')
|
||||
\ . ' write'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#syntax_tree#Fix(buffer) abort
|
||||
return {
|
||||
\ 'command': ale#fixers#syntax_tree#GetCommand(a:buffer),
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user