emacs: Fix highlighting in vue-mode

This commit is contained in:
Charlotte Van Petegem 2023-08-11 14:19:43 +02:00
parent 767b399ead
commit b4685fcbca
No known key found for this signature in database
GPG key ID: 019E764B7184435A

View file

@ -111,6 +111,8 @@
;; Vue language support
(use-package vue-mode
:mode "\\.vue\\'"
:custom
(mmm-submode-decoration-level 0 "Don't color submodes differently")
:config
(defun vue-eglot-init-options ()
(let ((tsdk-path "${pkgs.typescript}/lib/node_modules/typescript/lib"))
@ -128,6 +130,32 @@
:documentSymbol t
:documentColor t)))))
(add-to-list 'eglot-server-programs `(vue-mode . ("${pkgs.nodePackages.volar}/bin/vue-language-server" "--stdio" :initializationOptions ,(vue-eglot-init-options))))
(setq vue--front-tag-lang-regex
(concat "<%s" ; The tag name
"\\(?:" ; Zero of more of...
"\\(?:\\s-+\\w+=[\"'].*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar"
"\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute
"\\|\\(?:\\s-+module\\)" ; The optional "module" attribute
"\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute
"\\)*"
"\\(?:\\s-+lang=[\"']%s[\"']\\)" ; The language specifier (required)
"\\(?:" ; Zero of more of...
"\\(?:\\s-+\\w+=[\"'].*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar"
"\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute
"\\|\\(?:\\s-+module\\)" ; The optional "module" attribute
"\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute
"\\)*"
" *>\n")) ; The end of the tag
(setq vue--front-tag-regex
(concat "<%s" ; The tag name
"\\(?:" ; Zero of more of...
"\\(?:\\s-+" vue--not-lang-key "[\"'][^\"']*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar".
;; ^ Disallow "lang" in k/v pairs to avoid matching regions with non-default languages
"\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute
"\\|\\(?:\\s-+module\\)" ; The optional "module" attribute
"\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute
"\\)*"
"\\s-*>\n")) ; The end of the tag
)
;; HTML (and HTML template) support