From 13cc065ec014b86369dfe4ad60d1a43fa06fd251 Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Thu, 17 Sep 2026 19:45:23 +0100 Subject: dotfiles Shell, editor and terminal configuration, the tools that go with them, and szecret, an age-based secret manager whose store lives elsewhere. History restarts here. What came before was not written to be read by anyone else, and carried machine names, addresses and an encrypted secret store; it is kept privately instead. What is left is meant to be safe on any machine, including one whose owner is not me: see CLAUDE.md for the rule it is written to. --- .../local-plugins/cfg-watch/lua/cfg_watch/init.lua | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 config/nvim/local-plugins/cfg-watch/lua/cfg_watch/init.lua (limited to 'config/nvim/local-plugins/cfg-watch/lua/cfg_watch/init.lua') diff --git a/config/nvim/local-plugins/cfg-watch/lua/cfg_watch/init.lua b/config/nvim/local-plugins/cfg-watch/lua/cfg_watch/init.lua new file mode 100644 index 0000000..3b5c9d6 --- /dev/null +++ b/config/nvim/local-plugins/cfg-watch/lua/cfg_watch/init.lua @@ -0,0 +1,58 @@ +local M = {} + +local function load_config_path(filepath) + local uv = vim.uv or vim.loop + + if uv.fs_stat(filepath) == nil then + local dir = filepath:match("(.*/)") + if dir and uv.fs_stat(dir) == nil then + assert(uv.fs_mkdir(dir, 448)) -- 0o700 + end + local file, err = io.open(filepath, "w") + if not file then + vim.schedule(function() + vim.notify("Error creating file: " .. filepath .. "\n" .. err, vim.log.levels.ERROR) + end) + return + end + file:write("-- Created by cfg-watch\n") + file:close() + else + vim.schedule(function() + local ok, err = pcall(dofile, filepath) + if not ok then + vim.schedule(function() + vim.notify("Error loading config: " .. filepath .. "\n" .. err, vim.log.levels.ERROR) + end) + end + end) + end +end + +function M.load_colors() + local filepath = vim.fn.stdpath("data") .. "/colors.lua" -- ~/.local/share/nvim/colors.lua + load_config_path(filepath) + + local ok, fwatch = pcall(require, "fwatch") + if ok and fwatch and fwatch.once then + fwatch.once(filepath, { + on_event = function() M.load_colors() end, + on_error = function(err) + vim.notify("fwatch error: " .. err, vim.log.levels.ERROR) + end, + }) + else + vim.notify("cfg-watch: fwatch not available", vim.log.levels.ERROR) + end + + vim.schedule(function() + vim.cmd("hi Normal guibg=NONE ctermbg=NONE") + end) +end + +function M.load_config(name) + local filepath = vim.fn.stdpath("config") .. "/lua/" .. name .. ".lua" + load_config_path(filepath) +end + +return M -- cgit v1.2.3