This commit is contained in:
f0ldspace
2025-10-04 12:02:00 +01:00
parent cf43844a50
commit ccd42b30a2
3 changed files with 163 additions and 1 deletions

28
plugin/fatebook.lua Normal file
View File

@@ -0,0 +1,28 @@
if vim.g.loaded_fatebook then
return
end
vim.g.loaded_fatebook = true
vim.api.nvim_create_user_command("Predict", function(opts)
local fatebook = require("fatebook")
local args = opts.args
local question, forecast, date = args:match('^"([^"]+)"%s*,%s*(%d+)%s*,%s*([%d%-]+)$')
if not question or not forecast or not date then
question, forecast, date = args:match("^([^,]+),%s*(%d+)%s*,%s*([%d%-]+)$")
end
if not question or not forecast or not date then
vim.notify('Fatebook: Invalid format. Use :Predict "question", 55, DD-MM-YYYY', vim.log.levels.ERROR)
return
end
question = question:match("^%s*(.-)%s*$")
fatebook.create_prediction(question, forecast, date)
end, {
nargs = 1,
desc = "Create a Fatebook prediction",
})