summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/rafta.lua39
-rw-r--r--lua/rafta/init.lua67
2 files changed, 67 insertions, 39 deletions
diff --git a/lua/rafta.lua b/lua/rafta.lua
deleted file mode 100644
index b3483a4..0000000
--- a/lua/rafta.lua
+++ /dev/null
@@ -1,39 +0,0 @@
-local M = {}
-
-M.setup = function()
- -- nothing
-end
-
----@class rafta.Slides
----@fields slides string[]: The slides of the file
-
---- Takes some lines and parses them
----@param lines string[]: The lines in the buffer
----@return rafta.Slides
-local parse_slides = function(lines)
- local current_slide = {}
- local sep = "^#"
-
- local slides = { slides = {} }
- for _, line in ipairs(lines) do
- print(line, "find:", line:find(sep), "|")
- if line:find(sep) then
- if #current_slide > 0 then
- table.insert(slides.slides, current_slide)
- end
- current_slide = {}
- end
- table.insert(current_slide, line)
- end
- table.insert(slides.slides, current_slide)
- return slides
-end
-
-vim.print(parse_slides({
- "# Hello",
- "this is something else",
- "# World",
- "this is another thing",
-}))
-
-return M
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