Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@neovim.autocmd('VimEnter', pattern='*', sync=True)
def event_vim_enter(self):
"""Find and retain the plugin instance."""
# Don't import semshi on top so it's not collected as a plugin again
from semshi.plugin import Plugin
# Using the garbage collector interface to find the instance is a bit
# hacky, but works reasonably well and doesn't require changes to the
# plugin code itself.
for obj in gc.get_objects():
if isinstance(obj, Plugin):
self._plugin = obj
return
raise Exception('Can\'t find plugin instance.')
@pynvim.autocmd('BufEnter', pattern='*', eval='expand("")')
def onBufEnter(self, path):
if not self._hasInitialized:
return
try:
self._onBufEnterInternal(path)
except Exception as e:
self._log.exception(e)
@neovim.autocmd('VimLeave', sync=True)
def event_vim_leave(self):
for handler in self._handlers.values():
handler.shutdown()