aboutsummaryrefslogtreecommitdiffstats
path: root/lua/conform/formatters/prettier.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/conform/formatters/prettier.lua')
-rw-r--r--lua/conform/formatters/prettier.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/lua/conform/formatters/prettier.lua b/lua/conform/formatters/prettier.lua
new file mode 100644
index 0000000..6f4bbfb
--- /dev/null
+++ b/lua/conform/formatters/prettier.lua
@@ -0,0 +1,24 @@
+local util = require("conform.util")
+---@type conform.FormatterConfig
+return {
+ meta = {
+ url = "https://github.com/prettier/prettier",
+ description = [[Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.]],
+ },
+ command = util.from_node_modules("prettier"),
+ args = { "--stdin-filepath", "$FILENAME" },
+ cwd = util.root_file({
+ -- https://prettier.io/docs/en/configuration.html
+ ".prettierrc",
+ ".prettierrc.json",
+ ".prettierrc.yml",
+ ".prettierrc.yaml",
+ ".prettierrc.json5",
+ ".prettierrc.js",
+ ".prettierrc.cjs",
+ ".prettierrc.toml",
+ "prettier.config.js",
+ "prettier.config.cjs",
+ "package.json",
+ }),
+}