Nvim TypeScript LSP is getting restarted constantly

277 views Asked by At

This is an issue I've been facing for about a month already. My TS LSP is getting constantly reloaded for certain projects and I can't find a fix for it. I'm constantly getting an Initializing JS/TS language features....

According to the log this happens due to some kind of updates to the tscofnig.json file, but there's nothing that updates it, I don't see any writes to the file or anything.

What I already tried:

  • LazyNvim and Astro distros;
  • My own configuration based on lazy.nvim;
  • Disabled every plugin except for lsp-config and mason;
  • Tried pure nvim config with Packer and only lsp-config;
  • Tried two different LSP's: tsserver and vtsls;

On the other hand VSCode doesn't seem to have this issue in those projects that are causing problems in nvim.

The only thing I found is that this happens for projects with TS 4.9 and above, no issues with TS 4.2 and below. Although, I haven't found any relevant information about incompatibility between tsserver/vtsls and latest versions of TypeScript.

Here's the log message after which the project is getting reloaded:

Info 1525 [16:30:00.888] event:
    {"seq":0,"type":"event","event":"projectLoadingStart","body":{"projectName":"[path-to-project]/tsconfig.json","reason":"Change in config file detected"}}

System:

  • MacBook Pro M1 Max
  • macOS Sonoma
  • nvim 0.9.2

Let me know if I can bring any more information to debug it.

2

There are 2 answers

0
nick.skriabin On BEST ANSWER

It turned out to be git related for some reason. I haven’t figured it out completely, but whenever I commit changes to tsconfig.json the problem disappears and LSP works just fine. I can live with that for now and gonna accept this answer until (if ever) somebody post a real solution.

4
obama On

I wish I could put this in a comment, as I'm not sure it really justifies an "answer", but I don't have enough reputation.

My VSCode was doing this prior to being away from work for 1.5 weeks, and I got back today and it's now working. It's possible something happened with our repo while I was gone that fixed this, but one thing I did today was update my .NET Core Runtime for an unrelated issue, so you could check that. I removed 6.0.16 and 5.0.17 from my PC and installed 7.0.12. I did do a cursory look through a diff of our repo from 2 weeks ago and didn't see anything Typescript related or package.json related that I would expect to have fixed this. That's not to say it isn't possible that some commit in that time fixed it.

In my search for a solution a few weeks ago I came across https://github.com/microsoft/TypeScript/issues/51927, which was the only open ticket I could find relating to this issue. I see that someone posted a potential solution in that thread 2 weeks ago, so you could try that as well.