Giter VIP home page Giter VIP logo

Comments (7)

Iron-E avatar Iron-E commented on June 11, 2024 1

Thanks for bringing it to my attention!

I have some time to look at this and the other issue today; this should hopefully be a simple fix

from nvim-libmodal.

mawkler avatar mawkler commented on June 11, 2024 1

Awesome! Thank you!

from nvim-libmodal.

Iron-E avatar Iron-E commented on June 11, 2024

I've pushed to a new branch. v:count can't be updated manually, so I've created an alternate facility which tracks count until commands are executed:

local my_mode = {
	g = function()
		vim.notify('count: ' .. vim.g.myModeModeCount)
	end
}

vim.keymap.set('n', 'M', function()
	require('libmodal').mode.enter('My mode', my_mode)
end)

Let me know if this will work for you :)

from nvim-libmodal.

mawkler avatar mawkler commented on June 11, 2024

Too bad v:count can't be set manually. It doesn't look as clean but it does work for me. Thank you :)

from nvim-libmodal.

Iron-E avatar Iron-E commented on June 11, 2024

Given that #30 allows the self param, I can add self.count in a followup PR. That might look a little nicer 😅

from nvim-libmodal.

mawkler avatar mawkler commented on June 11, 2024

Yeah that might be a good idea 🙂

from nvim-libmodal.

Iron-E avatar Iron-E commented on June 11, 2024

The PR was updated. This now works:

local libmodal = require 'libmodal'

-- register keymaps for splitting windows and then closing windows
local fooModeKeymaps =
{
	h = function(self)
		self.count:set(0)
	end,
	G = function(self)
		local count = self.count:get()
		vim.api.nvim_command('norm! ' .. count .. 'G')
	end,
}

-- enter the mode using the keymaps
libmodal.mode.enter('FOO', fooModeKeymaps)

And FYI, I changed :exit() to just be a simple flag:

local libmodal = require 'libmodal'

local barModeKeymaps = {
	p = function() vim.notify('Hello!') end,
}

-- register key commands and what they do
local fooModeKeymaps =
{
	q = 'let g:fooModeExit = 1', -- exits all instances of this mode
	w = function(self)
		self.exit:set_global(true) -- exits all instances of the mode (with lua)
	end,
	x = function(self)
		self.exit:set_local(true) -- exits this instance of the mode
	end,
	y = function(self)
		self:switch('Bar', barModeKeymaps) -- enters Bar and then exits Foo when it is done
	end,
	z = libmodal.mode.switch('Bar', barModeKeymaps), -- the same as above, but more convenience
}

-- enter the mode using the keymaps created before
libmodal.mode.enter('FOO', fooModeKeymaps)

Documentation has been updated for what values are available in self, and what functions (e.g. :get(), :set_local()) are available:

from nvim-libmodal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.