feat: add plantuml preset
Problem: PlantUML (`.puml`) diagrams have no built-in preview support. Solution: Add a `plantuml` preset that compiles to SVG via `plantuml -tsvg`, with an error parser for `Error line N` diagnostics. Add `plantuml` to the nix dev shell.
This commit is contained in:
parent
837c97cd09
commit
6b123dd6e1
2 changed files with 32 additions and 0 deletions
|
|
@ -32,6 +32,7 @@
|
||||||
pkgs.stylua
|
pkgs.stylua
|
||||||
pkgs.selene
|
pkgs.selene
|
||||||
pkgs.lua-language-server
|
pkgs.lua-language-server
|
||||||
|
pkgs.plantuml
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,37 @@ M.asciidoctor = {
|
||||||
reload = true,
|
reload = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---@type preview.ProviderConfig
|
||||||
|
M.plantuml = {
|
||||||
|
ft = 'plantuml',
|
||||||
|
cmd = { 'plantuml' },
|
||||||
|
args = function(ctx)
|
||||||
|
return { '-tsvg', ctx.file }
|
||||||
|
end,
|
||||||
|
output = function(ctx)
|
||||||
|
return (ctx.file:gsub('%.puml$', '.svg'))
|
||||||
|
end,
|
||||||
|
error_parser = function(output)
|
||||||
|
local diagnostics = {}
|
||||||
|
for line in output:gmatch('[^\r\n]+') do
|
||||||
|
local lnum = line:match('^Error line (%d+) in file:')
|
||||||
|
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('%.puml$', '.svg')) }
|
||||||
|
end,
|
||||||
|
open = true,
|
||||||
|
}
|
||||||
|
|
||||||
---@type preview.ProviderConfig
|
---@type preview.ProviderConfig
|
||||||
M.quarto = {
|
M.quarto = {
|
||||||
ft = 'quarto',
|
ft = 'quarto',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue