From 50fd58be614230e9f0ad5fcf79aa7a5f3a499e04 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 14 Jan 2023 22:41:00 +0100 Subject: [PATCH] Use treesit-sentence-type-regexp in java-ts-mode Initial support for forward/backward-sentence movement with tree-sitter. Include all statements, and some declarations. Don't include the bigger declarations we don't want to jump over too big blocks of code. * lisp/progmodes/java-ts-mode.el (java-ts-mode): Add relevant node types to treesit-sentence-type-regexp. --- lisp/progmodes/java-ts-mode.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 5f4c1275f66..eac052ca4f1 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -319,6 +319,14 @@ Return nil if there is no name or if NODE is not a defun node." "module_declaration"))) (setq-local treesit-defun-name-function #'java-ts-mode--defun-name) + (setq-local treesit-sentence-type-regexp + (regexp-opt '("statement" + "local_variable_declaration" + "field_declaration" + "module_declaration" + "package_declaration" + "import_declaration"))) + ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list -- 2.39.5