-
-
Notifications
You must be signed in to change notification settings - Fork 691
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 variable to control AutoTrigger #1551
Conversation
I worry a bit about performance. Calling out to vim.eval is slow and this code will run on every cursor movement. This should probably be checked in vimscript before calling into python. Overall, I am fine with the feature. |
9327e7a
to
bb6d6fc
Compare
Yes this can be done much better by removing/re-creating the |
To not complicate things, I added only a global toggling mechanism. @ces42 To be honest, I wasn't sure wheter |
Adding this to function! UltiSnips#EnableAutotrigger() abort
augroup UltiSnips_AutoTrigger
au!
au InsertCharPre * call UltiSnips#TrackChange()
au TextChangedI * call UltiSnips#TrackChange()
if exists('##TextChangedP')
au TextChangedP * call UltiSnips#TrackChange()
endif
augroup END
endfunction
function! UltiSnips#DisableAutotrigger() abort
augroup UltiSnips_AutoTrigger
au!
augroup END
endfunction
function! UltiSnips#ToggleAutotrigger() abort
" if exists('#UltiSnips_AutoTrigger')
if exists('#UltiSnips_AutoTrigger#TextChangedI')
call UltiSnips#DisableAutotrigger()
else
call UltiSnips#EnableAutotrigger()
endif
endfunction EDIT: apparently the augroup doesn't get deleted when you do |
Great, but a test is still missing. Will you work on that @jdujava ? |
Now it is possible to disable AutoTrigger via global variable `g:UltiSnipsAutoTrigger`, and to dynamically toggle AutoTrigger on/off with `Ultisnips#ToggleAutoTrigger()`.
bb6d6fc
to
b2bf213
Compare
@SirVer Added tests and documentation, does it look OK? |
@SirVer is it good to merge, or is there perhaps anything else to do? |
@jdujava Yes, it looks great, an exemplary contribution to an open source project. Thank you very much! Sorry that I took so long to get around to it. |
Now it is possible to disable AutoTrigger in the current buffer by setting the buffer variableb:UltiSnipsAutoTrigger = 0
.Now it is possible to disable AutoTrigger via global variable
g:UltiSnipsAutoTrigger
, and to dynamically toggle AutoTrigger on/off withUltisnips#ToggleAutoTrigger()
.This is just a first crude shot at implementing this "toggling feature" (documentation and so on TODO).
What do you think, is this alright, or is there perhaps some better way in your opinion?