From bfa0f772960616e5bc69eb5cd45dbe33a0fe2eae Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 1 Mar 2026 17:38:08 -0500 Subject: [PATCH] feat(neovim): install pandoc --- config/nvim/after/ftplugin/markdown.lua | 31 +++++++++++++++++++++++++ config/nvim/lua/plugins/dev.lua | 16 ++++++++++++- home/modules/editor.nix | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/config/nvim/after/ftplugin/markdown.lua b/config/nvim/after/ftplugin/markdown.lua index 570d861..c89492d 100644 --- a/config/nvim/after/ftplugin/markdown.lua +++ b/config/nvim/after/ftplugin/markdown.lua @@ -1,2 +1,33 @@ vim.o.conceallevel = 1 vim.o.textwidth = 80 + +local buf = vim.api.nvim_get_current_buf() +local opened = false + +vim.api.nvim_create_autocmd('User', { + pattern = 'RenderCompileSuccess', + callback = function(args) + if args.data.bufnr ~= buf then + return + end + local html = args.data.output + if not opened and html and html ~= '' then + opened = true + vim.system({ 'xdg-open', html }) + end + end, +}) + +vim.api.nvim_create_autocmd('BufWritePost', { + buffer = buf, + callback = function() + local ok, render = pcall(require, 'render') + if ok then + render.compile(buf) + end + end, +}) + +vim.keymap.set('n', 't', function() + require('render').compile(buf) +end, { buffer = true }) diff --git a/config/nvim/lua/plugins/dev.lua b/config/nvim/lua/plugins/dev.lua index 83bc331..0322056 100644 --- a/config/nvim/lua/plugins/dev.lua +++ b/config/nvim/lua/plugins/dev.lua @@ -409,7 +409,7 @@ return { }, { 'barrettruth/render.nvim', - ft = { 'typst', 'tex' }, + ft = { 'typst', 'tex', 'markdown' }, before = function() vim.g.render = { providers = { @@ -432,10 +432,24 @@ return { end, clean = { 'latexmk', '-c' }, }, + pandoc = { + cmd = { 'pandoc' }, + args = function(ctx) + local output = ctx.file:gsub('%.md$', '.html') + return { ctx.file, '-s', '--embed-resources', '-o', output } + end, + output = function(ctx) + return ctx.file:gsub('%.md$', '.html') + end, + clean = function(ctx) + return { 'rm', '-f', ctx.file:gsub('%.md$', '.html') } + end, + }, }, providers_by_ft = { typst = 'typst', tex = 'latexmk', + markdown = 'pandoc', }, } end, diff --git a/home/modules/editor.nix b/home/modules/editor.nix index e0001a7..a5ad6fe 100644 --- a/home/modules/editor.nix +++ b/home/modules/editor.nix @@ -18,6 +18,7 @@ in emmet-language-server lua-language-server mdx-language-server + pandoc pytest-language-server ruff tinymist