mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-21 02:22:13 +08:00
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
This commit is contained in:
@@ -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'],
|
||||
|
||||
16
autoload/ale/fixers/styler.vim
Normal file
16
autoload/ale/fixers/styler.vim
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user