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

feature: prepend_args support for "nvim-lint" #1887

Open
1 task done
UtkarshVerma opened this issue Oct 27, 2023 · 0 comments
Open
1 task done

feature: prepend_args support for "nvim-lint" #1887

UtkarshVerma opened this issue Oct 27, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@UtkarshVerma
Copy link

Did you check the docs?

  • I have read all the LazyVim docs

Is your feature request related to a problem? Please describe.

If I want to specify extra args for linters, there's no provision for doing that. For conform.nvim, we have prepend_args and LazyVim merges the passed opts with the defaults.

Describe the solution you'd like

As it is with formatters, support for this would be great. For example, since nvim-lint does not have a prepend_args key, we could reserve this key just for LazyVim where the config() function extends the default linter with the passed args.

This would result in a clean config on the user side like this:

  {
    "nvim-lint",
    opts = {
      linters_by_ft = {
        sh = { "shellcheck" },
      },
      linters = {
        shellcheck = {
          prepend_args = {
            "-x",
          },
        },
      },
    },
  },

Describe alternatives you've considered

mfussenegger/nvim-lint#397 discusses this, but when I assigned a function for shellcheck doing the same list extension, it did not work as the function overrides the default linter table.

Additional context

For now, in my config I have the following if condition to implement this feature.

      local lint = require("lint")
      for name, linter in pairs(opts.linters) do
        if type(linter) == "table" and type(lint.linters[name]) == "table" then
          lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter)

          if type(linter.prepend_args) == "table" then
            vim.list_extend(lint.linters[name].args, linter.prepend_args)
          end
        else
          lint.linters[name] = linter
        end
      end
      lint.linters_by_ft = opts.linters_by_ft
@UtkarshVerma UtkarshVerma added the enhancement New feature or request label Oct 27, 2023
@UtkarshVerma UtkarshVerma changed the title feature: feature: prepend_args support for "nvim-lint" Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant