Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better syntax support #17

Merged
merged 2 commits into from
Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions d2-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@

(defconst d2-font-lock-keywords
`((,(regexp-opt '("shape" "md" ) 'words) . font-lock-keyword-face)
("---\\|-?->*\\+?\\|==>\\|===|->" . font-lock-function-name-face)))
("---\\|-?->*\\+?\\|==>\\|===|->" . font-lock-variable-name-face)
(":\\|{\\|}\\|\|\\|+" . font-lock-builtin-face)
(,(regexp-opt '("go" "js") 'lang) . font-lock-preprocessor-face)
(,(regexp-opt '("class" "string" ) 'words2) . font-lock-type-face)))

(defvar d2-syntax-table
(let ((syntax-table (make-syntax-table)))
Expand Down Expand Up @@ -119,17 +122,14 @@
nil))

(defun d2--locate-declaration (str)
"Locate a certain declaration and return the line difference and indentation.

STR is the declaration."
"Locate a certain declaration and return the line difference
and indentation. STR is the declaration."
(let ((l (line-number-at-pos)))
(save-excursion
(if (re-search-backward str (point-min) t)
(cons (- l (line-number-at-pos)) (current-indentation))
(cons -1 -1)))))

;; TODO: Indent line code

(defun d2-compile ()
"Compile the current d2 file using d2."
(interactive)
Expand Down Expand Up @@ -186,4 +186,4 @@ STR is the declaration."

(provide 'd2-mode)

;;; d2-mode.el ends here
;;; d2-mode.el ends here