Skip to content

Long wait when exiting neovim #254

@pirey

Description

@pirey

After I open opencode buffer, every time I want to exit I have to wait for quite some time.

I took a peek at the opencode server shutdown function and noticed that the shutdown_promise is only resolved when there is no job, thus the callback in VimLeavePre will wait for entire 2000ms before exiting.

I try to resolve the promise after killing the job in the shutdown function and wait time is slightly reduced, although still noticeable.

    vim.defer_fn(function()
      if job and job.pid then
        pcall(function()
          job:kill(9) -- SIGKILL
        end)
        self.shutdown_promise:resolve(true) -- added here
      end
    end, 500)

some demo for comparison of before and after I applied the promise resolve.

Screen.Recording.2026-02-09.at.06.39.18.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions