nvim-better-n icon indicating copy to clipboard operation
nvim-better-n copied to clipboard

Repeating f, F, t, and T mappings with n/N breaks when remapping ;

Open bmrips opened this issue 8 months ago • 2 comments

When you remap ;, you can not repeat f/F/t/T mappings with n/N.

I compared the last two commits and observed that the error only occurs on the latest commit.

This is a minimal working example:

-- ################################################
-- ### USAGE: nvim --clean -u better-n.lua ###
-- ################################################

local root = vim.fn.stdpath("run") .. "/nvim/nvim-better-n"
vim.fn.mkdir(root, "p")

-- set stdpaths to use root
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    'jonatan-branting/nvim-better-n',
    event = 'VeryLazy',
    config = true,
  },
  -- ##################################################################
  -- ### ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
  -- ##################################################################
}
require("lazy").setup(plugins, { root = root .. "/plugins" })
require("lazy").sync({ show = false, wait = true })

-- ############################################################################
-- ### ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
-- ############################################################################
vim.keymap.set({ 'n', 'o', 'x' }, ';', ':')

bmrips avatar Apr 25 '25 10:04 bmrips

Ah, thanks for the report!

In the latest PR, I started extracting the rhs of a mapping to make sure we can support mapping ]] and such, which feels builtin, but gets remapped on a filetype basis.

This causes problems when you don't want to use the remap (but rather, the original command). This is an annoying problem. I think I need to introduce some sort of remap/noremap option when creating a repeatable mapping.

jonatan-branting avatar Apr 25 '25 13:04 jonatan-branting

I see. The additional option sounds like a good idea!

bmrips avatar Apr 25 '25 21:04 bmrips