Closed plokid closed 7 months ago
Unfortunately the symbols shown in the outline is determined by the provider (LSP/CoC). If you're using LSP, maybe that is all the information that the LSP provides?
OK, I found it's rust-analyzer problem. Thank you.
I found it problem is still there. rust-analyzer could provide the right information, like bellow
StructureNode { parent: None, label: "main", navigation_range: 3..7, node_range: 0..39, kind: SymbolKind(Function),
detail: Some("fn()"), deprecated: false }
StructureNode { parent: None, label: "A", navigation_range: 65..66, node_range: 41..106, kind: SymbolKind(Struct), d
etail: None, deprecated: false }
StructureNode { parent: Some(1), label: "index1", navigation_range: 73..79, node_range: 73..86, kind: SymbolKind(Fie
ld), detail: Some("usize"), deprecated: false }
StructureNode { parent: Some(1), label: "index2", navigation_range: 92..98, node_range: 92..103, kind: SymbolKind(Fi
eld), detail: Some("i32"), deprecated: false }
StructureNode { parent: None, label: "impl A", navigation_range: 113..114, node_range: 108..209, kind: SymbolKind(Im
pl), detail: None, deprecated: false }
StructureNode { parent: Some(4), label: "new", navigation_range: 128..131, node_range: 121..207, kind: SymbolKind(Fu
nction), detail: Some("fn(index1: usize, index2: i32) -> Self"), deprecated: false }
It looks like SymbolKind(Impl)
can not be handled correctly.
Could you share a source file with this issue so I can test it?
// src/main.rs
fn main() {
let a = A::new(1, 2);
}
struct A {
index1: usize,
index2: i32,
}
impl A {
pub fn new(index1: usize, index2: i32) -> Self {
Self { index1, index2 }
}
}
type B = u32;
static mut STATIC: usize = 0;
cat src/main.rs | rust-analyzer symbols
Btw before your comment I did a quick search and tried with this file: https://github.com/erikgrinaker/toydb/blob/master/src/client.rs
Here's what I get:
And using the code you provided:
Note that I don't know rust, but it looks like symbols with impl
are shown in both examples?
rustc 1.74.0 (79e9716c9 2023-11-13)
rust-analyzer 0.3.1730-standalone
I use lazyvim, it looks like there are some custom configuration that make it really chaos. anyway, thank you.
I noticed that symbols-outline.nvim does not parse
impl trait
and its functions in Rust. This makes it difficult to navigate through the codebase. I have attached two screenshots for comparison. The first screenshot shows the symbols parsed by symbols-outline.nvim, while the second screenshot shows the symbols parsed by github. I think the latter one is better.