1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 01:20:05 +08:00
SpaceVim/bundle/vim-zettelkasten/plugin/zettelkasten.lua

32 lines
973 B
Lua
Raw Normal View History

local api = vim.api
local s_config = require("zettelkasten.config")
if vim.fn.exists(":ZkNew") == 0 then
vim.cmd([[command ZkNew :lua _G.zettelkasten.zknew()]])
end
if vim.fn.exists(":ZkBrowse") == 0 then
vim.cmd([[command ZkBrowse :lua _G.zettelkasten.zkbrowse()]])
end
_G.zettelkasten = {
tagfunc = require("zettelkasten").tagfunc,
completefunc = require("zettelkasten").completefunc,
zknew = function()
vim.cmd([[new | setlocal filetype=markdown]])
if s_config.zettel_dir ~= "" then
if vim.fn.isdirectory(s_config.zettel_dir) == 0 then
vim.fn.mkdir(vim.fn.expand(s_config.zettel_dir), 'p', '0700')
end
vim.cmd("lcd " .. s_config.zettel_dir)
end
vim.cmd("normal ggI# New Note")
require("zettelkasten").set_note_id(vim.api.nvim_get_current_buf())
vim.cmd("normal $")
end,
zkbrowse = function()
vim.cmd("edit zk://browser")
end,
}