Iniital upload
Removing from my nixos config to add congruency with all nvim installs
This commit is contained in:
155
lua/vimwiki.lua
Normal file
155
lua/vimwiki.lua
Normal file
@@ -0,0 +1,155 @@
|
||||
local vim = vim
|
||||
local opt = vim.opt
|
||||
-- opt.wildmenu = true
|
||||
-- vim.g.netrw_keepdir = 0
|
||||
-- vim.treesitter.language.register("markdown", "vimwiki")
|
||||
-- vim.g.vimwiki_folding = 'expr'
|
||||
-- vim.g.vimwiki_header_type = "="
|
||||
|
||||
-- vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
-- pattern = "*.wiki", -- Adjust this pattern if your Vimwiki files have a different extension
|
||||
-- callback = function()
|
||||
-- vim.cmd("TWSyncTasks")
|
||||
-- end,
|
||||
-- })
|
||||
-- Sync the current wiki's assets directory into its path_html/assets
|
||||
-- local function sync_assets_for_current_wiki()
|
||||
-- local vget = vim.fn['vimwiki#vars#get_wikilocal']
|
||||
-- local wiki_root = vim.fn.expand(vget('path'))
|
||||
-- local html_root = vim.fn.expand(vget('path_html'))
|
||||
-- if wiki_root == '' or html_root == '' then return end
|
||||
--
|
||||
-- local src = wiki_root .. "/assets"
|
||||
-- local dst = html_root .. "/assets"
|
||||
--
|
||||
-- -- Ensure dst exists; prefer rsync if available, else shell cp -a
|
||||
-- vim.fn.mkdir(dst, "p")
|
||||
-- local has_rsync = vim.fn.executable("rsync") == 1
|
||||
--
|
||||
-- local cmd
|
||||
-- if has_rsync then
|
||||
-- cmd = { "rsync", "-a", "--delete", src .. "/", dst .. "/" }
|
||||
-- else
|
||||
-- -- cp -a keeps tree; the dot copies contents, not the dir itself
|
||||
-- cmd = { "sh", "-lc", string.format("mkdir -p %q && cp -a %q. %q", dst, src .. "/", dst .. "/") }
|
||||
-- end
|
||||
--
|
||||
-- vim.fn.jobstart(cmd, { detach = true })
|
||||
-- end
|
||||
--
|
||||
-- -- After each wiki page save, give Vimwiki a moment to write HTML, then sync assets
|
||||
-- vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
-- pattern = "*.wiki",
|
||||
-- callback = function()
|
||||
-- vim.defer_fn(sync_assets_for_current_wiki, 150)
|
||||
-- end,
|
||||
-- })
|
||||
--
|
||||
-- -- Also sync when you edit files under the wiki's assets dir (js/css/images)
|
||||
-- -- Adjust the glob if your wiki path differs
|
||||
-- vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
-- pattern = {
|
||||
-- vim.fn.expand("~/wiki/assets/*"),
|
||||
-- vim.fn.expand("~/wiki/assets/**/*"),
|
||||
-- },
|
||||
-- callback = function()
|
||||
-- sync_assets_for_current_wiki()
|
||||
-- end,
|
||||
-- })
|
||||
--
|
||||
-- -- Optional: a manual command you can run anytime
|
||||
-- vim.api.nvim_create_user_command("VimwikiSyncAssets", sync_assets_for_current_wiki, {})
|
||||
|
||||
-- Autocommand to trigger LuaSnip snippet expansion for new diary files
|
||||
vim.api.nvim_create_autocmd("BufNewFile", {
|
||||
pattern = "diary/*.wiki", -- Adjust this path to match your diary directory
|
||||
callback = function()
|
||||
-- Expand the 'diary_template' snippet automatically
|
||||
ls.snip_expand(ls.snippets.diary_template[1])
|
||||
end,
|
||||
})
|
||||
vim.g.vimwiki_automatic_nested_syntaxes = 1
|
||||
vim.g.vimwiki_list = {
|
||||
{
|
||||
name = "PersonalWiki",
|
||||
path = '~/wiki/',
|
||||
path_html = '~/Public/html/',
|
||||
syntax = 'default',
|
||||
ext = '.wiki',
|
||||
diary_rel_path = 'diary/',
|
||||
diary_index = "diary_index",
|
||||
auto_tags = 1,
|
||||
auto_toc = 1,
|
||||
auto_export = 1,
|
||||
template_path = "~/wiki/templates/",
|
||||
template_default = "default",
|
||||
template_ext = ".html",
|
||||
css_name = "main.css",
|
||||
maxhi = 1, -- BUG: Can be a source of lag.
|
||||
diary_caption_level = 1,
|
||||
bullet_types = { "-", "*", "#", "→" },
|
||||
cycle_bullets = 1,
|
||||
generated_links_caption = 1,
|
||||
listsyms = '✗○◐●✓',
|
||||
-- listsym_rejected = '✗',
|
||||
auto_diary_index = 1,
|
||||
auto_generate_links = 1,
|
||||
auto_generate_tags = 1,
|
||||
exclude_files = { "**/README.md" },
|
||||
rss_name = "feed.rss",
|
||||
base_url = "https://th3r00t.net",
|
||||
}
|
||||
}
|
||||
vim.g.vimwiki_syntax_plugins = {
|
||||
codeblock = {
|
||||
["```lua"] = { parser = "lua" },
|
||||
["```python"] = { parser = "python" },
|
||||
["```javascript"] = { parser = "javascript" },
|
||||
["```bash"] = { parser = "bash" },
|
||||
["```html"] = { parser = "html" },
|
||||
["```css"] = { parser = "css" },
|
||||
["```c"] = { parser = "c" },
|
||||
["```zig"] = { parser = "zig" },
|
||||
},
|
||||
}
|
||||
vim.g.vimwiki_toc_header = "Nav"
|
||||
vim.g.vimwiki_toc_header_level = 2
|
||||
vim.g.vimwiki_hl_cb_checked = 1
|
||||
vim.g.vimwiki_global_ext = 1
|
||||
vim.g.vimwiki_auto_chdir = 1
|
||||
vim.g.wimwiki_markdown_link_ext = 1
|
||||
-- vim.g.vimwiki_folding = 'list'
|
||||
vim.g.vimwiki_folding = 'expr'
|
||||
vim.g.vimwiki_use_calendar = 1
|
||||
vim.api.nvim_set_keymap('n', '<Leader>ww', '<Cmd>VimwikiIndex<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<Leader>wt', '<Cmd>VimwikiTabIndex<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<Leader>ws', '<Cmd>VimwikiUISelect<CR>', { noremap = true, silent = true })
|
||||
local function setup_vimwiki_highlights()
|
||||
-- Define color scheme mappings
|
||||
local colors = {
|
||||
header1 = "#81a1c1", -- Tokyo Night blue
|
||||
header2 = "#88c0d0", -- Tokyo Night light blue
|
||||
header3 = "#8fbcbb", -- Tokyo Night greenish blue
|
||||
bold = "#eceff4", -- Tokyo Night bright white
|
||||
italic = "#5e81ac", -- Tokyo Night dark blue
|
||||
link = "#b48ead", -- Tokyo Night purple
|
||||
list = "#d08770", -- Tokyo Night orange
|
||||
}
|
||||
|
||||
-- Apply highlights for vimwiki syntax elements
|
||||
vim.api.nvim_set_hl(0, "VimwikiHeader1", { fg = colors.header1, bold = true })
|
||||
vim.api.nvim_set_hl(0, "VimwikiHeader2", { fg = colors.header2, bold = true })
|
||||
vim.api.nvim_set_hl(0, "VimwikiHeader3", { fg = colors.header3, bold = true })
|
||||
vim.api.nvim_set_hl(0, "VimwikiBold", { fg = colors.bold, bold = true })
|
||||
vim.api.nvim_set_hl(0, "VimwikiItalic", { fg = colors.italic, italic = true })
|
||||
vim.api.nvim_set_hl(0, "VimwikiLink", { fg = colors.link, underline = true })
|
||||
vim.api.nvim_set_hl(0, "VimwikiList", { fg = colors.list })
|
||||
end
|
||||
setup_vimwiki_highlights()
|
||||
-- Define the Lua function for generating the diary template
|
||||
--
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/vimwiki/vimwiki", opt = true },
|
||||
})
|
||||
|
||||
vim.cmd.packadd("vimwiki")
|
||||
Reference in New Issue
Block a user