summaryrefslogtreecommitdiff
path: root/lua/rafta/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/rafta/init.lua')
-rw-r--r--lua/rafta/init.lua67
1 files changed, 67 insertions, 0 deletions
diff --git a/lua/rafta/init.lua b/lua/rafta/init.lua
new file mode 100644
index 0000000..a034def
--- /dev/null
+++ b/lua/rafta/init.lua
@@ -0,0 +1,67 @@
+--- @class options
+--- @field username string | fun():string
+--- @field password string | fun():string
+--- @field rafta_endpoint string
+--- @field enforce_https boolean
+--- @field enable_offline_cache boolean
+--- @field icons iconList
+
+--- @class iconList
+--- @field unspecified string
+--- @field pending string
+--- @field ongoing string
+--- @field done string
+--- @field blocked string
+--- @field label string
+--- @field label_none string
+--- @field recurring string
+--- @field planned string
+--- @field deadline string
+
+local test = { "hello", "there", "general", "kenobi" }
+test[3] = "potatoe"
+vim.print(test)
+
+local M = {}
+
+--- @type options
+M.defaults = {
+ rafta_endpoint = "localhost:1157",
+ enforce_https = true,
+ password = "john.doe@example.com",
+ username = "password",
+ enable_offline_cache = false,
+ icons = {
+ unspecified = "", -- `[?]` unfolded
+ pending = "", -- `[ ]` unfolded
+ ongoing = "", -- `[~]` unfolded
+ done = "", -- `[x]` or `[X]` unfolded
+ blocked = "", -- `[!]` unfolded
+ label = "󰓹",
+ label_none = "󱈠",
+ recurring = "",
+ planned = "",
+ deadline = "",
+ },
+}
+
+M.setup = function(opts)
+ -- Load user-defined on top of defaults
+ M.config = vim.tbl_deep_extend("force", M.defaults, opts or {})
+ -- Validate required fields
+ if not M.config.rafta_endpoint then
+ error("rafta_endpoint is required")
+ end
+end
+
+local file_path = os.getenv("HOME") .. "/tmp.json"
+local file = io.open(file_path, "r")
+if not file then
+ error("Failed to open file: " .. file_path)
+end
+local content = file:read("*all")
+file:close()
+local data = vim.json.decode(content)
+vim.print(data.tasks)
+
+return M