From 3d12333b3117871b7510dbe5e779ef993cc094f3 Mon Sep 17 00:00:00 2001 From: akioweh <0@akioweh.com> Date: Fri, 30 Jan 2026 05:43:59 +0000 Subject: [PATCH 1/2] fix(extras/prettier): run "prettier" command in a shell ...instead of running it directly, which fails for installations where "prettier" is a shell script (and not an executable) --- .../plugins/extras/formatting/prettier.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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 From 7b970d2caa95c7ba45630e5972df24c5cf950697 Mon Sep 17 00:00:00 2001 From: akioweh <0@akioweh.com> Date: Fri, 30 Jan 2026 06:16:16 +0000 Subject: [PATCH 2/2] split shellcmdflag properly --- .../plugins/extras/formatting/prettier.lua | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index 3b90d370..6c5317f2 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -30,13 +30,10 @@ local supported = { --- Checks if a Prettier config file exists for the given context ---@param ctx ConformCtx function M.has_config(ctx) - local res = vim - .system({ - vim.o.sh, - vim.o.shcf, - "prettier --find-config-path " .. vim.fn.shellescape(ctx.filename), - }, { text = true }) - :wait() + local args = { vim.o.sh } + vim.list_extend(args, vim.split(vim.o.shcf, " ", { trimempty = true })) + table.insert(args, "prettier --find-config-path " .. vim.fn.shellescape(ctx.filename)) + local res = vim.system(args, { text = true }):wait() return res.code == 0 end @@ -51,13 +48,10 @@ function M.has_parser(ctx) return true end -- otherwise, check if a parser can be inferred - local ret = vim - .system({ - vim.o.sh, - vim.o.shcf, - "prettier --file-info " .. vim.fn.shellescape(ctx.filename), - }, { text = true }) - :wait().stdout + local args = { vim.o.sh } + vim.list_extend(args, vim.split(vim.o.shcf, " ", { trimempty = true })) + table.insert(args, "prettier --file-info " .. vim.fn.shellescape(ctx.filename)) + local ret = vim.system(args, { text = true }):wait().stdout ---@type boolean, string? local ok, parser = pcall(function() return vim.fn.json_decode(ret).inferredParser