Compare commits
2 commits
feat/merma
...
build/nix-
| Author | SHA1 | Date | |
|---|---|---|---|
| e76ace674f | |||
| 6f090fdcf3 |
2 changed files with 15 additions and 23 deletions
|
|
@ -19,8 +19,7 @@
|
|||
{
|
||||
formatter = forEachSystem (pkgs: pkgs.nixfmt-tree);
|
||||
|
||||
devShells = forEachSystem (
|
||||
pkgs:
|
||||
devShells = forEachSystem (pkgs:
|
||||
let
|
||||
devTools = [
|
||||
(pkgs.luajit.withPackages (
|
||||
|
|
@ -51,7 +50,6 @@
|
|||
pkgs.mermaid-cli
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,24 +115,6 @@ 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',
|
||||
|
|
@ -331,7 +313,19 @@ M.mermaid = {
|
|||
return (ctx.file:gsub('%.mmd$', '.svg'))
|
||||
end,
|
||||
error_parser = function(output)
|
||||
return parse_mermaid(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
|
||||
end,
|
||||
clean = function(ctx)
|
||||
return { 'rm', '-f', (ctx.file:gsub('%.mmd$', '.svg')) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue