-
Notifications
You must be signed in to change notification settings - Fork 291
feat(keymap): add jump_by
option to navigate by item property
#2085
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
base: main
Are you sure you want to change the base?
Conversation
@mikavilpas, could you try this and let me know if it works for you? |
Works for me! output.mp4suggestion: the |
Introduce `jump_by` option for `select_next` and `select_prev` commands to jump to the item whose specified property differs from the current one. Support primitive properties (`string`, `number`, `boolean`) of a completion item, including: - client_id - client_name - deprecated - exact - kind - score - score_offset - source_id - source_name Honor cycling, set by `completion.list.cycle.from_[top|bottom]`. Falls back to `count` when no match is found. Example, jump to the next/previous `source_id`: ```lua opts.keymap = { -- ... ['<C-f>'] = { function(cmp) return cmp.select_next({ jump_by = 'source_id' }) end, 'fallback', }, ['<C-b>'] = { function(cmp) return cmp.select_prev({ jump_by = 'source_id' }) end, 'fallback', }, }, ``` Closes #1890
9f0cc38
to
3705d3a
Compare
Thanks for the quick feedback and for catching that typo — fixed it! |
This is really cool! Perhaps it makes sense to provide a
Perhaps it makes more sense to return opts.keymap = {
-- ...
['<C-f>'] = {
function(cmp) return cmp.select_next({ jump_by = 'source_id' }) end,
'select_next',
'fallback',
},
['<C-b>'] = {
function(cmp) return cmp.select_prev({ jump_by = 'source_id' }) end,
'select_prev',
'fallback',
},
}, P.S. Sorry for the pile up of PRs. I'll be slow to respond for another few weeks, doing a bit of traveling |
Someone? You mean Mika, right? 😄 Either way works for me. The current setup is simple, easy to use, and has a solid list of jump props, nicely autocompleted. What’s the real benefit of using a function here? Got a concrete example?
Good point, I’ll address that.
No worries, take your time and enjoy your travels, you only live once! |
Haha it wasn't Mika but I can't find the poster anymore. The use case was skipping past copilot suggestions since they use |
Selecting an item was always possible but with the introduction of the `jump_by` feature, it now *may* not select an item depending on the context. Thus, we need to implements a fallback mechanism for the `select_prev` and `select_next` commands when selection fails.
Thanks for the explanation! I'll see what I can do about it. To handle the fallback, I had to get rid of If you have any other suggestions on how to tackle this, I’d be happy to hear them! |
Introduce
jump_by
option forselect_next
andselect_prev
commands to jump to the item whose specified property differs from the current one.Support primitive properties (
string
,number
,boolean
) of a completion item, including:Honor cycling, set by
completion.list.cycle.from_[top|bottom]
.Example, jump to the next/previous
source_id
:Closes #1890