From 1fe385f5720f4767cc418684255bfec231e70589 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 31 Aug 2024 16:41:44 -0400 Subject: [PATCH] feat: add flexible package manager detection in pigeon setup --- lua/data/types.lua | 35 +++++++++++++++++++++++++++++++++++ lua/plugins/util.lua | 4 ++++ 2 files changed, 39 insertions(+) diff --git a/lua/data/types.lua b/lua/data/types.lua index cf99cce..fe1058e 100644 --- a/lua/data/types.lua +++ b/lua/data/types.lua @@ -280,6 +280,41 @@ M.plugin_reloader = { }, } +M.pigeon = function() + local data = require("data") + local platform = data.func.get_os("platform") + local lazy_installed = pcall(require, "lazy") + local packer_installed = pcall(require, "packer_plugins") + local pigeon_enabled = true -- default + local plugman = "lazy" -- default package manager + if lazy_installed then + plugman = "lazy" + elseif packer_installed then + plugman = "packer" + elseif vim.fn.exists("g:plugs") == 1 then + plugman = "vim-plug" + else + data.func.notify( + "Failed to detect package manager.\nPigeon disabled.", + "ERROR" + ) + pigeon_enabled = false + return + end + local config = { + enabled = pigeon_enabled, + os = platform, + plugin_manager = plugman, + callbacks = { + killing_pigeon = nil, + respawning_pigeon = nil, + }, + -- more config options here + } + + require("pigeon").setup(config) +end + M.substitute = { yank_substituted_text = false, preserve_cursor_position = true, diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index bd43151..f9c1ebe 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -137,4 +137,8 @@ return { end, dependencies = data.deps.needs_telescope, }, + { + "Pheon-Dev/pigeon", + config = data.types.pigeon, + }, }