-
Notifications
You must be signed in to change notification settings - Fork 156
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 monarch support for sora-editor #580
Merged
Merged
+7,773
−41
Conversation
This file contains 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
This commit adds support for the Monarch language system, including the implementation of MonarchGrammarDefinitionDSL for grammar definition, and updates to the language-monarch module to handle language loading and configuration. Theme support for Monarch is also introduced, allowing for dark and light mode theming consistency with TextMate.
Themes now load colors asynchronously, which prevents blocking the main thread when parsing and applying theme settings. This optimization enhances the overall performance andresponsiveness of the application when switching or initializing themes. The TokenTheme adapter was updated to handle the asynchronous loading of theme colors. MonarchColorScheme was modified to apply themes more efficiently, especially when dealing with legacy TextMate themes. Additionally, the theme registration and management logic was refactored to ensure themes are loaded only when necessary.
…kens Adjust the theme loading function to collect colors into a map when provided with a nullthemeColorsMap. This change simplifies theme loading logic and avoids unnecessary skipping of values. Additionally, modify the token color reading function to add a default empty token, ensuring that at least one token is always present. This prevents potential runtime issues due to empty token lists.
consistency and adhere to coding standards.
…x implementation Update the regex libraries to the latest versions and modify the implementation in the MonarchLanguage class to support the additional regex features. Additionally, refactor the JSON parsing logic in the AutoClosingPairConditional loading process for better clarity.
- Remove unnecessary logging statements in AsyncIncrementalAnalyzeManager to clean up the code. - Adjust if-statement formatting for consistency and better readability. - Eliminate unused code segments in JsonParseTests and adjust import statements. - Ensure consistent code formatting across the specified files for enhanced maintainability.
This looks great! Why it's not merged yet?? |
This commit merges `surroundingPairs` into `autoClosingPairs` in Monarch language configuration to simplify symbol pair matching. The logic for handling symbol pairs has been updated to consider both `surroundingPairs` and `autoClosingPairs` when determining matching pairs. If a pair is defined in both lists, the `notIn` property from both definitions is merged. Additionally, the behavior of auto-closing pairs has been refined. Now, auto-closing pairs will not be completed if no text is selected, preventing unintended insertions. This change aligns the behavior with common editor practices and improves user experience.
This commit fixes an issue where auto-closing pairs defined in Monarch language configurations were not being properly matched due to an incorrect flag in the SymbolPairEx initialization. The isMonarch flag is now correctly set to true, ensuring that auto-closing pair logic functions as intended within Monarch language definitions.
I'm planning to test monarch support, and I will merge this PR after that. |
…uration does not offer `onEnterRules`
…arch source files
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.
This PR introduces the monarch to sora-editor.
Introduction
Monarch is a lightweight, declarative lexical specification-based syntax highlighter designed by the VSCode development team. The main purpose of introducing this library is to leverage Monarch's concise syntax definition and loading speed. Compared to the TextMate module, it offers a 10% - 40% speed advantage when rendering large text code, making it suitable for scenarios that don't require complex highlighting effects but desire dynamically loaded syntax highlighting with a certain level of speed.
Usage
Refer to MainActivity.kt for usage, similar to
lang-textmate
.Screenshots and Comparison
Monarch effect and rendering time for View.java
output1.mp4
TextMate effect and rendering time for View.java
output.mp4
Other
This PR also implements VSCode theme loading and grammar repository abstraction, which may be useful in the future when rewriting the
lang-textmate
module to Kotlin implementation.