Fix treesit-forward-sexp/list navigation in the middle of a node.
* lisp/treesit.el (treesit--forward-list-with-default): Check the thing 'sexp-default' (bug#76791). * lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode): * lisp/progmodes/go-ts-mode.el (go-ts-mode): * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): * lisp/progmodes/sh-script.el (bash-ts-mode): Add the thing 'sexp-default' to 'treesit-thing-settings'.
This commit is contained in:
parent
addcab6891
commit
ec62674cb9
5 changed files with 32 additions and 13 deletions
|
@ -720,6 +720,11 @@ Return nil if NODE is not a defun node or doesn't have a name."
|
|||
"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
|
||||
|
|
|
@ -306,6 +306,11 @@
|
|||
"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")))))
|
||||
|
||||
|
|
|
@ -1219,6 +1219,12 @@ leading double colon is not added."
|
|||
"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"
|
||||
|
@ -1226,19 +1232,8 @@ leading double colon is not added."
|
|||
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)
|
||||
|
|
|
@ -1662,6 +1662,12 @@ not written in Bash or sh."
|
|||
"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"
|
||||
|
|
|
@ -3049,6 +3049,14 @@ ARG is described in the docstring of `forward-list'."
|
|||
;; 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))
|
||||
|
|
Loading…
Add table
Reference in a new issue