forked from colonelpanic/dotfiles
[Emacs] Seems the lsp manuevering I was doing wasn't necessary with a new
version of lsp mode
This commit is contained in:
parent
a37287524c
commit
92f3992a98
@ -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)
|
||||||
do
|
(let ((targets (if (listp from) from (list from))))
|
||||||
(let ((from (treesit-auto-recipe-remap recipe))
|
(cl-loop for from in targets
|
||||||
(to (treesit-auto-recipe-ts-mode recipe)))
|
do
|
||||||
(treesit-auto-copy-lsp-language from to)
|
(letrec ((to-hook (treesit-auto-get-mode-hook-symbol to))
|
||||||
(treesit-auto-copy-lsp-client-languages from to))))
|
(from-hook (treesit-auto-get-mode-hook-symbol from))
|
||||||
|
(treesit-auto-hook-name
|
||||||
(defun treesit-auto-copy-lsp-language (from to)
|
(intern
|
||||||
(let ((from-value (alist-get from lsp-language-id-configuration)))
|
(concat "treesit-auto-run-"
|
||||||
(when from-value
|
(symbol-name from-hook)
|
||||||
(add-to-list 'lsp-language-id-configuration `(,to . ,from-value))
|
"-for-" (symbol-name to)))))
|
||||||
from-value)))
|
(defalias treesit-auto-hook-name
|
||||||
|
`(lambda ()
|
||||||
(defun treesit-auto-copy-lsp-client-languages (from to)
|
(when (and treesit-auto-run-original-hooks
|
||||||
(cl-loop for client in (hash-table-values lsp-clients)
|
(boundp ',from-hook)
|
||||||
do
|
(not (memq '(,from . ,to) treesit-auto-hook-copy-blacklist)))
|
||||||
(let ((major-modes (lsp--client-major-modes client)))
|
(message "Running hooks from %s for %s" ',from-hook ',to)
|
||||||
(when (memq from major-modes)
|
(run-mode-hooks ',from-hook))))
|
||||||
(setf (lsp--client-major-modes client)
|
(add-hook to-hook treesit-auto-hook-name))))))))
|
||||||
(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
|
||||||
|
Loading…
Reference in New Issue
Block a user