fix(lsp): ensure watcher cancel

* Cancel watcher in the "force" case.
* Cancel watcher outside the async callback. It seems nvim doesn't wait
  async jobs on quitting, leaving detached inotifywait processes.
* Clean up cancelling callbacks.
This commit is contained in:
Jaehwang Jung
2025-01-02 17:33:16 +09:00
committed by Lewis Russell
parent efe1732c6f
commit 9d9ee3476e
2 changed files with 3 additions and 1 deletions

View File

@ -174,6 +174,7 @@ function M.cancel(client_id)
cancel()
end
end
cancels[client_id] = nil
end
return M

View File

@ -805,6 +805,8 @@ function Client:stop(force)
return
end
vim.lsp._watchfiles.cancel(self.id)
if force or not self.initialized or self._graceful_shutdown_failed then
rpc.terminate()
return
@ -819,7 +821,6 @@ function Client:stop(force)
rpc.terminate()
self._graceful_shutdown_failed = true
end
vim.lsp._watchfiles.cancel(self.id)
end)
end