diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/syntax_tree.vim | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 85fef81d..9281ec61 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -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'], diff --git a/autoload/ale/fixers/syntax_tree.vim b/autoload/ale/fixers/syntax_tree.vim new file mode 100644 index 00000000..7ae03373 --- /dev/null +++ b/autoload/ale/fixers/syntax_tree.vim @@ -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 |