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

Add new semantic token types #4232

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

bstaletic
Copy link
Collaborator

@bstaletic bstaletic commented May 10, 2024

PR Prelude

Thank you for working on YCM! :)

Please complete these steps and check these boxes (by putting an x inside
the brackets) before filing your PR:

  • I have read and understood YCM's CONTRIBUTING document.
  • I have read and understood YCM's CODE_OF_CONDUCT document.
  • I have included tests for the changes in my PR. If not, I have included a
    rationale for why I haven't.
  • I understand my PR may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Why this change is necessary and useful

The decorator type was introduced in LSP 1.17.
The concept type is used by clangd.

Reported by @amosnier on gitter.
The mapped value is just the first thing that came to my mind. Feel free to suggest bette alternatives.

[Please explain in detail why the changes in this PR are needed.]


This change is Reviewable

Copy link

codecov bot commented May 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.79%. Comparing base (5d8a7fe) to head (0af031d).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4232      +/-   ##
==========================================
- Coverage   89.87%   89.79%   -0.09%     
==========================================
  Files          37       37              
  Lines        4780     4780              
==========================================
- Hits         4296     4292       -4     
- Misses        484      488       +4     

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 LGTMs obtained (waiting on @bstaletic)


python/ycm/semantic_highlighting.py line 53 at r1 (raw file):

  'regexp': 'String',
  'operator': 'Operator',
  'decorator': 'Comment',

did a quick scan of the existing vim runtime files for decorator and see a little bit of inconsistency, but nothing like Comment; more decorators are highlighted like macros:

313:hi def link pythonDecorator		Define
314:hi def link pythonDecoratorName		Function
2091:hi def link typescriptDecorator             Special

Taking some liberty, I checked annotation too (as decorator/annotation are similar concepts), where PreProc is common:

385:hi def link dAnnotation          PreProc
208:hi def link scalaAnnotation PreProc
201:hi def link scalaParameterAnnotation Function
202:hi def link scalaParamAnnotationValue Keyword
203:hi def link scalaCommentAnnotation Function
348:hi def link javaAnnotation		PreProc

So I suggest following something like that. Maybe PreProc, maybe Special?


python/ycm/semantic_highlighting.py line 58 at r1 (raw file):

  # These are not part of the spec, but are used by clangd
  'bracket': 'Normal',
  'concept': 'Normal',

concept is a sort-of type right ? how does this look in practice ?

I know users can override HL groups but I feel like we should make it look good in the general case?

Copy link
Collaborator Author

@bstaletic bstaletic left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 LGTMs obtained (waiting on @puremourning)


python/ycm/semantic_highlighting.py line 53 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

did a quick scan of the existing vim runtime files for decorator and see a little bit of inconsistency, but nothing like Comment; more decorators are highlighted like macros:

313:hi def link pythonDecorator		Define
314:hi def link pythonDecoratorName		Function
2091:hi def link typescriptDecorator             Special

Taking some liberty, I checked annotation too (as decorator/annotation are similar concepts), where PreProc is common:

385:hi def link dAnnotation          PreProc
208:hi def link scalaAnnotation PreProc
201:hi def link scalaParameterAnnotation Function
202:hi def link scalaParamAnnotationValue Keyword
203:hi def link scalaCommentAnnotation Function
348:hi def link javaAnnotation		PreProc

So I suggest following something like that. Maybe PreProc, maybe Special?

Went with Special, but could not get pyright to work, so could not test.


python/ycm/semantic_highlighting.py line 58 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

concept is a sort-of type right ? how does this look in practice ?

I know users can override HL groups but I feel like we should make it look good in the general case?

Tested with Type. Here's asciinema:
https://asciinema.org/a/4CdIJRP3ktEbrVlrpd8nmP35z

Copy link
Member

@puremourning puremourning left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: 1 of 2 LGTMs obtained (waiting on @bstaletic)


python/ycm/semantic_highlighting.py line 58 at r1 (raw file):

Previously, bstaletic (Boris Staletic) wrote…

Tested with Type. Here's asciinema:
https://asciinema.org/a/4CdIJRP3ktEbrVlrpd8nmP35z

I think I like Type for this. thanks.

@puremourning
Copy link
Member

@Mergifyio rebase

The `decorator` type was introduced in LSP 1.17.
The `concept` type is used by clangd.
Copy link
Contributor

mergify bot commented Aug 15, 2024

rebase

✅ Branch has been successfully rebased

@puremourning puremourning added the Ship It! Manual override to merge a PR by maintainer label Aug 15, 2024
Copy link
Contributor

mergify bot commented Aug 15, 2024

Thanks for sending a PR!

@mergify mergify bot merged commit f67e5e6 into ycm-core:master Aug 15, 2024
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ship It! Manual override to merge a PR by maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants