Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: started typing _setup, Setup, and cfg #333

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lua/telekasten.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2751,6 +2751,7 @@ end
--
-- Overrides config with elements from cfg. See top of file for defaults.
--
---@param cfg VaultConfig
local function Setup(cfg)
cfg = cfg or {}

Expand Down Expand Up @@ -2849,6 +2850,17 @@ local function Setup(cfg)
config.options.media_extensions = config.options.media_extensions
end

---Type in progress
---@class VaultConfig
---@field home string

---@class MultiVaultConfig
---@field vaults table<string, VaultConfig>
---@field default_vault? string

--- Wrapper around the Setup function to handle cfgs variable input type
--- Try the specified key -> vault as default, then the "default" -> vault, then its a VaultConfig
---@param cfg MultiVaultConfig | VaultConfig
local function _setup(cfg)
if cfg.vaults ~= nil and cfg.default_vault ~= nil then
M.vaults = cfg.vaults
Expand All @@ -2861,6 +2873,7 @@ local function _setup(cfg)
elseif cfg.home ~= nil then
M.vaults = cfg.vaults or {}
cfg.vaults = nil
---@cast cfg VaultConfig
M.vaults["default"] = cfg
Setup(cfg)
end
Expand Down
Loading