-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(format): use conform for code formatting
- Loading branch information
1 parent
92c5a93
commit 17593ca
Showing
6 changed files
with
45 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
return { | ||
{ | ||
"stevearc/conform.nvim", | ||
dependencies = { "mason.nvim" }, | ||
event = "BufWritePre", | ||
cmd = "ConformInfo", | ||
|
||
keys = { | ||
{ | ||
"<leader>lf", | ||
function() | ||
vim.g.autoformat = not vim.g.autoformat | ||
vim.notify("Format on save: " .. (vim.g.autoformat and "on" or "off")) | ||
if vim.g.autoformat then | ||
require("conform").format() | ||
end | ||
end, | ||
desc = "toggle auto formatting", | ||
}, | ||
}, | ||
|
||
---@type conform.setupOpts | ||
opts = { | ||
formatters_by_ft = { | ||
lua = { "stylua", lsp_format = "never" }, | ||
sh = { "shfmt" }, | ||
sql = { "sqlfluff" }, | ||
}, | ||
default_format_opts = { | ||
timeout_ms = 3000, | ||
async = false, | ||
quiet = false, | ||
lsp_format = "fallback", | ||
}, | ||
format_on_save = function() | ||
if not vim.g.autoformat then | ||
return | ||
end | ||
return {} | ||
end, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters