Function: qml-ts-mode
qml-ts-mode is an interactive and natively compiled function defined
in qml-ts-mode.el.
Signature
(qml-ts-mode)
Documentation
Major mode for editing QML.
In addition to any hooks its parent mode prog-mode might have run,
this mode runs the hook qml-ts-mode-hook, as the final or
penultimate step during initialization.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/mpfi9fgjwxji7ck8nsrasywj35794lzz-emacs-packages-deps/share/emacs/site-lisp/qml-ts-mode.el
;;;###autoload
(define-derived-mode qml-ts-mode prog-mode "QML"
"Major mode for editing QML."
:group 'qml-ts
:syntax-table js-mode-syntax-table
(when (treesit-ready-p 'qmljs)
;; Comment
(c-ts-common-comment-setup)
(setq-local comment-multi-line t)
(setq-local treesit-text-type-regexp
(regexp-opt '("comment"
"template_string")))
;; Treesit setup
(treesit-parser-create 'qmljs)
;; Indent
(setq-local treesit-simple-indent-rules qml--treesit-indent-rules)
;; Fontification.
;; (setq-local treesit--font-lock-verbose t)
;; (setq-local treesit-font-lock-level 4)
(setq-local treesit-font-lock-settings qml--treesit-font-lock-settings)
;; Level 1 usually contains only comments and definitions.
;; Level 2 usually adds keywords, strings, data types, etc.
;; Level 3 usually represents full-blown fontifications, including
;; assignments, constants, numbers and literals, etc.
;; Level 4 adds everything else that can be fontified: delimiters,
(setq-local treesit-font-lock-feature-list
'(( comment definition)
( keyword string type)
( assignment constant escape-sequence number pattern string-interpolation)
( bracket delimiter function operator)
;; ( bracket delimiter function operator property)
))
;; Navigation.
(setq-local treesit-defun-prefer-top-level t)
(setq-local treesit-defun-type-regexp
(rx (or "class_declaration"
"method_definition"
"function_declaration"
"lexical_declaration"
"ui_object_definition")))
(setq-local treesit-defun-name-function #'qml--treesit-defun-name)
(setq-local treesit-sentence-type-regexp
(regexp-opt js--treesit-sentence-nodes))
;; Imenu
(setq treesit-simple-imenu-settings
`(("Function" "\\`function_declaration\\'" nil nil)
("Property" "\\`ui_property\\'" nil nil)
("Signal" "\\`ui_signal\\'" nil nil)
("Component" "\\`ui_object_definition\\'" nil nil)))
(treesit-major-mode-setup)))