dotfiles/.config/nvim/syntax/hiswiki.lua
histalek 69465809e5
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
2023-09-04 19:02:33 +02:00

13 lines
534 B
Lua

-- 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