init
This commit is contained in:
28
plugin/fatebook.lua
Normal file
28
plugin/fatebook.lua
Normal 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",
|
||||
})
|
||||
Reference in New Issue
Block a user