From ba36c8c9f857a617b94211054308ef436b8a60ad Mon Sep 17 00:00:00 2001 From: MisanthropicBit Date: Thu, 10 Sep 2026 21:34:21 +0200 Subject: [PATCH 1/2] Enable dot repeat --- lua/decipher/motion.lua | 20 +++++--------------- tests/dot_repeat_spec.lua | 12 ++++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 tests/dot_repeat_spec.lua diff --git a/lua/decipher/motion.lua b/lua/decipher/motion.lua index ddea749..27e7be2 100644 --- a/lua/decipher/motion.lua +++ b/lua/decipher/motion.lua @@ -3,36 +3,26 @@ local motion = {} local selection = require("decipher.selection") --- If the type describes a motion or not ----@param type string | nil +---@param type string? ---@return boolean local function is_motion_type(type) return type == "block" or type == "char" or type == "line" end --- Operator function for encode/decoding motions ----@param maybe_motion? string either the type of motion or nil for the initial call ----@param handler fun(): nil the motion function to call when the motion is completed +---@param maybe_motion string? either the type of motion or nil for the initial call +---@param handler fun() the motion function to call when the motion is completed local function _decipher_motion(maybe_motion, handler) -- If we did not receive a motion type, it is a codec name and we set up -- the operatorfunc for the g@ motion operator. Otherwise, the user - -- completed the motion operator and we call decipher.encode_motion + -- completed the motion operator and we encode/decode if not is_motion_type(maybe_motion) then - local old_operatorfunc = vim.go.operatorfunc - -- Use a global function for the operatorfunc until the global option -- supports accepting a lua function: https://github.com/neovim/neovim/issues/14157 - _G._decipher_operatorfunc = function(_motion) - -- Restore the old operatorfunc and remove the global function - vim.go.operatorfunc = old_operatorfunc - _G._decipher_operatorfunc = nil - - _decipher_motion(_motion, handler) - end + _G._decipher_operatorfunc = handler vim.go.operatorfunc = "v:lua._decipher_operatorfunc" vim.api.nvim_feedkeys("g@", "n", false) - else - handler() end end diff --git a/tests/dot_repeat_spec.lua b/tests/dot_repeat_spec.lua new file mode 100644 index 0000000..257cf81 --- /dev/null +++ b/tests/dot_repeat_spec.lua @@ -0,0 +1,12 @@ +local vader = require("decipher.util.vader") +local given, normal, expect = vader.given, vader.normal, vader.expect + +describe("dot repeat", function() + it("supports dot repeat", function() + given("bGlnaHQgdw==\nbGlnaHQgdw==", function(context) + normal("gg0griwj.") + + expect({ "light w", "light w" }, context.buffer) + end) + end) +end) From cf00af7cae7505f692a0d5e07f17d15cee9fc14f Mon Sep 17 00:00:00 2001 From: MisanthropicBit Date: Thu, 10 Sep 2026 21:39:15 +0200 Subject: [PATCH 2/2] Add v0.12.0 to test workflow --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 71578f0..2a9c35b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - neovim_version: ['v0.8.0', 'v0.9.0', 'v0.10.0', 'v0.11.0', 'nightly'] + neovim_version: ['v0.8.0', 'v0.9.0', 'v0.10.0', 'v0.11.0', 'v0.12.0', 'nightly'] steps: - uses: actions/checkout@v4