Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a fixer for r based on the styler package #2401

Merged
merged 8 commits into from Apr 23, 2019
Next

Add styler as a new fixer for R files

  • Loading branch information...
tvatter committed Mar 28, 2019
commit 6b7fce0c77769f51549035568a0d2db32fa08d9b
@@ -280,6 +280,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.',
\ },
\}

" Reset the function registry to the default entries.
@@ -0,0 +1,16 @@
" Author: tvatter <thibault.vatter@gmail.com>
" Description: Fixing R files with syler.

This comment has been minimized.

Copy link
@lorenzwalthert

lorenzwalthert Apr 10, 2019

There is a typo in syler.

This comment has been minimized.

Copy link
@tvatter

tvatter Apr 10, 2019

Author Contributor

Just corrected


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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.