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

Typescript tsx improvements #15895

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions layers/+lang/typescript/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,9 @@
"==" 'spacemacs/typescript-format))
('tide (spacemacs/set-leader-keys-for-major-mode mode
"=" 'spacemacs/typescript-format))))

;; Workaround to fix tsx highlighting error.
;; Disable web-modes font-lock syntax highlighting for tsx files.
;; See: https://github.com/emacs-tree-sitter/tree-sitter-langs/issues/23#issuecomment-832815710
(defun spacemacs//typescript-tsx-mode-fix-tree-sitter()
(setq-local tree-sitter-hl-use-font-lock-keywords nil))
6 changes: 5 additions & 1 deletion layers/+lang/typescript/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@
(defun typescript/post-init-web-mode ()
(define-derived-mode typescript-tsx-mode web-mode "TypeScript-tsx")
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode))
(spacemacs/typescript-mode-config 'typescript-tsx-mode))
(spacemacs/typescript-mode-config 'typescript-tsx-mode)
(with-eval-after-load 'tree-sitter
(tree-sitter-require 'tsx)
(add-hook 'typescript-tsx-mode-hook #'spacemacs//typescript-tsx-mode-fix-tree-sitter)
(add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx))))

(defun typescript/init-typescript-mode ()
(use-package typescript-mode
Expand Down
2 changes: 2 additions & 0 deletions layers/+tools/lsp/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
(spacemacs/lsp-bind-upstream-keys)
(spacemacs/lsp-bind-keys))
(setq lsp-prefer-capf t)
;; This sets the lsp indentation for all modes derived from web-mode.
(setf (alist-get 'web-mode lsp--formatting-indent-alist) 'web-mode-markup-indent-offset)
(add-hook 'lsp-after-open-hook (lambda ()
"Setup xref jump handler"
(spacemacs//setup-lsp-jump-handler))))))
Expand Down