mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 10:35:08 +02:00
feat(config): allow disabling reload-on-save (#3261)
This commit is contained in:
parent
b7b9087d34
commit
6f6cbc394d
3 changed files with 22 additions and 18 deletions
|
@ -1,5 +1,6 @@
|
|||
return {
|
||||
leader = "space",
|
||||
reload_config_on_save = true,
|
||||
colorscheme = "tokyonight",
|
||||
transparent_window = false,
|
||||
format_on_save = {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = "*",
|
||||
|
|
Loading…
Reference in a new issue