From ff5d74f03827f7b41e58c297b63423ea24e77817 Mon Sep 17 00:00:00 2001 From: Tim Heuett Date: Thu, 24 Jul 2025 21:43:54 -0700 Subject: [PATCH 1/6] uncomment test make tasks --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7f818800..ef08f3a4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ # Run all test files -# test: deps/mini.nvim -test: +test: deps/mini.nvim nvim --headless --noplugin -u ./tests/scripts/minimal_init.lua -c "lua MiniTest.run()" # Run test from file at `$FILE` environment variable @@ -8,7 +7,7 @@ test_file: deps/mini.nvim nvim --headless --noplugin -u ./tests/scripts/minimal_init.lua -c "lua MiniTest.run_file('$(FILE)')" # Download 'mini.nvim' to use its 'mini.test' testing module -# deps/mini.nvim: -# @mkdir deps -# git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim -# git clone https://github.com/jbyuki/one-small-step-for-vimkind deps/osv +deps/mini.nvim: + @mkdir -p deps + git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim + git clone https://github.com/jbyuki/one-small-step-for-vimkind deps/osv From be537e314b991d9b771fda9e85ee578e77a179a1 Mon Sep 17 00:00:00 2001 From: Tim Heuett Date: Thu, 24 Jul 2025 21:44:38 -0700 Subject: [PATCH 2/6] more permissive handling of copilot_node_command config * use vim.system for version check in place of vim.fn.systemlist * disable executable check --- lua/copilot/lsp/nodejs.lua | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lua/copilot/lsp/nodejs.lua b/lua/copilot/lsp/nodejs.lua index 3954072e..5b5f9131 100644 --- a/lua/copilot/lsp/nodejs.lua +++ b/lua/copilot/lsp/nodejs.lua @@ -13,10 +13,13 @@ local M = { ---@return nil|string node_version_error function M.get_node_version() if not M.node_version then - local cmd = { M.node_command, "--version" } - local cmd_output_table = vim.fn.executable(M.node_command) == 1 and vim.fn.systemlist(cmd, nil, 0) or { "" } - local cmd_output = cmd_output_table[#cmd_output_table] - local cmd_exit_code = vim.v.shell_error + local cmd = vim.split(M.node_command, " ") + table.insert(cmd, "--version") + + local process = vim.system(cmd) + local result = process:wait() + local cmd_output = result.stdout or "" + local cmd_exit_code = result.code local node_version = string.match(cmd_output, "^v(%S+)") or "" local node_version_major = tonumber(string.match(node_version, "^(%d+)%.")) or 0 @@ -58,12 +61,12 @@ function M.validate_node_version() end function M.node_exists() - local node_exists = vim.fn.executable(M.node_command) == 1 - - if not node_exists then - logger.error("node.js is not installed or not in PATH") - return false - end + -- local node_exists = vim.fn.executable(M.node_command) == 1 + -- + -- if not node_exists then + -- logger.error("node.js is not installed or not in PATH") + -- return false + -- end return true end @@ -95,11 +98,10 @@ end ---@return table function M.get_execute_command() - return { - M.node_command, - M.server_path or M.get_server_path(), - "--stdio", - } + local cmd = vim.split(M.node_command, " ") + table.insert(cmd, M.server_path or M.get_server_path()) + table.insert(cmd, "--stdio") + return cmd end ---@param node_command? string From 8fad072eba3b5dcdd36813594bde591863348e4e Mon Sep 17 00:00:00 2001 From: Tim Heuett Date: Sun, 3 Aug 2025 11:00:36 -0700 Subject: [PATCH 3/6] remove unused node_exists command --- lua/copilot/lsp/nodejs.lua | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/lua/copilot/lsp/nodejs.lua b/lua/copilot/lsp/nodejs.lua index 5b5f9131..bd7e423a 100644 --- a/lua/copilot/lsp/nodejs.lua +++ b/lua/copilot/lsp/nodejs.lua @@ -13,10 +13,10 @@ local M = { ---@return nil|string node_version_error function M.get_node_version() if not M.node_version then - local cmd = vim.split(M.node_command, " ") - table.insert(cmd, "--version") + local version_cmd = vim.split(M.node_command, " ") + table.insert(version_cmd, "--version") - local process = vim.system(cmd) + local process = vim.system(version_cmd) local result = process:wait() local cmd_output = result.stdout or "" local cmd_exit_code = result.code @@ -60,17 +60,6 @@ function M.validate_node_version() return true end -function M.node_exists() - -- local node_exists = vim.fn.executable(M.node_command) == 1 - -- - -- if not node_exists then - -- logger.error("node.js is not installed or not in PATH") - -- return false - -- end - - return true -end - ---@param server_path? string ---@return boolean function M.init_agent_path(server_path) @@ -110,7 +99,7 @@ end function M.setup(node_command, custom_server_path) M.node_command = node_command or "node" - if not M.node_exists() or not M.validate_node_version() or not M.init_agent_path(custom_server_path) then + if not M.validate_node_version() or not M.init_agent_path(custom_server_path) then return false end From 5f2d8246a18014c4b9f5ce51d6c2dd9053cf7b53 Mon Sep 17 00:00:00 2001 From: Tim Heuett Date: Sun, 3 Aug 2025 11:30:19 -0700 Subject: [PATCH 4/6] recomment make test tasks it looks like these got commented out for use with the github workflow --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ef08f3a4..434ba826 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ # Run all test files -test: deps/mini.nvim +# test: deps/mini.nvim +test: nvim --headless --noplugin -u ./tests/scripts/minimal_init.lua -c "lua MiniTest.run()" # Run test from file at `$FILE` environment variable -test_file: deps/mini.nvim +# test_file: deps/mini.nvim +test_file: nvim --headless --noplugin -u ./tests/scripts/minimal_init.lua -c "lua MiniTest.run_file('$(FILE)')" # Download 'mini.nvim' to use its 'mini.test' testing module -deps/mini.nvim: - @mkdir -p deps - git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim - git clone https://github.com/jbyuki/one-small-step-for-vimkind deps/osv +# deps/mini.nvim: +# @mkdir -p deps +# git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim +# git clone https://github.com/jbyuki/one-small-step-for-vimkind deps/osv From 75f9ae5fa60afa5c2a667c5df55613d8417becbc Mon Sep 17 00:00:00 2001 From: Tim Heuett Date: Sun, 3 Aug 2025 11:31:34 -0700 Subject: [PATCH 5/6] just restore makefile back to master --- Makefile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 434ba826..7f818800 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,14 @@ # Run all test files # test: deps/mini.nvim -test: +test: nvim --headless --noplugin -u ./tests/scripts/minimal_init.lua -c "lua MiniTest.run()" # Run test from file at `$FILE` environment variable -# test_file: deps/mini.nvim -test_file: +test_file: deps/mini.nvim nvim --headless --noplugin -u ./tests/scripts/minimal_init.lua -c "lua MiniTest.run_file('$(FILE)')" # Download 'mini.nvim' to use its 'mini.test' testing module # deps/mini.nvim: -# @mkdir -p deps -# git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim +# @mkdir deps +# git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim # git clone https://github.com/jbyuki/one-small-step-for-vimkind deps/osv From 80540d8e276fffb818660e1d561d290f2ddd1fea Mon Sep 17 00:00:00 2001 From: Antoine Gaudreau Simard Date: Thu, 14 Aug 2025 20:42:34 -0400 Subject: [PATCH 6/6] improve handling of missing nodejs --- lua/copilot/client/init.lua | 6 +++++- lua/copilot/lsp/init.lua | 7 ++++++- lua/copilot/lsp/nodejs.lua | 24 +++++++++++++----------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/lua/copilot/client/init.lua b/lua/copilot/client/init.lua index 4e65031e..bff572a3 100644 --- a/lua/copilot/client/init.lua +++ b/lua/copilot/client/init.lua @@ -140,7 +140,11 @@ end function M.setup() logger.trace("setting up client") local node_command = config.copilot_node_command - lsp.setup(config.server, node_command) + if not lsp.setup(config.server, node_command) then + is_disabled = true + return + end + M.config = require("copilot.client.config").prepare_client_config(config.server_opts_overrides, M) if not M.config then diff --git a/lua/copilot/lsp/init.lua b/lua/copilot/lsp/init.lua index 11b0e6de..5391584f 100644 --- a/lua/copilot/lsp/init.lua +++ b/lua/copilot/lsp/init.lua @@ -54,20 +54,25 @@ end ---@param server_config ServerConfig ---@param copilot_node_command string +---@return boolean function M.setup(server_config, copilot_node_command) + local result = true + if not server_config then logger.error("server_config is required") end if server_config.type == "nodejs" then - M.nodejs.setup(copilot_node_command, server_config.custom_server_filepath) + result = M.nodejs.setup(copilot_node_command, server_config.custom_server_filepath) elseif server_config.type == "binary" then M.binary.setup(server_config.custom_server_filepath) else logger.error("invalid server_config.type") + result = false end M.config = server_config + return result end return M diff --git a/lua/copilot/lsp/nodejs.lua b/lua/copilot/lsp/nodejs.lua index 50c619ab..c6a38124 100644 --- a/lua/copilot/lsp/nodejs.lua +++ b/lua/copilot/lsp/nodejs.lua @@ -16,19 +16,21 @@ function M.get_node_version() local version_cmd = vim.split(M.node_command, " ") table.insert(version_cmd, "--version") - local process = vim.system(version_cmd) - local result = process:wait() - local cmd_output = result.stdout or "" - local cmd_exit_code = result.code - local node_version_major = 0 local node_version = "" - - if cmd_output then - node_version = string.match(cmd_output, "^v(%S+)") or node_version - node_version_major = tonumber(string.match(node_version, "^(%d+)%.")) or node_version_major - else - cmd_output = "[no output]" + local cmd_exit_code = -1 + local cmd_output = "[no output]" + local ok, process = pcall(vim.system, version_cmd) + + if ok and process then + local result = process:wait() + cmd_output = result.stdout or cmd_output + cmd_exit_code = result.code + + if cmd_output and cmd_output ~= "[no output]" then + node_version = string.match(cmd_output, "^v(%S+)") or node_version + node_version_major = tonumber(string.match(node_version, "^(%d+)%.")) or node_version_major + end end if node_version_major == 0 then