-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconform.lua
More file actions
88 lines (76 loc) · 2.13 KB
/
Copy pathconform.lua
File metadata and controls
88 lines (76 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
vim.pack.add({ "https://github.com/stevearc/conform.nvim" })
local conform = require("conform")
local prose_wrap = false
conform.formatters = {
topiary_nu = {
command = "topiary",
args = { "format", "--language", "nu" },
},
["biome-organize-imports"] = {
command = "biome",
},
biome = {
command = "biome",
},
qmlformat = {
append_args = { "-w 4" },
},
sleek = {
append_args = { "--indent-spaces=2", "--lines-between-queries=1" },
},
sqlfluff = {
command = "sqlfluff",
args = { "fix", "--dialect=snowflake", "--templater=jinja" },
require_cwd = false,
stdin = true,
},
deno_fmt_md = {
inherit = "deno_fmt",
append_args = function()
return { "--prose-wrap=" .. (prose_wrap and "always" or "never") }
end,
},
}
conform.setup({
formatters_by_ft = {
javascriptreact = { "biome", "rustywind" },
typescriptreact = { "biome", "rustywind" },
javascript = { "biome", "rustywind" },
typescript = { "biome", "rustywind" },
svelte = { "biome", "rustywind" },
graphql = { "biome" },
css = { "biome" },
html = { "deno_fmt", "rustywind" },
xml = { "xmlstarlet" },
jsonc = { "deno_fmt" },
json = { "deno_fmt" },
nu = { "topiary_nu" },
sh = { "beautysh" },
-- bash = { "shfmt" },
fish = { "fish_indent" },
-- python = { "ruff_format", "ruff_organize_imports" },
htmldjango = { "djlint", "rustywind" },
jinja = { "djlint", "rustywind" },
j2 = { "sqlfluff" },
ocaml = { "ocamlformat" },
markdown = { "deno_fmt_md" },
qmljs = { "qmlformat" },
yaml = { "yamlfmt" },
kdl = { "kdlfmt" },
lua = { "stylua" },
nix = { "nixfmt" },
sql = { "sqlfluff" },
},
format_on_save = {
lsp_fallback = true,
timeout_ms = 2000,
async = false,
},
})
vim.keymap.set("n", "<leader>mp", function()
conform.format({ lsp_fallback = true, async = false, timeout_ms = 2000 })
end, { desc = "Make Pretty" })
vim.keymap.set("n", "<leader>mw", function()
prose_wrap = not prose_wrap
vim.notify("Prose wrap: " .. (prose_wrap and "always" or "never"))
end, { desc = "Toggle markdown prose wrap" })