pounce.nvim
pounce.nvim copied to clipboard
If lazy-loaded pounce does not work for the first time
If lazy-loaded pounce does not work for the first time. However, after the first try everything works as expected. Here is my config using packer:
vim.cmd [[
nmap <leader>p <cmd>Pounce<CR>
vmap <leader>p <cmd>Pounce<CR>
omap <leader>P <cmd>Pounce<CR>
]]
use {
"rlane/pounce.nvim",
cmd = {"Pounce"},
config = function()
require "pounce".setup {
accept_keys = "JFKDLSAHGNUVRBYTMICEOXWPQZ",
debug = false
}
vim.cmd [[
nmap <leader>p <cmd>Pounce<CR>
vmap <leader>p <cmd>Pounce<CR>
omap <leader>P <cmd>Pounce<CR>
]]
end
}
I haven't used packer before. Here's my init.lua attempting to reproduce this:
return require('packer').startup(function()
vim.cmd [[
nmap <leader>p <cmd>Pounce<CR>
vmap <leader>p <cmd>Pounce<CR>
omap <leader>P <cmd>Pounce<CR>
]]
use {
"rlane/pounce.nvim",
cmd = {"Pounce"},
opt = true,
config = function()
require "pounce".setup {
accept_keys = "JFKDLSAHGNUVRBYTMICEOXWPQZ",
debug = false
}
vim.cmd [[
nmap <leader>p <cmd>Pounce<CR>
vmap <leader>p <cmd>Pounce<CR>
omap <leader>P <cmd>Pounce<CR>
]]
end
}
end)
With this config, hitting \p
starts Pounce normally for me. Could you try to reproduce the issue with a minimal config?
It seems like the config can also be shortened:
return require('packer').startup(function()
vim.cmd [[
nmap <leader>p <cmd>Pounce<CR>
vmap <leader>p <cmd>Pounce<CR>
omap <leader>P <cmd>Pounce<CR>
]]
use { "rlane/pounce.nvim", cmd = {"Pounce"}, opt = true }
end)
I know this issue is over a year old but I'll put this here to avoid opening redundant issues.
When lazy loading with lazy.nvim, highlight groups are not set at all. Because of #37 highlights are only defined on the ColorScheme
autocommand, which is called before pounce
is even loaded. If the user never switches color schemes, it won't be called again. Currently I am solving this by manually defining the highlights in the config
function of lazy
.
require('lazy').setup({
-- other plugins...
{
'rlane/pounce.nvim',
keys = {
{ 's', '<cmd>Pounce<CR>' }
},
config = function()
local str_color = vim.api.nvim_get_hl(0, { name = 'String' }).fg
local num_color = vim.api.nvim_get_hl(0, { name = 'Number' }).fg
local const_color = vim.api.nvim_get_hl(0, { name = 'Constant' }).fg
local spec_color = vim.api.nvim_get_hl(0, { name = 'Special' }).fg
vim.api.nvim_set_hl(0, 'PounceMatch', { bold = true, fg = 'bg', bg = str_color })
vim.api.nvim_set_hl(0, 'PounceUnmatched', { link = 'None' })
vim.api.nvim_set_hl(0, 'PounceGap', { bold = true, fg = 'bg', bg = num_color })
vim.api.nvim_set_hl(0, 'PounceAccept', { bold = true, fg = 'black', bg = const_color })
vim.api.nvim_set_hl(0, 'PounceAcceptBest', { bold = true, fg = 'black', bg = spec_color })
-- not required
-- require('pounce').setup{}
end
},
-- other plugins
})
I am also using this opportunity to get the colors to match my color scheme by pulling from the already defined highlights.
This gives me several ideas about user configurable highlights or dynamically changing highlights to fit the color scheme in use (or even moving to 100% lua - everything exists in the lua api for that now). I could totally start working on a PR if any of that is of interest, though I would wait for #36 to get merged first.
Could you check if #36 fixed this? It's now setting up the highlights both in the ColorScheme autocommand and when the plugin loads.
Could you check if #36 fixed this? It's now setting up the highlights both in the ColorScheme autocommand and when the plugin loads.
Must have missed that when I looked over it last. I will test when I have the chance soon.
Can confirm lazy loading works as expected now, awesome job.