nvim-treesitter-textobjects icon indicating copy to clipboard operation
nvim-treesitter-textobjects copied to clipboard

Allow repeating swap operation

Open andymass opened this issue 4 years ago • 1 comments

An attempt at #52; allows repeating swap with .

andymass avatar Apr 23 '21 01:04 andymass

Is this stale?

stellarhoof avatar Apr 01 '22 02:04 stellarhoof

@clason it does not seem to be possible to set operatorfunc to a Lua function. I would prefer to wait for this feature or a general way to make a Lua function repeatable (without

The best thing that I could get working was (see #343)

        local function fn()
          if opts.repeatable then
            _G._nvim_treesitter_textobject_last_function = function()
              require("nvim-treesitter.textobjects." .. submodule)[function_call](query)
            end
            vim.o.opfunc = "v:lua._nvim_treesitter_textobject_last_function"
            vim.api.nvim_feedkeys("g@l", "n", false)
          else
            require("nvim-treesitter.textobjects." .. submodule)[function_call](query)
          end
        end
        vim.keymap.set(
          keymap_modes,
          mapping,
          fn,
          { buffer = bufnr, silent = true, remap = false, desc = mapping_description }
        )

since opfunc seems to insist on a string

theHamsta avatar Dec 22 '22 13:12 theHamsta

it does not seem to be possible to set operatorfunc to a Lua function.

That's right; this is tracked here: https://github.com/neovim/neovim/issues/18132 and here: https://github.com/neovim/neovim/issues/14157

Your workaround seems similar to https://github.com/neovim/neovim/issues/14157#issuecomment-1320787927

clason avatar Dec 22 '22 14:12 clason

Superseded by #343

theHamsta avatar Dec 23 '22 13:12 theHamsta