simrat39 / symbols-outline.nvim

A tree like view for symbols in Neovim using the Language Server Protocol. Supports all your favourite languages.
MIT License
1.85k stars 100 forks source link

some thing goes wrong at parser.lua:254 when using coc #164

Open yuklin opened 2 years ago

yuklin commented 2 years ago

some thing goes wrong at parser.lua:254

-- local hl_type = config.options.symbols[symbols.kinds[node.kind]].hl local hl_type = config.options.symbols[node.kind].hl

use symbols[node.kind] will be fine?

xyven1 commented 2 years ago

I am having an issue on the same line with CoQ and ccls. No issue when using CoQ with other parsers though. Seems to be related to other ccls issues, such as issue #28

rbjorklin commented 1 year ago

I arrived at the same conclusion and until #181 is merged you can try this instead:

use {
    "rbjorklin/symbols-outline.nvim",
    branch = "fix-outline-detection"
}
chrboesch commented 1 year ago

I arrived at the same conclusion and until #181 is merged you can try this instead: use { "rbjorklin/symbols-outline.nvim", ...

I tried, but get the same error as before: symbols-outline/parser.lua:254: attempt to index a nil value

rbjorklin commented 1 year ago

My PR was superseded by #183 so do give that a try.

chrboesch commented 1 year ago

Now I have looked at the source code. There is no check that the value "node.kind" is not equal to nil. That is the cause of the error if it is equal to nil.

badosu commented 1 year ago

I have the same error while using ccls and neovim lsp, I tried #181 and it didn't fix it for me.

geekifan commented 1 year ago

Now I have looked at the source code. There is no check that the value "node.kind" is not equal to nil. That is the cause of the error if it is equal to nil.

In fact, different lsp servers return different symbol infomation structures. The symbol information returned from some lsp servers may have no kind field at all. The code in this project is not rebust enough to handle all the conditions. I think it is necessary to refractor the providers and make sure the symbol info returned from these providers follows a predefined structure (it helps reduce code coupling).

badosu commented 1 year ago

The reason I'm sticking with this project is because the tree structure looks so much better than the alternatives, but if I can't get cpp to work then it's not useful to me :-/

chrboesch commented 1 year ago

When you change parser.lua line 254 into

    local hl_type = ""
    if symbols.kinds[node.kind] ~= nil then
        hl_type = config.options.symbols[symbols.kinds[node.kind]].hl
    end

then the error is fixed (at least for me).

badosu commented 1 year ago

Thank you! Works like a charm