Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect new SymbolKinds #344

Open
dbaeumer opened this issue Nov 27, 2017 · 35 comments
Open

Collect new SymbolKinds #344

dbaeumer opened this issue Nov 27, 2017 · 35 comments
Labels
document symbols feature-request Request for new features or functionality
Milestone

Comments

@dbaeumer
Copy link
Member

Collects new symbol kinds.

@dbaeumer dbaeumer added this to the On Deck milestone Nov 27, 2017
@dbaeumer dbaeumer added the feature-request Request for new features or functionality label Nov 27, 2017
@vladdu
Copy link
Contributor

vladdu commented Nov 27, 2017

I assume it's best to propose one item per comment, so that people can vote for it.

@vladdu
Copy link
Contributor

vladdu commented Nov 27, 2017

  • pragma / directive

@vladdu
Copy link
Contributor

vladdu commented Nov 27, 2017

  • macro

@rictic
Copy link
Contributor

rictic commented Nov 27, 2017

Slot, in the sense of a named, declared hole in a template that a user of the element can use to insert content.

e.g. <slot> in Shadow Dom v1, <content> in Shadow Dom v0, transclusion points in AngularJS, <ng-content> in Angular.

@laughedelic
Copy link
Contributor

laughedelic commented Nov 29, 2017

Value: There is CompletionItemKind.Value, but no SymbolKind.Value

This was referenced Dec 11, 2017
@tsmaeder
Copy link

Annotation

@raja-s
Copy link

raja-s commented Jan 8, 2019

Some languages make a fundamental distinction between a function that has a return type and a "function" that doesn't return anything, unlike in C for example where it's simply determined by whether or not the return type is void, so it would be useful to have a separate symbol kind that could be called for example Procedure.

@raja-s
Copy link

raja-s commented Jan 8, 2019

Type for type declarations.

@raja-s
Copy link

raja-s commented Jan 10, 2019

Parameter/Argument to be able to distinguish function/constructor/... parameters from actual variables.

@kenkangxgwe
Copy link
Contributor

Section for typesetting languages

@dbaeumer
Copy link
Member Author

@kenkangxgwe can you provide me with an example.

@kenkangxgwe
Copy link
Contributor

@dbaeumer
In LaTeX,

\section{Introduction}
%...

In Wolfram Language

(* ::Section:: *)
(*Introduction*)

In MATLAB

%%Introduction
// ...

In C#

#region section
// ...
#endregion  

@KamasamaK
Copy link
Contributor

KamasamaK commented Jan 25, 2019

Markdown also has sections. The VS Code built-in extension is currently using SymbolKind.String for them.

@movie-travel-code
Copy link

Should provide a symbol kind for the type alias?

go code as bellow.

type DogName = string

swift code as bellow.

typealias DogName = String

@anton-dessiatov
Copy link

That's pretty much Haskell-specific, but we could have a pattern symbol kind?

There is a GHC Extension named PatternSynonyms that enables syntax for sort-of-first-class patterns like this:

data Type = App String [Type]
pattern Arrow t1 t2 = App "->" [t1, t2]
pattern Int = App "Int" []

The lack of dedicated symbol kind It's not that big of a problem, currently Haskell Language Server happily uses Function for pattern synonyms, but for the sake of correctness it would be nice to have a special kind.

@DanTup
Copy link
Contributor

DanTup commented Sep 2, 2019

Dart is adding extension classes, and currently we're having to send SymbolKind=Class to avoid VS code using a default icon. It'd be nice to have some ability to have Extension classes and Extension methods better supported (either as kinds, or modifiers).

There are other comments here suggesting we should just make our own up, but the concerns with that are:

  1. Clients will show default icons which may be less appropriate than reusing other icons (for example the VS Code "Class" looks better for extension classes and mixins than the default icon)
  2. No guidance is given on the values - if we put them after the existing values, it's possible the spec will gain new ones. Should we just pick arbitrary large numbers?

@DavidGoldman
Copy link

Dart is adding extension classes, and currently we're having to send SymbolKind=Class to avoid VS code using a default icon. It'd be nice to have some ability to have Extension classes and Extension methods better supported (either as kinds, or modifiers).

There are other comments here suggesting we should just make our own up, but the concerns with that are:

  1. Clients will show default icons which may be less appropriate than reusing other icons (for example the VS Code "Class" looks better for extension classes and mixins than the default icon)
  2. No guidance is given on the values - if we put them after the existing values, it's possible the spec will gain new ones. Should we just pick arbitrary large numbers?

+1 to adding extension support to LSP's SymbolKind, potentially with a differentiator between Interface extensions and Class/Struct (implementation) extensions.

Objective-C itself contains categories which are widely used:

@interface MyClass : NSObject
@property int foo;
@end

@interface MyClass (CategoryAddingNewMethod)
- (void)doSomethingWithFoo;
@end

