From f5266cc05662930fe126afdba01268041069da90 Mon Sep 17 00:00:00 2001 From: Ajay Mamtora <45173937+Ajaymamtora@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:01:55 +0100 Subject: [PATCH] feat(settings): refresh state feat(settings): refresh state --- lua/neoconf/settings.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lua/neoconf/settings.lua b/lua/neoconf/settings.lua index 10a1a22..9c8e0d9 100644 --- a/lua/neoconf/settings.lua +++ b/lua/neoconf/settings.lua @@ -163,4 +163,27 @@ function M.get_global() return settings end +function M.refresh() + local Workspace = require("neoconf.workspace") + -- Clear the internal state + M.options = {} + + -- Clear the Settings cache + M._cache = {} + + -- Re-read the global config file + local global_settings = M.get_global() + M.options = vim.tbl_deep_extend("force", M.options, global_settings:get()) + + -- Re-read the local config file + local workspace = Workspace.get() + if workspace.root_dir then + local local_settings = M.get_local(workspace.root_dir) + M.options = vim.tbl_deep_extend("force", M.options, local_settings:get()) + end + + -- Fire the on_update event for plugins + require("neoconf.plugins").fire("on_update") +end + return M