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:
parent
5bab19cfdd
commit
69465809e5
2 changed files with 21 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
||||||
-- Autocmds are automatically loaded on the VeryLazy event
|
-- 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
|
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||||
-- Add any additional autocmds here
|
-- 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,
|
||||||
|
})
|
||||||
|
|
13
.config/nvim/syntax/hiswiki.lua
Normal file
13
.config/nvim/syntax/hiswiki.lua
Normal 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
|
Loading…
Add table
Reference in a new issue