symbols-outline.nvim icon indicating copy to clipboard operation
symbols-outline.nvim copied to clipboard

Current symbol preview is Empty

Open AniAggarwal opened this issue 1 year ago • 19 comments

When using this plugin, the symbol preview is always empty, regardless of which LSP is used.

Screenshots: On sumneko_lua: Screenshot from 2022-09-29 11-34-19

On Pyright: Screenshot from 2022-09-29 11-35-18

On Jdtls: Screenshot from 2022-09-29 11-36-05

Let me know if you need any other details on my config.

AniAggarwal avatar Sep 29 '22 15:09 AniAggarwal

Until #181 is merged you can try this instead:

use {
    "rbjorklin/symbols-outline.nvim",
    branch = "fix-outline-detection"
}

rbjorklin avatar Oct 10 '22 02:10 rbjorklin

Until #181 is merged you can try this instead:

use {
    "rbjorklin/symbols-outline.nvim",
    branch = "fix-outline-detection"
}

I tried it and it works fine, thanks

wqk151 avatar Oct 10 '22 10:10 wqk151

I get the following error when using that branch:

toggle:

E5108: Error executing lua ...acker/start/symbols-outline.nvim/lua/symbols-outline.lua:307: attempt to index field 'view' (a nil value)                                     
stack traceback:                                                                                                                                                            
        ...acker/start/symbols-outline.nvim/lua/symbols-outline.lua:307: in function 'toggle_outline'                                                                       
        [string ":lua"]:1: in main chunk   

open:

E5108: Error executing lua ...acker/start/symbols-outline.nvim/lua/symbols-outline.lua:315: attempt to index field 'view' (a nil value)                                     
stack traceback:                                                                                                                                                            
        ...acker/start/symbols-outline.nvim/lua/symbols-outline.lua:315: in function 'open_outline'                                                                         
        [string ":lua"]:1: in main chunk                                   

AniAggarwal avatar Oct 10 '22 18:10 AniAggarwal

@AniAggarwal I can recreate that error if I comment out all my configuration. Are you not initializing the plugin?

You need to explicitly configure this plugin in a file, for example: ~/.config/nvim/after/plugin/symbols.lua

local status, symbols = pcall(require, "symbols-outline")
if (not status) then return end

symbols.setup({
-- <config from README goes here>
})

rbjorklin avatar Oct 10 '22 23:10 rbjorklin

I am, except I'm just doing it at once as it should be equivalent.

Config using packer:

    use {
        "rbjorklin/symbols-outline.nvim",
        branch = "fix-outline-detection",
		config = function()
			require("symbols-outline").setup({ wrap = true })
		end,
    }

Error with this current setup:

Error executing vim.schedule lua callback: ...tart/symbols-outline.nvim/lua/symbols-outline/parser.lua:254: attempt to index a nil value                                                                                                                        
stack traceback:                                                                                                                                                                                                                                                
        ...tart/symbols-outline.nvim/lua/symbols-outline/parser.lua:254: in function 'get_lines'                                                                                                                                                                
        ...tart/symbols-outline.nvim/lua/symbols-outline/writer.lua:91: in function 'parse_and_write'                                                                                                                                                           
        ...acker/start/symbols-outline.nvim/lua/symbols-outline.lua:301: in function 'callback'                                                                                                                                                                 
        /opt/nvim/usr/share/nvim/runtime/lua/vim/lsp.lua:1958: in function 'handler'                                                                                                                                                                            
        /opt/nvim/usr/share/nvim/runtime/lua/vim/lsp.lua:1390: in function ''                                                                                                                                                                                   
        vim/_editor.lua: in function <vim/_editor.lua:0>          

EDIT: Using your setup with calling the setup in a different file results in the same above error.

AniAggarwal avatar Oct 11 '22 00:10 AniAggarwal

Just to be clear, this plugin doesn't seem to have a working default configuration so you need to provide the entire config block from the README for it to work.

