elijah-potter / harper

The Grammar Checker for Developers
https://writewithharper.com
Apache License 2.0
1.91k stars 35 forks source link

Strange behaviour when calling `LSPStop` in neovim #139

Open dehanj opened 2 months ago

dehanj commented 2 months ago

Hi,

When i try to stop the harper-ls using LSPStop, the diagnostic hints stays in the buffer with the swirly lines under the words. It seems as the ls has actually stopped because the Code Action is not available anymore. If I try to start harper-ls again, it does not seem to change anything. No Code action available, but the diagnostics with swirly lines is still there.

It seems isolated to harper-ls, I can toggle other ls just fine.

Not sure if this is a bug or something I'm missing.

I run NVIM v0.10.1. I have installed harper-ls through Mason:

    ◍ harper-ls harper_ls
      The Grammar Checker for Developers.

      installed version v0.10.0                                                                         
      homepage          https://github.com/elijah-potter/harper                                         
      languages         Markdown, Rust, TypeScript, JavaScript, Python, Go, C, C++, Ruby, C#, TOML, Lua 
      categories        LSP                                                                             
      executables       harper-ls                                                                       

In the lsp.log I do see these entries:

[ERROR][2024-09-05 09:25:09] .../vim/lsp/rpc.lua:770    "rpc"   "/Users/dh/.local/share/nvim/mason/bin/harper-ls"   "stderr"    "\27[2m2024-09-05T07:25:09.954766Z\27[0m \27[32m INFO\27[0m \27[2mtower_lsp::service::layers\27[0m\27[2m:\27[0m exit notification received, stopping\n"
[ERROR][2024-09-05 09:27:15] .../vim/lsp/rpc.lua:770    "rpc"   "/Users/dh/.local/share/nvim/mason/bin/harper-ls"   "stderr"    "\27[2m2024-09-05T07:27:15.166087Z\27[0m \27[31mERROR\27[0m \27[2mtower_lsp::transport\27[0m\27[2m:\27[0m language server has exited\n"

I cannot find any entries in the lsp.log about starting harper_ls, not even after calling LSPStart harper-ls

Let me know if some more info is needed. Any help would be appreciated.

piersolenski commented 2 months ago

Having this issue too!

adam-coates commented 1 month ago

Also same here, and :Lsprestart won't restart harper-ls. This might also be related, but when I use a user defined dictionary (e.g. nvim's native dictionary vim.fn.stdpath("config") .. "/spell/en.utf-8.add") and then add a new word to the dictionary, then harper-ls still flags this word as misspelled, unless I close and reopen the nvim buffer.

jfly commented 1 month ago

This seems to be an issue with the underlying tower-lsp crate:

One LSP server has implemented a workaround for this in https://github.com/denoland/deno/pull/21251/, but it would sure be preferable if things were just fixed in tower-lsp.

Edit: I've put together a PR to tower-lsp here: https://github.com/ebkalderon/tower-lsp/pull/428, and confirmed that this solves this issue. If you want to try it out, you can try my harper fork here: https://github.com/jfly/harper/tree/actually-exit.

elijah-potter commented 4 weeks ago

Oh wow. @jfly that's fantastic. While it would be great if you're PR was merged into tower-lsp, it doesn't look like the maintainer is still working on it. If we don't see your PR merged in the next week or so, a separately maintained fork might be necessary.

jfly commented 4 weeks ago

Emphasis mine:

it would be great if you're PR was merged into tower-lsp

https://github.com/elijah-potter/harper/issues/225 ;) (sorry! this is meant as a joke)

it doesn't look like the maintainer is still working on it

Yeah, things seem pretty dead upstream, and the code in master doesn't even compile :cry:

a separately maintained fork might be necessary

If you want to wait and see before forking, an alternative would be to implement some version of the workaround deno did: https://github.com/denoland/deno/pull/21251. (I personally would prefer that you use a fork with my change, though)

SylvanFranklin commented 2 weeks ago

Hullo! Sorry about now finding this issue before posting mine. Thanks @jfly for working on this! Unfortunate about the inactivity around Tower, seems like it could use a new head maintainer.