Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Current symbol preview is Empty #176

Open
AniAggarwal opened this issue Sep 29, 2022 · 19 comments
Open

Current symbol preview is Empty #176

AniAggarwal opened this issue Sep 29, 2022 · 19 comments

Comments

@AniAggarwal
Copy link

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.

@rbjorklin
Copy link

Until #181 is merged you can try this instead:

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

@wqk151
Copy link

wqk151 commented Oct 10, 2022

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

@AniAggarwal
Copy link
Author

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                                   

@rbjorklin
Copy link

@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>
})

@AniAggarwal
Copy link
Author

AniAggarwal commented Oct 11, 2022

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.

@rbjorklin
Copy link

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.

@AniAggarwal
Copy link
Author

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> 

@patilatharva
Copy link

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

@AniAggarwal
Copy link
Author

AniAggarwal commented Dec 20, 2022

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:
3fdc994

@pipoprods
Copy link

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?

@dpetka2001
Copy link

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?

@simrat39
Copy link
Owner

The issues should be fixed now

@dpetka2001
Copy link

dpetka2001 commented Jan 26, 2023

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?

@juanlopez4691
Copy link

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

@rockyzhang24
Copy link

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

@AniAggarwal
Copy link
Author

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

@AniAggarwal AniAggarwal reopened this Jan 31, 2023
@RobertLemmens
Copy link

same here

@enddeadroyal
Copy link

enddeadroyal commented Apr 25, 2023

@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

@dpetka2001
Copy link

@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?

cstsunfu added a commit to cstsunfu/symbols-outline.nvim that referenced this issue May 17, 2023
hedyhli added a commit to hedyhli/outline.nvim that referenced this issue Nov 1, 2023
Fix simrat39/symbols-outline.nvim#176

I was going to pull @enddeadroyal's commit from their
'bugfix/symbol-hover-misplacement' branch in their fork but they changed
indentation so I had to apply the relevant changes myself instead.

However, credits for this fix goes to @enddeadroyal from the issue
commit in 176.

Also fixed the "No info available" markdown as it wasn't rendering
properly for me without a space after the '###'.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests