summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorThibault Vatter <thibault.vatter@gmail.com>2019-04-23 14:44:26 -0400
committerw0rp <w0rp@users.noreply.github.com>2019-04-23 19:44:26 +0100
commitce0b14979ea7429f07b6ca496333f72d93a8d013 (patch)
tree337a94162284dac87f87e155a27e5837ec3435ea /autoload
parent893ac34cca903df14dabee7bdee7a018675c16d4 (diff)
downloadale-ce0b14979ea7429f07b6ca496333f72d93a8d013.zip
Add a fixer for r based on the styler package (#2401)
* Add styler as a new fixer for R files * Add to the list of supported tools * Add documentation
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/styler.vim16
2 files changed, 21 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 2b43e40a..45da359a 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -285,6 +285,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['kt'],
\ 'description': 'Fix Kotlin files with ktlint.',
\ },
+\ 'styler': {
+\ 'function': 'ale#fixers#styler#Fix',
+\ 'suggested_filetypes': ['r'],
+\ 'description': 'Fix R files with styler.',
+\ },
\ 'latexindent': {
\ 'function': 'ale#fixers#latexindent#Fix',
\ 'suggested_filetypes': ['tex'],
diff --git a/autoload/ale/fixers/styler.vim b/autoload/ale/fixers/styler.vim
new file mode 100644
index 00000000..7ff3275c
--- /dev/null
+++ b/autoload/ale/fixers/styler.vim
@@ -0,0 +1,16 @@
+" Author: tvatter <thibault.vatter@gmail.com>
+" Description: Fixing R files with styler.
+
+call ale#Set('r_styler_executable', 'Rscript')
+call ale#Set('r_styler_options', 'tidyverse_style')
+
+function! ale#fixers#styler#Fix(buffer) abort
+ return {
+ \ 'command': 'Rscript --vanilla -e '
+ \ . '"suppressPackageStartupMessages(library(styler));'
+ \ . 'style_file(commandArgs(TRUE), style = '
+ \ . ale#Var(a:buffer, 'r_styler_options') . ')"'
+ \ . ' %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction