From 8b84ab86253961b04bf95cd2dd9d9efe51237dc0 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 26 Feb 2022 19:52:40 +0100 Subject: [PATCH] home: vim: add statement objects/moves And document it. --- home/vim/after/plugin/mappings/tree-sitter-textobjects.vim | 3 +++ home/vim/plugin/settings/tree-sitter.vim | 3 +++ 2 files changed, 6 insertions(+) diff --git a/home/vim/after/plugin/mappings/tree-sitter-textobjects.vim b/home/vim/after/plugin/mappings/tree-sitter-textobjects.vim index 0014975..9cabd91 100644 --- a/home/vim/after/plugin/mappings/tree-sitter-textobjects.vim +++ b/home/vim/after/plugin/mappings/tree-sitter-textobjects.vim @@ -4,10 +4,12 @@ local wk = require("which-key") local motions = { ["]m"] = "Next method start", ["]M"] = "Next method end", + ["]S"] = "Next statement start", ["]]"] = "Next class start", ["]["] = "Next class end", ["[m"] = "Previous method start", ["[M"] = "Previous method end", + ["[S"] = "Previous statement start", ["[["] = "Previous class start", ["[]"] = "Previous class end", } @@ -22,6 +24,7 @@ local objects = { ["af"] = "a function", ["if"] = "inner function", ["ak"] = "a comment", + ["aS"] = "a statement", } wk.register(motions, { mode = "n" }) diff --git a/home/vim/plugin/settings/tree-sitter.vim b/home/vim/plugin/settings/tree-sitter.vim index 059fac7..ab38090 100644 --- a/home/vim/plugin/settings/tree-sitter.vim +++ b/home/vim/plugin/settings/tree-sitter.vim @@ -24,6 +24,7 @@ ts_config.setup({ ["af"] = "@function.outer", ["if"] = "@function.inner", ["ak"] = "@comment.outer", + ["aS"] = "@statement.outer", }, }, move = { @@ -32,6 +33,7 @@ ts_config.setup({ set_jumps = true, goto_next_start = { ["]m"] = "@function.outer", + ["]S"] = "@statement.outer", ["]]"] = "@class.outer", }, goto_next_end = { @@ -40,6 +42,7 @@ ts_config.setup({ }, goto_previous_start = { ["[m"] = "@function.outer", + ["[S"] = "@statement.outer", ["[["] = "@class.outer", }, goto_previous_end = {