5dec7c2

dotfiles.git > main > 5dec7c2 > files / nvim / ftplugin

Show # Title in markdown files

Grahp, 2026-11-09

Commit: 5dec7c23b9de9b952607feed014d4fd7689d1451
Parent: e434f76

2 changed files:

nvim/ftplugin/markdown.lua modified (view file)

@@ -9,6 +9,14 @@ require("wikilink") vim.treesitter.start() +--- Obsidian shows the note's name as a heading above it, so do the same instead of writing # Titles+local function set_title()+  local name = vim.fn.expand("%:t:r")+  vim.b.header_lines = name ~= "" and {{{"# " .. name, "@markup.heading.1"}}} or nil+end+set_title()+vim.api.nvim_create_autocmd("BufFilePost", {buffer = 0, callback = set_title})+ local follow = function(fallback) return function() require("wikilink").follow(fallback) end end vim.keymap.set("n", "gd", follow("gd"), {buffer = true}) vim.keymap.set("n", "gf", follow("gf"), {buffer = true})

nvim/lua/center.lua modified (view file)

@@ -39,7 +39,10 @@     local blank_line = {{""}} -   set_padding_lines(replicate(win_height, blank_line))+   --- Buffers can put their own lines (like a title) right above the first line+   local padding = replicate(win_height, blank_line)+   vim.list_extend(padding, vim.b.header_lines or {})+   set_padding_lines(padding)     local _, _, col, off, curswant = unpack(vim.fn.getcurpos())    vim.cmd("norm! zz")