From e72a645ea7597353937bbcdae9340b4015f3aadb Mon Sep 17 00:00:00 2001 From: Feliche-Demian Netliukh <51330172+Demianeen@users.noreply.github.com> Date: Thu, 28 Mar 2024 06:52:37 +0000 Subject: [PATCH] feat(extras): add chezmoi extra --- lua/lazyvim/plugins/extras/util/chezmoi.lua | 77 +++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/util/chezmoi.lua diff --git a/lua/lazyvim/plugins/extras/util/chezmoi.lua b/lua/lazyvim/plugins/extras/util/chezmoi.lua new file mode 100644 index 00000000..a224fcaf --- /dev/null +++ b/lua/lazyvim/plugins/extras/util/chezmoi.lua @@ -0,0 +1,77 @@ +return { + { + -- highlighting for chezmoi files template files + "alker0/chezmoi.vim", + opts = { + use_tmp_buffer = true, + source_dir_path = os.getenv("HOME") .. "/.local/share/chezmoi", + }, + config = function(_, opts) + for key, value in pairs(opts) do + vim.g["chezmoi#" .. key] = value + end + end, + }, + { + "xvzc/chezmoi.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + keys = { + { + "sz", + function() + require("telescope").extensions.chezmoi.find_files() + end, + desc = "Chezmoi", + }, + }, + opts = { + edit = { + watch = false, + force = false, + }, + notification = { + on_open = true, + on_apply = true, + on_watch = false, + }, + telescope = { + select = { "" }, + }, + }, + config = function(_, opts) + require("chezmoi").setup(opts) + + -- run chezmoi edit on file enter + vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + pattern = { os.getenv("HOME") .. "/.local/share/chezmoi/*" }, + callback = function() + vim.schedule(require("chezmoi.commands.__edit").watch) + end, + }) + end, + }, + { + "nvimdev/dashboard-nvim", + optional = true, + opts = function(_, opts) + local projects = { + action = "Telescope chezmoi find_files", + desc = " Config", + icon = "", + key = "c", + } + + projects.desc = projects.desc .. string.rep(" ", 43 - #projects.desc) + projects.key_format = " %s" + + -- remove lazyvim config property + for i = #opts.config.center, 1, -1 do + if opts.config.center[i].key == "c" then + table.remove(opts.config.center, i) + end + end + + table.insert(opts.config.center, 5, projects) + end, + }, +}