-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep labels unchanged on first press of the repeat key #170
Comments
Another issue I just noticed is that the repeat keys still seem to be active even when you are no longer in the context of leaping. This leads to some weird behavior when using repeat keys with flit (with multiline disabled), as leap's repeat will take over and cause the cursor to jump to the next occurrence of the previous leap pattern. |
These keys repeat the last motion directly, the intended use case is doing a IMO there is not much value in
That said, if this annoys you a lot, you can set up an autocommand that maps
Hmm, it shouldn't... in flit, |
Off-topic: what is the colorscheme? Looks nice :) |
Thanks for the thorough reply, it was really insightful.
Oh wow, I didn't even realize -- edit: this somehow breaks highlighting for unlabeled phase one targets
config = function()
local sk = (require "leap").opts.special_keys
local saved_next_target, saved_prev_target
local id_1, id_2
local function set_mappings()
pcall(vim.api.nvim_del_autocmd, id_2)
saved_next_target = sk.next_target
saved_prev_target = sk.prev_target
sk.next_target = ";"
sk.prev_target = ","
local function remove_mappings()
pcall(vim.api.nvim_del_autocmd, id_1)
sk.next_target = saved_next_target
sk.prev_target = saved_prev_target
id_1 = vim.api.nvim_create_autocmd("User", { pattern = "LeapPatternPost", once = true, callback = set_mappings })
end
id_2 = vim.api.nvim_create_autocmd("User", { pattern = "LeapLeave", once = true, callback = remove_mappings })
return nil
end
id_1 = vim.api.nvim_create_autocmd("User", { pattern = "LeapPatternPost", once = true, callback = set_mappings })
end, While this does seem to work for the most part, it unfortunately overwrites the default
Oh wait, I think there might be a bug with flit. When pressing I also might've been confused because when there is only a single occurence of a character on a line, pressing
I think that makes a lot of sense, and would align better with default vim behavior, since tldr; I think that it might be more intuitive for
Cappuccin with these highlight groups :) local colors = require("catppuccin.palettes").get_palette()
LeapMatch = { fg = colors.text, bold = true, nocombine = true },
LeapLabelPrimary = { fg = colors.pink, bold = true, nocombine = true },
LeapLabelSecondary = { fg = colors.blue, bold = true, nocombine = true }, |
I'm gonna close this issue now since I believe it will be solved by the repeat parameter hinted in #176. |
Nope, unrelated :) |
Oh whoops I completely forgot what this issue was originally about, I was mainly referring to the inconsistent |
Here is a clean solution: local set_phase2_traversal_keys
do
-- Set a counter in this closure and generate a unique autogroup
-- each time, so that multiple key pairs can be defined (e.g. ;/,
-- and s/S).
local n = 0
set_phase2_traversal_keys = function (next_key, prev_key)
local group = ('LeapSetPhase2TraversalKeys_' .. n)
n = n + 1
vim.api.nvim_create_augroup(group, {})
vim.api.nvim_create_autocmd('User', {
pattern = 'LeapPatternPost',
group = group,
callback = function ()
local args = require('leap').state.args -- argument table passed to `leap()`
if args['repeat'] or args.target_windows then
return
end
-- Note: `require('leap').opts` would dispatch to
-- `opts.default` (see `init.fnl`).
local opts = require('leap.opts').default
local opts_cc = require('leap.opts').current_call
if not opts_cc.special_keys then
-- Copy the defaults - we need to keep the group switch
-- keys - the `__index` method of `opts` will not fall
-- back to `opts.default` for `special_keys` anymore if
-- there is such a table in `current_call`. (And obviously
-- deep-copy, don't overwrite the original.)
opts_cc.special_keys = vim.deepcopy(opts.special_keys)
end
local cc_next = opts_cc.special_keys.next_target or {}
local cc_prev = opts_cc.special_keys.prev_target or {}
if (type(cc_next) == 'string') then cc_next = {cc_next} end
if (type(cc_prev) == 'string') then cc_prev = {cc_prev} end
table.insert(cc_next, next_key)
table.insert(cc_prev, prev_key)
opts_cc.special_keys.next_target = cc_next
opts_cc.special_keys.prev_target = cc_prev
end
})
end
end
set_phase2_traversal_keys(';', ',')
set_phase2_traversal_keys('s', 'S') Actually, it might be worth including this in |
Hi, I'm really liking the new repeat key functionality you implemented in 108222e, but I noticed that the labels change the first time the repeat key is pressed after "leaping". Subsequent presses of the repeat key don't change the labels.
I'm assuming this is not the intended behavior? To me, it makes more since for the labels to either always remain constant, or be updated on every repeat so that the nth leapable match can always be jumped to with with the same keystroke.
Thanks for the great plugin!
The text was updated successfully, but these errors were encountered: