summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Chiarulli <[email protected]>2022-11-04 17:04:05 -0400
committerChristian Chiarulli <[email protected]>2022-11-04 17:32:46 -0400
commit08d3c056ffe989b97b11afee9ad1db108d3ccfb5 (patch)
treef5d2f26e602f232fcc115f4c38e29722e8b92148
parent57c159fe3c4aec49aeb5a4df78275e7092fc21fa (diff)
chore: format on save off by default
chore: check if table
-rw-r--r--lua/lvim/config/defaults.lua2
-rw-r--r--lua/lvim/core/autocmds.lua4
-rw-r--r--utils/installer/config.example.lua2
-rw-r--r--utils/installer/config_win.example.lua2
4 files changed, 7 insertions, 3 deletions
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