1

I recently installed the ultisnips plugin on neovim, and I'm having an issue with it:

When I enable ultisnips, when I press < in visual mode, there's a delay until my lines are left-shifted, but my right-shifting using > works instantly.

If I run :verbose map <, I see the following

x  <nop>       * :call UltiSnips#SaveLastVisualSelection()<CR>gvs
        Last set from ~/.vim/plugged/ultisnips/autoload/UltiSnips/map_keys.vim line 64
s  <nop>       * <Esc>:call UltiSnips#ExpandSnippet()<CR>
        Last set from ~/.vim/plugged/ultisnips/autoload/UltiSnips/map_keys.vim line 62

And from what I see, the bindings are coming from the snippet files and they're not my mapping, so I was wondering if there's any way for me fix the issue.

Thank you

Farzad
  • 1,770
  • 4
  • 26
  • 48
  • Are you sure you haven't set `g:UltiSnipsExpandTrigger`? The default is ``. It looks like you've set yours to ``. – Jake Grossman Sep 19 '20 at 06:42
  • You're completely right @JakeGrossman, I have `let g:UltiSnipsExpandTrigger = ""` in my settings (I think it was because it was interfering with something in `coc`), so does that have anything to do with the behavior I'm seeing? – Farzad Sep 19 '20 at 18:03
  • Yes. Do you want to disable mappings for UltiSnips? The `` isn't the action in this case, it's the mapping itself. So effectively what you've done is map the literal keys `` to an UltiSnips function. – Jake Grossman Sep 19 '20 at 18:42
  • Actually now I remember: I added that line because of [this GitHub comment](https://github.com/SirVer/ultisnips/issues/1052#issuecomment-504719268) because it was interfering with `coc`'s tab completion. Do you have any suggestions about what I can do? And yes, I think I can confirm that if I remove that line from my settings, the left-shifting seems to work fine, but then I can't use TAB to navigate `coc`'s completion menu – Farzad Sep 20 '20 at 03:09
  • I tried putting the line in my Vimrc and it gives me an error on startup, saying `E117: Unknown function: UltiSnips#map_keys#MapKeys` – Farzad Sep 20 '20 at 04:09
  • You’re right, I didn’t look too close. Really you could just set it to any mapping you don’t use, check out `:h key-codes` to see your options. – Jake Grossman Sep 20 '20 at 05:27

1 Answers1

1

You have set g:UltiSnipExpandTrigger="<nop>".

Line 62 of ultisnips/blob/master/autoload/UltiSnips/map_keys.vim:

exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandTrigger()<cr>"

You can see that this does not, in fact, disable a mapping for g:UltiSnipExpandTrigger. Instead, it maps the literal keys <nop> to <Esc>:call UltiSnips#ExpandTrigger()<cr>.

Vim is waiting once you type < to see if you will then press nop>. After waiting a period of time, only then will it shift your selection left (how long depends on the value of 'timeoutlen').

What you need to do is set g:UltiSnipExpandTrigger to a different key. If you want to disable it, you could map it to a function key between 13 and 19 (you probably don't have it on your keyboard):

let g:UltiSnipExpandTrigger = "<F13>"
Jake Grossman
  • 382
  • 2
  • 9