-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86d2f30
commit 1f59def
Showing
6 changed files
with
194 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
(require 'sdml-mode) | ||
(require 'sdml-mode-ctags) | ||
(require 'pretty-hydra) | ||
|
||
(cond | ||
((featurep 'pretty-hydra) | ||
(pretty-hydra-define sdml-mode-hydra | ||
(:color blue :quit-key "q" :title "SDML") | ||
("Edit" | ||
(("t" sdml-mode-current-buffer-dependency-tree "Open dependency tree") | ||
("T" sdml-mode-current-buffer-dependency-graph "Open dependency graph") | ||
("v" sdml-mode-validate-current-buffer "Validate current buffer") | ||
("V" sdml-mode-validate-file "Validate file") | ||
("g" sdml-mode-ctags-generate "Generate ctags") | ||
("f" flycheck-list-errors "Open Flycheck errors") | ||
("n" display-line-numbers-mode "Toggle line numbers" :toggle t)) | ||
"Document" | ||
(("d d" sdml-mode-document-module "Document module") | ||
("d b" sdml-mode-document-project "Document project") | ||
("d c" sdml-mode-draw-concept "Draw concept diagram") | ||
("d e" sdml-mode-draw-entities "Draw E/R diagram") | ||
("d u" sdml-mode-draw-uml "Draw UML diagram")) | ||
"Generate" | ||
(("c r" sdml-mode-generate-rdf "Generate RDF representation") | ||
("c s" sdml-mode-generate-scheme "Generate scheme representation") | ||
("c j" sdml-mode-generate-json "Generate JSON representation") | ||
("c t" sdml-mode-generate-with-tera "Generate using Tera templates")) | ||
"Debug" | ||
(("h d" tree-sitter-debug-mode "Toggle ts debug tree mode" :toggle t) | ||
("h q" tree-sitter-query-builder "Open ts query builder")))) | ||
(bind-key "C-c C-s h" 'sdml-mode-hydra/body) | ||
(bind-key "<f9> s" 'sdml-mode-hydra/body)) | ||
|
||
|
||
;; ((featurep 'hydra) (message "plain") | ||
;; (defhydra sdml-mode-hydra (:color pink :hint nil) | ||
;; " | ||
;; ^Edit^ ^Document^ ^Tree-Sitter^ | ||
;; ^^^^^^^^----------------------------------------------------------------- | ||
;; _t_: dependency tree _u_: unmark _d_: debug tree | ||
;; _T_: dependency graph _U_: unmark up _q_: query builder | ||
;; _v_: validate buffer | ||
;; _V_: validate file | ||
;; " | ||
;; ("t" sdml-mode-current-buffer-dependency-tree) | ||
;; ("T" sdml-mode-current-buffer-dependency-graph) | ||
;; ("v" sdml-mode-validate-current-buffer) | ||
;; ("V" sdml-mode-validate-file) | ||
;; ("u" nil) | ||
;; ("U" Buffer-menu-save) | ||
;; ("d" tree-sitter-debug-mode) | ||
;; ("q" tree-sitter-query-builder))) | ||
(t | ||
(message "Install 'hydra or 'pretty-hydra"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
;;; sdml-mode.el --- Major mode for SDML -*- lexical-binding: t; -*- | ||
|
||
;; Author: Simon Johnston <[email protected]> | ||
;; Version: 0.1.9 | ||
;; Package-Requires: ((emacs "28.1") (tree-sitter "0.18.0") (tree-sitter-indent "0.3")) | ||
;; Version: 0.2.0 | ||
;; Package-Requires: ((emacs "28.1") (tree-sitter "0.18.0") (tree-sitter-indent "0.4")) | ||
;; URL: https://github.com/johnstonskj/emacs-sdml-mode | ||
;; Keywords: languages tools | ||
|
||
|
@@ -180,7 +180,7 @@ platform-specific extension in `tree-sitter-load-suffixes'." | |
'(sdml-mode . sdml)))) | ||
|
||
;; -------------------------------------------------------------------------- | ||
;; Buffer Commands Validation | ||
;; Commands Validation | ||
;; -------------------------------------------------------------------------- | ||
|
||
(defconst sdml-mode-validation-error-regexp | ||
|
@@ -239,7 +239,7 @@ usual." | |
|
||
|
||
;; -------------------------------------------------------------------------- | ||
;; Buffer Commands Dependencies | ||
;; Commands Dependencies | ||
;; -------------------------------------------------------------------------- | ||
|
||
|
||
|
@@ -285,6 +285,103 @@ using the key `q', and it's content may be refreshed with the key | |
(sdml-mode-cli-run-command cmd-line "*SDML Dependencies*" nil t)))) | ||
|
||
|
||
;; -------------------------------------------------------------------------- | ||
;; Commands Placeholders | ||
;; -------------------------------------------------------------------------- | ||
|
||
(defun sdml-mode-document-module () | ||
"Generate standard documentation for module in current buffer." | ||
(interactive nil sdml-mode) | ||
(let* ((inp-file (buffer-file-name)) | ||
(out-file (if (null inp-file) "-" | ||
(concat (file-name-sans-extension inp-file) ".org"))) | ||
(out-buffer (if (null inp-file) "*SDML Documentation*" nil))) | ||
(let ((cmd-line (sdml-mode-cli-make-command | ||
"doc" | ||
(sdml-mode-cli-make-arg 'output-format 'org-mode) | ||
(sdml-mode-cli-make-arg 'output out-file) | ||
'current-buffer))) | ||
(when cmd-line | ||
(sdml-mode-cli-run-command cmd-line out-buffer nil t) | ||
(cond | ||
((not (null out-buffer)) | ||
(with-current-buffer out-buffer | ||
(org-mode))) | ||
((not (eq out-file "-")) | ||
(find-file out-file))))))) | ||
|
||
(defun sdml-mode-document-project () | ||
"Do something." | ||
(interactive nil sdml-mode) | ||
t) | ||
|
||
(defun sdml-mode-draw-concept () | ||
"Do something." | ||
(interactive nil sdml-mode) | ||
t) | ||
|
||
(defun sdml-mode-draw-entities () | ||
"Do something." | ||
(interactive nil sdml-mode) | ||
t) | ||
|
||
(defun sdml-mode-draw-uml () | ||
"Do something." | ||
(interactive nil sdml-mode) | ||
t) | ||
|
||
(defun sdml-mode-generate-rdf () | ||
"Do something." | ||
(interactive nil sdml-mode) | ||
t) | ||
|
||
(defun sdml-mode-generate-scheme () | ||
"Generate Scheme representation of the current buffer." | ||
(interactive nil sdml-mode) | ||
(let* ((inp-file (buffer-file-name)) | ||
(out-file (if (null inp-file) "-" | ||
(concat (file-name-sans-extension inp-file) ".scm"))) | ||
(out-buffer (if (null inp-file) "*SDML Parse-tree Scheme*" nil))) | ||
(let ((cmd-line (sdml-mode-cli-make-command | ||
"convert" | ||
(sdml-mode-cli-make-arg 'output-format 's-expr) | ||
(sdml-mode-cli-make-arg 'output out-file) | ||
'current-buffer))) | ||
(when cmd-line | ||
(sdml-mode-cli-run-command cmd-line out-buffer nil t) | ||
(cond | ||
((and (not (null out-buffer)) (featurep 'scheme-mode)) | ||
(with-current-buffer out-buffer | ||
(scheme-mode))) | ||
((not (eq out-file "-")) | ||
(find-file out-file))))))) | ||
|
||
(defun sdml-mode-generate-json () | ||
"Generate JSON representation of current buffer." | ||
(interactive nil sdml-mode) | ||
(let* ((inp-file (buffer-file-name)) | ||
(out-file (if (null inp-file) "-" | ||
(concat (file-name-sans-extension inp-file) ".json"))) | ||
(out-buffer (if (null inp-file) "*SDML Parse-tree JSON*" nil))) | ||
(let ((cmd-line (sdml-mode-cli-make-command | ||
"convert" | ||
(sdml-mode-cli-make-arg 'output-format 'json-pretty) | ||
(sdml-mode-cli-make-arg 'output out-file) | ||
'current-buffer))) | ||
(when cmd-line | ||
(sdml-mode-cli-run-command cmd-line out-buffer nil t) | ||
(cond | ||
((and (not (null out-buffer)) (featurep 'json-mode)) | ||
(with-current-buffer out-buffer | ||
(json-mode))) | ||
((not (eq out-file "-")) | ||
(find-file out-file))))))) | ||
|
||
(defun sdml-mode-generate-with-tera () | ||
"Do something." | ||
(interactive nil sdml-mode) | ||
t) | ||
|
||
;; -------------------------------------------------------------------------- | ||
;; Key Bindings | ||
;; -------------------------------------------------------------------------- | ||
|