add: alternative config disable format on save

This commit is contained in:
asep.komarudin 2024-06-24 05:54:11 +07:00
parent aeeb5ccd1f
commit 4392eb6d59
3 changed files with 16 additions and 10 deletions

View file

@ -4,7 +4,7 @@
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
"bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" },
"bufferline.nvim": { "branch": "main", "commit": "6ac7e4f1eead72507cfdbc94dcd0c26b98b2f86e" }, "bufferline.nvim": { "branch": "main", "commit": "46192e794b73f92136326c10ecdbdbf15e35705f" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
@ -45,7 +45,7 @@
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-scrollview": { "branch": "main", "commit": "fd334e5ad0c616987d1b9114890a59c97165cf83" }, "nvim-scrollview": { "branch": "main", "commit": "fd334e5ad0c616987d1b9114890a59c97165cf83" },
"nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" }, "nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" },
"nvim-treesitter": { "branch": "master", "commit": "0941c1147a1c8d7f9c8f712a9856412db3fbc560" }, "nvim-treesitter": { "branch": "master", "commit": "9d80c1497ec343f81c0c5800b65f2e73ca569025" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
"nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" }, "nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },

View file

@ -47,12 +47,15 @@ if pcode.active_cpp_config then
"stevearc/conform.nvim", "stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" }, event = { "BufReadPre", "BufNewFile" },
opts = function(_, opts) opts = function(_, opts)
local psave = pcode.format_on_save or 0
opts.formatters_by_ft = opts.formatters_by_ft or {} opts.formatters_by_ft = opts.formatters_by_ft or {}
opts.formatters_by_ft.cpp = { "clang-format" } opts.formatters_by_ft.cpp = { "clang-format" }
if psave == 1 then
opts.format_on_save = { opts.format_on_save = {
timeout_ms = 500, timeout_ms = 500,
lsp_fallback = true, lsp_fallback = true,
} }
end
return opts return opts
end, end,
config = function(_, opts) config = function(_, opts)

View file

@ -50,12 +50,15 @@ if pcode.active_java_config.active then
"stevearc/conform.nvim", "stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" }, event = { "BufReadPre", "BufNewFile" },
opts = function(_, opts) opts = function(_, opts)
local psave = pcode.format_on_save or 0
opts.formatters_by_ft = opts.formatters_by_ft or {} opts.formatters_by_ft = opts.formatters_by_ft or {}
opts.formatters_by_ft.java = { "google-java-format" } opts.formatters_by_ft.java = { "google-java-format" }
if psave == 1 then
opts.format_on_save = { opts.format_on_save = {
timeout_ms = 500, timeout_ms = pcode.format_timeout_ms or 500,
lsp_fallback = true, lsp_fallback = true,
} }
end
return opts return opts
end, end,
config = function(_, opts) config = function(_, opts)