731e616a79 made it so passing `{env = nil, clear_env = true }` would
pass `{env = {}}` to `vim.uv.spawn`.
However this is not what `clear_env` is (arguably) supposed to do.
If `env=nil` then that implies the uses wants `vim.uv.spawn()` to use
the default environment. Adding `clear_env = true` simply prevents
`NVIM` (the base environment) from being added.
Fixes#34730
Problem:
In setup_env, some needed logic is bypassed when clear_env=true.
Solution:
Drop the early return in setup_env().
Co-authored-by: BirdeeHub <birdee@localhost>
Problem:
vim.uv.spawn will emit ENOENT for either when the cmd or cwd do not
exist and does not tell you which.
Solution:
If an error occurs, check if cwd was supplied and included in the error
message if it does not exist.
Problem:
When a command is not found or not executable, the error message gives
no indication about what command was actually tried.
Solution:
Always append the command name to the error message.
BEFORE:
E5108: Error executing lua …/_system.lua:248: ENOENT: no such file or directory
AFTER:
E5108: Error executing lua …/_system.lua:249: ENOENT: no such file or directory: "foo"
fix#33445
Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.
Closes https://github.com/neovim/neovim/issues/27004.
Problem:
Processing non-fast events during SystemObj:wait() may cause two pieces
of code to interfere with each other, and is different from jobwait().
Solution:
Don't process non-fast events during SystemObj:wait().
feat(lua): add vim.system()
Problem:
Handling system commands in Lua is tedious and error-prone:
- vim.fn.jobstart() is vimscript and comes with all limitations attached to typval.
- vim.loop.spawn is too low level
Solution:
Add vim.system().
Partly inspired by Python's subprocess module
Does not expose any libuv objects.