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

Support for dynamic commands #18

Closed
yorickpeterse opened this issue May 14, 2021 · 4 comments
Closed

Support for dynamic commands #18

yorickpeterse opened this issue May 14, 2021 · 4 comments

Comments

@yorickpeterse
Copy link
Contributor

Some linters may need a dynamic command. For example, RuboCop (https://rubocop.org/) is a popular Ruby linter. Projects managing their Ruby dependencies using Bundler (https://bundler.io/) would have to run RuboCop using bundle exec rubocop .... Projects not using Bundler in turn have to use just rubocop.

Looking at the code of nvim-lint, there's only support for a static linter command (i.e. a string). This makes it impossible (I think?) to change the command to run based on the presence of a certain file (or some other condition).

Would it be possible to extend nvim-lint so the cmd field can be a function? In that case it would have to return the command to run. Argument wise I think it would only need the buffer number, as that should be enough to derive all the needed information (e.g. the directory of the buffer file).

@mfussenegger
Copy link
Owner

Would it be possible to extend nvim-lint so the cmd field can be a function? In that case it would have to return the command to run. Argument wise I think it would only need the buffer number, as that should be enough to derive all the needed information (e.g. the directory of the buffer file).

Yes, sounds good to me 👍

@mfussenegger
Copy link
Owner

#26 Allows the whole linter to be a function, so any option can be set dynamically if necessary.

@mfussenegger
Copy link
Owner

Closing this for now - I think #26 should be sufficient.

andreaswachowski added a commit to andreaswachowski/dotfiles that referenced this issue Sep 27, 2023
Basic setup from [^1]. Basic bundle integration found in [^3].

Open issues:
- Linting fails when rubocop is not available in the bundle.
  One can provide a function for the linter[^2] and should be able to
  use either the bundled rubocop, or a global rubocop as fallback.
- When rubocop itself fails (with error code 2), like when it sees an
  unrecognized cop in .rubocop.yml, this is unnoticed during editing.
- Make rubocop run on BufReadPost, InsertLeave, and TextChanged events.
  This is mentioned in mfussenegger/nvim-lint#336

[^1]: dietrichm/dotfiles#138
[^2]: mfussenegger/nvim-lint#18
[^3]: https://github.com/pfeiferj/dotfiles/blob/9fe44801e52590610d2090f2c03df6fbb31b6f57/dot_config/nvim/lua/plugins/lint.lua
@ooloth
Copy link

ooloth commented Feb 4, 2024

Closing this for now - I think #26 should be sufficient.

One drawback of only allowing the whole linter to be a function (instead of allowing individual options to be functions), is that if we only want to set one option dynamically (e.g. cmd), we still have to return the default values for all the other options as well (to avoid wiping them out).

For some linters, that involves copy/pasting quite a bit of custom logic from this repo, making our own configs more complicated than is ideal making it hard to tell which logic represents our change vs. the default values.

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

No branches or pull requests

3 participants