-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Language Server Syntax Highlights #1985
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
Language Server Syntax Highlights #1985
Conversation
…ecoolwinter/CodeEdit into feat/lsp-semantic-highlighter
This is officially ready for review with passing tests! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Looks good, will approve after the comments are resolved |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. 👍
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
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.SemanticTokenHighlightProvider
typeHighlightProviding
protocol.SemanticTokenMap
typeSemanticTokenStorage
Related Issues
Checklist
Screenshots
Live editing demo, note the highlights on the variable types and switch cases.
CodeEdit.mp4