]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/r/lintr.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'd49e95aa7ba744f0a7f544aca43afdb6aab41f24' as '.vim/bundle/asyncomplete...
[etc/vim.git] / .vim / bundle / ale / ale_linters / r / lintr.vim
1 " Author: Michel Lang <michellang@gmail.com>, w0rp <devw0rp@gmail.com>,
2 "         Fenner Macrae <fmacrae.dev@gmail.com>,
3 "         ourigen <https://github.com/ourigen>
4 " Description: This file adds support for checking R code with lintr.
5
6 let g:ale_r_lintr_options = get(g:, 'ale_r_lintr_options', 'with_defaults()')
7 " A reasonable alternative default:
8 "   get(g:, 'ale_r_lintr_options', 'with_defaults(object_usage_linter = NULL)')
9
10
11 let g:ale_r_lintr_lint_package = get(g:, 'ale_r_lintr_lint_package', 0)
12
13 function! ale_linters#r#lintr#GetCommand(buffer) abort
14     if ale#Var(a:buffer, 'r_lintr_lint_package')
15         let l:lint_cmd = 'lint_package(cache = FALSE, linters = '
16         \   . ale#Var(a:buffer, 'r_lintr_options') . ')'
17     else
18         let l:lint_cmd = 'lint(cache = FALSE, commandArgs(TRUE), '
19         \   . ale#Var(a:buffer, 'r_lintr_options') . ')'
20     endif
21
22     let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));'
23     \   . l:lint_cmd
24
25     return 'Rscript --no-save --no-restore --no-site-file --no-init-file -e ' . ale#Escape(l:cmd_string) . ' %t'
26 endfunction
27
28 call ale#linter#Define('r', {
29 \   'name': 'lintr',
30 \   'executable': 'Rscript',
31 \   'cwd': '%s:h',
32 \   'command': function('ale_linters#r#lintr#GetCommand'),
33 \   'callback': 'ale#handlers#gcc#HandleGCCFormat',
34 \   'output_stream': 'both',
35 \})