[Emacs] Seems the lsp manuevering I was doing wasn't necessary with a new

version of lsp mode
This commit is contained in:
Ivan Malison 2023-07-31 21:27:27 -06:00
parent a37287524c
commit 92f3992a98

View File

@ -1583,45 +1583,32 @@ out how to detect that a buffer is a man mode buffer.
(to (treesit-auto-recipe-ts-mode recipe))) (to (treesit-auto-recipe-ts-mode recipe)))
(funcall fn from to)))) (funcall fn from to))))
;; (treesit-auto-for-each
;; (lambda (from to)
;; (letrec ((to-hook (treesit-auto-get-mode-hook-symbol to))
;; (from-hook (treesit-auto-get-mode-hook-symbol from))
;; (set-exp (list 'setq to-hook from-hook)))
;; (message (format "%s" set-exp))
;; (when (boundp from-hook)
;; (eval result)))))
(defun treesit-auto-get-mode-hook-symbol (mode) (defun treesit-auto-get-mode-hook-symbol (mode)
(intern (concat (symbol-name mode) "-hook"))) (intern (concat (symbol-name mode) "-hook")))
(treesit-auto-get-mode-hook-symbol 'python-mode) (defvar treesit-auto-run-original-hooks t)
(defvar treesit-auto-hook-copy-blacklist '((rust-mode . rust-ts-mode)))
(defun treesit-auto-copy-all-lsp-languages () (treesit-auto-for-each
(cl-loop for recipe in treesit-auto-recipe-list (lambda (from to)
(let ((targets (if (listp from) from (list from))))
(cl-loop for from in targets
do do
(let ((from (treesit-auto-recipe-remap recipe)) (letrec ((to-hook (treesit-auto-get-mode-hook-symbol to))
(to (treesit-auto-recipe-ts-mode recipe))) (from-hook (treesit-auto-get-mode-hook-symbol from))
(treesit-auto-copy-lsp-language from to) (treesit-auto-hook-name
(treesit-auto-copy-lsp-client-languages from to)))) (intern
(concat "treesit-auto-run-"
(defun treesit-auto-copy-lsp-language (from to) (symbol-name from-hook)
(let ((from-value (alist-get from lsp-language-id-configuration))) "-for-" (symbol-name to)))))
(when from-value (defalias treesit-auto-hook-name
(add-to-list 'lsp-language-id-configuration `(,to . ,from-value)) `(lambda ()
from-value))) (when (and treesit-auto-run-original-hooks
(boundp ',from-hook)
(defun treesit-auto-copy-lsp-client-languages (from to) (not (memq '(,from . ,to) treesit-auto-hook-copy-blacklist)))
(cl-loop for client in (hash-table-values lsp-clients) (message "Running hooks from %s for %s" ',from-hook ',to)
do (run-mode-hooks ',from-hook))))
(let ((major-modes (lsp--client-major-modes client))) (add-hook to-hook treesit-auto-hook-name))))))))
(when (memq from major-modes)
(setf (lsp--client-major-modes client)
(append major-modes (list to)))))))
(use-package lsp-mode
:config
(treesit-auto-copy-all-lsp-languages))))
#+end_src #+end_src
* helpful * helpful
#+begin_src emacs-lisp #+begin_src emacs-lisp