@implementation MyClass (CategoryAddingNewMethod)
- (void)doSomethingWithFoo {
  NSLog(@"Foo: %@", @(self.foo));
}
@end

and Swift contains extensions, which are also widely used:

class MyClass {
  var foo: Int
}
extension MyClass: SomeProtocol {
  func someMethodForProtocol {
    print("hi")
  }
}

@matklad
Copy link
Contributor

matklad commented Jan 13, 2020

@dbaeumer macro has quite a few upvotes, seems pretty uncontroversial to add, and does not really map to any of the existing symbol kinds.

What's the process for actually adding it to the protocol? I'd love to use it for rust-analyzer

@dbaeumer
Copy link
Member Author

@matklad for 3.16 we can make a push to add new kinds. I will synchronize with VS Code as well otherwise they will not be rendered nicely :-)

@DavidGoldman
Copy link

Friendly ping, is this still on the radar?

@dbaeumer
Copy link
Member Author

I checked with the VS Code team and there are currently no plans to add new symbol kinds. To work on this and propose new once we need a client that implements so. Otherwise only having them in the spec with no implementation is not very helpful.

@dbaeumer dbaeumer modified the milestones: 3.16, On Deck Nov 17, 2020
@matklad
Copy link
Contributor

matklad commented Nov 17, 2020

This list (attribute/annotation, union, typeAlias) is what's been implemented in rust-analyzer for a while, and which feels general-purpose enough to uplift to the protocol proper.

@dbaeumer
Copy link
Member Author

@matklad this is about SymbolKind and not about semantic tokens.

@matklad
Copy link
Contributor

matklad commented Nov 17, 2020

Oh, my bad, I confused both SemanticTokenType with SymbolKind, and server with client, sorry about that 🤦

But yeah, rust-analyzer will be ready to use macro, typeAlias and union for SymbolKind as soon as they are available! I don't think we can do this before the protocol is stabilized though: SymbolKinds, unlike SemanticTokenTypes, are not extensible.

@sam-mccall
Copy link
Contributor

sam-mccall commented Dec 8, 2020

Otherwise only having them in the spec with no implementation is not very helpful

They're valuable once implemented in both server and client, so there's a first-mover disadvantage.
We have several language servers saying they're willing to go first, but are unwilling to break the spec in order to do so. So having them in the spec solves the coordination problem (and practically, avoids having servers and other clients blocked on VSCode prioritizing this).

(FWIW I'd be eager to add both server and client support for StaticField and StaticMethod or so for both client and servers - the server is open-source but the client is not)

@dbaeumer
Copy link
Member Author

dbaeumer commented Dec 9, 2020

IMO StaticField and StaticMethod shouldn't be new symbol kinds. If we want to express this we should adopt the way how this is handled in semantic tokens. So I would rather have a SymbolModifier which says static, async, ..

@KamasamaK
Copy link
Contributor

@dbaeumer

So I would rather have a SymbolModifier which says static, async, ..

Did you mean SymbolTag?

@dbaeumer
Copy link
Member Author

dbaeumer commented Dec 9, 2020

@KamasamaK yes sorry. Was confused with semantic tokens.

@sam-mccall
Copy link
Contributor

Since this enum can't be extended by clients/servers, it would be useful to have unknown or other or something.

For C++ we'd like to be able to include macro expansions (not definitions) in the hierarchy in certain cases. (Basically, when a macro dumps a bunch of implementation-detail symbols with into a namespace, the outline is pretty confusing if we can't group those somehow). This is a weird thing to do and I'm not sure it makes sense to add a macroExpansion kind to LSP (especially if VSCode folks don't want more kinds). On the other hand, having to pretend these symbols are nulls or namespaces or something is pretty bad!

(I do agree with your point about StaticField and StaticMethod... the semantic tokens data model is nice!)

@DavidGoldman
Copy link

Just to confirm, if we wanted to implement this, we'd need to include support for a client as well, likely VS Code, right? How would we go about making contributions to VS Code - what needs to be done to support it in VS Code exactly? New icons + support for the new symbol kinds?

@dbaeumer
Copy link
Member Author

If you want new kinds to light up in VS Code then yes, we need support for VS Code as well. We can still extend the list in LSP and guard the new symbol kinds using a capability.

@gerdleon
Copy link

Some languages make a fundamental distinction between a function that has a return type and a "function" that doesn't return anything, unlike in C for example where it's simply determined by whether or not the return type is void, so it would be useful to have a separate symbol kind that could be called for example Procedure.

I would very much appreciate this.

@gerdleon
Copy link

To support languages that describe database structures table would be useful.

@kraigher
Copy link
Contributor

I wrote a proposal here #1186 (comment) that avoids the need to collect a long list symbol kinds globally.

@yyny
Copy link

yyny commented Apr 21, 2024

Label, for C/C++/Zig/JavaScript/Lua/Assembly/LLVM/etc. labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document symbols feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests