Update init.lua
This commit is contained in:
+21
-3
@@ -4,12 +4,30 @@ M.language_configs = {}
|
|||||||
|
|
||||||
-- Load language module and apply its config
|
-- Load language module and apply its config
|
||||||
function M.load_language_module(lang)
|
function M.load_language_module(lang)
|
||||||
local lang_module = require("Polydev." .. lang)
|
-- Check if the language module is already loaded
|
||||||
if lang_module then
|
if M.loaded_languages[lang] then return true end
|
||||||
|
|
||||||
|
-- Only attempt to load if it's a valid language (exclude non-programming filetypes)
|
||||||
|
local valid_languages = { "java", "c", "python", "go", "rust" } -- Add more languages as needed
|
||||||
|
local is_valid = false
|
||||||
|
for _, valid_lang in ipairs(valid_languages) do
|
||||||
|
if lang == valid_lang then
|
||||||
|
is_valid = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If it's a valid language, attempt to load the module
|
||||||
|
if is_valid then
|
||||||
|
local ok, lang_module = pcall(require, "Polydev." .. lang)
|
||||||
|
if ok and lang_module.setup then
|
||||||
lang_module.setup()
|
lang_module.setup()
|
||||||
M.language_configs[lang] = lang_module.config or {} -- Store the configuration
|
M.loaded_languages[lang] = lang_module
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If not a valid language or module not found, suppress the error
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user