Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda