From 3a273afd06192e56f1548a0915f333beac54de8e Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Fri, 12 Jul 2024 13:26:26 +0200 Subject: [PATCH] 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. --- .../nvim/lua/fschauen/plugins/plantuml-previewer.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config/nvim/lua/fschauen/plugins/plantuml-previewer.lua b/config/nvim/lua/fschauen/plugins/plantuml-previewer.lua index 0a6b9c1..dd56c4e 100644 --- a/config/nvim/lua/fschauen/plugins/plantuml-previewer.lua +++ b/config/nvim/lua/fschauen/plugins/plantuml-previewer.lua @@ -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, }