bmatcuk / stylelint-lsp

A stylelint Language Server
MIT License
48 stars 4 forks source link

Slow shutdown after stylelint-lsp is running #17

Closed Gelio closed 3 years ago

Gelio commented 3 years ago

Hey :slightly_smiling_face: I've been using the LSP for a while and I have noticed that when existing neovim there is a noticeable delay when stylelint-lsp is active.

stylelint-lsp enabled:

https://user-images.githubusercontent.com/889383/116515211-43401500-a8cc-11eb-9baf-966a4580d7f8.mp4

stylelint-lsp disabled:

https://user-images.githubusercontent.com/889383/116515227-476c3280-a8cc-11eb-9328-0617e12b6d6f.mp4

A single video with stylelint-lsp enabled & then disabled:

https://user-images.githubusercontent.com/889383/116515383-84d0c000-a8cc-11eb-8f24-93b59c4fd44a.mp4

I'm not sure what could be causing this, I did not dive deep enough. This happens both in projects that use stylelint (have it configured) and those that do not (but the stylelint-lsp is still started).

bmatcuk commented 3 years ago

Hmm, when stylelint-lsp exits, it tries to send a message to let the client know - that's handled by coc-stylelintplus, but I doubt neovim's built-in lsp support does anything with it. It also delays 1s so the message can get through. That's probably the issue. You could try removing it and see if that helps. Comment out or delete these lines: https://github.com/bmatcuk/stylelint-lsp/blob/f00f5d1a1decf1c7f876dc75cbb8f50b7d2ad004/src/index.ts#L84-L91

Gelio commented 3 years ago

Yup, bullseye, that's it. After removing the lines you pointed out, nvim exits instantly, as if stylelint-lsp was not initialized.

I'm sure you'll have a better idea how to preserve this functionality only for coc-stylelintplus, so I'm not attempting to fix it 🙂

Anyway, I did not know a process can delay its exit by overwriting process.exit 😮 TIL

Gelio commented 3 years ago

Works great, this is indeed fixed - neovim exits instantly now with v1.2.3 😄 Thanks!