module: add :lang graphviz
Close: #7546 Co-authored-by: nbfalcon <nbfalcon@users.noreply.github.com> Co-authored-by: peterhoeg <peterhoeg@users.noreply.github.com>
This commit is contained in:
parent
fc35b3cf37
commit
f6b7e8ae48
6 changed files with 132 additions and 0 deletions
64
modules/lang/graphviz/README.org
Normal file
64
modules/lang/graphviz/README.org
Normal file
|
@ -0,0 +1,64 @@
|
|||
:PROPERTIES:
|
||||
:ID: 3efe8402-e4a1-41c3-ad1a-9aaa3783f68f
|
||||
:END:
|
||||
#+title: :lang graphviz
|
||||
#+subtitle: Diagrams to confuse yourself even more
|
||||
#+created: Nov 14, 2023
|
||||
#+since: 23.09.0-pre
|
||||
|
||||
* Description :unfold:
|
||||
This module adds graphviz support to Emacs, allowing you to generate diagrams
|
||||
from plain text. Flycheck is supported.
|
||||
|
||||
** Maintainers
|
||||
/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]]
|
||||
|
||||
** Module flags
|
||||
/This module has no flags./
|
||||
|
||||
** Packages
|
||||
- [[doom-package:graphviz-dot-mode]]
|
||||
|
||||
** Hacks
|
||||
/No hacks documented for this module./
|
||||
|
||||
** TODO Changelog
|
||||
# This section will be machine generated. Don't edit it by hand.
|
||||
/This module does not have a changelog yet./
|
||||
|
||||
* Installation
|
||||
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
||||
|
||||
This module requires that the =graphviz= package be installed on your system to
|
||||
build diagrams with. You can install it using:
|
||||
#+begin_src shell
|
||||
sudo dnf install graphviz # For fedora
|
||||
sudo apt install graphviz # For debian/ubuntu
|
||||
#+end_src
|
||||
|
||||
* Usage
|
||||
This module should configure "out-of-the-box" if you have installed graphviz on
|
||||
your system.
|
||||
|
||||
With org-babel LaTeX/PDF-export, use a file naming ending with ".pdf", otherwise
|
||||
LaTeX might complain about a non-existant ~\\includesvg~ command.
|
||||
#+begin_src dot :file graph-1.pdf
|
||||
digraph {
|
||||
A -> B;
|
||||
B -> D;
|
||||
}
|
||||
#+end_src
|
||||
|
||||
* Configuration
|
||||
There is nothing to configure. Just install dot and it should work.
|
||||
|
||||
* Troubleshooting
|
||||
/There are no known problems with this module./ [[doom-report:][Report one?]]
|
||||
|
||||
* Frequently asked questions
|
||||
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
|
||||
|
||||
* TODO Appendix
|
||||
#+begin_quote
|
||||
This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
||||
#+end_quote
|
19
modules/lang/graphviz/autoload.el
Normal file
19
modules/lang/graphviz/autoload.el
Normal file
|
@ -0,0 +1,19 @@
|
|||
;;; lang/graphviz/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(cl-defun +graphviz-formatter (&key _buffer scratch callback &allow-other-keys)
|
||||
"Format graphviz graphs."
|
||||
(with-current-buffer scratch
|
||||
(let ((inhibit-message t)
|
||||
(message-log-max nil))
|
||||
(goto-char (point-min))
|
||||
(graphviz-dot-indent-graph))
|
||||
(funcall callback)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +graphviz/toggle-preview ()
|
||||
"Toggle `graphviz-dot-auto-preview-on-save'."
|
||||
(interactive nil 'graphviz-dot-mode)
|
||||
(if graphviz-dot-auto-preview-on-save
|
||||
(graphviz-turn-off-live-preview)
|
||||
(graphviz-turn-on-live-preview)))
|
38
modules/lang/graphviz/config.el
Normal file
38
modules/lang/graphviz/config.el
Normal file
|
@ -0,0 +1,38 @@
|
|||
;;; lang/graphviz/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(use-package! graphviz-dot-mode
|
||||
:mode "\\.\\(?:nw\\|rack\\)diag\\'"
|
||||
:init
|
||||
(after! org-src
|
||||
(add-to-list '+org-babel-mode-alist '(dot . graphviz-dot-mode))
|
||||
(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot-mode)))
|
||||
:config
|
||||
(set-company-backend! 'graphviz-dot-mode 'company-graphviz-dot-backend)
|
||||
(set-formatter! 'graphviz-dot #'+graphviz-formatter :modes '(graphviz-dot-mode))
|
||||
(set-tree-sitter-lang! 'graphviz-dot-mode 'dot)
|
||||
|
||||
(when (modulep! +tree-sitter)
|
||||
(add-hook 'graphiz-dot-mode-hook #'tree-sitter!))
|
||||
|
||||
(after! dtrt-indent
|
||||
(add-to-list 'dtrt-indent-hook-mapping-list '(graphviz-mode graphviz-dot-indent-width)))
|
||||
|
||||
(when (and (modulep! :checker syntax)
|
||||
(not (modulep! :checker syntax +flymake)))
|
||||
(after! flycheck
|
||||
(flycheck-define-checker graphviz-dot
|
||||
"A checker using graphviz dot."
|
||||
:command ("dot")
|
||||
:standard-input t
|
||||
:error-patterns ((error line-start "Error: <stdin>: " (message "syntax error in line " line (* nonl)))
|
||||
;; I have no idea if this can actually be printed
|
||||
(error line-start "Error: <stdin>: " (message)))
|
||||
:modes graphviz-dot-mode)
|
||||
(add-to-list 'flycheck-checkers 'graphviz-dot)))
|
||||
|
||||
(map! :map graphviz-dot-mode-map
|
||||
:localleader
|
||||
:desc "External view" :nv "e" #'graphviz-dot-view
|
||||
:desc "Preview" :nv "p" #'graphviz-dot-preview
|
||||
:prefix ("t" . "toggle")
|
||||
:desc "Preview" :nv "p" #'+graphviz/toggle-preview))
|
6
modules/lang/graphviz/doctor.el
Normal file
6
modules/lang/graphviz/doctor.el
Normal file
|
@ -0,0 +1,6 @@
|
|||
;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||
;;; lang/graphviz/doctor.el
|
||||
|
||||
(when (require 'graphviz-dot-mode nil t)
|
||||
(unless (executable-find graphviz-dot-dot-program)
|
||||
(warn! "Couldn't find dot. Previewing and exporting will not work")))
|
4
modules/lang/graphviz/packages.el
Normal file
4
modules/lang/graphviz/packages.el
Normal file
|
@ -0,0 +1,4 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/graphviz/packages.el
|
||||
|
||||
(package! graphviz-dot-mode :pin "8ff793b13707cb511875f56e167ff7f980a31136")
|
Loading…
Add table
Add a link
Reference in a new issue