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

Added language service support for auto-completion and semantic token #1175

Merged
merged 1 commit into from
Jun 1, 2024

Conversation

veler
Copy link
Collaborator

@veler veler commented May 26, 2024

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • New feature or enhancement
  • UI change (please include screenshot!)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Internationalization and localization
  • Other (please describe):

What is the current behavior?

There's no way to have a custom language support using Monaco Editor in DevToys.

What is the new behavior?

Added a Language Service API that reflects the one of Monaco Editor (but simplified and abstracted as much as possible). Specifically, auto-completion and semantic colorization is supported.

Other information

To use it, in a DevToys extension:

[Export(typeof(ILanguageService))]
[Name("my-language")]
internal sealed class MyLanguageService : ILanguageService
{
    public async Task<IReadOnlyList<AutoCompletionItem>> GetAutoCompletionItemsAsync(string textDocument, TextSpan span, CancellationToken cancellationToken)
    {
        // TODO
    }
    
    public async Task<IReadOnlyList<SemanticToken>> GetSemanticTokensAsync(string textDocument, CancellationToken cancellationToken)
    {
        // TODO
    }
}

// And then, in a IGuiTool:

MultiLineTextInput().Language("my-language")

Here is how things can look like when implementing these methods:

image

Quality check

Before creating this PR:

  • Did you follow the code style guideline as described in CONTRIBUTING.md
  • Did you build the app and test your changes?
  • Did you check for accessibility? On Windows, you can use Accessibility Insights for this.
  • Did you verify that the change work in Release build configuration
  • Did you verify that all unit tests pass
  • Tested manually with a sample extension.
  • If necessary and if possible, did you verify your changes on:
    • Windows
    • macOS
    • Linux

@veler veler requested a review from btiteux May 26, 2024 20:42
@veler veler merged commit 0c3c85d into main Jun 1, 2024
3 checks passed
@veler veler deleted the language-service branch June 1, 2024 17:03
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.

2 participants