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

I can't make UltiSnips to set <tab> as jump forward trigger #1554

Closed
BODH1SATVA opened this issue May 8, 2024 · 4 comments
Closed

I can't make UltiSnips to set <tab> as jump forward trigger #1554

BODH1SATVA opened this issue May 8, 2024 · 4 comments

Comments

@BODH1SATVA
Copy link

BODH1SATVA commented May 8, 2024

I want to set <tab> for both to expand and jump forward but it seems like
vim.g.UltiSnipsExpandOrJumpTrigger = '<tab>' does not work.
I thought that other maps could get in the way or it might be due to the conflict with other plugins, but I don't use <tab> in any other maps and I have tried deleting other plugins (left only VimTex and UltiSnips), It still would not work. Later I found that this does not work for any keys not just for <tab>.
vim.g.UltiSnipsJumpBackwardTrigger = '<s-tab>' works fine though.

I use lazy.nvim as my plugin manager. I have tried updating UltiSnips but it says it's up to date.

I have tried more direct way and I changed my ultisnips.lua file inside my plugins folder to have

return {"SirVer/ultisnips", 

lazy = false, 
config = function()
vim.api.nvim_set_keymap('i', '<tab>', '<C-R>=UltiSnips#ExpandSnippetOrJump()<CR>', {noremap = true, silent = true})
end

}

This works with other keys ( <c-k> for example ) but not with <tab> (also this does not remove default mappings obviously). When I try to set <tab> this way and use command :imap<tab> it gives me <C-R>=UltiSnips#ExpandSnippet()<CR> instead of <C-R>=UltiSnips#ExpandSnippetOrJump()<CR> .


  • Operating System: Pop!_OS 22.04 LTS
  • Vim Version:
    NVIM v0.10.0-dev-3020+g435dee74b
    Build type: RelWithDebI
  • Python inside Vim: 3.10.12
@AshyAspen
Copy link

AshyAspen commented May 9, 2024

I'm not sure about the specifics of your case, but I just thought I'd share that I was having a similar problem recently because I was trying to define the remap in a config file set in a snips.lua file in the "after" folder specifically for UltiSnips, like I do for most config stuff. I found that the was working for expanding but not jumping and wasn't sure why.

I ended up putting

vim.cmd([[                    
let g:UltiSnipsExpandTrigger = '<tab>'                              
let g:UltiSnipsJumpForwardTrigger = '<tab>'                                          
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'                                                 
]])

in my init.lua and everything works fine now like I was trying to get it.

Perhaps doing separate commands for forward and expand would work? Or moving it to a piece of your config that initializes sooner, if you're having a problem I was having? I'm not exactly sure but I thought I'd share. Sorry I can't help more.

@BODH1SATVA
Copy link
Author

BODH1SATVA commented May 9, 2024

@AshyAspen I tried moving commands to init.lua file and tried separate commands. It still would not work. Thanks for suggestion though.

I also noticed that vim.g.UltiSnipsExpandTrigger does not work in my case. I can't set anything other then <tab> as an expand trigger.

I still don't have any idea what could be wrong here. I checked my config several times, all I have there is simple stuff like setting colorscheme, line numbers... and few other maps that don't use <tab> (most of them are for normal mode anyway).

@BODH1SATVA
Copy link
Author

I have figured these out. I changed my ultisnips.lua file to have

return {"SirVer/ultisnips", 
lazy = false, 
init = function()
vim.g.UltiSnipsExpandOrJumpTrigger = '<tab>'
vim.g.UltiSnipsJumpBackwardTrigger = '<s-tab>'
end
}

Everithing works as it should now.

@SirVer
Copy link
Owner

SirVer commented May 13, 2024

Glad you made it work. I do not use Neovim and it is officially not supported by UltiSnips, hence i could not have helped in either case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants