branch: externals/csharp-mode commit 1c2b9cb51b6ecc8bf52d3f040b6c02639310a153 Author: Theodor Thornhill <t...@thornhill.no> Commit: Theodor Thornhill <t...@thornhill.no>
Add more nodes to beginning/end-of-defun I did not yet extract that list of declarations into a customizable variable, but I think that is a reasonable thing to do at some point. Not completely sure how this should behave. Now tree-sitter defines things as a tree (obviously...), so we need to be able to jump to siblings as well. Add more nodes to beginning/end-of-defun I did not yet extract that list of declarations into a customizable variable, but I think that is a reasonable thing to do at some point. Not completely sure how this should behave. Now tree-sitter defines things as a tree (obviously...), so we need to be able to jump to siblings as well. --- csharp-tree-sitter.el | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/csharp-tree-sitter.el b/csharp-tree-sitter.el index 3518f8d..976519f 100644 --- a/csharp-tree-sitter.el +++ b/csharp-tree-sitter.el @@ -26,6 +26,7 @@ ;;; Code: (require 'cl-lib) +(require 'cl-extra) (require 'seq) (require 'tree-sitter) @@ -317,14 +318,26 @@ (defun csharp-beginning-of-defun () "Replacement-function for `beginning-of-defun' for `csharp-tree-sitter-mode'." (interactive) - (when-let ((method (tree-sitter-node-at-point 'method_declaration))) - (goto-char (tsc-node-start-position method)))) + (when-let ((declaration + (cl-some (lambda (decl) + (tree-sitter-node-at-point decl)) + '(method_declaration + constructor_declaration + class_declaration + namespace_declaration)))) + (goto-char (tsc-node-start-position declaration)))) (defun csharp-end-of-defun () "Replacement-function for `end-of-defun' for `csharp-tree-sitter-mode'." (interactive) - (when-let ((method (tree-sitter-node-at-point 'method_declaration))) - (goto-char (tsc-node-end-position method)))) + (when-let ((declaration + (cl-some (lambda (decl) + (tree-sitter-node-at-point decl)) + '(method_declaration + constructor_declaration + class_declaration + namespace_declaration)))) + (goto-char (tsc-node-end-position declaration)))) (defun csharp-delete-method-at-point () "Deletes the method at point."