Skip to content

Commit

Permalink
Merge pull request #17 from andorsk/syntax-imporvements
Browse files Browse the repository at this point in the history
better syntax support
  • Loading branch information
andorsk authored Nov 29, 2022
2 parents c02a462 + 68393d4 commit fe99e33
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit fe99e33

Please sign in to comment.