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

bug: Trouble spams error messages under certain circumstances #527

Closed
3 tasks done
KodyVB opened this issue Jul 4, 2024 · 1 comment · Fixed by #530
Closed
3 tasks done

bug: Trouble spams error messages under certain circumstances #527

KodyVB opened this issue Jul 4, 2024 · 1 comment · Fixed by #530
Labels
bug Something isn't working

Comments

@KodyVB
Copy link

KodyVB commented Jul 4, 2024

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0

Operating system/version

Arch Linux 6.9.7

Describe the bug

Using Ruff and Python, if the wrong indentation is used and Trouble is brought up, a concat error is thrown, usually many times.

Steps To Reproduce

  1. Create a Python file with an error which will not cause this issue and save it
def main() -> None:
    prnt('a')
    print('b')


if __name__ == "__main__":
    main()
  1. Run :lua require("trouble").open("diagnostics")
  2. With the diagnostic tab still open, change the Python file so it has no errors and save it again
def main() -> None:
    print('a')
    print('b')


if __name__ == "__main__":
    main()
  1. Now introduce an indentation error
def main() -> None:
        print('a')
    print('b')


if __name__ == "__main__":
    main()
  1. Move the cursor around in normal mode and open command mode via :

Expected Behavior

Any errors should ideally show up once - this causes continuous errors after the cursor is moved around a few times.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/trouble.nvim",
{
-- for getting ruff installed
  "williamboman/mason.nvim",
  build = ":MasonUpdate",
  dependencies = {
    "WhoIsSethDaniel/mason-tool-installer.nvim",
  },
  config = function()
    local mason = require("mason")
    local mason_tool_installer = require("mason-tool-installer")

    mason.setup({})

    mason_tool_installer.setup({
      ensure_installed = {
        "ruff",
      },
      auto_update = false,
      run_on_start = true,
      start_delay = 0,
      debounce_hours = 0,
    })
  end,
},
{
-- to get ruff linting
  "mfussenegger/nvim-lint",
  config = function()
    local lint = require("lint")
    lint.linters_by_ft = {
      python = { "ruff" },
    }

    local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })

    vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "TextChanged" }, {
      group = lint_augroup,
      callback = function()
        lint.try_lint()
      end,
    })
  end,
}

}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@KodyVB KodyVB added the bug Something isn't working label Jul 4, 2024
@folke folke closed this as completed in edd9684 Jul 4, 2024
@folke
Copy link
Owner

folke commented Jul 4, 2024

Something weird is going on with ruff and Neovim.
It generates a vim.NIL as the diagnostics code, whcih is not supposed to happen.

Fixed it anyway. Thank you for the detailed bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants