Skip to content

Commit

Permalink
Merge pull request #40 from p4v4n/treesitter-check
Browse files Browse the repository at this point in the history
Check for tree-sitter before activating clojure-ts-mode
  • Loading branch information
dannyfreeman authored Jun 18, 2024
2 parents 649bf11 + 3c0f8be commit 7b7a470
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions clojure-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -994,27 +994,30 @@ See `clojure-ts--font-lock-settings' for usage of MARKDOWN-AVAILABLE."
(add-to-list 'auto-mode-alist '("\\.cljd\\'" . clojure-ts-clojuredart-mode))
(add-to-list 'auto-mode-alist '("\\.jank\\'" . clojure-ts-jank-mode)))

;; Redirect clojure-mode to clojure-ts-mode if clojure-mode is present
(if (require 'clojure-mode nil 'noerror)
(progn
(add-to-list 'major-mode-remap-alist '(clojure-mode . clojure-ts-mode))
(add-to-list 'major-mode-remap-alist '(clojurescript-mode . clojure-ts-clojurescript-mode))
(add-to-list 'major-mode-remap-alist '(clojurec-mode . clojure-ts-clojurec-mode))
(clojure-ts--register-novel-modes))
;; Clojure-mode is not present, setup auto-modes ourselves
;; Regular clojure/edn files
;; I believe dtm is for datomic queries and datoms, which are just edn.
(add-to-list 'auto-mode-alist
'("\\.\\(clj\\|dtm\\|edn\\)\\'" . clojure-ts-mode))
(add-to-list 'auto-mode-alist '("\\.cljs\\'" . clojure-ts-clojurescript-mode))
(add-to-list 'auto-mode-alist '("\\.cljc\\'" . clojure-ts-clojurec-mode))
;; boot build scripts are Clojure source files
(add-to-list 'auto-mode-alist '("\\(?:build\\|profile\\)\\.boot\\'" . clojure-ts-mode))
;; babashka scripts are Clojure source files
(add-to-list 'interpreter-mode-alist '("bb" . clojure-ts-mode))
;; nbb scripts are ClojureScript source files
(add-to-list 'interpreter-mode-alist '("nbb" . clojure-ts-clojurescript-mode))
(clojure-ts--register-novel-modes))
(if (treesit-available-p)
;; Redirect clojure-mode to clojure-ts-mode if clojure-mode is present
(if (require 'clojure-mode nil 'noerror)
(progn
(add-to-list 'major-mode-remap-alist '(clojure-mode . clojure-ts-mode))
(add-to-list 'major-mode-remap-alist '(clojurescript-mode . clojure-ts-clojurescript-mode))
(add-to-list 'major-mode-remap-alist '(clojurec-mode . clojure-ts-clojurec-mode))
(clojure-ts--register-novel-modes))
;; When Clojure-mode is not present, setup auto-modes ourselves
(progn
;; Regular clojure/edn files
;; I believe dtm is for datomic queries and datoms, which are just edn.
(add-to-list 'auto-mode-alist
'("\\.\\(clj\\|dtm\\|edn\\)\\'" . clojure-ts-mode))
(add-to-list 'auto-mode-alist '("\\.cljs\\'" . clojure-ts-clojurescript-mode))
(add-to-list 'auto-mode-alist '("\\.cljc\\'" . clojure-ts-clojurec-mode))
;; boot build scripts are Clojure source files
(add-to-list 'auto-mode-alist '("\\(?:build\\|profile\\)\\.boot\\'" . clojure-ts-mode))
;; babashka scripts are Clojure source files
(add-to-list 'interpreter-mode-alist '("bb" . clojure-ts-mode))
;; nbb scripts are ClojureScript source files
(add-to-list 'interpreter-mode-alist '("nbb" . clojure-ts-clojurescript-mode))
(clojure-ts--register-novel-modes)))
(message "Clojure TS Mode will not be activated as tree-sitter support is missing."))

(defvar clojure-ts--find-ns-query
(treesit-query-compile
Expand Down

0 comments on commit 7b7a470

Please sign in to comment.