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

First attempt to include the semantic highlight feature, introduced in specification 3.16.0. #740

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jlahoda
Copy link
Contributor

@jlahoda jlahoda commented Dec 25, 2020

This is a crude attempt to include semantic highlights introduced in LSP spec 3.16.0:
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_semanticTokens

It is mostly copied src/message_handler.cc#emitSemanticHighlight, with some tweaks. Feedback is welcome!

@MaskRay
Copy link
Owner

MaskRay commented Dec 26, 2020

Thanks! I guess the specification is probably a bit unfortunate, since the payload may be much larger than the ccls extension...

@FelipeLema
Copy link

I've been using this branch today and it looks like it works all right (at least, for starters… I didn't see any obvious errors or problems)

@MaskRay is there any documentation of how to handle the missing TODOs? (I didn't seem to run to any of these errors, btw)

Copy link
Owner

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

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

Do you know which client can be used for testing? It seems that semantic tokens do not support rainbow semantic highlighting?

@@ -25,6 +25,47 @@
namespace ccls {
using namespace llvm;

std::vector<const char *> SEMANTIC_TOKENS = {
Copy link
Owner

Choose a reason for hiding this comment

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

const char *SEMANTIC_TOKENS[] =

@@ -0,0 +1,257 @@
// Copyright 2017-2020 ccls Authors
Copy link
Owner

Choose a reason for hiding this comment

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

Omit year number // Copyright ccls Authors


}

void MessageHandler::textDocument_semanticTokensFull(
Copy link
Owner

Choose a reason for hiding this comment

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

This replicates too many lines in message_handler.cc. You can make the message_handler.cc implementation public and call that function.

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.

None yet

3 participants