summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorMatthew Lanigan <rintaun@gmail.com>2019-07-13 12:37:48 -0400
committerw0rp <w0rp@users.noreply.github.com>2019-07-13 17:37:48 +0100
commitabb38955d3acd452e37c15e7bae62022d1153859 (patch)
tree3dbb6b8d04a13c26d6f067e7c56da0aa59bcac03 /autoload
parent6c47d7fc352659cd2dc869a9a46a04a8492fc829 (diff)
downloadale-abb38955d3acd452e37c15e7bae62022d1153859.zip
Add Sorbet ruby linter and fixer (#2614)
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/sorbet.vim19
2 files changed, 24 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 121a33bd..c5ef1544 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -115,6 +115,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['scala'],
\ 'description': 'Fix Scala files using scalafmt',
\ },
+\ 'sorbet': {
+\ 'function': 'ale#fixers#sorbet#Fix',
+\ 'suggested_filetypes': ['ruby'],
+\ 'description': 'Fix ruby files with srb tc --autocorrect.',
+\ },
\ 'standard': {
\ 'function': 'ale#fixers#standard#Fix',
\ 'suggested_filetypes': ['javascript'],
diff --git a/autoload/ale/fixers/sorbet.vim b/autoload/ale/fixers/sorbet.vim
new file mode 100644
index 00000000..182f7300
--- /dev/null
+++ b/autoload/ale/fixers/sorbet.vim
@@ -0,0 +1,19 @@
+call ale#Set('ruby_sorbet_executable', 'srb')
+call ale#Set('ruby_sorbet_options', '')
+
+function! ale#fixers#sorbet#GetCommand(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable')
+ let l:options = ale#Var(a:buffer, 'ruby_sorbet_options')
+
+ return ale#handlers#ruby#EscapeExecutable(l:executable, 'srb')
+ \ . ' tc'
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' --autocorrect --file %t'
+endfunction
+
+function! ale#fixers#sorbet#Fix(buffer) abort
+ return {
+ \ 'command': ale#fixers#sorbet#GetCommand(a:buffer),
+ \ 'read_temporary_file': 1,
+ \}
+endfunction