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

Unable to add args to flake8 #734

Open
SafetyMary opened this issue Jan 26, 2025 · 2 comments
Open

Unable to add args to flake8 #734

SafetyMary opened this issue Jan 26, 2025 · 2 comments

Comments

@SafetyMary
Copy link

SafetyMary commented Jan 26, 2025

My flake8 linter stops showing errors in neovim if i include a bare args = {} key value pair in my config. (But works in command mode "!flake8 my_script.py")

  {
    "mfussenegger/nvim-lint",
    opts = {
      linters_by_ft = {
        python = { "mypy", "flake8" },
      },
      linters = {
        mypy = {},
        flake8 = {
          args = {
          },
        },

Works fine if i commented out args = {}

  {
    "mfussenegger/nvim-lint",
    opts = {
      linters_by_ft = {
        python = { "mypy", "flake8" },
      },
      linters = {
        mypy = {},
        flake8 = {
          -- args = {
          -- },
        },

My end goal is to point it to a custom config location.

  {
    "mfussenegger/nvim-lint",
    opts = {
      linters_by_ft = {
        python = { "mypy", "flake8" },
      },
      linters = {
        mypy = {},
        flake8 = {
          args = {
            "--config",
            vim.fn.expand("~/.config/nvim/lua/plugins/.flake8"),
            "--",
          },
        },

It would work normally if i simply execute

!flake8 my_script.py --config "/home/<User>/.config/nvim/lua/plugins/.flake8"
@korney4eg
Copy link

korney4eg commented Jan 26, 2025

in my case I needed to add cmd parameter. So here is configuration for markdownlint:

      local lint = require 'lint'
      lint.linters_by_ft = {
        markdown = { 'markdownlint' },
      }
      lint.linters = {
        markdownlint = {
          args = { "--disable", "MD013", "--" },
          cmd = { 'markdownlint' }
        },

      }

So probably your config should look like

  {
    "mfussenegger/nvim-lint",
    opts = {
      linters_by_ft = {
        python = { "mypy", "flake8" },
      },
      linters = {
        mypy = {},
        flake8 = {
          args = {
            "--config",
            vim.fn.expand("~/.config/nvim/lua/plugins/.flake8"),
            "--",
          },
         cmd = {'flake8','my_script.py'}
        },

@SafetyMary
Copy link
Author

SafetyMary commented Jan 27, 2025

I tried adding cmd parameter but it did not help. Having bare args = {}, still stops flake8 from showing errors in neovim.

  {
    "mfussenegger/nvim-lint",
    opts = {
      linters_by_ft = {
        python = { "mypy", "flake8" },
      },
      linters = {
        mypy = {},
        flake8 = {
          cmd = "flake8",
          -- only works if the args parameter is removed
          -- args = {
          -- },
        },

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

2 participants