nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.46k stars 287 forks source link

Floating window doesn't close when closing the buffer #843

Closed dane-harnett closed 1 year ago

dane-harnett commented 1 year ago

Describe the bug

When I open a hover doc or line diagnostics and then close the buffer using :bdelete the floating window persists

Steps to reproduce

local plugins = {
    {
        "nvim-treesitter/nvim-treesitter",
        config = function()
            local ts_configs_status_ok, ts_configs = pcall(require, "nvim-treesitter.configs")
            if not ts_configs_status_ok then
                return false
            end

            ts_configs.setup({
                ensure_installed = {
                    "bash",
                    "css",
                    "html",
                    "java",
                    "javascript",
                    "json",
                    "lua",
                    "markdown",
                    "tsx",
                    "typescript",
                },
                highlight = {
                    enable = true,
                },
            })
        end,
    },
    {
        "neovim/nvim-lspconfig",
        config = function()
            local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
            if not lspconfig_status_ok then
                return
            end
            local mason_status_ok, mason = pcall(require, "mason")
            if not mason_status_ok then
                return
            end
            local mason_lspconfig_status_ok, mason_lspconfig = pcall(require, "mason-lspconfig")
            if not mason_lspconfig_status_ok then
                return
            end
            local status_ok, lspsaga = pcall(require, "lspsaga")
            if not status_ok then
                return
            end

            local capabilities = vim.lsp.protocol.make_client_capabilities()

            mason.setup()
            mason_lspconfig.setup({
                ensure_installed = {
                    sumneko_lua,
                },
            })

            local runtime_path = vim.split(package.path, ";")
            table.insert(runtime_path, "lua/?.lua")
            table.insert(runtime_path, "lua/?/init.lua")
            lspconfig.sumneko_lua.setup({
                capabilities = capabilities,
                settings = {
                    Lua = {
                        runtime = {
                            version = "LuaJIT",
                            path = runtime_path,
                        },
                        diagnostics = {
                            globals = { "vim" },
                        },
                        workspace = {
                            library = vim.api.nvim_get_runtime_file("", true),
                        },
                        telemetry = {
                            enable = false,
                        },
                    },
                },
            })
            lspsaga.setup({})
        end,
        dependencies = {
            {
                "williamboman/mason.nvim",
            },
            {
                "williamboman/mason-lspconfig.nvim",
            },
            {
                "glepnir/lspsaga.nvim",
            },
        },
    },
}

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

require("lazy").setup(plugins)

nvim --clean -u min.lua

Open a *.lua file Place the cursor over a symbol :Lspsaga hover_doc :bd

See that the hover doc persists

Expected behavior

I expect the hover_doc to close when the buffer that is associated with it is also closed.

Neovim version (nvim -v)

NVIM v0.9.0-dev-4893+gadfad50ac-dirty

lspsaga commit

46231733235e44e9c4b32ddd9de1e77e37bc377f

Terminal name/version

wezterm 20221119-145034-49b9839f

dane-harnett commented 1 year ago

❤️ thank you.

dane-harnett commented 1 year ago

@glepnir I just noticed this also occurs when switching to a different buffer. Steps to reproduce: Trigger a hover while on a symbol and then trigger a go-to-definition for that same symbol which opens a different file in another buffer.

glepnir commented 1 year ago

fixed