Iron-E / nvim-libmodal

Create new "modes" for Neovim!
Other
118 stars 7 forks source link

feat: `Mode:exit` #30

Closed Iron-E closed 8 months ago

Iron-E commented 8 months ago

Closes #28.

Allows closing modes with self:exit

local M = {}

M.mode1 = {
  m = function()
    vim.notify('Mode 1')
  end,
  n = function(self)
    require('libmodal').mode.enter('My mode 2', M.mode2)
    self:exit()
  end
}

M.mode2 = {
  m = function()
    vim.notify('Mode 2')
  end,
  n = function(self)
    require('libmodal').mode.enter('Mode 1', M.mode1)
    self:exit()
  end
}

vim.keymap.set('n', 'M', function()
  require('libmodal').mode.enter('Mode 1', M.mode1)
end)