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
Jump by sign names #8
Comments
Hi there!
Would you mind giving an example use case for this? I'm not sure (though I
could certainly be wrong) if signs would always wind up with the same ids
between sessions, or whenever the plugin that generated them re-generates
them, so why would a mapping to a particular id be useful?
…On Thu, Sep 20, 2018, 09:53 Brendan Maginnis ***@***.***> wrote:
It would be nice to be able to set up a mapping something like
nnoremap ]d signjump#next_sign(123, 234)
which would only jump to signs 123 and 234 instead of all signs
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAr7dd4FhwI8N02IX06AYBcAgQmVQn6bks5uc8gkgaJpZM4WyiFy>
.
|
Hi! Maybe I didnt understand enough about signs but I spotted a usage here: Having looked a bit closer at this https://github.com/w0rp/ale/blob/06132954b12ba87c7bba8fb7d5a40e4ff8b774e8/autoload/ale/sign.vim#L126 it would seem that signs with different ids can be of the same type. I guess ideally the mapping would be able to take a list of sign names instead of ids then |
Actually, that would be me in this case :) When writing the plugin, I had only read enough about them as I needed to implement what I have now. I didn't realize that the sign IDs were manually set. Thank you for the examples as well, I can see how this would be useful. |
So my current thinking is to allow passing a list of sign IDs to noremap ]d @=signjump#next_sign([123, 456, 789])<CR> Keep in mind that different signs can have the same ID, so in this way plugins that utilize specific IDs for their signs could be filtered to be the only ones jumped to. Is this roughly what you had in mind? |
I think having read a little more about it, it should work by sign names instead of sign ids. That way I could have something like noremap ]e @=signjump#next_sign(['ALEErrorSign', 'ALEErrorStyleSign'])<CR>
noremap ]w @=signjump#next_sign(['ALEWarningSign', 'ALEWarningStyleSign'])<CR> |
Yeah, I'm liking this idea. I'll work on adding this later in the day. Thank you for your interest! |
@brendanator Hi there! I've pushed some commits to master that adds this functionality. You can create your mappings by hand, however I highly recommend that you use the experimental helper function As an example, you could add the following to your configuration: call signjump#add_name_map(']e', 'next', ['ALEErrorSign', 'ALEErrorStyleSign'])
call signjump#add_name_map(']w', 'next', ['ALEWarningSign', 'ALEWarningStyleSign']) This would do the same thing as the example you gave in your last comment, with the addition of a visual mode mapping as well. In fact, the sign names are interpreted as patterns, so you could even do: call signjump#add_name_map(']e', 'next', ['ALEError'])
call signjump#add_name_map(']w', 'next', ['ALEWarning']) Please let me know what you think, and if you have any further suggestions. |
Looks good! Thanks Adding the mapping directly works for me nmap [r @=signjump#prev_sign(['ALEErrorSign'], 1)<cr>
xmap [r @=signjump#prev_sign(['ALEErrorSign'], 1)<cr> but using I suspect this can be easily fixed by moving signjump#add_name_map into the autoload file I also spotted that if there's no matching signs the cursor is moved to the beginning of the line. Ideally it would be left where it is |
I can't reproduce either of those problems with a fresh user and Vim config using vim-plug. Are you attempting to call |
I call it after
Can confirm the jump to start of line issue too |
Hmm...I don't know why I can't reproduce this; perhaps I'm missing something. Could you share your nvim configuration, please? Could you also try to reproduce this behavior with a minimal configuration? |
I just realized you wrote line and not file. 😓 Yeah, I can reproduce that; that's not supposed to happen. I'm still trying to figure out why I should probably just make |
I pushed a small commit bdc30b9 that makes the map function global, which should solve the unknown function problem (I'd still like to know the reason behind its cause, but oh well). |
That doesn't work either. The problem is the load order of scripts.
The solution is to put |
I was under the impression that after Thank you for your patience, it seems there's many pitfalls when it comes to Vim scripting/plugin authoring. |
Great! This works. Thank you |
It would be nice to be able to set up a mapping something like
which would only jump to signs 123 and 234 instead of all signs
The text was updated successfully, but these errors were encountered: