Skip to content

Async server download#48

Merged
ericdallo merged 17 commits intomainfrom
async-server-download
Oct 7, 2025
Merged

Async server download#48
ericdallo merged 17 commits intomainfrom
async-server-download

Conversation

@joaopluigi
Copy link
Copy Markdown
Contributor

@joaopluigi joaopluigi commented Oct 6, 2025

solves #21

Copilot AI review requested due to automatic review settings October 6, 2025 17:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements asynchronous server downloading and startup functionality for the ECA server. The changes move from synchronous path finding to an asynchronous approach that uses a separate Neovim process to handle server path resolution and downloading.

  • Replaces synchronous server path finding with asynchronous path resolution using a separate Neovim process
  • Adds proper waiting mechanisms in tests to handle the asynchronous server startup
  • Changes default server auto-start behavior to false and adds conditional startup logic

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_server_integration.lua Adds vim.wait calls to handle asynchronous server startup in tests
scripts/server_path.lua New script that handles server path finding in a separate Neovim process
lua/eca/server.lua Refactors server startup to use async path resolution via external script
lua/eca/path_finder.lua Updates path finder to support custom paths and improves error handling
lua/eca/init.lua Makes server auto-start conditional based on configuration
lua/eca/config.lua Changes default auto_start_server setting to false

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread lua/eca/server.lua Outdated
Comment on lines 113 to 114
local lua_cmd = string.format("lua ServerPath.run(%s)", Config.server_path or "")

Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Config.server_path value is not properly quoted for shell execution. If the path contains spaces or special characters, this will cause command execution failures.

Suggested change
local lua_cmd = string.format("lua ServerPath.run(%s)", Config.server_path or "")
local function lua_quote(str)
-- Escape backslashes and double quotes for Lua string literal
return '"' .. tostring(str):gsub('\\', '\\\\'):gsub('"', '\\"') .. '"'
end
local lua_cmd = string.format("lua ServerPath.run(%s)", lua_quote(Config.server_path or ""))

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, I added this to utils.lua

Comment thread lua/eca/path_finder.lua

-- Make executable (if not Windows)
if not vim.loop.os_uname().sysname:lower():match("windows") then
if not uv.os_uname().sysname:lower():match("windows") then
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct use of 'uv' global may not be available in all Neovim versions. Consider using 'vim.uv' or 'vim.loop' for better compatibility.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv is defined as local uv = vim.uv or vim.loop in the first line of the file

Comment thread scripts/server_path.lua Outdated
Comment on lines +4 to +5
_G.ServerPath = ServerPath

Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting globals in a script can lead to namespace pollution. Consider using a local approach or checking if the global already exists before setting it.

Suggested change
_G.ServerPath = ServerPath

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was moved to a condition that consider the --headless execution of neovim, it should make sense now.

@joaopluigi joaopluigi marked this pull request as draft October 6, 2025 21:24
@joaopluigi joaopluigi marked this pull request as ready for review October 7, 2025 16:21
ericdallo
ericdallo previously approved these changes Oct 7, 2025
@joaopluigi joaopluigi marked this pull request as draft October 7, 2025 17:44
tomgeorge
tomgeorge previously approved these changes Oct 7, 2025
@joaopluigi joaopluigi dismissed stale reviews from tomgeorge and ericdallo via abffd15 October 7, 2025 17:51
@joaopluigi joaopluigi marked this pull request as ready for review October 7, 2025 17:51
@ericdallo ericdallo merged commit 8ae1e0a into main Oct 7, 2025
0 of 3 checks passed
@joaopluigi joaopluigi deleted the async-server-download branch October 8, 2025 11:30
joaopluigi added a commit that referenced this pull request Oct 9, 2025
…r-download"

This reverts commit 8ae1e0a, reversing
changes made to 6161194.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants