Skip to content

Commit 1cd7210

Browse files
committed
fix(repeatable_move): fix repeatable_move when nil was returned; modified the README to address the change; no longer requires { expr = true }
1 parent b54cec3 commit 1cd7210

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ local ts_repeat_move = require "nvim-treesitter-textobjects.repeatable_move"
170170

171171
-- Repeat movement with ; and ,
172172
-- ensure ; goes forward and , goes backward regardless of the last direction
173-
vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_next, { expr = true })
174-
vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_previous, { expr = true })
173+
vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_next)
174+
vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_previous)
175175

176176
-- vim way: ; goes to the direction you were moving.
177177
-- vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move)
@@ -238,6 +238,7 @@ Here are some rules about the query names that should be noted.
238238
## Built-in Textobjects
239239

240240
<!--textobjectinfo-->
241+
241242
1. @assignment.inner
242243
2. @assignment.lhs
243244
3. @assignment.outer

lua/nvim-treesitter-textobjects/repeatable_move.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@ M.make_repeatable_move = function(move_fn)
2727
end
2828

2929
---@param opts_extend TSTextObjects.MoveOpts?
30-
---@return string?
3130
M.repeat_last_move = function(opts_extend)
3231
if not M.last_move then
3332
return
3433
end
3534
local opts = vim.tbl_deep_extend('force', M.last_move.opts, opts_extend or {})
3635
if M.last_move.func == 'f' or M.last_move.func == 't' then
37-
return opts.forward and ';' or ','
36+
vim.api.nvim_feedkeys(vim.v.count1 .. (opts.forward and ';' or ','), 'n', true)
3837
elseif M.last_move.func == 'F' or M.last_move.func == 'T' then
39-
return opts.forward and ',' or ';'
38+
vim.api.nvim_feedkeys(vim.v.count1 .. (opts.forward and ',' or ';'), 'n', true)
4039
else
41-
return M.last_move.func(opts, unpack(M.last_move.additional_args))
40+
M.last_move.func(opts, unpack(M.last_move.additional_args))
4241
end
4342
end
4443

queries/fennel/textobjects.scm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@
102102
rhs: (_) @assignment.rhs) @assignment.inner) @assignment.outer
103103

104104
(set_form
105-
(binding_pair
106-
lhs: (_) @assignment.lhs
107-
rhs: (_) @assignment.rhs) @assignment.inner) @assignment.outer
105+
lhs: (_) @assignment.lhs
106+
rhs: (_) @assignment.rhs) @assignment.inner @assignment.outer
108107

109108
(let_vars
110109
(binding_pair

0 commit comments

Comments
 (0)