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, }