summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorMo Lawson <mo@molawson.com>2022-08-09 07:11:20 -0500
committerGitHub <noreply@github.com>2022-08-09 21:11:20 +0900
commit233b68102990ee016f08614291ae92c6a0e2b90f (patch)
tree854596a2af98fa5f52bfc42f3b60150939abc779 /autoload
parent5063804d44fe149ed39149848f92b5960f4f7164 (diff)
downloadale-233b68102990ee016f08614291ae92c6a0e2b90f.zip
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
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/syntax_tree.vim19
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