diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-10-06 13:55:50 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-10-06 14:27:56 -0500 |
commit | 183406c250b55415beecaa4e3baca0112bb06291 (patch) | |
tree | 0354127b039872af3633fac53338fbcfe134540b /nvim/.config | |
parent | 2b3985da873b2337a2ebe083f4d1f15cc1930171 (diff) |
feat(nvim): add local_use function for packer with optional fallback
Diffstat (limited to 'nvim/.config')
-rw-r--r-- | nvim/.config/nvim/lua/tobyvin/plugins.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins.lua b/nvim/.config/nvim/lua/tobyvin/plugins.lua index 0776b93..7dc5666 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins.lua @@ -2,6 +2,31 @@ local utils = require("tobyvin.utils") local M = {} M.plugins = function(use) + ---@diagnostic disable-next-line: unused-local, unused-function + local local_use = function(opts, skip_missing) + skip_missing = vim.F.if_nil(skip_missing, false) + + if type(opts) == "string" then + opts = { opts } + end + + ---@diagnostic disable-next-line: missing-parameter + local local_path = vim.fn.expand("~/src/" .. vim.fs.basename(opts[1])) + if vim.fn.isdirectory(local_path) == 1 then + opts[1] = local_path + else + local notif_opts = { title = "[Packer] Missing local plugin" } + local notif_msg = string.format("Failed to find local plugin: %s", local_path) + if skip_missing then + vim.notify(string.format("%s\nSkipping.", notif_msg), vim.log.levels.WARN, notif_opts) + return + end + vim.notify(string.format("%s\nFalling back to '%s'", notif_msg, opts[1]), vim.log.levels.WARN, notif_opts) + end + + use(opts) + end + use("wbthomason/packer.nvim") use({ |