From 3f3e4837d5f7d2d9cb1c89bd3a5b2ee8a730772a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 16 Oct 2024 17:03:48 +0100 Subject: perf(validate): use lighter version - Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number. --- runtime/lua/vim/_system.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'runtime/lua/vim/_system.lua') diff --git a/runtime/lua/vim/_system.lua b/runtime/lua/vim/_system.lua index d603971495..9e27b4c152 100644 --- a/runtime/lua/vim/_system.lua +++ b/runtime/lua/vim/_system.lua @@ -309,11 +309,9 @@ end --- @param on_exit? fun(out: vim.SystemCompleted) --- @return vim.SystemObj function M.run(cmd, opts, on_exit) - vim.validate({ - cmd = { cmd, 'table' }, - opts = { opts, 'table', true }, - on_exit = { on_exit, 'function', true }, - }) + vim.validate('cmd', cmd, 'table') + vim.validate('opts', opts, 'table', true) + vim.validate('on_exit', on_exit, 'function', true) opts = opts or {} -- cgit From ad3472e291694b6c589d8a664459b03962eaac95 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 7 Nov 2024 16:21:49 +0000 Subject: fix(vim.system): resolve executable paths on windows Fixes #31107 --- runtime/lua/vim/_system.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'runtime/lua/vim/_system.lua') diff --git a/runtime/lua/vim/_system.lua b/runtime/lua/vim/_system.lua index 9e27b4c152..ce5dbffeaa 100644 --- a/runtime/lua/vim/_system.lua +++ b/runtime/lua/vim/_system.lua @@ -230,6 +230,8 @@ local function default_handler(stream, text, bucket) end end +local is_win = vim.fn.has('win32') == 1 + local M = {} --- @param cmd string @@ -238,6 +240,13 @@ local M = {} --- @param on_error fun() --- @return uv.uv_process_t, integer local function spawn(cmd, opts, on_exit, on_error) + if is_win then + local cmd1 = vim.fn.exepath(cmd) + if cmd1 ~= '' then + cmd = cmd1 + end + end + local handle, pid_or_err = uv.spawn(cmd, opts, on_exit) if not handle then on_error() -- cgit