Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!