coder3101 / protols

Language Server for protocol buffers
MIT License
46 stars 2 forks source link

try to add a document_symbols handler #9

Closed emarcotte-dh closed 3 months ago

emarcotte-dh commented 3 months ago

started using this the lsp the other day and found it very helpful to jump from message-to-message. thanks!

i use https://github.com/hedyhli/outline.nvim and work with some massive proto files, so i thought it might be nice to be able to get an outline of the file in the outline view.

i'm not an expert with treesitter node walking nor language servers so there are probably several optimizations that could be made.

not sure if there's interest in this but I figured i would post it anyway.

coder3101 commented 3 months ago

I'll check the PR later today. Thanks for the contribution.

emarcotte-dh commented 3 months ago

thanks for the notes! will prob be a few days before i get back to this

emarcotte-dh commented 3 months ago

I did have one other question that feels very "Man I haven't written enough rust" -- The lsp types struct for document symbols doesn't have any constructors/default implementation that I can find, but marks one if its fields deprecated. is there any way to avoid this:

warning: use of deprecated field `async_lsp::lsp_types::DocumentSymbol::deprecated`: Use tags instead
   --> src/parser.rs:199:21
    |
199 |                     deprecated: None,
    |                     ^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default
coder3101 commented 3 months ago

Best we can do is to suppress that deprecated struct initialisation using #[allow(deprecated)]. See https://github.com/rust-lang/rust/issues/102777

coder3101 commented 3 months ago

We can probably leverage DocumentSymbol for other operation such as goto-def, hover etc. But that is out of your PR's scope so I let that go for now.