Friday, February 24, 2017

Re: Reload ~/.vim/pythonx libraries without quitting vim?

2017-02-24 15:35 GMT+03:00 BPJ <bpj@melroch.se>:
> Is there a way to reload libraries in ~/.vim/pythonx (after editing them)
> without quitting/restarting vim?
>
> If there is it's probably in the help, but I usually can't find things there
> without already knowing the tag I should look for...

Without intentionally creating code in libraries (and all of their
users, though you may try to construct something which will only need
code in your library: I have some ideas) which will reload them you
can't possibly do this properly. You can use `reload()` Python
function (Python-3+: in imp module, Python-2: just there in
__builtin__) and end with a reloaded module in sys.modules, but this
is not going to do you any good in general: all existing references to
your module will still reference the old version.

You may want to check how powerline implements reload():
https://github.com/powerline/powerline/blob/72572c86954cdf8869a1abe9957857f79990d354/powerline/__init__.py#L907.
Note the modules_keeper: I do not remember the details, but it was
fixing some bug. Not sure, but AFAIR one of the initial versions used
reload().

It is also generally good to ask on Python mailing list, Vim does not
provide any code for this job. Additionally you may want to try doing
something on top of Neovim: since it is running Python in a separate
process it may be feasible to kill it and restart. Obviously such
action will take down *all* plugins, not just the one you want to
reload.

>
> TIA,
>
> /bpj
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> --- You received this message because you are subscribed to the Google
> Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: