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

[Bug] Color not applied in registerHoverProvider #4806

Open
1 of 2 tasks
hpvcodeDev opened this issue Jan 19, 2025 · 0 comments
Open
1 of 2 tasks

[Bug] Color not applied in registerHoverProvider #4806

hpvcodeDev opened this issue Jan 19, 2025 · 0 comments

Comments

@hpvcodeDev
Copy link

hpvcodeDev commented Jan 19, 2025

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

Hello, I am implementing my hoover tool to see the description of my TOKENs using monaco.languages.registerHoverProvider, it works very well for me when they are default languages ​​in monaco editor but if I use a custom language the content of the hoover panel is not painted with it color of my token assigned when creating my theme.

// Registrar el Hover Provider para el lenguaje 'ppl'
monaco.languages.registerHoverProvider('ppl', {
  provideHover: function (model, position) {
    const word = model.getWordAtPosition(position);
    if (!word) {
      return null; // Si no hay ninguna palabra bajo el cursor, no mostramos nada.
    }

    // Aquí puedes personalizar las palabras clave que quieres que tengan un hover especial
    if (word.word === 'FOR') {
      return {
        range: new monaco.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn),
        contents: [
          { value: '**FOR**: Esta es una declaración de bucle en PPL.' },
          { value: '---' }, // Esto crea una línea horizontal (separador)
          { value: 'Sintaxis: `FOR variable := 1 TO max DO`' },
          { value: '---' }, // Esto crea una línea horizontal (separador)
          { value: '**Documentación**: Permite iterar sobre un rango de valores.' }
        ]
      };
    }

    // Si no se encuentra una palabra clave, devolvemos null
    return null;
  }
});

Image

In theory it should use the colors that were assigned in my monaco.editor.defineTheme('ppl-theme-light', { and it doesn't, I don't know how to activate it if there is an option to do that.

For example, in VSCode, when you implement a custom language and add hoover, the color of your custom language is automatically assigned.

Image

Well I hope someone can help me achieve my goal, I leave you my code in Monaco editor Custom Code

Monaco Editor Playground Code

Reproduction Steps

No response

Actual (Problematic) Behavior

No response

Expected Behavior

No response

Additional Context

No response

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

No branches or pull requests

1 participant