feat: Added FormatEnable and FormatDisable for conform
This commit is contained in:
@@ -36,7 +36,18 @@ in rec {
|
||||
conform-nvim = {
|
||||
enable = true;
|
||||
settings = {
|
||||
format_on_save.lsp_format = "fallback";
|
||||
format_on_save =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
function(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
return { timeout_ms = 500, lsp_format = "fallback" }
|
||||
end
|
||||
'';
|
||||
formatters_by_ft = {
|
||||
d2 = ["d2"];
|
||||
sql = ["sleek"];
|
||||
@@ -632,6 +643,24 @@ in rec {
|
||||
end,
|
||||
{})
|
||||
|
||||
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
|
||||
end
|
||||
end, {
|
||||
desc = "Disable autoformat-on-save",
|
||||
bang = true,
|
||||
})
|
||||
vim.api.nvim_create_user_command("FormatEnable", function()
|
||||
vim.b.disable_autoformat = false
|
||||
vim.g.disable_autoformat = false
|
||||
end, {
|
||||
desc = "Re-enable autoformat-on-save",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command('Sqlfmt',
|
||||
function()
|
||||
pcall(vim.cmd'%!${pkgs.sleek}/bin/sleek')
|
||||
|
||||
Reference in New Issue
Block a user