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

Custom triggers? #8

Closed
dbmrq opened this issue Oct 12, 2016 · 6 comments
Closed

Custom triggers? #8

dbmrq opened this issue Oct 12, 2016 · 6 comments

Comments

@dbmrq
Copy link

dbmrq commented Oct 12, 2016

Good job here. :)

I'm not sure how this works behind the scenes, but vimtex has its own omni completion function (it completes bibliography entry names, source files to include and so on) and when using NeoComplete or YouCompleteMe you can set up custom triggers to call it, like this:

  let g:neocomplete#sources#omni#input_patterns.tex =
        \ '\v\\%('
        \ . '\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \ . '|\a*ref%(\s*\{[^}]*|range\s*\{[^,}]*%(}\{)?)'
        \ . '|hyperref\s*\[[^]]*'
        \ . '|includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \ . '|%(include%(only)?|input)\s*\{[^}]*'
        \ . '|\a*(gls|Gls|GLS)(pl)?\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \ . '|includepdf%(\s*\[[^]]*\])?\s*\{[^}]*'
        \ . '|includestandalone%(\s*\[[^]]*\])?\s*\{[^}]*'
        \ . ')'

(The full documentation is here.)

Is there a way to do something like that here?

Also those other plugins work with UltiSnips too, completing the snippet triggers. That would be great!

@maralla
Copy link
Owner

maralla commented Oct 15, 2016

Now you can config tex completion like this:

let g:completor_tex_omni_trigger = '\\\\(:?'
        \ .  '\w*cite\w*(?:\s*\[[^]]*\]){0,2}\s*{[^}]*'
        \ . '|\w*ref(?:\s*\{[^}]*|range\s*\{[^,}]*(?:}{)?)'
        \ . '|hyperref\s*\[[^]]*'
        \ . '|includegraphics\*?(?:\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \ . '|(?:include(?:only)?|input)\s*\{[^}]*'
        \ . '|\w*(gls|Gls|GLS)(pl)?\w*(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
        \ . '|includepdf(\s*\[[^]]*\])?\s*\{[^}]*'
        \ . '|includestandalone(\s*\[[^]]*\])?\s*\{[^}]*'
        \ .')$'

@dbmrq
Copy link
Author

dbmrq commented Oct 15, 2016

Uhm, now I'm getting this:

Error detected while processing function <lambda>5[1]..<SNR>135_complete[13]..<SNR>135_trigger[4]..completor#utils#get_completions:
line    7:
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/Users/daniel/.vim/bundle/completor.vim/pythonx/completers/_omni.py", line 41, in parse
    if start < 0:
TypeError: unorderable types: str() < int()

@maralla
Copy link
Owner

maralla commented Oct 16, 2016

The pr #15 fixed the problem. You can try it again.

@dbmrq
Copy link
Author

dbmrq commented Oct 17, 2016

Awesome, it's looking great! 🎉
Now I just miss the UltiSnips integration, but I can live without it for now.
Thank you!

@maralla
Copy link
Owner

maralla commented Oct 18, 2016

Now it has UltiSnips integration.

@dbmrq
Copy link
Author

dbmrq commented Oct 19, 2016

Awesome, thank you! ❤️
I'm on a trip right now, so I won't be be to test it for a few days, but I'll close this issue then, and I'll reopen id there are any problems.
Thabks again for your amazing work on this.

@dbmrq dbmrq closed this as completed Oct 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants