Skip to content

Commit 53a6313

Browse files
azdanovUzaaft
andauthored
feat(pack): add prettier pack (#1502)
* feat(pack): add prettier pack * add additional filetypes and config files * use prettier instead of prettierd * Revert using prettier instead of prettierd It would be better to do this in a separate PR * inline variables * remove cache variables * early return if prettier found * simplify config --------- Co-authored-by: Uzair Aftab <[email protected]>
1 parent 8e359d7 commit 53a6313

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Prettier
2+
3+
[Prettier](https://prettier.io/) is an opinionated code formatter with support for:
4+
5+
JavaScript · TypeScript · Flow · JSX · JSON
6+
CSS · SCSS · Less
7+
HTML · Vue · Angular
8+
GraphQL · Markdown · YAML
9+
[Your favorite language?](https://prettier.io/docs/plugins)
10+
11+
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.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---@type LazySpec
2+
return {
3+
{
4+
"jay-babu/mason-null-ls.nvim",
5+
optional = true,
6+
opts = function(_, opts)
7+
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed or {}, { "prettierd" })
8+
end,
9+
},
10+
{
11+
"stevearc/conform.nvim",
12+
optional = true,
13+
opts = function(_, opts)
14+
if not opts.formatters_by_ft then opts.formatters_by_ft = {} end
15+
for _, filetype in ipairs {
16+
"javascript",
17+
"javascriptreact",
18+
"typescript",
19+
"typescriptreact",
20+
"vue",
21+
"css",
22+
"scss",
23+
"less",
24+
"html",
25+
"json",
26+
"jsonc",
27+
"yaml",
28+
"markdown",
29+
"markdown.mdx",
30+
"graphql",
31+
"handlebars",
32+
"svelte",
33+
"astro",
34+
"htmlangular",
35+
} do
36+
opts.formatters_by_ft[filetype] = { "prettierd" }
37+
end
38+
end,
39+
},
40+
{
41+
"WhoIsSethDaniel/mason-tool-installer.nvim",
42+
optional = true,
43+
opts = function(_, opts)
44+
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed or {}, { "prettierd" })
45+
end,
46+
},
47+
{
48+
"echasnovski/mini.icons",
49+
optional = true,
50+
opts = function(_, opts)
51+
if not opts.file then opts.file = {} end
52+
for _, filename in ipairs {
53+
".prettierrc",
54+
".prettierrc.cjs",
55+
".prettierrc.cts",
56+
".prettierrc.js",
57+
".prettierrc.json",
58+
".prettierrc.json5",
59+
".prettierrc.mjs",
60+
".prettierrc.mts",
61+
".prettierrc.toml",
62+
".prettierrc.ts",
63+
".prettierrc.yaml",
64+
".prettierrc.yml",
65+
"prettier.config.cjs",
66+
"prettier.config.js",
67+
"prettier.config.mjs",
68+
"prettier.config.mts",
69+
"prettier.config.ts",
70+
} do
71+
opts.file[filename] = { glyph = "", hl = "MiniIconsPurple" }
72+
end
73+
end,
74+
},
75+
}

0 commit comments

Comments
 (0)