exe option needs to be able to search relative to the current file
Opened this issue · 0 comments
NullVoxPopuli commented
Shell command and output (optional):
Which configuration?
Type (custom or builtin):
Filetype:
Formatter:
Configuration(s) (post all the variants you tried):
my linting.lua (i separate out my packer configs by groups of plugins + config)
-- Linters don't all have language server plugins,
-- otherwise I'd use the lsp integration
return function (use)
use {
'mhartington/formatter.nvim',
config = function()
-- Utilities for creating configurations
local util = require "formatter.util"
local prettierConfig = function()
return {
exe = "./node_modules/.bin/prettier",
args = {"--stdin-filepath", vim.fn.shellescape(vim.api.nvim_buf_get_name(0)), "--single-quote"},
stdin = true
}
end
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
require("formatter").setup {
-- All formatter configurations are opt-in
filetype = {
-- lua = {function() return {exe = "lua-format", stdin = true} end},
json = { prettierConfig },
html = { prettierConfig },
typescript = { prettierConfig },
javascript = { prettierConfig },
handlebars = { prettierConfig },
['typescript.glimmer'] = { prettierConfig },
['javascript.glimmer'] = { prettierConfig },
-- Use the special "*" filetype for defining formatter configurations on
-- any filetype
["*"] = {
-- "formatter.filetypes.any" defines default configurations for any
-- filetype
require("formatter.filetypes.any").remove_trailing_whitespace
}
}
}
end
}
end
Expected behavior
in my monorepo, the exe
should match the nearest node_modules
directory, rather than require that my monorepo-root (CWD) have the bins available.
Actual behaviour
command not found
Additional context
using a monorepo where the CWD is the monorepo root. My configuration works if I install prettier at the top level directory (root package.json -- (all JS projects))