feat(config): allow disabling reload-on-save (#3261)

This commit is contained in:
Christian Chiarulli 2022-10-17 08:06:12 -04:00 committed by GitHub
parent b7b9087d34
commit 6f6cbc394d
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 18 deletions

View file

@ -1,5 +1,6 @@
return {
leader = "space",
reload_config_on_save = true,
colorscheme = "tokyonight",
transparent_window = false,
format_on_save = {

View file

@ -139,6 +139,10 @@ function M:load(config_path)
if lvim.transparent_window then
autocmds.enable_transparent_mode()
end
if lvim.reload_config_on_save then
autocmds.enable_reload_config_on_save()
end
end
--- Override the configuration with a user provided one

View file

@ -3,13 +3,6 @@ local Log = require "lvim.core.log"
--- Load the default set of autogroups and autocommands.
function M.load_defaults()
local user_config_file = require("lvim.config"):get_user_config_path()
if vim.loop.os_uname().version:match "Windows" then
-- autocmds require forward slashes even on windows
user_config_file = user_config_file:gsub("\\", "/")
end
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = {
"Jaq",
@ -41,17 +34,6 @@ function M.load_defaults()
end,
},
},
{
"BufWritePost",
{
group = "_general_settings",
pattern = user_config_file,
desc = "Trigger LvimReload on saving " .. vim.fn.expand "%:~",
callback = function()
require("lvim.config"):reload()
end,
},
},
{
"FileType",
{
@ -181,6 +163,23 @@ function M.toggle_format_on_save()
end
end
function M.enable_reload_config_on_save()
local user_config_file = require("lvim.config"):get_user_config_path()
if vim.loop.os_uname().version:match "Windows" then
-- autocmds require forward slashes even on windows
user_config_file = user_config_file:gsub("\\", "/")
end
vim.api.nvim_create_autocmd("BufWritePost", {
group = "_general_settings",
pattern = user_config_file,
desc = "Trigger LvimReload on saving config.lua",
callback = function()
require("lvim.config"):reload()
end,
})
end
function M.enable_transparent_mode()
vim.api.nvim_create_autocmd("ColorScheme", {
pattern = "*",