This repository has been archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved the code and made it easier to pick up and maintain
- Loading branch information
1 parent
b5d896a
commit de3c0f3
Showing
10 changed files
with
293 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
local M = {} | ||
|
||
---@param registery RegisteryEntry[] | ||
M.write_registery = function(registery) | ||
local encoded = vim.fn.json_encode(registery) | ||
REGISTERY_PATH:write(encoded, "w") | ||
end | ||
|
||
---@param index IndexObject | ||
M.write_index = function(index) | ||
local encoded = vim.fn.json_encode(index) | ||
INDEX_PATH:write(encoded, "w") | ||
end | ||
|
||
---@param lockfile table<string, RegisteryEntry> | ||
M.write_lockfile = function(lockfile) | ||
local encoded = vim.fn.json_encode(lockfile) | ||
LOCK_PATH:write(encoded, "w") | ||
end | ||
|
||
---@return RegisteryEntry[]? | ||
M.read_registery = function() | ||
if not REGISTERY_PATH:exists() then return end | ||
local buf = REGISTERY_PATH:read() | ||
return vim.fn.json_decode(buf) | ||
end | ||
|
||
---@return IndexObject? | ||
M.read_index = function() | ||
if not INDEX_PATH:exists() then return end | ||
local buf = INDEX_PATH:read() | ||
return vim.fn.json_decode(buf) | ||
end | ||
|
||
---@return table<string, RegisteryEntry>? | ||
M.read_lockfile = function() | ||
if not LOCK_PATH:exists() then return end | ||
local buf = LOCK_PATH:read() | ||
return vim.fn.json_decode(buf) | ||
end | ||
|
||
---@param alias string | ||
M.remove_docs = function(alias) | ||
local doc_path = DOCS_DIR:joinpath(alias) | ||
doc_path:rm({ recursive = true }) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.