simplify conform config

This commit is contained in:
Ray Elliott 2026-01-12 18:58:16 +00:00
parent 16004b6117
commit 530a65a81a
1 changed files with 2 additions and 36 deletions

View File

@ -7,34 +7,6 @@ return {
config = function() config = function()
local conform = require("conform") local conform = require("conform")
-- Helper: Find project-local executable, fallback to global
-- Searches node_modules/.bin/, vendor/bin/, and Mason bin first
local function find_executable(names)
local cwd = vim.fn.getcwd()
local mason_bin = vim.fn.stdpath("data") .. "/mason/bin/"
local search_paths = {
cwd .. "/node_modules/.bin/",
cwd .. "/vendor/bin/",
mason_bin,
}
for _, name in ipairs(names) do
for _, path in ipairs(search_paths) do
local full_path = path .. name
if vim.fn.executable(full_path) == 1 then
return full_path
end
end
if vim.fn.executable(name) == 1 then
return name
end
end
return nil
end
conform.setup({ conform.setup({
formatters_by_ft = { formatters_by_ft = {
-- JavaScript, TypeScript, CSS, SCSS, JSON, HTML, Markdown -- JavaScript, TypeScript, CSS, SCSS, JSON, HTML, Markdown
@ -56,18 +28,12 @@ return {
lua = { "stylua" }, lua = { "stylua" },
}, },
-- Custom formatter definitions with executable resolution -- Formatter customization
formatters = { formatters = {
prettier = { -- Add WordPress coding standard to phpcbf
command = find_executable({ "prettier" }) or "prettier",
},
phpcbf = { phpcbf = {
-- Extend built-in phpcbf to add WordPress standard
prepend_args = { "--standard=WordPress" }, prepend_args = { "--standard=WordPress" },
}, },
stylua = {
command = find_executable({ "stylua" }) or "stylua",
},
}, },
-- Format on save -- Format on save