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

Do not request "textDocument/documentSymbol" when content changed #209

Closed
xiong-ang opened this issue Apr 21, 2020 · 5 comments
Closed

Do not request "textDocument/documentSymbol" when content changed #209

xiong-ang opened this issue Apr 21, 2020 · 5 comments
Labels

Comments

@xiong-ang
Copy link

Want to implement "Semantic Coloring" by the monaco-languageclient and LSP server.
But I find it does not request "textDocument/documentSymbol".
Desperately want to know whether the function is available? How to open it? Or are there any documents on this?

@CGNonofr
Copy link
Collaborator

To do so, you'll need a more recent version of monaco editor

I opened a PR (#207) to update to monaco 20.0.0

but I didn't implement registerDocumentSemanticTokensProvider and registerDocumentRangeSemanticTokensProvider (they are binded to unsupported), so I guess we'll need some changes to make it work

@xiong-ang
Copy link
Author

Good news. Wish that comes soon!

@rcjsuen
Copy link
Collaborator

rcjsuen commented Apr 21, 2020

Even if you hook up the semantic tokens provider, you won't get any colouring support because of microsoft/monaco-editor#1833.

@CGNonofr
Copy link
Collaborator

CGNonofr commented Apr 26, 2020

I just updated my PR to implement the new semantic token API, and I managed to make it work on the docker lsp (https://github.com/rcjsuen/dockerfile-language-server-nodejs) which is the only implementation for the moment

What you need to do is:

  • Use the code from my PR
  • enable semanticHighlighting:
import { StaticServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices'
StaticServices.configurationService.get().updateValue('editor.semanticHighlighting', {
  enabled: true
});
  • implement the getTokenStyleMetadata theme method:
import { StaticServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices'
const ThemeClass = StaticServices.standaloneThemeService.get()._theme.constructor;

interface ITokenStyle {
  readonly foreground?: number;
  readonly bold?: boolean;
  readonly underline?: boolean;
  readonly italic?: boolean;
}

ThemeClass.prototype.getTokenStyleMetadata = function (type: string, modifiers: string[], modelLanguage: string): ITokenStyle {
  // whatever you want based on the type and the modifier
  return {
    foreground: this.tokenTheme._colorMap.getId('#ff0000'),
    bold: true
  };
}

(The last parameter (modelLanguage) is undefined for the moment. It's already fixed in vscode but monaco-editor@0.20.0 was bundled before the fix)

  • register the feature on the language client:
const client = new MonacoLanguageClient({ ... })
client.registerProposedFeatures()

@stale
Copy link

stale bot commented Jun 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 26, 2020
@stale stale bot closed this as completed Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants