Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using tree sitter modes does not play well with lsp #51

Closed
colonelpanic8 opened this issue Jul 31, 2023 · 1 comment
Closed

Using tree sitter modes does not play well with lsp #51

colonelpanic8 opened this issue Jul 31, 2023 · 1 comment

Comments

@colonelpanic8
Copy link

This is probably more of an issue with lsp-mode than treesit-auto, and to that end I have filed emacs-lsp/lsp-mode#4117

Still, it could be worth considering adding something here, or at least making treesit-auto users aware of this issue.

Also, here's my config that hackily fixes the issue, in case any one wants something like this:

(use-package treesit-auto
  :demand t
  :config
  (progn
	(setq treesit-auto-install t)
	(global-treesit-auto-mode +1)

	(defun treesit-auto-copy-all-lsp-languages ()
	  (cl-loop for recipe in treesit-auto-recipe-list
			   do
			   (let ((from (treesit-auto-recipe-remap recipe))
					 (to (treesit-auto-recipe-ts-mode recipe)))
				 (treesit-auto-copy-lsp-language from to)
				 (treesit-auto-copy-lsp-client-languages from to))))

	(defun treesit-auto-copy-lsp-language (from to)
	  (let ((from-value (alist-get from lsp-language-id-configuration)))
		(when from-value
		  (add-to-list 'lsp-language-id-configuration `(,to . ,from-value))
		  from-value)))

	(defun treesit-auto-copy-lsp-client-languages (from to)
	  (cl-loop for client in (hash-table-values lsp-clients)
			   do (let ((major-modes (lsp--client-major-modes client)))
					(when (memq from major-modes)
					  (message (concat "Matched " (symbol-name from) " with " (symbol-name (lsp--client-server-id client))))
					  (setf (lsp--client-major-modes client) (append major-modes (list to)))))))

	(use-package lsp-mode
	  :config
	  (treesit-auto-copy-all-lsp-languages))))
@renzmann
Copy link
Owner

renzmann commented Nov 3, 2023

I can't quote discern if there's a bug report about treesit-auto in here; I'll likely close this if there isn't something specific about this package that we need to address.

@renzmann renzmann closed this as not planned Won't fix, can't repro, duplicate, stale Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants