Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions config/plugins/lsp/conform.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
''
local slow_format_filetypes = {}

vim.api.nvim_create_user_command("FormatDisable", function(args)
vim.api.nvim_create_user_command("ConformFormatDisable", function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
Expand All @@ -21,13 +21,13 @@
desc = "Disable autoformat-on-save",
bang = true,
})
vim.api.nvim_create_user_command("FormatEnable", function()
vim.api.nvim_create_user_command("ConformFormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Re-enable autoformat-on-save",
})
vim.api.nvim_create_user_command("FormatToggle", function(args)
vim.api.nvim_create_user_command("ConformFormatToggle", function(args)
if args.bang then
-- Toggle formatting for current buffer
vim.b.disable_autoformat = not vim.b.disable_autoformat
Expand All @@ -39,6 +39,25 @@
desc = "Toggle autoformat-on-save",
bang = true,
})

vim.api.nvim_create_user_command("AllFormatDisable", function()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have this block somewhere else. Technically, it does neither belong to the convirm nor the lsp-format plugin. I did not see an obvious candidate for this extra config lua section.

vim.cmd([[ConformFormatDisable]]) -- conform-nvim
vim.cmd([[FormatDisable]]) -- lsp-conform
end, {
desc = "Disable formatting for all plugins",
})
vim.api.nvim_create_user_command("AllFormatEnable", function()
vim.cmd([[ConformFormatEnable]]) -- conform-nvim
vim.cmd([[FormatEnable]]) -- lsp-conform
end, {
desc = "Re-enable formatting for all plugins",
})
vim.api.nvim_create_user_command("AllFormatToggle", function()
vim.cmd([[ConformFormatToggle]]) -- conform-nvim
vim.cmd([[FormatToggle]]) -- lsp-conform
end, {
desc = "Toggle formatting for all plugins",
})
'';
plugins.conform-nvim = {
enable = true;
Expand Down