diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-07 17:15:10 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-07 18:36:02 +0200 |
| commit | f2c4081c9251e6f688c206bb90c8f646daaa640c (patch) | |
| tree | ef5f5c70d38d0ad21135f784904c670462a17641 | |
| parent | a8e96131b873729c40644c34fc7ac060aa50168c (diff) | |
| download | dotfiles-f2c4081c9251e6f688c206bb90c8f646daaa640c.tar.gz dotfiles-f2c4081c9251e6f688c206bb90c8f646daaa640c.zip | |
feat(nvim): add markdown rendering with `render-markdown.nvim`
See https://github.com/MeanderingProgrammer/render-markdown.nvim
- Don't set `'colorcolumn'` and `'conceallevel'` in markdown ftplugin
- Treesitter plugin doesn't install the markdown and markdown_inline
parsers. `50-markdown.lua` does it instead, so that it is
self-contained. It also installs extra parsers it needs: yaml, html
and latex.
- Remove markdown highlight adjustments in `50-colors.lua`
- Remove `markdown/injections.scm` that was disabling treesitter
highlighting inside fenced code blocks.
| -rw-r--r-- | .config/nvim/after/ftplugin/markdown.lua | 3 | ||||
| -rw-r--r-- | .config/nvim/plugin/10-treesitter.lua | 2 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-colors.lua | 14 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-markdown.lua | 24 | ||||
| -rw-r--r-- | .config/nvim/queries/markdown/injections.scm | 26 |
5 files changed, 24 insertions, 45 deletions
diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua index 755b9aa..d0513b6 100644 --- a/.config/nvim/after/ftplugin/markdown.lua +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -63,12 +63,9 @@ vim.opt_local.signcolumn = "auto" vim.opt_local.foldcolumn = "0" -- vim.opt_local.textwidth = 120 -- gw wraps at this value -vim.opt_local.colorcolumn = "+1" -- Highlight one column after 'textwidth' vim.opt_local.foldlevel = 1 -- Replace concealed text with a character from `'listchars'` -- With `'foldmethod'` set to `expr` and `'foldlevel'` set to 2 fenced code blocks are concealed and completely invisible --- I guess that's a TODO for later, find a way to use `'conceallevel'` = 2 but with folded fenced code blocks visible -vim.opt_local.conceallevel = 1 vim.opt_local.complete = { "o", -- 'omnifunc' ".", -- current buffer diff --git a/.config/nvim/plugin/10-treesitter.lua b/.config/nvim/plugin/10-treesitter.lua index 4602519..aa68fdc 100644 --- a/.config/nvim/plugin/10-treesitter.lua +++ b/.config/nvim/plugin/10-treesitter.lua @@ -11,8 +11,6 @@ require("nvim-treesitter").install({ "ini", "json", "lua", - "markdown", - "markdown_inline", "readline", "vim", "vimdoc", diff --git a/.config/nvim/plugin/50-colors.lua b/.config/nvim/plugin/50-colors.lua index f713a74..4d9774e 100644 --- a/.config/nvim/plugin/50-colors.lua +++ b/.config/nvim/plugin/50-colors.lua @@ -36,20 +36,6 @@ local function adjust_highlight() vim.api.nvim_set_hl(0, "Cursorline", { bg = "#043624" }) vim.api.nvim_set_hl(0, "NormalFloat", { bg = solarized_colors.base02 }) end - - -- Markdown highlight - if vim.o.background == "light" then - vim.api.nvim_set_hl(0, "@markup.raw", { bg = solarized_colors.base2, update = true }) - elseif vim.o.background == "dark" then - vim.api.nvim_set_hl(0, "@markup.raw", { bg = solarized_colors.base02, update = true }) - end - vim.api.nvim_set_hl(0, "@markup.raw.block", { fg = solarized_colors.cyan, update = true }) - vim.api.nvim_set_hl(0, "@markup.heading.1", { link = "@markup.heading" }) - vim.api.nvim_set_hl(0, "@markup.heading.2", { link = "@markup.heading" }) - vim.api.nvim_set_hl(0, "@markup.heading.3", { link = "@markup.heading" }) - vim.api.nvim_set_hl(0, "@markup.heading.4", { link = "@markup.heading" }) - vim.api.nvim_set_hl(0, "@markup.heading.5", { link = "@markup.heading" }) - vim.api.nvim_set_hl(0, "@markup.heading.6", { link = "@markup.heading" }) end end diff --git a/.config/nvim/plugin/50-markdown.lua b/.config/nvim/plugin/50-markdown.lua new file mode 100644 index 0000000..d033d32 --- /dev/null +++ b/.config/nvim/plugin/50-markdown.lua @@ -0,0 +1,24 @@ +-- +-- Markdown rendering plugin +-- +-- Uses `render-markdown`, see https://github.com/MeanderingProgrammer/render-markdown.nvim + +vim.pack.add({ + "https://github.com/nvim-treesitter/nvim-treesitter", + "https://github.com/nvim-tree/nvim-web-devicons", + "https://github.com/MeanderingProgrammer/render-markdown.nvim", +}) + +require("nvim-treesitter").install({ + "html", + "latex", + "markdown", + "markdown_inline", + "yaml", +}) + +require("render-markdown").setup({ + heading = { width = "block", min_width = 120 }, + code = { position = "center", sign = false, width = "block", min_width = 60, left_margin = 2 }, + dash = { width = 120 }, +}) diff --git a/.config/nvim/queries/markdown/injections.scm b/.config/nvim/queries/markdown/injections.scm deleted file mode 100644 index c24cbd8..0000000 --- a/.config/nvim/queries/markdown/injections.scm +++ /dev/null @@ -1,26 +0,0 @@ -; See /home/tvanbesi/.local/share/nvim/site/queries/markdown/injections.scm -; It's the same but with language-specific highlighting disabled in fenced code blocks - -(fenced_code_block - (code_fence_content) @injection.content) - -((html_block) @injection.content - (#set! injection.language "html") - (#set! injection.combined) - (#set! injection.include-children)) - -((minus_metadata) @injection.content - (#set! injection.language "yaml") - (#offset! @injection.content 1 0 -1 0) - (#set! injection.include-children)) - -((plus_metadata) @injection.content - (#set! injection.language "toml") - (#offset! @injection.content 1 0 -1 0) - (#set! injection.include-children)) - -([ - (inline) - (pipe_table_cell) -] @injection.content - (#set! injection.language "markdown_inline")) |
