Closed scottmckendry closed 1 month ago
I've just tested this on my Linux machine and can not replicate the error - so it's isolated to Windows 11. The exact same issue is also occurring with stylua. Works on Linux, and doesn't spawn on Windows (which is why I'm using lsp format instead).
gofmt is working fine in both os
None of us have a windows device I believe. Attach a lot of debugging info and also try to fix the issue yourself. Make sure/check that the process is executable (vim.fn.executable
), that you can start a job with it (uv.spawn
), etc.
I personally don't see an obvious issue so :( And as you said it's your win machine only so if it's not a uv.spawn
quirk then I am not sure how to approach this.
I've just tested this on my Linux machine and can not replicate the error - so it's isolated to Windows 11. The exact same issue is also occurring with stylua. Works on Linux, and doesn't spawn on Windows (which is why I'm using lsp format instead).
gofmt is working fine in both os
You need to add .cmd
to those Node.js based tools on Windows, uv.spawn
won't see these .cmd
scripts as executable as vim.fn.executable
on Windows.
{
cmd = "prettier.cmd",
args = { '--stdin-filepath' },
fname = true,
stdin = true,
}
@UnderCooled thanks for helping out with this. I looked at the executable()
documentation and it seems like it automatically searches using the .cmd
extension, so uv.spawn()
failing instead does make sense.
I'm not accustomed to windows systems - isn't it true that some of the programs that, for example, guard-collection uses, could be .cmd
, while others could be .exe
?
If that's the case, I'm not sure how we could resolve this besides offering a warning to windows systems that no extension is specified.
@barrett-ruth you can patch https://github.com/nvimdev/guard.nvim/blob/394317c25a6b0f0e064aebcfcf902e46fb0a04ba/lua/guard/spawn.lua#L38
local cmd = vim.fn.exepath(opt.cmd)
:echo exepath('npm')
D:\dev_env\lang\node\npm.CMD
:checkheath guard
shows prettier as executablebut when testing prettier on an HTML file I get the message:
[Guard] failed to spawn process prettier
This is my config:
running
cat index.html | prettier --stdin-filepath index.html
from the commandlne outputs the formatted file with no errors.Any ideas what I can check/test to try and get this working?