Skip to content

Instantly share code, notes, and snippets.

@tamago324
Last active September 27, 2020 15:03
Show Gist options
  • Save tamago324/a975712c3f9c7ad2e86580e0f32d8daf to your computer and use it in GitHub Desktop.
Save tamago324/a975712c3f9c7ad2e86580e0f32d8daf to your computer and use it in GitHub Desktop.
"""
:Leaderf ghq
してから
py3file ~\ghq\github.com\tamago324\sandbox\vim\leaderf\add_command_leaderf_ghq.py
で読み込む
"""
from functools import wraps
from ghqExpl import ghqExplManager
from leaderf.utils import *
# もとの関数をとっておく
_loaded = False
if not _loaded:
_loaded = True
_orig_func = ghqExplManager._cmdExtension
def open_browser(self, *args, **kwargs):
instance = self._getInstance()
line = instance.currentLine
url = "https://github.com/" + line.split(" ", 1)[0]
lfCmd(f'call openbrowser#open("{url}")')
def deco(func):
@wraps(func)
def wrapper(*args, **kwargs):
cmd = args[0]
if cmd.lower() == "<C-z>".lower():
open_browser(ghqExplManager, *args, **kwargs)
return True
return func(*args, **kwargs)
return wrapper
ghqExplManager._cmdExtension = deco(_orig_func)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment