mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Fix treesit-outline related settings
* lisp/treesit.el (treesit-outline-level): Use level 1 by default since treesit-outline--at-point now always returns the current node. * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Use 'bos' instead of 'bol'. Add "singleton_class" to 'treesit-outline-predicate'. Use new condition 'named' in 'treesit-outline-predicate' (bug#74963).
This commit is contained in:
parent
b514ec87b6
commit
44c11cd424
2 changed files with 52 additions and 52 deletions
|
|
@ -1168,7 +1168,7 @@ leading double colon is not added."
|
|||
(setq-local treesit-thing-settings
|
||||
`((ruby
|
||||
(sexp ,(cons (rx
|
||||
bol
|
||||
bos
|
||||
(or
|
||||
"class"
|
||||
"singleton_class"
|
||||
|
|
@ -1211,49 +1211,48 @@ leading double colon is not added."
|
|||
"instance_variable"
|
||||
"global_variable"
|
||||
)
|
||||
eol)
|
||||
eos)
|
||||
#'ruby-ts--sexp-p))
|
||||
(list
|
||||
,(cons (rx
|
||||
bol
|
||||
(or
|
||||
"begin_block"
|
||||
"end_block"
|
||||
"method"
|
||||
"singleton_method"
|
||||
"method_parameters"
|
||||
"parameters"
|
||||
"block_parameters"
|
||||
"class"
|
||||
"singleton_class"
|
||||
"module"
|
||||
"do"
|
||||
"case"
|
||||
"case_match"
|
||||
"array_pattern"
|
||||
"find_pattern"
|
||||
"hash_pattern"
|
||||
"parenthesized_pattern"
|
||||
"expression_reference_pattern"
|
||||
"if"
|
||||
"unless"
|
||||
"begin"
|
||||
"parenthesized_statements"
|
||||
"argument_list"
|
||||
"do_block"
|
||||
"block"
|
||||
"destructured_left_assignment"
|
||||
"interpolation"
|
||||
"string"
|
||||
"string_array"
|
||||
"symbol_array"
|
||||
"delimited_symbol"
|
||||
"regex"
|
||||
"heredoc_body"
|
||||
"array"
|
||||
"hash")
|
||||
eol)
|
||||
#'ruby-ts--list-p))
|
||||
(list ,(cons (rx
|
||||
bos
|
||||
(or
|
||||
"begin_block"
|
||||
"end_block"
|
||||
"method"
|
||||
"singleton_method"
|
||||
"method_parameters"
|
||||
"parameters"
|
||||
"block_parameters"
|
||||
"class"
|
||||
"singleton_class"
|
||||
"module"
|
||||
"do"
|
||||
"case"
|
||||
"case_match"
|
||||
"array_pattern"
|
||||
"find_pattern"
|
||||
"hash_pattern"
|
||||
"parenthesized_pattern"
|
||||
"expression_reference_pattern"
|
||||
"if"
|
||||
"unless"
|
||||
"begin"
|
||||
"parenthesized_statements"
|
||||
"argument_list"
|
||||
"do_block"
|
||||
"block"
|
||||
"destructured_left_assignment"
|
||||
"interpolation"
|
||||
"string"
|
||||
"string_array"
|
||||
"symbol_array"
|
||||
"delimited_symbol"
|
||||
"regex"
|
||||
"heredoc_body"
|
||||
"array"
|
||||
"hash")
|
||||
eos)
|
||||
#'ruby-ts--list-p))
|
||||
(text ,(lambda (node)
|
||||
(or (member (treesit-node-type node)
|
||||
'("comment" "string_content" "heredoc_content"))
|
||||
|
|
@ -1275,12 +1274,14 @@ leading double colon is not added."
|
|||
|
||||
;; Outline minor mode.
|
||||
(setq-local treesit-outline-predicate
|
||||
(rx bos (or "singleton_method"
|
||||
"method"
|
||||
"alias"
|
||||
"class"
|
||||
"module")
|
||||
eos))
|
||||
`(and ,(rx bos (or "singleton_method"
|
||||
"method"
|
||||
"alias"
|
||||
"singleton_class"
|
||||
"class"
|
||||
"module")
|
||||
eos)
|
||||
named))
|
||||
;; Restore default values of outline variables
|
||||
;; to use `treesit-outline-predicate'.
|
||||
(kill-local-variable 'outline-regexp)
|
||||
|
|
|
|||
|
|
@ -3501,7 +3501,7 @@ when a major mode sets it.")
|
|||
treesit-simple-imenu-settings))
|
||||
|
||||
(defun treesit-outline--at-point ()
|
||||
"Return the outline heading at the current line."
|
||||
"Return the outline heading node at the current line."
|
||||
(let* ((pred treesit-outline-predicate)
|
||||
(bol (pos-bol))
|
||||
(eol (pos-eol))
|
||||
|
|
@ -3551,8 +3551,7 @@ For BOUND, MOVE, BACKWARD, LOOKING-AT, see the descriptions in
|
|||
(defun treesit-outline-level ()
|
||||
"Return the depth of the current outline heading."
|
||||
(let* ((node (treesit-outline--at-point))
|
||||
(level (if (treesit-node-match-p node treesit-outline-predicate)
|
||||
1 0)))
|
||||
(level 1))
|
||||
(while (setq node (treesit-parent-until node treesit-outline-predicate))
|
||||
(setq level (1+ level)))
|
||||
(if (zerop level) 1 level)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue