From 6fe386a100b0ccb379c0e61cf18039f2151e39e8 Mon Sep 17 00:00:00 2001 From: lnk3 Date: Wed, 6 Dec 2023 17:18:57 +0100 Subject: [PATCH] plug(Lazy): specify developer plugin folder path in custom file in each machine --- .gitignore | 1 + lua/core/lazy.lua | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 9bbbeea..bd2a30a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .luarc.json +dev_path.txt diff --git a/lua/core/lazy.lua b/lua/core/lazy.lua index e481076..4e99c2c 100644 --- a/lua/core/lazy.lua +++ b/lua/core/lazy.lua @@ -11,18 +11,39 @@ if not vim.loop.fs_stat(lazypath) then lazypath, }) end +local dev_path_file = vim.fn.stdpath("config") .. "/lua/plugins/dev_path.txt" +-- Check if the file with custom dev plugins folder path exists +if vim.fn.filereadable(dev_path_file) ~= 1 then + -- File doesn't exist, ask the user for a path + local desired_path = vim.fn.input("Enter the path for custom neovim plugins: ", dev_path_file) + -- Ask for confirmation before writing to the file + local confirm = vim.fn.confirm( + "Save the path '" .. desired_path .. "' to " .. dev_path_file .. "?", + "&Yes\n&No", + 2) + + if confirm == 1 then + -- Write the user's input to the file + vim.fn.writefile({ desired_path }, dev_path_file) + else + print("Plugin path not saved. Using fallback path.") + end +end +local dev_path = vim.fn.trim(vim.fn.readfile(dev_path_file)[1]) + vim.opt.rtp:prepend(lazypath) local lazy = Prequire("lazy") +if not lazy then return end -->-- lazy.setup("plugins", { defaults = { lazy = true }, lockfile = vim.fn.stdpath("config") .. "/.lazy-lock.json", git = { log = { "-5" } }, -- Show the last 5 commits - dev = { path = "~/projects/neovim_plugins", fallback = true }, + dev = { path = dev_path or "~/projects", fallback = true }, ui = { border = "rounded" }, install = { - colorscheme = { "rose-pine", "habamax" } + colorscheme = { "rose-pine", "habamax" }, }, change_detection = { notify = false }, checker = { enabled = true }, @@ -39,9 +60,9 @@ lazy.setup("plugins", { "tutor", "zipPlugin", "spellfile", - } -->-- - } - } + }, -->-- + }, + }, }) local lazymap = MAP("LAZY") -- 2.11.4.GIT