1
0
Fork 1
Dotfiles_nvim/lua/util/toolchain.lua

73 lines
2.1 KiB
Lua
Raw Normal View History

2024-07-02 21:52:43 +00:00
---@class Toolchain
---@field should_init fun():boolean
---@field requirements ToolchainRequirements
---@field formatters ToolchainFormatters
---@field language_servers ToolchainLanguageServers
---@field actions ToolchainActions
---@field diagnostics ToolchainDiagnostics
---@field debuggers ToolchainDebuggers
---@class ToolchainRequirements
---@field plugins LazySpec
---@field highlighters table
---@field language_servers table
---@class ToolchainLanguageServers
---@field requirements string[]
---@field setup fun(lspconfig:any, capabilities: any)
---@class ToolchainFormatters
---@field plugins LazySpec[]
---@field setup fun(null_ls: any):table
---@class ToolchainActions
---@field plugins LazySpec[]
---@field setup fun(null_ls: any):table
---@class ToolchainDiagnostics
---@field plugins LazySpec[]
---@field setup fun(null_ls: any):table
---@class ToolchainDebuggers
---@field plugins LazySpec[]
local TOOLCHAIN = {
---@type LazySpec[]
plugins = {},
---@type string[]
highlighters = {},
---@type string[]
lsp_requriemts = {},
---@type (fun(lspconfig, capabilities))[]
lsp_setups = {},
---@type (fun(null_ls):any)[]
null_ls = {},
}
local path = vim.fn.stdpath('config') .. '/lua/toolchain'
for _, moduleName in ipairs(vim.fn.readdir(path)) do
local submodulePath = 'toolchain' .. '.' .. moduleName
---@type Toolchain
local module = require(submodulePath)
if module.should_init() then
for _, plugin in pairs(module.requirements.plugins) do
table.insert(TOOLCHAIN.plugins, plugin)
end
for _, hl in pairs(module.requirements.highlighters) do
table.insert(TOOLCHAIN.highlighters, hl)
end
for _, lsp in pairs(module.requirements.language_servers) do
table.insert(TOOLCHAIN.lsp_requriemts, lsp)
end
table.insert(TOOLCHAIN.lsp_setups, module.language_servers.setup)
table.insert(TOOLCHAIN.null_ls, module.formatters.setup)
table.insert(TOOLCHAIN.null_ls, module.actions.setup)
table.insert(TOOLCHAIN.null_ls, module.diagnostics.setup)
end
end
return TOOLCHAIN