Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
how to get the word below the cursor when hovering over in LSP?

I am making a vscode extension for a programming language. At first i was doing all of the work using the extension api. Now i want to switch LSP. The feature I had implemented was that show the definition of builtin functions on hover.

This was the code:

vscode.languages.registerHoverProvider("lc", {
        provideHover(document, position) {
            const word = document.getText(
                document.getWordRangeAtPosition(position, /\b\w+(?=\(.*\))/)
            );
            if (builtin_funcs[word] != undefined) {
                return new vscode.Hover(
                    new vscode.MarkdownString(`${builtin_funcs[word]}`)
                );
            } else {
                return null;
            }
        },
    });

i was using the getWordRangeAtPosition function with the regex /\b\w+(?=\(.*\))/ to match functions. After getting the function name i searched it in the builtin_funcs array and returned the definition. function definition when hovering

Now i want to port this to LSP but i can't find getWordRangeAtPosition function equivalent.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda