Ale: Use .lintr files for lintr

Created on 3 Aug 2017  路  4Comments  路  Source: dense-analysis/ale

Hi,
I am using lintr to lint R files. However, the .lintr file, which is in the same directory is not read, so I can't set any configuration settings. How do I set configuration settings for lintr?

Thanks.

enhancement

Most helpful comment

When you run .lintr in Rstudio or from the console, it will read the file from the working directory.

Here's my workaround. I made a clone of your repo and modified the lint function, so I could pass parameters to it:
function! ale_linters#r#lintr#GetCommand(buffer) abort return ale#path#BufferCdString(a:buffer) \ . 'Rscript -e ' . ale#Escape('lintr::lint(commandArgs(TRUE), lintr::with_defaults(line_length_linter = lintr::line_length_linter(120), assignment_linter = NULL))') . ' %t' endfunction

A better solution would be to create a variable you could set in .vimrc, where you could put the R variables lintr::with_defaults(line_length_linter = lintr::line_length_linter(120), assignment_linter = NULL)).

If you like this solution I can put in a PR in the next few days.

All 4 comments

I'm not familiar with how lintr is supposed to read .lintr files. Is there a command line argument which can be used for specifying the file to load?

When you run .lintr in Rstudio or from the console, it will read the file from the working directory.

Here's my workaround. I made a clone of your repo and modified the lint function, so I could pass parameters to it:
function! ale_linters#r#lintr#GetCommand(buffer) abort return ale#path#BufferCdString(a:buffer) \ . 'Rscript -e ' . ale#Escape('lintr::lint(commandArgs(TRUE), lintr::with_defaults(line_length_linter = lintr::line_length_linter(120), assignment_linter = NULL))') . ' %t' endfunction

A better solution would be to create a variable you could set in .vimrc, where you could put the R variables lintr::with_defaults(line_length_linter = lintr::line_length_linter(120), assignment_linter = NULL)).

If you like this solution I can put in a PR in the next few days.

Okay then, that shouldn't be hard to fix. If the the linter has to be run from the directory containing the .lintr file, we should use the function for finding files to find a directory containing the file, and use the function you used before for changing directory. This is also easy to cover with Vader tests.

Then we could consider other options for configuring things.

@ilyakopy @w0rp

Would love to see that feature being added.
I work in projects with different style guides that make a global setting of g:ale_r_lintr_options not very practical.

Your last comment sounds like that implementing this would not be much of a hassle?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

glepnir picture glepnir  路  3Comments

EdmundsEcho picture EdmundsEcho  路  3Comments

amerov picture amerov  路  4Comments

trevordmiller picture trevordmiller  路  4Comments

kronos29296 picture kronos29296  路  4Comments