nvim: extract PlantUML JAR from launch script

I had previously hard-coded the path on my Debian install, but this
commit will find the correct JAR file as long as there is a `plantuml`
launch script in the PATH.
This commit is contained in:
Fernando Schauenburg 2024-07-12 13:26:26 +02:00
parent c91a813f83
commit 3a273afd06

View file

@ -15,10 +15,12 @@ return {
ft = "plantuml",
init = function()
-- Override the bundled JAR if one in installed in `/usr/local`.
local path = "/usr/local/share/plantuml/plantuml.jar"
if vim.loop.fs_stat(path) then
vim.g["plantuml_previewer#plantuml_jar_path"] = path
-- Prefer the system PlantUML (if any) over the one bundled with the plugin.
local cmdline = [[which plantuml | xargs cat | grep plantuml.jar]]
local regex = [[\v\s['"]?(\S+/plantuml\.jar)]]
local jar = vim.fn.matchlist(vim.fn.system(cmdline), regex)[2]
if jar and vim.loop.fs_stat(jar) then
vim.g["plantuml_previewer#plantuml_jar_path"] = jar
end
end,
}