last day (17 days later) » 

19:54
room topic changed to Conversation about UltiSnips: Continuation from the comments under this answer: stackoverflow.com/a/59846776/11384392 (no tags)
room topic changed to Conversation about UltiSnips: Continuation from the comments under this answer (no tags)
room topic changed to Conversation about UltiSnips: Continuation from the comments under this answer: stackoverflow.com/a/59846776/11384392 [vim]
Hi
Thanks for helping me with this
Yeah, no prob!
So the only thing I can think of that'd be wrong with the mapping is if you're testing it outside of insert mode
Since the inoremap only makes the mapping in that mode
yeah, in insert mode
But I also tried pressing tab in normal mode
Hm
Maybe try inserting call before the Ulti_Pairs() section?
which call?
20:08
So it'd be inoremap <Tab> <C-R>=(call Ulti_Pairs() > 0)?"":AutoPairsJump()<CR>
ah
one sec
no, still no echo
Bah
Okay, let me actually download the packages and do some tests
I'm thinking that something in this may collide with something else in my vimrc
but I have deactivated everything that I though could cause such a problem
It may, but there's really nothing I can think of unless you're remapping Tab again somewhere else
hm, right
I copied your code as it is though
And I am not remapping tab anywhere else
20:20
Hm, then there might be something internal to the plugins that's clashing (there shouldn't be)
I know people have had success in the past using the supertab plugin
Hm, alright, I will look into into it. Have you reproduced the problem though?
Yeah, I've gotten to the point where the function isn't doing anything :P
Ah, I see :D
I guess I'll be reading the supertab documentation then...
But thanks for the effort nonetheless!
Yeah no prob. I think I may have a lead. It's small, bu it might go somewhere. I'll keep you posted
Awesome, thx!
20:33
Oh yeah, apparently UltiSnips already has integration with supertab and has your functionality built in automatically
I see. So do I unserstand correctly - UltiSnips will default to supertab if there is nothing to expand, and I can configure supertab somehow to switch to auto-pais (I haven't looked at that plugin yet). The code below that paragrathere is almost identical to yours though
*paragraph
Yes, that's what I believe to be the case
And yeah, you caught me pasting from the docs :P
Hm, so I am able to get the code "working", but it's inserting 0 right before the closing element
This might be an AutoPairs issue
Yeah, it looks like an autopairs thing. I'm calling AutoPairsJump() directly, and it still inserts the 0
Oh, because the function expects to be in normal mode when called, but we're calling it from insert mode
huh
20:52
Oh :D. But there must be another function that does that in insert mode. Since auto-pairs normally behaves this way in insert mode.
Yeah, AutoPairsShortcutJump()
but that's giving me nasty looks
oh, the dev got rid of it as a func
I still cannot get the function to echo, even with that function. But since you say it is not there anymore, I guess it doesn't matter
Well that may have something to do with the use of <C-R>=, which allows expressions to be evaluated while still in insert mode
So something like <C-R>=128-120<CR> will output 8 at the cursor
This exceeds my knowledge of vimscript by a lot - I unserstand your example, but I cannot map it to how a modified remap would have to look like from that.
21:08
Got it
Finally
Let me update the answer; it'll be easier to copy that way
Awesome, thanks. I'll test it as soon as it is up
It's up now
In retrospect, it's a fair bit simpler than what the UltiSnips docs recommended
I can't get it to work still :D
D:
noooooo
Just to be sure, you did source the new vimrc?
Yes
21:19
Ugh
Is it just not doing anything?
same behavior as before
and no echo when I insert it
it is correct that I disabled the old tab remaps, right?
Yeah, they shouldn't be needed
I don't have them, and the function as I wrote it is jumping properly
What the heck
It is probably me messing something up in all likelihood
Can you maybe take a look at my vimrc now? It is not too long
Yeah for sure
ok, one sec
21:22
You might not be able to paste it all here, but feel free to link a paste or a gist
set cindent shiftwidth=4

setlocal spell
set spelllang=de,en_gb
set textwidth=100

inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u

nnoremap , :
nnoremap : ,
imap ö (
imap ä )
imap Ö [
imap Ä ]
imap ü {
imap Ü }
imap ß \

nmap ß \
nmap ö /

set termguicolors
set background=dark

" turn hybrid line numbers on
:set number relativenumber
:set nu rnu

let g:vimtex_compiler_progname = 'nvr'

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
let g:tex_flavor='latex'
let g:vimtex_quickfix_mode=0
let g:vimtex_view_method='zathura'
I'm using neovim by the way
hm
those colon remaps
let mw try something
Oh, I see what you might mean
But removing the remaps (or changing the colon does not do anything)
okay, was wondering if that applied, since nnoremap doesn't apply to command mode, but you have to type a colon to get into command mode
That being said, adding those remaps broke my function, but that might be something else
I'll keep that in mind and keep testing without the remaps then
21:28
oh nevermind
I forgot to source my vimrc
Oh no that did break it. I forgot my auto-sourcing the vimrc didn't work for all things
I commented out the remaps and still got the same behavior though
yeah, it might be something wonky with me. Now my function doesn't want to work and I've just put things back where they were
i was doing so well ;_;
:D
that sounds really strange
Yeah, still calling the function directly works. Does that work for you?
Ulti_Pairs()
yes
21:34
Huh so it must be something wonky with the mapping
Just for sanity's sake, make a backup of your vimrc, and try running the mapping/function with the minimum necessary (the function/mapping itself, and any package configs necessary)
okay :)
This is my vimrc now
call plug#begin('~/.vim/plugged')

Plug 'jiangmiao/auto-pairs'
"let g:AutoPairsShortcutJump = '<C-a>'

Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'

function! Ulti_Pairs()
call UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res == 0
call AutoPairsJump()
endif
endfunction

inoremap <Tab> <ESC>:call Ulti_Pairs()<CR>

call plug#end()
Still same behavior
wow that is ridiculous. I'm on the verge of just sharing my screen with you just to show you something happens and I'm not crazy :p
I believe you...it's probably something stupid
Maybe it is really some difference due to neovim instead of vim?
Well then maybe the thing to do is ask over on the Vim Stack Exchange site. Coz I don't know nothin else
Maybe? You could always install plain Vim real quick and test
But there really shouldn't be any functional differences in defining and calling functions
ok let me try that, I have it installed
in regular vim the vimrc is just in home/.vimrc right?
21:45
yeah, that's one of the default locations Vim looks in
No, same :(
I have always been amazing at finding the most impossible/unlikely bugs. This is just another demonstration of this talent...
I know the feeling. Well, sorry I couldn't help any. I still recommend posting over on the Vim SE site, linking to the post you already made on SO, explaining your bug, and posting your vimrc.
Just a thought, but what keyboard layout are you using?
german, why?
tab should be in the same spot? plus I have remapped it before
wait
Let me use something different than tab
Okay. I ask because sometimes things get wonky with different layouts, even if the keys are in the same place as an ISO/ANSI
Okay, this is strange
I mapped it to <C-d> instead of tab
now what happens is that tab still expands the snippet (and <C-d> doesn't), but <C-d> jumps
21:58
The former behavior might be a default UltiSnips thing
yes, looks like it
but do you know if you can make the remap affect that?
Hm, well the function calls UltiSnips#ExpandSnippetOrJump()
So it should expand if needed
I got it
I just needet to explicitly map the UltiSnip functions to another key
And everything works okay with the non-Tab key?
Or Tab too?
Oh no, I celebrated to early
22:01
D:
Doing that results in tab expanding and jumping in snippets fine, and the other key jumping in brackets
Can you show the vimrc again?
set cindent shiftwidth=4

setlocal spell
set spelllang=de,en_gb
set textwidth=100

inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u

"nnoremap , :
"nnoremap : ,
imap ö (
imap ä )
imap Ö [
imap Ä ]
imap ü {
imap Ü }
imap ß \

nmap ß \
nmap ö /

set termguicolors
set background=dark

" turn hybrid line numbers on
:set number relativenumber
:set nu rnu

let g:vimtex_compiler_progname = 'nvr'

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
let g:tex_flavor='latex'
let g:vimtex_quickfix_mode=0
let g:vimtex_view_method='zathura'
This is the one I'm working with again now
I uncommented these lines:
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
and also changed this to another combination earlier
Which is so weird, because if your expand trigger variable is the same as the jump forward trigger one, UltiSnips call ExpandSnippetOrJump() behind the scenes instead
Yes
But the function does get called
even if the correct behavior does not happen
which means that the problem is not just in the remap
22:10
ugh
This might be the time to throw our hands in the air and let SuperTabs do the work for us
When the solution to a script's problems is another script, you might be using Vim
Probably
But one last thing
Sure
I echoed expand or jump
and it returns zero even when I'm on a snippet
which is the reason it does not work
which means that #ExpandSnippetorJump() fails to set the global as expected?
22:14
Maybe. It's done in the plugin's python section here
So it's actually setting the global variable to a nonzero value
And it has to make it through all the failure cases before putting it back to zero
Hm
Could we not just use the return value of that function call instead of the global?
It's not returning anything. The UltiSnips#ExpandSnippetOrJump() function always returns "", and the Python code only sets the variable
I see
Yeah, it's a real puzzle
I also found this:
I'm not sure, but this contains a bunch of remaps
22:20
Yeah, where it decides what specific jump function to use
Actually what I thought does not make sense
That's just setting the default values, I believe
very weird
yeah
I thoight that it might overwrite what we do, but it obviously does not
It shouldn't, unless you're loading the plug after the custom function. But that would cause other errors, anyway
okay
it gets weirder
:D
22:21
D:
it now worked
but only for a certain snippet
I need to check this, one sec
okay, I have got no clue
snippet lr "left( right)" i
1 \left( ${1:${VISUAL}} \right) $0
2 endsnippet
3
4 snippet lr( "left( right)" i
5 \left( ${1:${VISUAL}} \right) $0
6 endsnippet
22:25
At the very least, it's useful additional info to pass onto more expert vim people
These are two snippets
they do the same thing
the first does not work, the second does
huh
but the opening paren after the second lr isn't closed?
And the addition of that ( is the only difference I see
What the heck
it might have something to do with the a at the end of the command
because I also have a snippet lra
and under some circumstances that gets expanded
its a mess :D
Maybe? The a is sent to Vim once it's in normal mode executing the command, and is used to return Vim to insert mode
I guess try changing the a to i and see what happens
The a was putting the cursor in a weird place, anyway
the a always gets pasted, even after the snippet is expanded when it is
But removing it does not really help; vim sometimes remains in normal mode then
same thing
it works for one snippet but not the other, and the i is inside the brackets in the end if the snippet is expanded
22:31
Only sometimes remains in normal mode? That doesn't sound good at all
one sec
yeah, when there is no snippet it goes into normal mode after
also, when it expands the snippet, it appends a random bracket for some reason
Okay, let's let this rest, at least for today. I need to prepare a talk for tomorrow, and it's pretty late already over here
Yeah, I'll bet. Take care, and good luck with the talk
Thanks! Let me know if you think of something. Otherwise I will try to make a cohesive story out of this and post it on SE in the coming days. Take care!
Okay, I couldn't resist trying one more time :D. I have managed to produce the behavior we wanted finally - it works if I have a whitespace after the snippet trigger for some reason. Then none of the weird things above happen
It works almost well if I change the remap to
inoremap <Tab> <space><ESC>:call Ulti_Pairs()<CR>
Only downside is that now every jump adds a whitespace

  last day (17 days later) »