Skip to content

Commit

Permalink
feat: improve diagram tools (#345)
Browse files Browse the repository at this point in the history
* feat: auto-revert images on change

* fix: associate d2-mode with d2 files

* feat: use transparent background for mermaid

* chore(flake): update flake.lock

* feat: add binding for compile-on-save-mode

* feat: use personal fork of d2-mode

* feat: configure compile command for d2-mode

* feat: configure compile command for mermaid-mode

* feat: use compile-multi to generate diagrams
  • Loading branch information
terlar authored Jun 12, 2024
1 parent 6708e0f commit 7f1b738
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 24 deletions.
32 changes: 16 additions & 16 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 41 additions & 2 deletions init.org
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,8 @@ More procedural scrolling.
Revert buffers when underlying files change.
#+begin_src emacs-lisp :tangle yes
(use-package autorevert
:hook
(image-mode-hook . auto-revert-mode)
:init
(setq auto-revert-verbose nil))
#+end_src
Expand Down Expand Up @@ -2100,6 +2102,7 @@ nothing happens."
'global
:prefix
local-leader-key
"a" 'compile-on-save-mode
"c" 'recompile
"C" 'compile)
:init
Expand Down Expand Up @@ -4484,7 +4487,22 @@ Packages that I am currently testing or evaluating.
** d2
#+begin_src emacs-lisp :tangle yes
(use-package d2-mode
:ensure t)
:ensure t
:mode "\\.d2\\'"
:commands
(d2-compile-buffer)
:preface
(defun d2-mode-set-compile-command ()
"Configure compile command for d2-mode."
(set (make-local-variable 'compile-command)
(mapconcat #'shell-quote-argument (append (list d2-location buffer-file-name) d2-flags)
" ")))
:hook
(d2-mode-hook . d2-mode-set-compile-command)
:config
(cl-pushnew `(d2-mode ("d2:generate" . ,#'d2-compile-buffer))
compile-multi-config
:test #'equal))
#+end_src

** eglot-x
Expand Down Expand Up @@ -4547,7 +4565,28 @@ Packages that I am currently testing or evaluating.
#+begin_src emacs-lisp :tangle yes
(use-package mermaid-mode
:ensure t
:mode "\\.\\(mmd|mermaid\\)\\'")
:mode "\\.\\(mmd|mermaid\\)\\'"
:commands
(mermaid-compile-buffer)
:preface
(defun mermaid-mode-set-compile-command ()
"Configure compile command for mermaid-mode."
(set (make-local-variable 'compile-command)
(concat (mapconcat #'shell-quote-argument
(list
mermaid-mmdc-location
"-i" buffer-file-name
"-o" (concat (file-name-sans-extension buffer-file-name) mermaid-output-format)) " ")
" "
mermaid-flags)))
:hook
(mermaid-mode-hook . mermaid-mode-set-compile-command)
:init
(setq mermaid-flags "--backgroundColor transparent")
:config
(cl-pushnew `(mermaid-mode ("mermaid:generate" . ,#'mermaid-compile-buffer))
compile-multi-config
:test #'equal))
#+end_src

** messages-are-flowing
Expand Down
10 changes: 5 additions & 5 deletions lock/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lock/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
};
d2-mode = {
flake = false;
owner = "andorsk";
owner = "terlar";
repo = "d2-mode";
type = "github";
};
Expand Down
2 changes: 2 additions & 0 deletions recipes/d2-mode
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(d2-mode :fetcher github
:repo "terlar/d2-mode")

0 comments on commit 7f1b738

Please sign in to comment.