Compare commits

..

6 commits

Author SHA1 Message Date
22ffea117c
ci: format 2026-03-05 12:05:25 -05:00
8501656546 merge: resolve conflicts with origin/main 2026-03-05 12:04:53 -05:00
8c04cf19ea
ci: format 2026-03-05 12:03:50 -05:00
59419e6003 refactor(presets): simplify mermaid error parser
Problem: the inline `mermaid` error_parser looped over every line and
used the `Parse error on line N:` header as the message, losing the
useful `Expecting ..., got ...` token detail.

Solution: extract `parse_mermaid` alongside the other parse functions,
use a single `output:match` (mermaid's JISON parser stops at the first
error), and surface the `Expecting ..., got ...` line as the message.
2026-03-05 12:02:32 -05:00
Barrett Ruth
8c9847e321
build: split nix dev shell into default and presets (#48)
Problem: the single dev shell mixed dev tooling (linters, test runner)
with preset compiler tools, causing heavy rebuilds (e.g. Chromium for
`mermaid-cli`) for contributors who only need the dev tools.

Solution: extract dev tooling into a shared `devTools` list and expose
two shells — `default` for development and `presets` for running all
built-in preset compilers (`typst`, `texliveMedium`, `tectonic`,
`pandoc`, `asciidoctor`, `quarto`, `plantuml`, `mermaid-cli`).
2026-03-05 11:05:16 -05:00
28dda6515e
feat: add mermaid preset
Problem: no built-in support for compiling mermaid diagrams via `mmdc`.

Solution: add a `mermaid` preset that compiles `.mmd` files to SVG and
parses `Parse error on line N` diagnostics from stderr. Add
`mermaid-cli` to the nix dev shell.
2026-03-05 10:43:08 -05:00
2 changed files with 23 additions and 15 deletions

View file

@ -19,7 +19,8 @@
{
formatter = forEachSystem (pkgs: pkgs.nixfmt-tree);
devShells = forEachSystem (pkgs:
devShells = forEachSystem (
pkgs:
let
devTools = [
(pkgs.luajit.withPackages (
@ -50,6 +51,7 @@
pkgs.mermaid-cli
];
};
});
}
);
};
}

View file

@ -115,6 +115,24 @@ local function parse_asciidoctor(output)
return diagnostics
end
---@param output string
---@return preview.Diagnostic[]
local function parse_mermaid(output)
local lnum = output:match('Parse error on line (%d+)')
if not lnum then
return {}
end
local msg = output:match('(Expecting .+)') or 'parse error'
return {
{
lnum = tonumber(lnum) - 1,
col = 0,
message = msg,
severity = vim.diagnostic.severity.ERROR,
},
}
end
---@type preview.ProviderConfig
M.typst = {
ft = 'typst',
@ -313,19 +331,7 @@ M.mermaid = {
return (ctx.file:gsub('%.mmd$', '.svg'))
end,
error_parser = function(output)
local diagnostics = {}
for line in output:gmatch('[^\r\n]+') do
local lnum = line:match('^%s*Parse error on line (%d+)')
if lnum then
table.insert(diagnostics, {
lnum = tonumber(lnum) - 1,
col = 0,
message = line,
severity = vim.diagnostic.severity.ERROR,
})
end
end
return diagnostics
return parse_mermaid(output)
end,
clean = function(ctx)
return { 'rm', '-f', (ctx.file:gsub('%.mmd$', '.svg')) }