typescript-language-server / typescript-language-server

TypeScript & JavaScript Language Server

Home Page:https://www.npmjs.com/package/typescript-language-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arrow Function Syntax Highlighting

paskozdilar opened this issue · comments

I opened an issue in NeoVim related to this issue: neovim/neovim#26246

They have pointed out that I should report this issue to the server, not the client.


Here's a code example that reproduces the invalid syntax highlighing when used in NeoVim:

function example(foo: string, bar: (baz: string, foobar: (foobaz: string, foobarbaz: () => void) => void) => void) {
  console.log('foo 1', foo);
  bar(foo, () => {
    console.log('foo 2', foo);
  });
}

function main() {
 example('foo', (baz: string, foobar: (foobaz: string, foobarbaz: () => void) => void) => {
   foobar(baz, () => {
      console.log('baz', baz);
   });
 });
}

The highlighting I get is this:

image

The arrow function callback on the line 10 is not highlighted properly. In contrast, the arrow function callback on line 3 is highlighted properly.

It's not the server highlighting those. It's the syntax highlighting rules that your editor uses.
The comment in the neovim issue is a bit confusing since it mentions both.

Okay, thanks for the quick feedback!

I was under the impression that language servers could (and did) override default syntax highlighting (especially in complex languages such as C++ and TypeScript), but I guess I was wrong :)

I have reported the issue to the appropriate place now.

server provides semantic highlighting but that just adds some highlights on top of normal syntax highlighting and is not responsible for what you see in that particular case