split shellcmdflag properly

This commit is contained in:
akioweh 2026-01-30 06:16:16 +00:00
parent 3d12333b31
commit 7b970d2caa
No known key found for this signature in database

View file

@ -30,13 +30,10 @@ local supported = {
--- Checks if a Prettier config file exists for the given context --- Checks if a Prettier config file exists for the given context
---@param ctx ConformCtx ---@param ctx ConformCtx
function M.has_config(ctx) function M.has_config(ctx)
local res = vim local args = { vim.o.sh }
.system({ vim.list_extend(args, vim.split(vim.o.shcf, " ", { trimempty = true }))
vim.o.sh, table.insert(args, "prettier --find-config-path " .. vim.fn.shellescape(ctx.filename))
vim.o.shcf, local res = vim.system(args, { text = true }):wait()
"prettier --find-config-path " .. vim.fn.shellescape(ctx.filename),
}, { text = true })
:wait()
return res.code == 0 return res.code == 0
end end
@ -51,13 +48,10 @@ function M.has_parser(ctx)
return true return true
end end
-- otherwise, check if a parser can be inferred -- otherwise, check if a parser can be inferred
local ret = vim local args = { vim.o.sh }
.system({ vim.list_extend(args, vim.split(vim.o.shcf, " ", { trimempty = true }))
vim.o.sh, table.insert(args, "prettier --file-info " .. vim.fn.shellescape(ctx.filename))
vim.o.shcf, local ret = vim.system(args, { text = true }):wait().stdout
"prettier --file-info " .. vim.fn.shellescape(ctx.filename),
}, { text = true })
:wait().stdout
---@type boolean, string? ---@type boolean, string?
local ok, parser = pcall(function() local ok, parser = pcall(function()
return vim.fn.json_decode(ret).inferredParser return vim.fn.json_decode(ret).inferredParser