rbjorklin avatar Oct 11 '22 00:10 rbjorklin

Oh, I didn't realize that. Here is current config and error:

Packer config:

    use {
        "rbjorklin/symbols-outline.nvim",
        branch = "fix-outline-detection",
    }

Symbols outline config:

local status, symbols = pcall(require, "symbols-outline")
if (not status) then return end

symbols.setup({
	highlight_hovered_item = true,
	show_guides = true,
	auto_preview = false,
	position = "right",
	relative_width = true,
	width = 25,
	auto_close = false,
	show_numbers = false,
	show_relative_numbers = false,
	show_symbol_details = true,
	preview_bg_highlight = "Pmenu",
	autofold_depth = nil,
	auto_unfold_hover = true,
	fold_markers = { "", "" },
	wrap = false,
	keymaps = { -- These keymaps can be a string or a table for multiple keys
		close = { "<Esc>", "q" },
		goto_location = "<Cr>",
		focus_location = "o",
		hover_symbol = "<C-space>",
		toggle_preview = "K",
		rename_symbol = "r",
		code_actions = "a",
		fold = "h",
		unfold = "l",
		fold_all = "W",
		unfold_all = "E",
		fold_reset = "R",
	},
	lsp_blacklist = {},
	symbol_blacklist = {},
	symbols = {
		File = { icon = "", hl = "TSURI" },
		Module = { icon = "", hl = "TSNamespace" },
		Namespace = { icon = "", hl = "TSNamespace" },
		Package = { icon = "", hl = "TSNamespace" },
		Class = { icon = "𝓒", hl = "TSType" },
		Method = { icon = "ƒ", hl = "TSMethod" },
		Property = { icon = "", hl = "TSMethod" },
		Field = { icon = "", hl = "TSField" },
		Constructor = { icon = "", hl = "TSConstructor" },
		Enum = { icon = "ℰ", hl = "TSType" },
		Interface = { icon = "ﰮ", hl = "TSType" },
		Function = { icon = "", hl = "TSFunction" },
		Variable = { icon = "", hl = "TSConstant" },
		Constant = { icon = "", hl = "TSConstant" },
		String = { icon = "𝓐", hl = "TSString" },
		Number = { icon = "#", hl = "TSNumber" },
		Boolean = { icon = "⊨", hl = "TSBoolean" },
		Array = { icon = "", hl = "TSConstant" },
		Object = { icon = "⦿", hl = "TSType" },
		Key = { icon = "🔐", hl = "TSType" },
		Null = { icon = "NULL", hl = "TSType" },
		EnumMember = { icon = "", hl = "TSField" },
		Struct = { icon = "𝓢", hl = "TSType" },
		Event = { icon = "🗲", hl = "TSType" },
		Operator = { icon = "+", hl = "TSOperator" },
		TypeParameter = { icon = "𝙏", hl = "TSParameter" },
	},
})

Error:

Error executing vim.schedule lua callback: ...tart/symbols-outline.nvim/lua/symbols-outline/parser.lua:254: attempt to index a nil value                                    
stack traceback:                                                                                                                                                            
        ...tart/symbols-outline.nvim/lua/symbols-outline/parser.lua:254: in function 'get_lines'                                                                            
        ...tart/symbols-outline.nvim/lua/symbols-outline/writer.lua:91: in function 'parse_and_write'                                                                       
        ...acker/start/symbols-outline.nvim/lua/symbols-outline.lua:301: in function 'callback'                                                                             
        /opt/nvim/usr/share/nvim/runtime/lua/vim/lsp.lua:1958: in function 'handler'                                                                                        
        /opt/nvim/usr/share/nvim/runtime/lua/vim/lsp.lua:1390: in function ''                                                                                               
        vim/_editor.lua: in function <vim/_editor.lua:0> 

AniAggarwal avatar Oct 12 '22 21:10 AniAggarwal

Facing the same issue - were you able to fix this?

patilatharva avatar Dec 12 '22 00:12 patilatharva

Yes. A few things:

Make sure this plugin and nvim treesitter are updated to the lastest version. Furthermore, the config needs to be changed to the following to fit the new namespaces with the latest treesitter update. Feel free to change/remove the custom icon declarations from my config.

symbols = require("symbols-outline")

symbols.setup({
	highlight_hovered_item = true,
	show_guides = true,
	auto_preview = false,
	position = "right",
	relative_width = true,
	width = 25,
	auto_close = false,
	show_numbers = false,
	show_relative_numbers = false,
	show_symbol_details = true,
	preview_bg_highlight = "Pmenu",
	autofold_depth = nil,
	auto_unfold_hover = true,
	fold_markers = { "", "" },
	wrap = false,
	keymaps = { -- These keymaps can be a string or a table for multiple keys
		close = { "<Esc>", "q" },
		goto_location = "<Cr>",
		focus_location = "o",
		hover_symbol = "<C-space>",
		toggle_preview = "K",
		rename_symbol = "r",
		code_actions = "a",
		fold = "h",
		unfold = "l",
		fold_all = "W",
		unfold_all = "E",
		fold_reset = "R",
	},
	lsp_blacklist = {},
	symbol_blacklist = {},
	symbols = {
		File = { icon = "", hl = "@text.uri" },
		Module = { icon = "", hl = "@namespace" },
		Namespace = { icon = "", hl = "@namespace" },
		Package = { icon = "", hl = "@namespace" },
		Class = { icon = "𝓒", hl = "@type" },
		Method = { icon = "ƒ", hl = "@method" },
		Property = { icon = "", hl = "@method" },
		Field = { icon = "", hl = "@field" },
		Constructor = { icon = "", hl = "@constructor" },
		Enum = { icon = "ℰ", hl = "@type" },
		Interface = { icon = "ﰮ", hl = "@type" },
		Function = { icon = "", hl = "@function" },
		Variable = { icon = "", hl = "@constant" },
		Constant = { icon = "", hl = "@constant" },
		String = { icon = "𝓐", hl = "@string" },
		Number = { icon = "#", hl = "@number" },
		Boolean = { icon = "⊨", hl = "@boolean" },
		Array = { icon = "", hl = "@constant" },
		Object = { icon = "⦿", hl = "@type" },
		Key = { icon = "🔐", hl = "@type" },
		Null = { icon = "NULL", hl = "@type" },
		EnumMember = { icon = "", hl = "@field" },
		Struct = { icon = "𝓢", hl = "@type" },
		Event = { icon = "🗲", hl = "@type" },
		Operator = { icon = "+", hl = "@operator" },
		TypeParameter = { icon = "𝙏", hl = "@parameter" },
	},
})

Check out this PR that updates the code in the README if you want to copy it from there instead of my config above: https://github.com/simrat39/symbols-outline.nvim/pull/191/commits/3fdc9942ee6726ac30621c5a91d424bb0eb74118

AniAggarwal avatar Dec 20 '22 22:12 AniAggarwal

I'm still having issues with PHP files… I've updated my plugins, I've updated all treesitter parsers and I'm only getting previews for top-most elements (namespaces & classes). Is there something I'm missing?

pipoprods avatar Dec 30 '22 15:12 pipoprods

Still getting an empty symbol preview even with the config in @AniAggarwal last post with the changes from the PR mentioned there. Using latest versions of both symbols-outline and nvim-treesitter. Is there anything else that might be needed or is something else wrong maybe?

dpetka2001 avatar Jan 24 '23 01:01 dpetka2001

The issues should be fixed now

simrat39 avatar Jan 25 '23 22:01 simrat39

Still getting an empty current symbol preview. It shows only the top-most elements. Are you able to get a preview for symbols except for the top-most level? Do you use something different in your config than the config provided a few posts above?

dpetka2001 avatar Jan 26 '23 00:01 dpetka2001

