diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index 6edd414c..3b90d370 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -30,8 +30,14 @@ local supported = { --- Checks if a Prettier config file exists for the given context ---@param ctx ConformCtx function M.has_config(ctx) - vim.fn.system({ "prettier", "--find-config-path", ctx.filename }) - return vim.v.shell_error == 0 + local res = vim + .system({ + vim.o.sh, + vim.o.shcf, + "prettier --find-config-path " .. vim.fn.shellescape(ctx.filename), + }, { text = true }) + :wait() + return res.code == 0 end --- Checks if a parser can be inferred for the given context: @@ -45,7 +51,13 @@ function M.has_parser(ctx) return true end -- otherwise, check if a parser can be inferred - local ret = vim.fn.system({ "prettier", "--file-info", ctx.filename }) + local ret = vim + .system({ + vim.o.sh, + vim.o.shcf, + "prettier --file-info " .. vim.fn.shellescape(ctx.filename), + }, { text = true }) + :wait().stdout ---@type boolean, string? local ok, parser = pcall(function() return vim.fn.json_decode(ret).inferredParser