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

Use .lintr files for lintr #824

Open
ilyakopy opened this issue Aug 3, 2017 · 4 comments
Open

Use .lintr files for lintr #824

ilyakopy opened this issue Aug 3, 2017 · 4 comments

Comments

@ilyakopy
Copy link

ilyakopy commented Aug 3, 2017

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.

@w0rp
Copy link
Member

w0rp commented Aug 3, 2017

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?

@w0rp w0rp changed the title Configuration for lintr Use .lintr files for lintr Aug 3, 2017
@ilyakopy
Copy link
Author

ilyakopy commented Aug 4, 2017

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.

@w0rp
Copy link
Member

w0rp commented Aug 4, 2017

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.

@pat-s
Copy link

pat-s commented May 3, 2019

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants