"do_block"
"anonymous_function")
eos)))
+ (sexp-default
+ ;; For `C-M-f' in "&|(a)"
+ ("(" . ,(lambda (node)
+ (equal (treesit-node-type (treesit-node-parent node))
+ "unary_operator"))))
(sentence
,(rx bos (or "call") eos))
(text
"argument_list"
"literal_value")
eos))
+ (sexp-default
+ ;; For `C-M-f' in "switch a |{ }"
+ (lambda (node)
+ (equal (treesit-node-type (treesit-node-parent node))
+ "expression_switch_statement")))
(sentence
(or "declaration" "statement")))))
"hash")
eos)
#'ruby-ts--list-p))
+ (sexp-default
+ ;; For `C-M-f' in "#|{a}"
+ ("#{" . ,(lambda (node)
+ (and (eq (char-after (point)) ?{)
+ (equal (treesit-node-type (treesit-node-parent node))
+ "interpolation")))))
(sentence ,(rx bos (or "return"
"body_statement"
"call"
eos))
(text ,(lambda (node)
(or (member (treesit-node-type node)
- '("comment" "string_content" "heredoc_content"))
- ;; for C-M-f in hash[:key] and hash['key']
- (and (member (treesit-node-text node)
- '("[" "]"))
- (equal (treesit-node-type
- (treesit-node-parent node))
- "element_reference"))
- ;; for C-M-f in "abc #{ghi} def"
- (and (member (treesit-node-text node)
- '("#{" "}"))
- (equal (treesit-node-type
- (treesit-node-parent node))
- "interpolation"))))))))
+ '("comment" "string_content"
+ "heredoc_content"))))))))
;; Imenu.
(setq-local imenu-create-index-function #'ruby-ts--imenu)
"command_substitution"
"process_substitution")
eos))
+ (sexp-default
+ ;; For `C-M-f' in "$|(a)"
+ ("$(" .
+ ,(lambda (node)
+ (equal (treesit-node-type (treesit-node-parent node))
+ "command_substitution"))))
(sentence
,(rx bos (or "redirected_statement"
"declaration_command"
;; Use the default function only if it doesn't go
;; over the sibling and doesn't go out of the current group.
(or (when (and default-pos
+ ;; Fallback to the default sexp function when
+ ;; matching the thing 'sexp-default' at point.
+ (treesit-node-match-p
+ (treesit-node-at (if (> arg 0) (point)
+ (max (1- (point)) (point-min))))
+ 'sexp-default t))
+ (goto-char default-pos))
+ (when (and default-pos
(or (null sibling)
(if (> arg 0)
(<= default-pos (treesit-node-start sibling))