2018-03-31 10:55:20 -04:00
|
|
|
" Author: Michel Lang <michellang@gmail.com>, w0rp <devw0rp@gmail.com>,
|
|
|
|
" Fenner Macrae <fmacrae.dev@gmail.com>
|
|
|
|
" Description: This file adds support for checking R code with lintr.
|
|
|
|
|
|
|
|
let g:ale_r_lintr_options = get(g:, 'ale_r_lintr_options', 'with_defaults()')
|
|
|
|
" A reasonable alternative default:
|
|
|
|
" get(g:, 'ale_r_lintr_options', 'with_defaults(object_usage_linter = NULL)')
|
|
|
|
|
|
|
|
|
|
|
|
let g:ale_r_lintr_lint_package = get(g:, 'ale_r_lintr_lint_package', 0)
|
|
|
|
|
|
|
|
function! ale_linters#r#lintr#GetCommand(buffer) abort
|
|
|
|
if ale#Var(a:buffer, 'r_lintr_lint_package')
|
|
|
|
let l:lint_cmd = 'lint_package(cache = FALSE, linters = '
|
|
|
|
\ . ale#Var(a:buffer, 'r_lintr_options') . ')'
|
|
|
|
else
|
|
|
|
let l:lint_cmd = 'lint(cache = FALSE, commandArgs(TRUE), '
|
|
|
|
\ . ale#Var(a:buffer, 'r_lintr_options') . ')'
|
|
|
|
endif
|
|
|
|
|
|
|
|
let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));'
|
|
|
|
\ . l:lint_cmd
|
|
|
|
|
|
|
|
return ale#path#BufferCdString(a:buffer)
|
2018-06-14 06:31:12 -04:00
|
|
|
\ . 'Rscript --vanilla -e '
|
2018-03-31 10:55:20 -04:00
|
|
|
\ . ale#Escape(l:cmd_string) . ' %t'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('r', {
|
|
|
|
\ 'name': 'lintr',
|
|
|
|
\ 'executable': 'Rscript',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'command': function('ale_linters#r#lintr#GetCommand'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
|
|
|
\ 'output_stream': 'both',
|
|
|
|
\})
|