Same here. I get empty symbol preview except for the top level. symbols-outline and tree-sitter up to date. My symbols-outline configuration:

config = function()
      require('symbols-outline').setup({
        highlight_hovered_item = true,
        show_guides = true,
        position = 'right',
        border = 'single',
        relative_width = true,
        width = 25,
        auto_close = false,
        auto_preview = false,
        show_numbers = false,
        show_relative_numbers = false,
        show_symbol_details = true,
        preview_bg_highlight = 'Pmenu',
        winblend = 0,
        autofold_depth = nil,
        auto_unfold_hover = true,
        fold_markers = { '', '' },
        wrap = false,
        keymaps = { -- These keymaps can be a string or a table for multiple keys
          close = { '<Esc>', 'q' },
          goto_location = '<Cr>',
          focus_location = 'o',
          hover_symbol = '<C-space>',
          toggle_preview = 'K',
          rename_symbol = 'r',
          code_actions = 'a',
          show_help = '?',
          fold = 'h',
          unfold = 'l',
          fold_all = 'W',
          unfold_all = 'E',
          fold_reset = 'R',
        },
        lsp_blacklist = {},
        symbol_blacklist = {},
        symbols = {
          File = { icon = '', hl = '@text.uri' },
          Module = { icon = '', hl = '@namespace' },
          Namespace = { icon = '', hl = '@namespace' },
          Package = { icon = '', hl = '@namespace' },
          Class = { icon = '𝓒', hl = '@type' },
          Method = { icon = 'ƒ', hl = '@method' },
          Property = { icon = '', hl = '@method' },
          Field = { icon = '', hl = '@field' },
          Constructor = { icon = '', hl = '@constructor' },
          Enum = { icon = 'ℰ', hl = '@type' },
          Interface = { icon = 'ﰮ', hl = '@type' },
          Function = { icon = '', hl = '@function' },
          Variable = { icon = '', hl = '@constant' },
          Constant = { icon = '', hl = '@constant' },
          String = { icon = '𝓐', hl = '@string' },
          Number = { icon = '#', hl = '@number' },
          Boolean = { icon = '⊨', hl = '@boolean' },
          Array = { icon = '', hl = '@constant' },
          Object = { icon = '⦿', hl = '@type' },
          Key = { icon = '🔐', hl = '@type' },
          Null = { icon = 'NULL', hl = '@type' },
          EnumMember = { icon = '', hl = '@field' },
          Struct = { icon = '𝓢', hl = '@type' },
          Event = { icon = '🗲', hl = '@type' },
          Operator = { icon = '+', hl = '@operator' },
          TypeParameter = { icon = '𝙏', hl = '@parameter' },
          Component = { icon = '', hl = '@function' },
          Fragment = { icon = '', hl = '@constant' },
        }
      })
    end

juanlopez4691 avatar Jan 27 '23 10:01 juanlopez4691

@simrat39 This issue still exists and it should be re-opened.

rockyzhang24 avatar Jan 31 '23 08:01 rockyzhang24

I am also now experiencing this issue again and seeing as many others are, I'll reopen it.

AniAggarwal avatar Jan 31 '23 14:01 AniAggarwal

same here

RobertLemmens avatar Apr 02 '23 23:04 RobertLemmens

@RobertLemmens @AniAggarwal @rockyzhang24 @dpetka2001 @pipoprods @simrat39 u can use my fix branch to resolve this problem Packer:

use({
        'enddeadroyal/symbols-outline.nvim', branch = 'bugfix/symbol-hover-misplacement'
    })

because The following code has a problem

local node = so.state.outline_items[hovered_line]

fix is:(reference to hover.lua)

local node = so.state.flattened_outline_items[hovered_line]

It works !!! image

enddeadroyal avatar Apr 25 '23 18:04 enddeadroyal

@enddeadroyal Thank you for the fix. It works as supposed. Would you be willing to make a PR, so it can get merged upstream hopefully?

dpetka2001 avatar Apr 25 '23 18:04 dpetka2001