mirror of
https://github.com/DefectingCat/nvim
synced 2025-07-16 01:01:34 +00:00
add custom commands
This commit is contained in:
31
lua/rua/core/usercmd.lua
Normal file
31
lua/rua/core/usercmd.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local user_command = vim.api.nvim_create_user_command
|
||||
|
||||
-- Toggle conform format on save
|
||||
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
|
||||
end
|
||||
end, {
|
||||
desc = "Disable autoformat-on-save",
|
||||
bang = true,
|
||||
})
|
||||
user_command("FormatEnable", function()
|
||||
vim.b.disable_autoformat = false
|
||||
vim.g.disable_autoformat = false
|
||||
end, {
|
||||
desc = "Re-enable autoformat-on-save",
|
||||
})
|
||||
user_command("FormatToggle", function()
|
||||
vim.b.disable_autoformat = not vim.b.disable_autoformat
|
||||
vim.g.disable_autoformat = not vim.g.disable_autoformat
|
||||
if vim.g.disable_autoformat then
|
||||
vim.notify("autoformat disabled")
|
||||
else
|
||||
vim.notify("autoformat enabled")
|
||||
end
|
||||
end, {
|
||||
desc = "Re-enable autoformat-on-save",
|
||||
})
|
Reference in New Issue
Block a user