Language Server Syntax Highlights#1985
Merged
thecoolwinter merged 27 commits intoCodeEditApp:mainfrom May 9, 2025
Merged
Conversation
…ecoolwinter/CodeEdit into feat/lsp-semantic-highlighter
Collaborator
Author
|
This is officially ready for review with passing tests! |
tom-ludwig
requested changes
Mar 27, 2025
Member
tom-ludwig
left a comment
There was a problem hiding this comment.
This looks really nice! I do have some questions—some are just out of personal interest
CodeEdit/Features/LSP/LanguageServer/Capabilities/LanguageServer+DocumentSync.swift
Show resolved
Hide resolved
CodeEdit/Features/LSP/LanguageServer/Capabilities/LanguageServer+SemanticTokens.swift
Outdated
Show resolved
Hide resolved
CodeEdit/Features/LSP/LanguageServer/Capabilities/LanguageServer+SemanticTokens.swift
Outdated
Show resolved
Hide resolved
CodeEdit/Features/LSP/LanguageServer/Capabilities/LanguageServer+SemanticTokens.swift
Outdated
Show resolved
Hide resolved
Member
|
Looks good, will approve after the comments are resolved |
FastestMolasses
previously approved these changes
Apr 5, 2025
tom-ludwig
approved these changes
Apr 28, 2025
Collaborator
Author
|
Failing test is due to a bug in CETV that's fixed with this PR. This should be good to merge and would be great to get done. |
austincondiff
approved these changes
May 9, 2025
Collaborator
austincondiff
left a comment
There was a problem hiding this comment.
This has been open for a while and seeing as @FastestMolasses's only concern has been fixed, it shouldn't be a problem to merge. Lets move forward. ⏩ I did give it a quick look and it looks good from what I can tell. 👍
0xWDG
approved these changes
May 9, 2025
FastestMolasses
pushed a commit
that referenced
this pull request
May 12, 2025
Adds semantic token syntax highlighting to the code file view. When an LSP is installed and configured for a language type, and has semantic highlights support, CodeEdit will install a new highlight provider on the source editor and begin processing syntax tokens for the file. Token processing happens asynchronously, and does **not** replace tree-sitter highlights. This builds off recent work in the source editor to support a hierarchy of highlight providers. Language server highlights are slow but more accurate, so we process them slowly and apply them when they become available. - Adds a new generic 'language server document' protocol that includes only what the language server code needs to know about a code document. This should solve the coupling issue we had with CodeFileDocument and the language server code. In the future, if we replace `CodeFileDocument`, it'll be a matter of conforming the new type to the protocol for it to work with the lsp code. - Reorganizes slightly to group lsp features into their own "Features" folder. - Adds a new `SemanticTokenHighlightProvider` type - Conforms to the `HighlightProviding` protocol. - Manages receiving edit notifications from the editor and forwards them to the language server service. - Adds a `SemanticTokenMap` type - Maps LSP semantic token data to a format CodeEdit can read. - Reads a LSP's capabilities to determine how to decode that data. - Adds `SemanticTokenStorage` - Provides an API for applying token deltas, and entire file token data. - Manages decoding, re-decoding (when dealing with deltas) and storing semantic tokens. - Provides an API for finding semantic tokens quickly. * closes #1950 - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code  Live editing demo, note the highlights on the variable types and switch cases. https://github.com/user-attachments/assets/e70bf93c-779d-412b-9b34-c68e46898921
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds semantic token syntax highlighting to the code file view.
When an LSP is installed and configured for a language type, and has semantic highlights support, CodeEdit will install a new highlight provider on the source editor and begin processing syntax tokens for the file.
Token processing happens asynchronously, and does not replace tree-sitter highlights. This builds off recent work in the source editor to support a hierarchy of highlight providers. Language server highlights are slow but more accurate, so we process them slowly and apply them when they become available.
Details
CodeFileDocument, it'll be a matter of conforming the new type to the protocol for it to work with the lsp code.SemanticTokenHighlightProvidertypeHighlightProvidingprotocol.SemanticTokenMaptypeSemanticTokenStorageRelated Issues
Checklist
Screenshots
Live editing demo, note the highlights on the variable types and switch cases.
CodeEdit.mp4