(:match "\\`?[#\"'`:?]" @char))
;; Symbols like :+, :<=> or :foo=.
((simple_symbol) @symbol
- (:match "[[:punct:]]" @symbol))
+ (:match "\\s." @symbol))
;; Method calls with name ending with ? or !.
((call method: (identifier) @ident)
(:match "[?!]\\'" @ident))
(put-text-property (1- (treesit-node-end node)) (treesit-node-end node)
'syntax-table (string-to-syntax "_")))
('symbol
- (put-text-property (1+ (treesit-node-start node)) (treesit-node-end node)
+ (goto-char (treesit-node-end node))
+ (skip-syntax-backward "." (treesit-node-start node))
+ (put-text-property (point) (treesit-node-end node)
'syntax-table (string-to-syntax "_")))
('heredoc
(put-text-property (treesit-node-start node) (1+ (treesit-node-start node))
(delete-char 1)
(should (string= (ruby-ts-add-log-current-function) "M::C#foo"))))
+(ert-deftest ruby-ts-syntax-propertize-symbol ()
+ (pcase-dolist (`(,str . ,expected)
+ '((":abc" . ":abc")
+ (":foo?" . #(":foo?" 4 5 (syntax-table (3))))
+ (":<=>" . #(":<=>" 1 4 (syntax-table (3))))))
+ (ruby-ts-with-temp-buffer str
+ (syntax-propertize (point-max))
+ (let ((text (buffer-string)))
+ (remove-text-properties 0 (1- (point-max))
+ '(fontified)
+ text)
+ (should (equal-including-properties
+ text
+ expected))))))
+
(defmacro ruby-ts-resource-file (file)
`(when-let ((testfile ,(or (macroexp-file-name)
buffer-file-name)))