Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 5 additions & 15 deletions lua/decipher/motion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions tests/dot_repeat_spec.lua
Original file line number Diff line number Diff line change
@@ -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)
Loading