Skip to content

Downloading Server causes Neovim to Stuck #21

Closed

Description

@joaopluigi

Every time eca-nvim downloads the server, my nvim gets stuck until the download is complete. See the GIF below:

Image

I'm wondering if this is something that only happens to me. The fix should be simple by spawning the server start process in another thread. Could be using uv.spawn or plenary.async. I don't think the change in that behavior will impact the current flow, WDYT?

Activity

  1. joaopluigi commented on Aug 6, 2025

    @joaopluigi
    ContributorAuthor

    The piece of code to change:

    M.server:start()

    I'm unsure if other server start occurrences, such as EcaStartServer command, should also have the async behavior.

    I'm also unsure about using vim.defer_fn there, not clear what are the benefits.

  2. tomgeorge commented on Aug 6, 2025

    @tomgeorge
    Member

    I'm a fan of using vim.system to manage the server process. It is available since vim > 0.10 but you can easily add a compatibility layer to support older neovims.

    --- copy system.lua from neovim runtime
    vim.system = vim.system or require("eca.system")
    
    vim.system("eca server", { 
      stdout = function(data, err)
        print(data)
      end,
    stderr = function(data, err)
        print(data)
      end
    }, some_on_exit_function())
  3. joaopluigi commented on Aug 7, 2025

    @joaopluigi
    ContributorAuthor

    @tomgeorge, I don't know vim.system, so I'll take a look, thanks for sharing.

    My initial idea was to do a minimal change like:

    Changing this:

      -- Start server automatically in background
      vim.defer_fn(function()
        M.server:start()
      end, 100) -- Small delay to ensure everything is loaded

    To something like this

    -- Start server automatically in background
    local ok, async = pcall(require, "plenary.async")
    if ok then
      async.run(function()
        M.server:start()
      end)
    else
      vim.defer_fn(function()
        M.server:start()
      end, 100) -- Small delay to ensure everything is loaded
    end
    
  4. joaopluigi commented on Oct 8, 2025

    @joaopluigi
    ContributorAuthor

    Solved by #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions