nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.47k stars 288 forks source link

Outline auto_preview fails on win_position = left #1340

Closed HyperCrusher closed 12 months ago

HyperCrusher commented 12 months ago

Describe the bug

Issue

When win_position of outline is set to 'left' instead of right the float for the previews fails to render, and causes an error.

if win_position is set to 'right' or if layout = 'float' the preview works as intended.

The Error

Error detected while processing CursorMoved Autocommands for "": Error executing lua callback: ...ocal/share/nvim/lazy/lspsaga.nvim/lua/lspsaga/window.lua:154: 'width' key must be a positive Integer stack traceback: [C]: in function 'nvim_open_win' ...ocal/share/nvim/lazy/lspsaga.nvim/lua/lspsaga/window.lua:154: in function 'new_float' ...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:365: in function 'create_preview_win' ...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:437: in function <...re/nvim/lazy/lspsaga.nvim/lua/lspsaga/symbol/outline.lua:422>

Steps to reproduce

Minimal init.lua

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",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable",
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
        "neovim/nvim-lspconfig",
        dependencies = {
            "williamboman/mason.nvim",
            "williamboman/mason-lspconfig.nvim"
        },
        config = function()
            local lspconfig = require("lspconfig")
            require("mason").setup()
            require("mason-lspconfig").setup({
                ensure_installed = {
                    "lua_ls"
                },
            })
            lspconfig.lua_ls.setup({})
        end,
    },
    {
        "nvimdev/lspsaga.nvim",
        dependencies = {
            "nvim-treesitter/nvim-treesitter",
            "nvim-tree/nvim-web-devicons"
        },
        opts = {
            outline = {
                win_position = "left",
            }
        },
    }
})

Steps to reproduce

  1. Save this as min.lua
  2. Run nvim --clean -u ./min.lua min.lua
  3. As long as you are in min.lua (or any lua file since thats the only lsp I setup here) run Lspsaga outline
  4. The above error will present itself

Expected behavior

The preview should be shown to the right of the outline, so the reverse of the layout that occurs when win_position = 'right'

Neovim version (nvim -v)

0.9.4

lspsaga commit

85f7c38

Terminal name/version

kitty 0.30.1