Skip to content

Make lsp-ui-imenu hierarchical #73

Closed
@MaskRay

Description

@MaskRay

lsp--imenu-create-index from lsp-imenu.el (in lsp-mode) does not take hierarchy into consideration. I think it might be useful if it can be used to visualize arbitrary symbol hierarchy, where the most common ones are:

  • member hierarchy: members of a type (e.g. members of a class/struct; enumeration constants in an enum; members in a module/namespace) are recursively expanded
struct B { B* x; int b; };
struct A { B b;  int c; };

may expand to

A
  B b
    int b
    B* x    // pointer types can optionally be expanded
      int b
      B* x   // but the client needs to explicitly trigger the expansion to avoid infinite recursion
        int b
        B* x
  int c
  • caller tree of a callable (e.g. function,method,...). (may be generalized to reference tree)
void foo() { bar(); quz(); foo(); }
void bar() { quz(); }

is visualized as:

quz
  foo
    foo   // explicit expansion to avoid infinite recursion
  bar
    foo
      foo
  • inheritance hierarchy (e.g. all derived classes of a C++ base class, or overriden virtual functions of a base function; Rust trait/impl; Java interface...)
struct B : A {};
struct C : B {};
struct D : B {};

is visualized as:

A
  B
    C
    D

LSP spec

interface SymbolInformation {
	name: string;
        // id is missing; name may be insufficient to identify a symbol
	kind: number;
	location: Location;
	containerName?: string;  // containerName is a string. If it was an identifier, it could be used to describe a parent pointer tree
}

When the point is at a reference of a symbol, textDocument/documentHighlight or other mechanism can be employed to highlight the imenu entry and there can be some keys to trigger these different kinds of hierarchies.

I'd like to know if such extensions have been implemented in other servers. We should unify these server API interfaces and even standardize it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions