nvim: FormatDisable disables globally with a bang
Switch the functionality of `FormatDisable` command around: Disables for the local buffer by default and disables globally if called with a bang.
This commit is contained in:
parent
d2a2537df0
commit
88f187160a
1 changed files with 5 additions and 3 deletions
|
@ -141,7 +141,9 @@ return {
|
|||
"stevearc/conform.nvim",
|
||||
config = function()
|
||||
require("conform").setup({
|
||||
|
||||
lsp_format = "fallback",
|
||||
|
||||
format_after_save = function(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
|
@ -152,10 +154,10 @@ return {
|
|||
})
|
||||
vim.api.nvim_create_user_command("FormatDisable", 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
|
||||
else
|
||||
-- FormatDisable! will disable formatting globally
|
||||
vim.b.disable_autoformat = true
|
||||
end
|
||||
end, {
|
||||
desc = "Disable formatting on save",
|
||||
|
|
Loading…
Reference in a new issue