Add ConformDisable / ConformEnable commands
This commit is contained in:
parent
027118070c
commit
e18c745662
2 changed files with 38 additions and 13 deletions
|
|
@ -2,6 +2,25 @@ return {
|
|||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre" },
|
||||
cmd = { "ConformInfo" },
|
||||
init = function()
|
||||
vim.api.nvim_create_user_command("ConformDisable", function(args)
|
||||
if args.bang then
|
||||
-- FormatDisable! will disable formatting just for this buffer
|
||||
vim.b.disable_autoformat = true
|
||||
else
|
||||
vim.g.disable_autoformat = true
|
||||
end
|
||||
end, {
|
||||
desc = "Disable autoformat-on-save",
|
||||
bang = true,
|
||||
})
|
||||
vim.api.nvim_create_user_command("ConformEnable", function()
|
||||
vim.b.disable_autoformat = false
|
||||
vim.g.disable_autoformat = false
|
||||
end, {
|
||||
desc = "Re-enable autoformat-on-save",
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
-- Customize or remove this keymap to your liking
|
||||
|
|
@ -24,6 +43,13 @@ return {
|
|||
},
|
||||
-- Set up format-on-save
|
||||
--format_on_save = { timeout_ms = 500, lsp_fallback = true },
|
||||
format_after_save = function(bufnr)
|
||||
-- Disable with a global or buffer-local variable
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
return { timeout_ms = 500, lsp_format = "fallback" }
|
||||
end,
|
||||
-- Customize formatters
|
||||
formatters = {
|
||||
shfmt = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue