machine_setup/ansible/roles/emacs/files/lang-javascript.el

88 lines
2.7 KiB
EmacsLisp
Raw Normal View History

2022-10-20 04:03:56 +00:00
(require 'common-lsp)
(require 'util-tree-sitter)
2023-05-27 20:52:29 +00:00
(use-package tsx-ts-mode
:ensure nil
2022-10-20 04:03:56 +00:00
:pin manual
2023-05-27 20:52:29 +00:00
:mode (
("\\.tsx\\'" . tsx-ts-mode)
2022-10-20 04:03:56 +00:00
)
2023-05-27 20:52:29 +00:00
:commands (tsx-ts-mode)
:init
(add-to-list 'treesit-language-source-alist '(tsx . ("https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")))
(unless (treesit-ready-p 'tsx) (treesit-install-language-grammar 'tsx))
2022-10-20 04:03:56 +00:00
)
2023-05-27 20:52:29 +00:00
(use-package typescript-ts-mode
:ensure nil
:pin manual
2022-10-20 04:03:56 +00:00
:mode (
2023-05-27 20:52:29 +00:00
("\\.ts\\'" . typescript-ts-mode)
2022-10-20 04:03:56 +00:00
)
2023-05-27 20:52:29 +00:00
:commands (typescript-ts-mode)
:init
(add-to-list 'treesit-language-source-alist '(typescript . ("https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")))
(unless (treesit-ready-p 'typescript) (treesit-install-language-grammar 'typescript))
2022-10-20 04:03:56 +00:00
)
2023-05-27 20:52:29 +00:00
;; (use-package js
;; :mode (
;; ("\\.js\\'" . js-mode)
;; ("\\.json\\'" . js-mode)
;; )
;; :commands js-mode
;; :pin manual
;; :hook (
;; (find-file . (lambda () (when (string= (file-name-extension buffer-file-name) "json") (add-hook 'before-save-hook 'json-fmt-jq nil 'local))))
;; (js-mode . (lambda ()
;; (tree-sitter-hl-mode +1)
;; )
;; )
;; )
;; :config
;; (setq js-indent-level 2)
;; )
;; (use-package typescript-mode
;; :mode (
;; ("\\.ts\\'" . typescript-mode)
;; ("\\.tsx\\'" . typescript-mode)
;; )
;; :hook (
;; (typescript-mode . (lambda ()
;; ;; (lsp-register-client
;; ;; (make-lsp-client :new-connection (lsp-stdio-connection '("deno" "lsp" --compat --unstable --allow-read))
;; ;; :major-modes '(typescript-mode)
;; ;; :server-id 'typescript-ls))
;; (eglot-ensure)
;; (tree-sitter-hl-mode +1)
;; ))
;; ;; (before-save . lsp-format-buffer)
;; )
;; )
;; (defun json-fmt-jq ()
;; "Run jq."
;; (run-command-on-buffer "jq" "--monochrome-output" ".")
;; )
;; (use-package web-mode
;; :mode (("\\.dust\\'" . web-mode)
;; )
;; :config
;; (setq web-mode-markup-indent-offset 2)
;; (setq web-mode-enable-current-element-highlight t)
;; )
;; ;; Define a custom mode for dust so that org-mode handle #+BEGIN_SRC dust blocks
;; (define-derived-mode dust-mode web-mode "WebDust"
;; "Major mode for editing dust templates in web-mode."
;; (web-mode)
;; (web-mode-set-engine "dust")
;; ;; (setq web-mode-content-type "html")
;; )
2022-10-20 04:03:56 +00:00
(provide 'lang-javascript)