Use web-mode derived modes for LSP support for JS and HTML

This commit is contained in:
Jeremy Dormitzer 2023-04-05 08:04:43 -04:00
parent 4d42431d0b
commit d4e928f09e
2 changed files with 18 additions and 2 deletions

View File

@ -40,12 +40,21 @@
(use-package eglot
:commands (eglot)
:config
(add-to-list 'eglot-server-programs
'(js-web-mode . ("typescript-language-server" "--stdio")))
(add-to-list 'eglot-server-programs
`(html-web-mode . ,(eglot-alternatives
'(("vscode-html-language-server" "--stdio")
("html-languageserver" "--stdio")))))
:hook
(java-mode . eglot-ensure)
(rust-mode . eglot-ensure)
(js-mode . eglot-ensure)
(typescript-mode . eglot-ensure)
(python-mode . eglot-ensure))
(python-mode . eglot-ensure)
(js-web-mode . eglot-ensure)
(html-web-mode . eglot-ensure))
;; Some compilation-mode conveniences
(use-package compile

View File

@ -9,7 +9,6 @@
("\\.mustache\\'" . web-mode)
("\\.djhtml\\'" . web-mode)
("\\.hbs\\'" . web-mode)
("\\.html?\\'" . web-mode)
("\\.mako\\'" . web-mode)
("\\.jinja2\\'" . web-mode))
:config
@ -21,4 +20,12 @@
(web-mode-code-indent-offset 2)
(web-mode-script-padding 2))
(define-derived-mode js-web-mode web-mode "JS Web Mode"
"Web mode in JS files.")
(add-to-list 'auto-mode-alist '("\\.jsx?\\'" . js-web-mode))
(define-derived-mode html-web-mode web-mode "HTML Web Mode"
"Web mode in HTML files.")
(add-to-list 'auto-mode-alist '("\\.html?\\'" . html-web-mode))
(provide 'init-web)