feat(nvim): Test out my take on blinry's vimboy wiki

Today i watched the recording of Blinry's talk about their personal wiki
at MRMCD23 [1] and was intrigued by the simplicity of it.

For now i only took the highlight group, syntax match and autocmd to set
the filetype.
This gives me the highlighting of 'wiki files'. As for opening those
files i'll use `gf`.

I'll probably iterate on this if i like and use it to a degree.

[1] https://media.ccc.de/v/2023-301-warum-ihr-alle-ein-persnliches-wiki-haben-wollt
This commit is contained in:
histalek 2023-09-04 18:15:16 +02:00
parent 5bab19cfdd
commit 69465809e5
Signed by: histalek
SSH key fingerprint: SHA256:6a6N2Wzk73nwURUHC/ubbCyqdB6yfie0Jv/NGvRcsIE
2 changed files with 21 additions and 0 deletions

View file

@ -1,3 +1,11 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here
--- test blinry's wiki setup
vim.api.nvim_create_autocmd({ "bufnewfile", "bufread" }, {
pattern = os.getenv("HOME") .. "/Documents/wiki/*",
callback = function()
vim.bo.filetype = "hiswiki"
end,
})

View file

@ -0,0 +1,13 @@
-- Link the 'hiswikiLink' highlight group to the existing 'Underlined' group.
vim.api.nvim_set_hl(0, "hiswikiLink", { link = "Underlined" })
-- Remove all existing hiswikiLink syntax matches.
vim.cmd("syntax clear hiswikiLink")
-- Find the directory of the current file.
local base_dir = vim.fn.expand("%:h")
-- Loop through all files in the directory, and add a syntax match for each one.
for _, file in ipairs(vim.fn.readdir(base_dir)) do
vim.cmd("syntax match hiswikiLink /\\c\\V\\<" .. vim.fn.escape(file, "/\\") .. "/")
end