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

[question] g:vimtex_doc_handlers cannot use autoload function #2153

Closed
Freed-Wu opened this issue Aug 30, 2021 · 3 comments
Closed

[question] g:vimtex_doc_handlers cannot use autoload function #2153

Freed-Wu opened this issue Aug 30, 2021 · 3 comments

Comments

@Freed-Wu
Copy link
Contributor

In https://github.com/lervag/vimtex/blob/master/autoload/vimtex/doc.vim#L26

  for l:handler in g:vimtex_doc_handlers
    if exists('*' . l:handler)
      if call(l:handler, [l:context]) | return | endif
    endif
  endfor

exists will return 0 for autoload function. Is there any method to use autoload function?

Thanks!

@lervag
Copy link
Owner

lervag commented Aug 30, 2021

Yes and no. The problem with an autoload function in this context is that it may or may not be sourced. An immediate way to make it work is to ensure it is sourced, i.e. something like this:

let g:vimtex_doc_handlers = ['my#cool#function']
runtime autoload/my/cool.vim

However, perhaps it could be solved from VimTeX by a minor change. Could you test to change the mentioned code into this:

for l:handler in g:vimtex_doc_handlers
  try
    if call(l:handler, [l:context]) | return | endif
  catch /E117/
    " E117: Unknown function
  endtry
endfor

@Freed-Wu
Copy link
Contributor Author

I have tested. It can work!

lervag added a commit that referenced this issue Aug 31, 2021
@lervag
Copy link
Owner

lervag commented Aug 31, 2021

Ok; I've pushed the code. Please update and verify that it now works as expected.

@lervag lervag closed this as completed Aug 31, 2021
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