SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.55k stars 691 forks source link

Cannot map <tab> in selection mode, despite not using it as UltiSnips bind #1558

Closed oiiiiiiii closed 1 month ago

oiiiiiiii commented 1 month ago

When I bind something to tab in select mode, I can only trigger that bind when there are no tabstops generated by snippets.

Expected behavior:

I can bind tab the way I like when I don't even use it for UltiSnips

Actual behavior:

I can not.

Steps to reproduce

  1. Setup g:UltiSnipsExpandTrigger to something entirely different than tab
  2. Bind something to tab in select mode (smap whatever
  3. Trigger a snippet with different tabstops
  4. Enter the select mode (gh) and select something (using arrows)
  5. Try triggering the bind in selection mode (doesn't work)

Context: The select mode is also being used for default placeholders (which is where I would like to have my own binding to tab) but this behavior also occurs in snippets that don't use that and when I manually select something as described in the reproduction steps.

If there are no active snippets, it works perfectly fine when I select something and trigger my custom map.


oiiiiiiii commented 1 month ago

Found a workaround by adding to g:UltiSnipsMappingsToIgnore. If this is the intended way to do it than I guess this issue can be closed

SirVer commented 1 month ago

Could it be that you wanted to map it in visual mode instead of select mode? Did you use xmap or smap or the much broader vmap? The expectation of a user in select mode (which is not visual mode) is that typing overwrites, so most select mode mapping that map to typable characters are done in error.

This is a common mistake, explained (maybe poorly) in https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt#L381. If you indeed want something mapped in select mode to tab, then setting the UltiSnipsMappingsToIgnore

oiiiiiiii commented 1 month ago

No I really meant the select mode, not visual mode. My problem was that I wanted to map to UltiSnips#JumpForwards() only if UltiSnips#CanJumpForward() because otherwise I want to jump to the next placeholder of my LSP provided snippets (that also use select mode for default values). But I couldn't manually map in s mode using smap or vmap, even when I didn't bind for ultisnips at all. But now it works using UltiSnipsMappingsToIgnore.