Skip to content
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

Add backward jump mapping #13

Merged
merged 4 commits into from
Dec 17, 2019
Merged

Add backward jump mapping #13

merged 4 commits into from
Dec 17, 2019

Conversation

hrsh7th
Copy link
Owner

@hrsh7th hrsh7th commented Dec 11, 2019

No description provided.

@hrsh7th hrsh7th mentioned this pull request Dec 11, 2019
@pwntester
Copy link

Thanks for implementing it, I had some trouble with muliple choice placeholders.

Does it work for you with a snippet such as?

{
  "foo": {
    "prefix": "foo",
    "body": [
        "FOO ${1:test}",
        "BAZ ${3|baz,lol,luz|}",
        "BAR ${2:bar}",
        "LM ${TM_CURRENT_LINE}"
    ],
    "description": "FOO TEST."
  }
}

In my case (using the following mappings:

imap <expr> <Tab> vsnip#available() ? '<Plug>(vsnip-expand-or-jump)' : '<Tab>'
smap <expr> <Tab> vsnip#available() ? '<Plug>(vsnip-expand-or-jump)' : '<Tab>'
imap <expr> <S-Tab> vsnip#available() ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
smap <expr> <S-Tab> vsnip#available() ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'

)

jumping forward skips the BAZ placeholder so it jumps from FOO to BAR
When on BAR, jumping backwards also skips BAZ so it jumps back to FOO

@hrsh7th
Copy link
Owner Author

hrsh7th commented Dec 12, 2019

It is my mistake. I understood the reason.
But it will need breaking change to solve it...
Anyway, fix it.

@hrsh7th
Copy link
Owner Author

hrsh7th commented Dec 15, 2019

@pwntester I've fixed the issue. Please check it if you have time.

It has breaking change, please check https://github.com/hrsh7th/vim-vsnip/pull/13/files#diff-4e12c6a37ff2cbb2c93d1b33324a6051R42 before check.

@pwntester
Copy link

Thanks,

Tried with:

imap <expr> <Tab> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<Tab>'
smap <expr> <Tab> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<Tab>'
imap <expr> <S-Tab> vsnip#available(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
smap <expr> <S-Tab> vsnip#available(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'

and got the same problems. Is that a correct config?

@hrsh7th
Copy link
Owner Author

hrsh7th commented Dec 16, 2019

@pwntester Ah, Sorry. The jump sequence is right.
Jump sequence is using tabstop order so the case should jump FOO -> BAR -> BAZ.

Your config is right.
If pr has no other problem, I will merge it.

P.S. If you want FOO -> BAZ -> BAR -> BAZ -> FOO, change tabstop number simply.

@pwntester
Copy link

pwntester commented Dec 16, 2019

oh my bad, I had incorrect order in placeholders. Now its working as expected, thanks!

The only odd thing is that first time that I get to the multi-option placeholder (2 after fixing order), the menu is displayed and immediatly closed. If then I move to 3rd placeholder and then back to the 2nd one, the menu is displayed and it stays.

Do you get the same behaviour?

@hrsh7th
Copy link
Owner Author

hrsh7th commented Dec 17, 2019

You use auto-completion engine, so pum is overwitten by it.
I want to fix it but it's difficult...

@hrsh7th
Copy link
Owner Author

hrsh7th commented Dec 17, 2019

the choice problemcis not related this PR.
So the PR ok to merge, I think.

@hrsh7th hrsh7th merged commit 3b825d0 into master Dec 17, 2019
@hrsh7th hrsh7th deleted the prev branch December 23, 2019 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants