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

Manual implementation of Debug trait for SymbolKind and CompletionItemKind as they are no longer Enums #221

Merged
merged 2 commits into from
Nov 1, 2021

Conversation

sidkshatriya
Copy link
Contributor

SymbolKind is no longer an Enum. The Debug trait needs to be manually implemented to prevent a regression downstream.

See kakoune-lsp/kakoune-lsp#550

@@ -1099,6 +1099,40 @@ impl SymbolKind {
pub const TYPE_PARAMETER: SymbolKind = SymbolKind(26);
}

impl Debug for SymbolKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find, thanks. IMO these stringified representations (with the official LSP names) should definitely be exposed, because they are good enough for many clients.

I wondered if we should implement Display instead of Debug because at least kak-lsp shows this to the user. Then again _ => write!(f, "SymbolKind({})", self.0), feel more at home in Debug, so I think it's fine.

In future it would be nice to have the same for the other 16 enum-turned-struct types. Maybe someone can devise a proc-macro to generate the methods - we just need to convert SOME_NAME to SomeName everywhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@sidkshatriya
Copy link
Contributor Author

Made a similar change for CompletionItemKind due to kakoune-lsp/kakoune-lsp#550 (comment)

@sidkshatriya sidkshatriya changed the title Manual implementation of Debug trait for SymbolKind now that it is not an Enum Manual implementation of Debug trait for SymbolKind and CompletionItemKind as they are no longer Enums Oct 31, 2021
@Marwes Marwes merged commit 6d9d04a into gluon-lang:master Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants