2017-07-08 23:05:23 +02:00
|
|
|
;;; lang/plantuml/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! plantuml-mode
|
2019-10-22 18:50:33 -04:00
|
|
|
:commands plantuml-download-jar
|
2018-02-14 07:40:05 -05:00
|
|
|
:init
|
2024-08-22 14:47:37 -04:00
|
|
|
(setq plantuml-jar-path (concat doom-data-dir "plantuml.jar"))
|
2018-02-14 07:40:05 -05:00
|
|
|
:config
|
2019-10-22 18:50:33 -04:00
|
|
|
(set-popup-rule! "^\\*PLANTUML" :size 0.4 :select nil :ttl 0)
|
|
|
|
(setq plantuml-default-exec-mode
|
2020-03-17 01:14:08 +00:00
|
|
|
(cond ((file-exists-p plantuml-jar-path) 'jar)
|
2024-08-22 14:47:37 -04:00
|
|
|
((executable-find plantuml-executable-path) 'executable)
|
|
|
|
(plantuml-default-exec-mode)))
|
|
|
|
;; HACK: If plantuml-jar-path is missing at startup, then plantuml-mode will
|
|
|
|
;; operate in another `plantuml-default-exec-mode'. After using
|
|
|
|
;; plantuml-download-jar, we change it to `jar' just for this session.
|
|
|
|
(defadvice! +plantuml--use-downloaded-jar-a (fn &rest args)
|
|
|
|
"Configure plantuml-mode to use the downloaded jar for this session."
|
|
|
|
:around #'plantuml-download-jar
|
|
|
|
(let ((downloaded? (not (file-exists-p plantuml-jar-path))))
|
|
|
|
(prog1 (apply fn args)
|
|
|
|
(when (and downloaded? (file-exists-p plantuml-jar-path))
|
|
|
|
(setq org-plantuml-jar-path plantuml-jar-path
|
|
|
|
plantuml-default-exec-mode 'jar))))))
|
2017-07-08 23:05:23 +02:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! flycheck-plantuml
|
2022-08-12 20:29:19 +02:00
|
|
|
:when (modulep! :checkers syntax)
|
2017-07-08 23:05:23 +02:00
|
|
|
:after plantuml-mode
|
2023-11-14 11:35:45 +01:00
|
|
|
:config
|
|
|
|
(flycheck-plantuml-setup)
|
|
|
|
(when (eq plantuml-default-exec-mode 'executable)
|
|
|
|
;; Surprisingly, this works, even though flycheck-plantuml specifies -Djava.awt...
|
|
|
|
(setq-default flycheck-plantuml-executable plantuml-executable-path)))
|
2019-09-07 12:27:23 +08:00
|
|
|
|
2019-09-13 21:59:03 -04:00
|
|
|
|
2019-09-07 12:27:23 +08:00
|
|
|
(after! ob-plantuml
|
2024-08-22 14:47:37 -04:00
|
|
|
;; The nested `after!' is needed to ensure `org-plantuml-jar-path's new
|
|
|
|
;; default without overwriting any user config.
|
|
|
|
(after! plantuml-mode
|
|
|
|
(when (equal org-plantuml-jar-path "")
|
|
|
|
(setq org-plantuml-jar-path plantuml-jar-path)))
|
|
|
|
|
|
|
|
;; HACK: Force ob-plantuml to use `plantuml-mode''s building mechanism, which
|
|
|
|
;; is more sophisticated.
|
2019-10-22 18:50:33 -04:00
|
|
|
(advice-add #'org-babel-execute:plantuml
|
|
|
|
:override #'+plantuml-org-babel-execute:plantuml-a)
|
2019-09-07 12:27:23 +08:00
|
|
|
(add-to-list 'org-babel-default-header-args:plantuml
|
|
|
|
'(:cmdline . "-charset utf-8")))
|