Variable: qml-ts-mode-map

qml-ts-mode-map is a variable defined in qml-ts-mode.el.

Value


Documentation

Keymap for qml-ts-mode.

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)))