Skip to content
11 changes: 11 additions & 0 deletions lua/astrocommunity/pack/prettier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Prettier

[Prettier](https://prettier.io/) is an opinionated code formatter with support for:

JavaScript · TypeScript · Flow · JSX · JSON
CSS · SCSS · Less
HTML · Vue · Angular
GraphQL · Markdown · YAML
[Your favorite language?](https://prettier.io/docs/plugins)

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.
75 changes: 75 additions & 0 deletions lua/astrocommunity/pack/prettier/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---@type LazySpec
return {
{
"jay-babu/mason-null-ls.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed or {}, { "prettierd" })
end,
},
{
"stevearc/conform.nvim",
optional = true,
opts = function(_, opts)
if not opts.formatters_by_ft then opts.formatters_by_ft = {} end
for _, filetype in ipairs {
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"css",
"scss",
"less",
"html",
"json",
"jsonc",
"yaml",
"markdown",
"markdown.mdx",
"graphql",
"handlebars",
"svelte",
"astro",
"htmlangular",
} do
opts.formatters_by_ft[filetype] = { "prettierd" }
end
end,
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed or {}, { "prettierd" })
end,
},
{
"echasnovski/mini.icons",
optional = true,
opts = function(_, opts)
if not opts.file then opts.file = {} end
for _, filename in ipairs {
".prettierrc",
".prettierrc.cjs",
".prettierrc.cts",
".prettierrc.js",
".prettierrc.json",
".prettierrc.json5",
".prettierrc.mjs",
".prettierrc.mts",
".prettierrc.toml",
".prettierrc.ts",
".prettierrc.yaml",
".prettierrc.yml",
"prettier.config.cjs",
"prettier.config.js",
"prettier.config.mjs",
"prettier.config.mts",
"prettier.config.ts",
} do
opts.file[filename] = { glyph = "", hl = "MiniIconsPurple" }
end
end,
},
}