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 v3: auto_close and auto_open broken #419

Closed
3 tasks done
simonmandlik opened this issue Apr 18, 2024 · 2 comments
Closed
3 tasks done

bug v3: auto_close and auto_open broken #419

simonmandlik opened this issue Apr 18, 2024 · 2 comments
Labels

Comments

@simonmandlik
Copy link

simonmandlik commented Apr 18, 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-dev-2949+g206475d79-Homebrew

Operating system/version

MacOS 14.4.1

Describe the bug

I can't get auto_open and auto_close to work even in the simplest configuration. Am I missing something?

Steps To Reproduce

  1. nvim -u repro.lua
  2. <leader>a, <leader>r
  3. <leader>xx
  4. <leader>a, <leader>r

Expected Behavior

I would expect the Trouble window to open after first <leader>a, and close after last <leader>r.

Actual behavior:

Screen.Recording.2024-04-18.at.15.26.16.mov

Thanks for the plugin!

Repro

Btw, the issue template for v3 doesn't contain branch = "dev", this may lead some people into installing v2 when creating MWEs by mistakes.

-- 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",
        branch = "dev",
        keys = {
            {
                "<leader>xx",
                "<cmd>Trouble diagnostics toggle<cr>",
                desc = "Diagnostics (Trouble)",
            },
        },
        opts = {
            auto_close = true,
            auto_open = true,
        }
    },
    {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        config = function ()
            require("nvim-treesitter.configs").setup {
                ensure_installed = { "markdown", "markdown_inline" },
            }
        end
    },
}

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

vim.cmd.colorscheme("tokyonight")
-- add anything else here

local ns = vim.api.nvim_create_namespace("test")

vim.keymap.set("n", "<leader>a", function()
    print("Adding diagnostics")
    vim.diagnostic.set(ns, 0, {{
        lnum=0,
        col=0,
        message="test",
        severity = vim.diagnostic.severity.ERROR,
    }})
end)

vim.keymap.set("n", "<leader>r", function()
    print("Removing diagnostics")
    vim.diagnostic.reset()
end)
@ejconlon
Copy link

I have also noticed that the latest version of trouble auto closes too early (when resolving the current error, not all errors).

folke added a commit that referenced this issue May 12, 2024
@folke
Copy link
Owner

folke commented May 12, 2024

Should be fixed now. Thank you for the detailed bug report!

@folke folke closed this as completed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants