nvim: Add util function to grab plugin conditionally
This commit is contained in:
parent
41934d3000
commit
497b19fcbe
1 changed files with 10 additions and 2 deletions
|
@ -5,10 +5,18 @@ local T = {}
|
||||||
---@param plugin string The plugin to search for
|
---@param plugin string The plugin to search for
|
||||||
---@return boolean available # Whether the plugin is available
|
---@return boolean available # Whether the plugin is available
|
||||||
function T.is_available(plugin)
|
function T.is_available(plugin)
|
||||||
local lazy_config_avail, lazy_config = pcall(require, "lazy.core.config")
|
return T.get_plugin(plugin) and true or false
|
||||||
return lazy_config_avail and lazy_config.plugins[plugin] ~= nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get the plugin file handle if it exists, return nil otherwise
|
||||||
|
function T.get_plugin(plugin)
|
||||||
|
local status, lib = pcall(require, plugin)
|
||||||
|
if(status) then return lib end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- get the current python environment
|
||||||
|
-- return its path
|
||||||
function T.get_python_venv(workspace)
|
function T.get_python_venv(workspace)
|
||||||
return require("util.pyenv").get_path(workspace)
|
return require("util.pyenv").get_path(workspace)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue