ale/ale_linters/r/lintr.vim

25 lines
926 B
VimL
Raw Normal View History

2017-07-03 21:34:22 +00:00
" Author: Michel Lang <michellang@gmail.com>, w0rp <devw0rp@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()')
2017-08-15 18:37:38 +00:00
" A reasonable alternative default:
" get(g:, 'ale_r_lintr_options', 'with_defaults(object_usage_linter = NULL)')
2017-08-15 18:37:38 +00:00
2017-07-03 21:34:22 +00:00
function! ale_linters#r#lintr#GetCommand(buffer) abort
let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));'
\ . 'lint(cache = FALSE, commandArgs(TRUE),'
\ . ale#Var(a:buffer, 'r_lintr_options') . ')'
2017-07-03 21:34:22 +00:00
return ale#path#BufferCdString(a:buffer)
\ . 'Rscript -e '
\ . ale#Escape(l:cmd_string) . ' %t'
2017-07-03 21:34:22 +00:00
endfunction
call ale#linter#Define('r', {
\ 'name': 'lintr',
\ 'executable': 'Rscript',
\ 'command_callback': 'ale_linters#r#lintr#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'output_stream': 'both',
\})