Skip to content

Commit

Permalink
select a wikid command
Browse files Browse the repository at this point in the history
  • Loading branch information
dneumann committed Feb 10, 2024
1 parent 5005478 commit ef16509
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# A wickedly cool wiki manager

# Usage

## Daily Notes

Open daily note by running the WikidDaily command

```lua
:WikidDaily<cr>
```
27 changes: 17 additions & 10 deletions lua/wikid.lua
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
local dashboard_module = require("wikid.dashboard")
local daily_module = require("wikid.daily")

local config = {
wiki_dir = "~/.wiki",
daily_date_format = "%m-%d-%Y",
daily_subdir = "daily"
}

local M = {
setup_called = false
setup_called = false,
config = config,
}

M.config = config

M.setup = function(args)
M.setup_called = true
M.config = vim.tbl_deep_extend("force", M.config, args or {})
end

M.dashboard = function()
assert(M.setup_called)
dashboard_module.show_dashboard()
if not M.setup_called then
return
end
require("wikid.dashboard").show_dashboard()
end

M.daily = function()
assert(M.setup_called)
daily_module.open_daily_entry(M.config)
if not M.setup_called then
return
end
require("wikid.daily").open_daily_entry(M.config)
end

M.commands = function()
local commands = { "dashboard", "daily" }
vim.ui.select(commands, { prompt = "Wikid" }, function(itm)
M[itm]()
end)
end

return M
1 change: 1 addition & 0 deletions plugin/wikid.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local wikid = require("wikid")
vim.api.nvim_create_user_command("WikidDashboard", wikid.dashboard, {})
vim.api.nvim_create_user_command("WikidDaily", wikid.daily, {})
vim.api.nvim_create_user_command("WikidCommands", wikid.commands, {})

0 comments on commit ef16509

Please sign in to comment.