Closed JamesMowery closed 7 months ago
I was able to resolve by doing the following in my hardtime.lua plugin (per issue with another distro):
return {
"m4xshen/hardtime.nvim",
command = "Hardtime",
event = "BufEnter",
dependencies = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
},
keys = {
{ "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"' },
{ "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"' },
},
opts = {},
}
Are there any other change to LazyVim I need to make to ensure no conflicts with this issue and potentially any others?
Update: The above change actually did not resolve the issue. Getting the following issue with the command box popping up on LazyVim when using j and k in a file now. Very strange.
v:count || mode(1)[0:1] == "no" ? "j" : "gj"
This kind of mapping only work for Vim-style mapping when using :map
. For Lua you should convert this into a function.
Example:
vim.keymap.set({ "n", "x" }, "j", function()
return vim.v.count > 0 and "j" or "gj"
end, { noremap = true, expr = true })
vim.keymap.set({ "n", "x" }, "k", function()
return vim.v.count > 0 and "k" or "gk"
end, { noremap = true, expr = true })
For someone coming to this later on, this works without problem -
{
'm4xshen/hardtime.nvim',
dependencies = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim' },
opts = {},
command = 'Hardtime',
event = 'BufEnter',
keys = {
{ 'n', 'j', '<cmd>Hardtime<CR>', desc = "Hardtime" },
{ 'n', 'k', '<cmd>Hardtime<CR>', desc = "Hardtime" },
{ 'n', 'gj', '<cmd>Hardtime<CR>', desc = "Hardtime" },
{ 'n', 'gk', '<cmd>Hardtime<CR>', desc = "Hardtime" },
},
},
Repeated h/j key presses are not being picked up when using LazyVim. Any advice on how to resolve?