feat: enhance dynamic plugin loading with framework support and AI integration
- Update all plugins to latest stable versions - Add dynamic framework module loading based on FRAMEWORK environment variable - Support Vue.js and Python framework-specific community modules - Implement conditional AI plugin activation via DEEPSEEK_API_KEY and THIRD_PARTY_AI_ASSISTANT environment variables - Improve modularity and configurability of Neovim setup Signed-off-by: User <user@example.com>
This commit is contained in:
+65
-3
@@ -2,10 +2,72 @@
|
||||
-- We import this file in `lazy_setup.lua` before the `plugins/` folder.
|
||||
-- This guarantees that the specs are processed before any user plugins.
|
||||
|
||||
--- @alias FrameworkModuleSpec { import: string }
|
||||
|
||||
--- @alias FrameworkModules table<string, FrameworkModuleSpec[]>
|
||||
|
||||
-- Framework-specific community module configurations
|
||||
--- @type FrameworkModules
|
||||
local FRAMEWORK_COMMUNITY_MODULES = {
|
||||
-- Base Lua pack - always included
|
||||
lua = {
|
||||
{ import = "astrocommunity.pack.lua" },
|
||||
},
|
||||
|
||||
-- Vue.js framework modules
|
||||
vue = {
|
||||
{ import = "astrocommunity.pack.vue" },
|
||||
},
|
||||
}
|
||||
|
||||
--- Retrieves the appropriate community modules based on the current framework environment
|
||||
--- @return LazySpec[] List of community modules to import for the detected framework
|
||||
local function get_framework_modules()
|
||||
--- @type string|nil
|
||||
local current_framework = os.getenv "FRAMEWORK"
|
||||
--- @type LazySpec[]
|
||||
local modules = {}
|
||||
|
||||
-- Always include base Lua pack
|
||||
for _, module in ipairs(FRAMEWORK_COMMUNITY_MODULES.lua) do
|
||||
table.insert(modules, module)
|
||||
end
|
||||
|
||||
-- If framework is not set or empty string, use only base modules
|
||||
if not current_framework or current_framework == "" then return modules end
|
||||
|
||||
-- Check if framework is valid (vue or python)
|
||||
if current_framework ~= "vue" and current_framework ~= "python" then
|
||||
error("Invalid framework: '" .. current_framework .. "'. Valid frameworks are: vue, python")
|
||||
end
|
||||
|
||||
-- Add framework-specific modules if framework is valid
|
||||
if FRAMEWORK_COMMUNITY_MODULES[current_framework] then
|
||||
for _, module in ipairs(FRAMEWORK_COMMUNITY_MODULES[current_framework]) do
|
||||
table.insert(modules, module)
|
||||
end
|
||||
end
|
||||
|
||||
return modules
|
||||
end
|
||||
|
||||
--- Checks if third-party AI assistant is enabled and adds Avante-nvim if true
|
||||
--- @return LazySpec|nil Avante-nvim module if AI is enabled, nil otherwise
|
||||
local function get_ai_modules()
|
||||
-- Check if third-party AI assistant is enabled
|
||||
local ai_enabled = os.getenv "THIRD_PARTY_AI_ASSISTANT"
|
||||
if ai_enabled and ai_enabled:lower() == "true" then return { import = "astrocommunity.completion.avante-nvim" } end
|
||||
return nil
|
||||
end
|
||||
|
||||
---@type LazySpec
|
||||
return {
|
||||
-- Base AstroCommunity plugin
|
||||
"AstroNvim/astrocommunity",
|
||||
{ import = "astrocommunity.pack.lua" },
|
||||
-- { import = "astrocommunity.completion.avante-nvim" },
|
||||
-- import/override with your plugins folder
|
||||
|
||||
-- Framework-specific modules
|
||||
unpack(get_framework_modules()),
|
||||
|
||||
-- AI modules if enabled
|
||||
get_ai_modules(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user