Skip to content

Commit

Permalink
Adds syntax table
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonjckn committed Jul 30, 2023
1 parent 0192986 commit 712dc77
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions clojure-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,51 @@
"Enables debugging messages, shows current node in mode-line.
Only intended for use at development time.")

(defvar clojure-ts-mode-syntax-table
(let ((table (make-syntax-table)))
;; Initialize ASCII charset as symbol syntax
(modify-syntax-entry '(0 . 127) "_" table)

;; Word syntax
(modify-syntax-entry '(?0 . ?9) "w" table)
(modify-syntax-entry '(?a . ?z) "w" table)
(modify-syntax-entry '(?A . ?Z) "w" table)

;; Whitespace
(modify-syntax-entry ?\s " " table)
(modify-syntax-entry ?\xa0 " " table) ; non-breaking space
(modify-syntax-entry ?\t " " table)
(modify-syntax-entry ?\f " " table)
;; Setting commas as whitespace makes functions like `delete-trailing-whitespace' behave unexpectedly (#561)
(modify-syntax-entry ?, "." table)

;; Delimiters
(modify-syntax-entry ?\( "()" table)
(modify-syntax-entry ?\) ")(" table)
(modify-syntax-entry ?\[ "(]" table)
(modify-syntax-entry ?\] ")[" table)
(modify-syntax-entry ?\{ "(}" table)
(modify-syntax-entry ?\} "){" table)

;; Prefix chars
(modify-syntax-entry ?` "'" table)
(modify-syntax-entry ?~ "'" table)
(modify-syntax-entry ?^ "'" table)
(modify-syntax-entry ?@ "'" table)
(modify-syntax-entry ?? "_ p" table) ; ? is a prefix outside symbols
(modify-syntax-entry ?# "_ p" table) ; # is allowed inside keywords (#399)
(modify-syntax-entry ?' "_ p" table) ; ' is allowed anywhere but the start of symbols

;; Others
(modify-syntax-entry ?\; "<" table) ; comment start
(modify-syntax-entry ?\n ">" table) ; comment end
(modify-syntax-entry ?\" "\"" table) ; string
(modify-syntax-entry ?\\ "\\" table) ; escape

table)
"Syntax table for clojure-ts-mode.")


(defconst clojure-ts--builtin-dynamic-var-regexp
(eval-and-compile
(concat "^"
Expand Down

0 comments on commit 712dc77

Please sign in to comment.