Function: go-ts-mode--font-lock-settings

go-ts-mode--font-lock-settings is a byte-compiled function defined in go-ts-mode.el.gz.

Signature

(go-ts-mode--font-lock-settings)

Documentation

Return font-lock rules for go-ts-mode.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/go-ts-mode.el.gz
(defun go-ts-mode--font-lock-settings ()
  "Return font-lock rules for `go-ts-mode'."
  (treesit-font-lock-rules
   :language 'go
   :feature 'bracket
   '(["(" ")" "[" "]" "{" "}"] @font-lock-bracket-face)

   :language 'go
   :feature 'comment
   '((comment) @font-lock-comment-face)

   :language 'go
   :feature 'builtin
   `((call_expression
      function: ((identifier) @font-lock-builtin-face
                 (:match ,(rx-to-string
                           `(seq bol
                                 (or ,@go-ts-mode--builtin-functions)
                                 eol))
                         @font-lock-builtin-face))))

   :language 'go
   :feature 'constant
   (treesit-query-with-optional 'go
     '([(false) (nil) (true)] @font-lock-constant-face
       (const_declaration
        (const_spec name: (identifier) @font-lock-constant-face
                    ("," name: (identifier) @font-lock-constant-face)*)))
     ;; Optional query added in newer version.
     '((iota) @font-lock-constant-face))

   :language 'go
   :feature 'delimiter
   '((["," "." ";" ":"]) @font-lock-delimiter-face)

   :language 'go
   :feature 'operator
   `([,@go-ts-mode--operators] @font-lock-operator-face)

   :language 'go
   :feature 'definition
   (treesit-query-with-optional 'go
     '((function_declaration
        name: (identifier) @font-lock-function-name-face)
       (method_declaration
        name: (field_identifier) @font-lock-function-name-face)
       (field_declaration
        name: (field_identifier) @font-lock-property-name-face)
       (parameter_declaration
        name: (identifier) @font-lock-variable-name-face)
       (variadic_parameter_declaration
        name: (identifier) @font-lock-variable-name-face)
       (short_var_declaration
        left: (expression_list
               (identifier) @font-lock-variable-name-face
               ("," (identifier) @font-lock-variable-name-face)*))
       (var_spec name: (identifier) @font-lock-variable-name-face
                 ("," name: (identifier) @font-lock-variable-name-face)*)
       (range_clause
        left: (expression_list
               (identifier) @font-lock-variable-name-face)))
     ;; tree-sitter-go changed method_spec to method_elem in
     ;; https://github.com/tree-sitter/tree-sitter-go/commit/b82ab803d887002a0af11f6ce63d72884580bf33
     '((method_elem
        name: (field_identifier) @font-lock-function-name-face))
     '((method_spec
        name: (field_identifier) @font-lock-function-name-face)))

   :language 'go
   :feature 'function
   '((call_expression
      function: (identifier) @font-lock-function-call-face)
     (call_expression
      function: (selector_expression
                 field: (field_identifier) @font-lock-function-call-face)))

   :language 'go
   :feature 'keyword
   `([,@go-ts-mode--keywords] @font-lock-keyword-face)

   :language 'go
   :feature 'label
   '((label_name) @font-lock-constant-face)

   :language 'go
   :feature 'number
   '([(float_literal)
      (imaginary_literal)
      (int_literal)] @font-lock-number-face)

   :language 'go
   :feature 'string
   '([(interpreted_string_literal)
      (raw_string_literal)
      (rune_literal)] @font-lock-string-face)

   :language 'go
   :feature 'type
   '([(package_identifier) (type_identifier)] @font-lock-type-face)

   :language 'go
   :feature 'property
   '((selector_expression field: (field_identifier) @font-lock-property-use-face)
     (keyed_element (_ (identifier) @font-lock-property-use-face)))

   :language 'go
   :feature 'variable
   '((identifier) @font-lock-variable-use-face)

   :language 'go
   :feature 'escape-sequence
   :override t
   '((escape_sequence) @font-lock-escape-face)

   :language 'go
   :feature 'error
   :override t
   '((ERROR) @font-lock-warning-face)))