diff options
Diffstat (limited to '.config/emacs/modules')
| -rw-r--r-- | .config/emacs/modules/mm-abbrev.el | 8 | ||||
| -rw-r--r-- | .config/emacs/modules/mm-buffer-menu.el | 15 | ||||
| -rw-r--r-- | .config/emacs/modules/mm-editing.el | 85 | ||||
| -rw-r--r-- | .config/emacs/modules/mm-humanwave.el | 141 | ||||
| -rw-r--r-- | .config/emacs/modules/mm-modeline.el | 5 | ||||
| -rw-r--r-- | .config/emacs/modules/mm-projects.el | 56 | ||||
| -rw-r--r-- | .config/emacs/modules/mm-theme.el | 30 | ||||
| -rw-r--r-- | .config/emacs/modules/mm-treesit.el | 96 |
8 files changed, 376 insertions, 60 deletions
diff --git a/.config/emacs/modules/mm-abbrev.el b/.config/emacs/modules/mm-abbrev.el index 937d558..66ca8d7 100644 --- a/.config/emacs/modules/mm-abbrev.el +++ b/.config/emacs/modules/mm-abbrev.el @@ -78,6 +78,14 @@ case-sensitive to avoid unexpected abbreviation expansions." "sme" "save-mark-and-excursion" "sr" "save-restriction") +(when mm-humanwave-p + (with-eval-after-load 'python-ts-mode + (mm-define-abbreviations python-ts-mode-abbrev-table + "empb" "with emphasize.Block():" + "empf" "@emphasize.func" + "empi" "from shared.system import emphasize" + "empt" "emphasize.this"))) + ;;; Template Configuration diff --git a/.config/emacs/modules/mm-buffer-menu.el b/.config/emacs/modules/mm-buffer-menu.el new file mode 100644 index 0000000..7b725c6 --- /dev/null +++ b/.config/emacs/modules/mm-buffer-menu.el @@ -0,0 +1,15 @@ +;;; mm-buffer-menu.el --- Buffer Menu configuration -*- lexical-binding: t; -*- + +(defun mm-Buffer-menu-delete-all () + "Mark all buffers for deletion." + (interactive nil Buffer-menu-mode) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (Buffer-menu-delete)))) + +(use-package buff-menu + :bind ( :map Buffer-menu-mode-map + ("D" . mm-Buffer-menu-delete-all))) + +(provide 'mm-buffer-menu)
\ No newline at end of file diff --git a/.config/emacs/modules/mm-editing.el b/.config/emacs/modules/mm-editing.el index dda5352..6054f5a 100644 --- a/.config/emacs/modules/mm-editing.el +++ b/.config/emacs/modules/mm-editing.el @@ -56,6 +56,7 @@ (go-ts-mode . (:extras go-ts-mode-indent-offset)) (gsp-ts-mode . (:width 2 :extras gsp-ts-mode-indent-rules)) (helpful-mode . (:width 8)) ; GNU code uses 8-column tabs + (json-ts-mode . (:extras json-ts-mode-indent-offset)) (latex-mode . (:width 2)) (lisp-data-mode . (:spaces t)) (lisp-interaction-mode . (:spaces t)) @@ -66,8 +67,12 @@ (python-ts-mode . (:extras python-indent-offset)) (sgml-mode . (:extras sgml-basic-offset)) (sh-mode . (:extras sh-basic-offset)) + (sql-mode . (:extras sqlind-basic-offset)) (tex-mode . (:width 2)) - (vimscript-ts-mode . (:extras vimscript-ts-mode-indent-level))) + (typescript-ts-mode . (:extras typescript-ts-mode-indent-offset)) + (vimscript-ts-mode . (:extras vimscript-ts-mode-indent-level)) + (vue-ts-mode . (:extras (typescript-ts-mode-indent-offset + vue-ts-mode-indent-offset)))) "Alist of indentation settings. Each pair in this alist is of the form (MODE . SETTINGS) where MODE specifies the mode for which the given SETTINGS should apply. @@ -122,21 +127,30 @@ those should be listed in `mm-editing-indentation-settings'." extras)) (set (make-local-variable extra) tabsize))))) +(use-package sh-mode + :custom + (sh-indent-for-case-label 0) + (sh-indent-for-case-alt #'+)) + ;;; Code Commenting -(defun mm-c-comment-no-leading-stars () +(defun mm-c-comment-no-continue () (setq-local comment-continue " ")) +(defun mm-mhtml-comment-no-continue () + (setq-local comment-continue " ")) + (use-package newcomment :custom (comment-style 'multi-line) :config (dolist (mode '(c-mode c++-mode)) - (add-hook (mm-mode-to-hook mode) #'mm-c-comment-no-leading-stars) + (add-hook (mm-mode-to-hook mode) #'mm-c-comment-no-continue) (when-let ((ts-mode (mm-mode-to-ts-mode mode)) ((fboundp ts-mode))) - (add-hook (mm-mode-to-hook ts-mode) #'mm-c-comment-no-leading-stars)))) + (add-hook (mm-mode-to-hook ts-mode) #'mm-c-comment-no-continue))) + (add-hook 'mhtml-mode #'mm-mhtml-comment-no-continue)) ;;; Multiple Cursors @@ -197,6 +211,7 @@ and *Messages* buffer. This forces that to not happen." (use-package multiple-cursors :ensure t + :demand t :bind (("C->" . #'mc/mark-next-like-this) ("C-<" . #'mc/mark-previous-like-this) ("C-M-<" . #'mc/mark-all-like-this-dwim) @@ -290,6 +305,18 @@ surround with spaces." (push '("`" . "'") surround-pairs)))) +;;; Insert Webpage Contents + +(defun mm-insert-from-url (url) + "Insert the contents of URL at point." + (interactive + (let ((url-at-point (thing-at-point 'url))) + (list (read-string + (format-prompt "URL" url-at-point) + nil nil url-at-point)))) + (call-process "curl" nil '(t nil) nil url)) + + ;;; Emmet Mode (defun mm-editing-emmet-dwim (arg) @@ -310,6 +337,36 @@ is as described by `emmet-expand-line'." (emmet-self-closing-tag-style "")) +;;; JQ Manipulation in JSON Mode + +(defun mm-jq-filter (query &optional beg end) + "TODO" + (interactive + (list + (read-string (format-prompt "Query" nil)) + (when (use-region-p) (region-beginning)) + (when (use-region-p) (region-end)))) + (let* ((beg (or beg (point-min))) + (end (or end (point-max))) + (temp-buffer (generate-new-buffer "* jq temp*")) + (exit-code (call-process-region beg end "jq" nil temp-buffer nil + "--tab" query)) + (output (with-current-buffer temp-buffer (buffer-string)))) + (if (zerop exit-code) + (atomic-change-group + (delete-region beg end) + (insert output) + (indent-region beg (point))) + (message "%s" output)) + (kill-buffer temp-buffer))) + +(use-package json-ts-mode + :bind ( :map json-ts-mode-map + ("C-|" . #'mm-jq-filter)) + :config + (require 'live-jq)) + + ;;; Number Formatting (use-package number-format-mode @@ -321,7 +378,9 @@ is as described by `emmet-expand-line'." ;;; Additional Major Modes (use-package awk-ts-mode :ensure t) +(use-package cmake-mode :ensure t) (use-package git-modes :ensure t) +(use-package po-mode :ensure t) (use-package sed-mode :ensure t) (use-package csv-mode @@ -330,6 +389,13 @@ is as described by `emmet-expand-line'." (csv-align-style 'auto) (csv-align-padding 2)) +(use-package xcompose-mode + :vc ( :url "https://git.thomasvoss.com/xcompose-mode" + :branch "master" + :rev :newest + :vc-backend Git) + :ensure t) + ;;; Mode-Specific Configurations @@ -345,6 +411,13 @@ is as described by `emmet-expand-line'." ;;; Add Missing Extensions -(add-to-list 'auto-mode-alist '("\\.tmac\\'" . nroff-mode)) +(dolist (pattern '("\\.tmac\\'" "\\.mom\\'")) + (add-to-list 'auto-mode-alist (cons pattern #'nroff-mode))) + + +;;; Subword Navigation + +(use-package subword + :hook prog-mode) -(provide 'mm-editing)
\ No newline at end of file +(provide 'mm-editing) diff --git a/.config/emacs/modules/mm-humanwave.el b/.config/emacs/modules/mm-humanwave.el new file mode 100644 index 0000000..3aa97b3 --- /dev/null +++ b/.config/emacs/modules/mm-humanwave.el @@ -0,0 +1,141 @@ +;;; mm-humanwave.el --- Humanwave extras -*- lexical-binding: t; -*- + + +;;; Query the Backend + +(defvar mm--humanwave-query-history nil + "History for endpoints given to `mm-humanwave-query'.") + +(defun mm-humanwave-query (endpoint &optional method) + "Query and display the result of an HTTP reqiest on ENDPOINT. +If METHOD is nil, a GET request is performed." + (interactive + (let* ((query (read-string (format-prompt "Query" nil) + (car-safe mm--humanwave-query-history) + 'mm--humanwave-query-history)) + (parts (string-split (string-trim query) " " :omit-nulls))) + (when (length> parts 2) + (user-error "Queries must be of the form `METHOD ENDPOINT' or `ENDPOINT'.")) + (nreverse parts))) + (let* ((project-root (project-root (project-current :maybe-prompt))) + (qry-path (expand-file-name "qry" project-root)) + extras) + (unless (file-executable-p qry-path) + (user-error "No `qry' executable found in the project root")) + (let ((output-buffer (get-buffer-create "*Query Response*"))) + (with-current-buffer output-buffer + (delete-region (point-min) (point-max)) + (call-process qry-path nil t nil + (string-trim endpoint) "-X" (or method "GET")) + (unless (eq major-mode 'json-ts-mode) + (json-ts-mode)) + (goto-char (point-min))) + (display-buffer output-buffer)))) + +(keymap-set project-prefix-map "q" #'mm-humanwave-query) + + +;;; IMenu Support for Handlers + +(defvar mm-humanwave-handler--regexp + (rx bol + (* blank) + (or "if" "elif") + (* blank) + (or "topic" "schedule") + (* blank) + "==" + (* blank) + (or (seq ?\' (* (not ?\')) ?\') + (seq ?\" (* (not ?\")) ?\")) + (* blank) + ?: + (* blank) + eol)) + +(defun mm-humanwave-handler-topic-imenu-index () + (let ((tree-index (when (fboundp 'treesit-simple-imenu--generic-function) + (treesit-simple-imenu--generic-function + treesit-simple-imenu-settings))) + (topic-index '())) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward mm-humanwave-handler--regexp nil :noerror) + (let ((label (match-string 0)) + (pos (match-beginning 0))) + (push (cons (format "Topic: %s" (string-trim label)) pos) topic-index)))) + (append (nreverse topic-index) tree-index))) + +(defun mm-humanwave-handler-topic-imenu-setup () + "Setup custom imenu index for `python-ts-mode'." + (when (and (string-match-p "handlers?" (or (buffer-file-name) "")) + (derived-mode-p #'python-ts-mode)) + (setq-local imenu-create-index-function + #'mm-humanwave-handler-topic-imenu-index))) + +(add-hook 'after-change-major-mode-hook + #'mm-humanwave-handler-topic-imenu-setup) + + +;;; Insert Imports in Vue + +(defun mm-humanwave-insert-vue-import-path (base-directory target-file) + "Insert an import directive at POINT. +The import directive imports TARGET-FILE relative from BASE-DIRECTORY. +When called interactively BASE-DIRECTORY is the directory of the current +open Vue file and TARGET-FILE is a file in the current project that is +queried interactively. + +When called interactively the prefix argument can be used to emulate the +behaviour of the INCLUDE-ALL-P argument to `mm-project-read-file-name'." + (interactive + (list + default-directory + (mm-humanwave-project-read-file-name current-prefix-arg))) + (let ((path (file-name-sans-extension + (file-relative-name target-file base-directory)))) + (unless (string-match-p "/" path) + (setq path (concat "./" path))) + (insert "import ") + (save-excursion + (insert (thread-last + (file-name-base path) + (mm-string-split "-") + (mapconcat #'capitalize))) + (push-mark (point)) + (insert (format " from '%s';" path))))) + +(defun mm-humanwave-project-read-file-name (&optional include-all-p) + "Prompt for a project file. +This function is similar to `project-find-file', but it returns the path +to the selected file instead of opening it. + +When called interactively the selected file is printed to the minibuffer, +otherwise it is returned. + +The prefix argument INCLUDE-ALL-P is the same as the INCLUDE-ALL argument +to the `project-find-file' command." + (interactive "P") + (let* ((project (project-current :maybe-prompt)) + (root (project-root project)) + (files (if include-all-p + (let ((vc-ignores (mapcar + (lambda (dir) (concat dir "/")) + vc-directory-exclusion-list))) + (project--files-in-directory root vc-ignores)) + (project-files project))) + (canditates (mapcar (lambda (f) (file-relative-name f root)) + files)) + (table (lambda (string predicate action) + (if (eq action 'metadata) + '(metadata (category . file)) + (complete-with-action action canditates string predicate)))) + (default-directory root) + (choice (completing-read (format-prompt "Find project file" nil) + table nil :require-match))) + (let ((path (expand-file-name choice root))) + (if (called-interactively-p 'any) + (message "%s" path) + path)))) + +(provide 'mm-humanwave) diff --git a/.config/emacs/modules/mm-modeline.el b/.config/emacs/modules/mm-modeline.el index dd42f6f..44fc115 100644 --- a/.config/emacs/modules/mm-modeline.el +++ b/.config/emacs/modules/mm-modeline.el @@ -52,7 +52,8 @@ ("Imake" . "IMake") ("Js" . "JavaScript") ("Ts Mode" . "Tree-Sitter Mode") - ("Wdired" . "WDired")) + ("Wdired" . "WDired") + ("Xcompose" . "XCompose")) "Alist of substrings in major mode names that should be remapped. Some major modes have substrings that would be better displayed in another manner. For example expanding an abbreviation such as ‘Js’ to @@ -89,7 +90,7 @@ the text it should be mapped to.") ((derived-mode-p 'comint-mode) "$ ") ((derived-mode-p 'conf-mode) "# ") ((derived-mode-p 'prog-mode) "λ ") - ((derived-mode-p 'special-mode) "❇ ") + ((derived-mode-p 'special-mode) "★ ") ((derived-mode-p 'text-mode) "§ ") (:default "")) 'face 'mm-modeline-major-mode-symbol-face)) diff --git a/.config/emacs/modules/mm-projects.el b/.config/emacs/modules/mm-projects.el index be80789..02d7af4 100644 --- a/.config/emacs/modules/mm-projects.el +++ b/.config/emacs/modules/mm-projects.el @@ -19,24 +19,19 @@ This is intended to be called interactively via (project-find-file "Find File" ?f) (mm-projects-project-magit-status "Git Status" ?s))) :config - (unless mm-darwin-p + (unless mm-humanwave-p (if-let ((repo-directory (getenv "REPODIR"))) - (with-eval-after-load 'async - (async-start - (lambda () - (require 'project) - (let* ((list-dir - (lambda (path) - (directory-files path :full "\\`[^.]"))) - (directories - (cl-loop for author in (funcall list-dir (getenv "REPODIR")) - append (cl-loop for path in (funcall list-dir author) - collect (list (concat path "/")))))) - (with-temp-buffer - (prin1 directories (current-buffer)) - (write-file project-list-file)))) - (lambda (_proc) - (project--read-project-list)))) + (let* ((list-dir + (lambda (path) + (directory-files path :full "\\`[^.]"))) + (directories + (cl-loop for author in (funcall list-dir (getenv "REPODIR")) + append (cl-loop for path in (funcall list-dir author) + collect (list (concat path "/")))))) + (with-temp-buffer + (prin1 directories (current-buffer)) + (write-file project-list-file)) + (project--read-project-list)) (warn "The REPODIR environment variable is not set.")))) @@ -52,9 +47,10 @@ This is intended to be called interactively via (use-package magit :ensure t - :bind ( :map magit-status-mode-map - ("[" . magit-section-backward-sibling) - ("]" . magit-section-forward-sibling)) + :bind (("C-c b" . magit-blame-addition) + :map magit-status-mode-map + ("[" . magit-section-backward-sibling) + ("]" . magit-section-forward-sibling)) :custom (git-commit-style-convention-checks '(non-empty-second-line overlong-summary-line)) @@ -75,11 +71,18 @@ This is intended to be called interactively via "push" "-v" args remote (format "refs/heads/%s:refs/heads/%s" branch branch))))) (transient-append-suffix #'magit-push '(1 -1) - '("a" "all remotes" mm-projects-magit-push-current-to-all-remotes))) + '("a" "all remotes" mm-projects-magit-push-current-to-all-remotes)) + (add-to-list 'magit-blame-styles + '(margin + (show-lines . t) + (margin-format . (" %C %a" " %s%f" " ")) + (margin-width . 73) + (margin-face . magit-blame-margin) + (margin-body-face . (magit-blame-dimmed))))) (use-package magit-repos :ensure nil ; Part of ‘magit’ - :if (not mm-darwin-p) + :if (not mm-humanwave-p) :commands (magit-list-repositories) :init (if-let ((directory (getenv "REPODIR"))) @@ -101,4 +104,11 @@ This is intended to be called interactively via (require 'ansi-color) (add-hook 'compilation-filter-hook #'ansi-color-compilation-filter)) -(provide 'mm-projects)
\ No newline at end of file + +;;; GitHub Pull Requests + +(require 'gh) +(keymap-global-set "C-c p c" #'gh-create-pr) +(keymap-global-set "C-c p o" #'gh-open-previous-pr) + +(provide 'mm-projects) diff --git a/.config/emacs/modules/mm-theme.el b/.config/emacs/modules/mm-theme.el index d9b129c..cde214a 100644 --- a/.config/emacs/modules/mm-theme.el +++ b/.config/emacs/modules/mm-theme.el @@ -8,7 +8,7 @@ ;;; Fonts -(defvar mm-theme-monospace-font `(,(if mm-darwin-p +(defvar mm-theme-monospace-font `(,(if mm-humanwave-p "Iosevka Custom" "Iosevka Smooth") :weight regular @@ -16,7 +16,9 @@ "The default monospace font. This is a plist containing a font name, -weight, and -height.") -(defvar mm-theme-proportional-font '("OpenSans" :weight regular :height 162) +(defvar mm-theme-proportional-font + `(,(if mm-darwin-p "Microsoft Sans Serif" "OpenSans") + :weight regular :height 162) "The default proportional font. This is a plist containing a font name, -weight, and -height.") @@ -164,6 +166,16 @@ See also the `mm-theme-background-opacity' variable." (("C-c h l" . pulsar-highlight-dwim))) +;;; In-buffer highlighting + +(require 'hi-lock) ; For extra face definitions +(use-package highlighter + :bind (("C-c h m" . #'highlighter-mark) + ("C-c h u" . #'highlighter-unmark) + ("C-c h U" . #'highlighter-unmark-buffer)) + :commands (highlighter-mark highlighter-unmark highlighter-unmark-buffer)) + + ;;; Add Padding (use-package spacious-padding @@ -219,4 +231,16 @@ See also the `mm-theme-background-opacity' variable." :custom (hl-line-sticky-flag nil)) -(provide 'mm-theme)
\ No newline at end of file + +;;; Indent Guides + +(when mm-humanwave-p + (use-package highlight-indent-guides + :ensure t + :hook ((jinja2-mode vue-ts-mode mhtml-mode) . highlight-indent-guides-mode) + :custom + (highlight-indent-guides-method 'fill) + (highlight-indent-guides-auto-even-face-perc 30) + (highlight-indent-guides-auto-odd-face-perc 0))) + +(provide 'mm-theme) diff --git a/.config/emacs/modules/mm-treesit.el b/.config/emacs/modules/mm-treesit.el index a41f52c..bd146ce 100644 --- a/.config/emacs/modules/mm-treesit.el +++ b/.config/emacs/modules/mm-treesit.el @@ -15,21 +15,46 @@ (setopt treesit-font-lock-level 4) (setopt treesit-language-source-alist - '((awk "https://github.com/Beaglefoot/tree-sitter-awk") - (c "https://github.com/tree-sitter/tree-sitter-c") - (cpp "https://github.com/tree-sitter/tree-sitter-cpp") - (css "https://github.com/tree-sitter/tree-sitter-css") - (go "https://github.com/tree-sitter/tree-sitter-go") - (gomod "https://github.com/camdencheek/tree-sitter-go-mod") - (gsp "git://git.thomasvoss.com/tree-sitter-gsp.git") - (html "https://github.com/tree-sitter/tree-sitter-html") - (java "https://github.com/tree-sitter/tree-sitter-java") - (javascript "https://github.com/tree-sitter/tree-sitter-javascript") - (python "https://github.com/tree-sitter/tree-sitter-python") - (typescript "https://github.com/tree-sitter/tree-sitter-typescript" - "master" "typescript/src") - (vim "https://github.com/tree-sitter-grammars/tree-sitter-vim") - (vue "https://github.com/ikatyang/tree-sitter-vue"))) + '((awk + "https://github.com/Beaglefoot/tree-sitter-awk") + (c + "https://github.com/tree-sitter/tree-sitter-c") + (cpp + "https://github.com/tree-sitter/tree-sitter-cpp") + (css + "https://github.com/tree-sitter/tree-sitter-css") + (go + "https://github.com/tree-sitter/tree-sitter-go") + (gomod + "https://github.com/camdencheek/tree-sitter-go-mod") + (gsp + "git://git.thomasvoss.com/tree-sitter-gsp.git") + (html + "https://github.com/tree-sitter/tree-sitter-html") + (java + "https://github.com/tree-sitter/tree-sitter-java") + (javascript + "https://github.com/tree-sitter/tree-sitter-javascript") + (json + "https://github.com/tree-sitter/tree-sitter-json") + (markdown + "https://github.com/tree-sitter-grammars/tree-sitter-markdown" + "split_parser" "tree-sitter-markdown/src") + (markdown-inline + "https://github.com/tree-sitter-grammars/tree-sitter-markdown" + "split_parser" "tree-sitter-markdown-inline/src") + (python + "https://github.com/tree-sitter/tree-sitter-python") + (tsx + "https://github.com/tree-sitter/tree-sitter-typescript" + "master" "tsx/src") + (typescript + "https://github.com/tree-sitter/tree-sitter-typescript" + "master" "typescript/src") + (vim + "https://github.com/tree-sitter-grammars/tree-sitter-vim") + (vue + "https://github.com/ikatyang/tree-sitter-vue"))) ;;; Install Missing Parsers @@ -72,13 +97,18 @@ The parsers are taken from `treesit-language-source-alist'." ;; NOTE: This package doesn’t autoload its ‘auto-mode-alist’ entries (use-package vue-ts-mode - :vc (:url "https://github.com/8uff3r/vue-ts-mode.git" - :branch "main" - :rev :newest - :vc-backend Git) + :vc ( :url "https://github.com/8uff3r/vue-ts-mode.git" + :branch "main" + :rev :newest + :vc-backend Git) :ensure t :mode "\\.vue\\'") +;; NOTE: This package doesn’t autoload its ‘auto-mode-alist’ entries +(use-package markdown-ts-mode + :ensure t + :mode "\\.md\\'") + ;;; Prefer Tree-Sitter Modes @@ -87,28 +117,39 @@ The parsers are taken from `treesit-language-source-alist'." ;; anyway. Same goes for ‘typescript-ts-mode’. (defvar mm-treesit-language-file-name-alist '((go . "\\.go\\'") - (go-mod . "/go\\.mod\\'") + (gomod . "/go\\.mod\\'") + (json . "\\.json\\'") + (tsx . "\\.tsx\\'") (typescript . "\\.ts\\'")) "Alist mapping languages to their associated file-names. This alist is a set of pairs of the form (LANG . REGEXP) where LANG is -the symbol corresponding to a major mode with the ‘-ts-mode’ suffix +the symbol corresponding to a major mode with the `-ts-mode' suffix removed. REGEXP is a regular expression matching filenames for which the associated language’s major-mode should be enabled. This alist is used to configure `auto-mode-alist'.") +(defvar mm-treesit-dont-have-modes + '(markdown-inline) + "List of languages that don't have modes. +Some languages may come with multiple parsers, (e.g. `markdown' and +`markdown-inline') and as a result one-or-more of the parsers won't be +associated with a mode. To avoid breaking the configuration, these +languages should be listed here.") + (dolist (spec treesit-language-source-alist) (let* ((lang (car spec)) - (lang (alist-get lang mm-treesit-language-remap-alist lang)) - (symbol-name (symbol-name lang)) - (name-mode (intern (concat symbol-name "-mode"))) - (name-ts-mode (intern (concat symbol-name "-ts-mode")))) + (lang-remap (alist-get lang mm-treesit-language-remap-alist lang)) + (name-mode (intern (format "%s-mode" lang-remap))) + (name-ts-mode (intern (format "%s-ts-mode" lang-remap)))) ;; If ‘name-ts-mode’ is already in ‘auto-mode-alist’ then we don’t ;; need to do anything, however if that’s not the case then if ;; ‘name-ts-mode’ and ‘name-mode’ are both bound we do a simple ;; remap. If the above is not true then we lookup the extensions in ;; ‘mm-treesit-language-file-name-alist’. (cond + ((memq lang mm-treesit-dont-have-modes) + nil) ((not (fboundp name-ts-mode)) (warn "`%s' is missing." name-ts-mode)) ((rassq name-ts-mode auto-mode-alist) @@ -121,6 +162,9 @@ This alist is used to configure `auto-mode-alist'.") (add-to-list 'auto-mode-alist (cons file-regexp name-ts-mode)) (warn "Unable to determine the extension for `%s'." name-ts-mode)))))) +;; JavaScript being difficult as usual +(add-to-list 'major-mode-remap-alist '(javascript-mode . js-ts-mode)) + ;;; Hack For C23 @@ -178,4 +222,4 @@ back to regular `expreg-expand'." :commands (mm-expreg-expand mm-expreg-expand-dwim) :bind ("M-SPC" . mm-expreg-expand-dwim)) -(provide 'mm-treesit)
\ No newline at end of file +(provide 'mm-treesit) |