diff --git a/lua/lvim/config/defaults.lua b/lua/lvim/config/defaults.lua index 74a94052..a03ee464 100644 --- a/lua/lvim/config/defaults.lua +++ b/lua/lvim/config/defaults.lua @@ -4,6 +4,8 @@ return { colorscheme = "lunar", transparent_window = false, format_on_save = { + ---@usage boolean: format on save (Default: false) + enabled = false, ---@usage pattern string pattern used for the autocommand (Default: '*') pattern = "*", ---@usage timeout number timeout in ms for the format request (Default: 1000) diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua index 21c7c1f0..61e3e676 100644 --- a/lua/lvim/core/autocmds.lua +++ b/lua/lvim/core/autocmds.lua @@ -158,7 +158,9 @@ function M.disable_format_on_save() end function M.configure_format_on_save() - if lvim.format_on_save then + if type(lvim.format_on_save) == "table" and lvim.format_on_save.enabled then + M.enable_format_on_save() + elseif lvim.format_on_save == true then M.enable_format_on_save() else M.disable_format_on_save() diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 292c3b6b..65415434 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -10,7 +10,7 @@ an executable -- general lvim.log.level = "warn" -lvim.format_on_save = false +lvim.format_on_save.enabled = false lvim.colorscheme = "lunar" -- to disable icons and use a minimalist setup, uncomment the following -- lvim.use_icons = false diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index 20fe0a55..4dfd6a3c 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -27,7 +27,7 @@ vim.g.clipboard = { -- general lvim.log.level = "warn" -lvim.format_on_save = true +lvim.format_on_save.enabled = false lvim.colorscheme = "lunar" -- to disable icons and use a minimalist setup, uncomment the following -- lvim.use_icons = false