Skip to content

Working example for neovim (custom text object with repeat) #92

Description

@JoseConseco

I had trouble to make vim-repeat work in neovim with lua, but finally here it is:

--  tpope/vim-repeat - allows . repeat
vim.api.nvim_create_user_command( 'BigInnerWord',
    function() get_big_word('i') end,
    {}
)
vim.fn['repeat#set'](":BigInnerWord"..t'<CR>')  -- the vim-repeat magic
vim.keymap.set('o', 'W', ':BigInnerWord'..t'<CR>') 

t() function is just nvim helper:

local function t(str)
    return vim.api.nvim_replace_termcodes(str, true, true, true)
end 

All you have to do is to write your custom : get_big_word('i') - function - in my case I wanted to write custom big WORD text object.
I guess it should work for any custom lua functions, not just o .
Hopefully people will find this useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions