diff options
Diffstat (limited to 'lisp/progmodes/ruby-ts-mode.el')
-rw-r--r-- | lisp/progmodes/ruby-ts-mode.el | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 91d65a2777b..7a00977f14a 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1086,6 +1086,15 @@ leading double colon is not added." (put-text-property pos (1+ pos) 'syntax-table (string-to-syntax "!")))))))) +(defun ruby-ts--sexp-p (node) + ;; Skip parenless calls (implicit parens are both non-obvious to the + ;; user, and might take over when we want to just over some physical + ;; parens/braces). + (or (not (equal (treesit-node-type node) + "argument_list")) + (equal (treesit-node-type (treesit-node-child node 0)) + "("))) + (defvar-keymap ruby-ts-mode-map :doc "Keymap used in Ruby mode" :parent prog-mode-map @@ -1113,6 +1122,45 @@ leading double colon is not added." ;; Navigation. (setq-local treesit-defun-type-regexp ruby-ts--method-regex) + (setq-local treesit-sexp-type-regexp + (cons (rx + bol + (or + "class" + "module" + "method" + "array" + "hash" + "parenthesized_statements" + "method_parameters" + "array_pattern" + "hash_pattern" + "if" + "unless" + "case" + "case_match" + "when" + "block" + "do_block" + "begin" + "integer" + "identifier" + "constant" + "simple_symbol" + "hash_key_symbol" + "symbol_array" + "string" + "string_array" + "heredoc_body" + "regex" + "argument_list" + "interpolation" + "instance_variable" + "global_variable" + ) + eol) + #'ruby-ts--sexp-p)) + ;; AFAIK, Ruby can not nest methods (setq-local treesit-defun-prefer-top-level nil) |