- Refactor community.lua module structure for better readability - Remove obsolete Mason configuration file - Add new plugins: nvim-lsp-file-operations, nvim-vtsls, package-info.nvim, tsc.nvim - Implement dynamic Mason package installation based on FRAMEWORK environment variable - Create custom command 'MasonInstallR' for framework-specific tool installation Signed-off-by: User <user@example.com>
82 lines
2.5 KiB
Lua
82 lines
2.5 KiB
Lua
-- AstroCommunity: import any community modules here
|
|
-- 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[]
|
|
local modules = {
|
|
-- Base AstroCommunity plugin
|
|
"AstroNvim/astrocommunity",
|
|
}
|
|
|
|
-- Add framework-specific modules
|
|
local framework_modules = get_framework_modules()
|
|
for _, module in ipairs(framework_modules) do
|
|
table.insert(modules, module)
|
|
end
|
|
|
|
-- Add AI modules if enabled
|
|
local ai_module = get_ai_modules()
|
|
if ai_module then
|
|
table.insert(modules, ai_module)
|
|
end
|
|
|
|
return modules
|