def __call__(self, pl, segment_info, create_watcher, status_colors=False, ignore_statuses=()): name = self.get_directory(segment_info) if name: repo = guess(path=name, create_watcher=create_watcher) if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: try: status = tree_status(repo, pl) except Exception as e: pl.exception('Failed to compute tree status: {0}', str(e)) status = '?' else: status = status and status.strip() if status in ignore_statuses: status = None scol.insert(0, 'branch_dirty' if status else 'branch_clean') return [{ 'contents': branch, 'highlight_groups': scol, 'divider_highlight_group': self.divider_highlight_group, }]
def branch(pl, segment_info, status_colors=False): '''Return the current working branch. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. Divider highlight group used: ``branch:divider``. ''' name = segment_info['buffer'].name skip = not (name and (not vim_getbufoption(segment_info, 'buftype'))) if not skip: repo = guess(path=name) if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: status = tree_status(repo, pl) scol.insert( 0, 'branch_dirty' if status and status.strip() else 'branch_clean') return [{ 'contents': branch, 'highlight_group': scol, 'divider_highlight_group': 'branch:divider', }]
def __call__(self, pl, segment_info, create_watcher, status_colors=False, ignore_statuses=()): name = self.get_directory(segment_info) if name: repo = guess(path=name, create_watcher=create_watcher) if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: try: status = tree_status(repo, pl) except Exception as e: pl.exception('Failed to compute tree status: {0}', str(e)) status = '?' else: status = status and status.strip() if status: if 'U' in status: branch += ' +' if 'D' in status: status = 'branch_dirty' else: status = 'branch_clean' else: status = 'branch_clean' if status in ignore_statuses: status = None scol.insert(0, status) return [{ 'contents': branch, 'highlight_groups': scol, 'divider_highlight_group': self.divider_highlight_group, }]
def branch(pl, segment_info, status_colors=False): '''Return the current working branch. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. Divider highlight group used: ``branch:divider``. ''' name = segment_info['buffer'].name skip = not (name and (not vim_getbufoption(segment_info, 'buftype'))) if not skip: repo = guess(path=name) if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: status = tree_status(repo, pl) scol.insert(0, 'branch_dirty' if status and status.strip() else 'branch_clean') return [{ 'contents': branch, 'highlight_group': scol, 'divider_highlight_group': 'branch:divider', }]
def branch(pl, segment_info, status_colors=False): '''Return the current VCS branch. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. ''' name = segment_info['getcwd']() return name repo = guess(path=name) return [{ 'contents': repo, 'highlight_group': ['branch_clean', 'branch'] }] if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: status = tree_status(repo, pl) scol.insert(0, 'branch_dirty' if status and status.strip() else 'branch_clean') return [{ 'contents': branch, 'highlight_group': scol, }]
def branch(pl, segment_info, status_colors=False, path=None): '''Return the current VCS branch in specified directory. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. :param string path: determines which directory will be watched. current directory will be set if this is None. Default: None. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. ''' if path is None: path = segment_info['getcwd']() repo = guess(path=path) if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: status = tree_status(repo, pl) scol.insert( 0, 'branch_dirty' if status and status.strip() else 'branch_clean') return [{ 'contents': branch, 'highlight_group': scol, }]
def branch(pl, segment_info, create_watcher, status_colors=False): '''Return the current VCS branch. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. ''' name = segment_info['getcwd']() repo = guess(path=name, create_watcher=create_watcher) if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: try: status = tree_status(repo, pl) except Exception as e: pl.exception('Failed to compute tree status: {0}', str(e)) status = '?' scol.insert( 0, 'branch_dirty' if status and status.strip() else 'branch_clean') return [{ 'contents': branch, 'highlight_group': scol, }]
def is_dirty(pl, repo, ignore_statuses): try: status = tree_status(repo, pl) except Exception as e: pl.exception('Failed to compute tree status: {0}', str(e)) status = '?' else: status = status and status.strip() if status in ignore_statuses: return False return bool(status)
def branch(pl, segment_info, status_colors=False): """Return the current VCS branch. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. """ name = segment_info["getcwd"]() repo = guess(path=name) if repo is not None: branch = repo.branch() scol = ["branch"] if status_colors: status = tree_status(repo, pl) scol.insert(0, "branch_dirty" if status and status.strip() else "branch_clean") return [{"contents": branch, "highlight_group": scol}]
def branch(pl, segment_info, status_colors=False): '''Return the current VCS branch. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. ''' name = segment_info['getcwd']() repo = guess(path=name) if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: status = tree_status(repo, pl) scol.insert(0, 'branch_dirty' if status and status.strip() else 'branch_clean') return [{ 'contents': branch, 'highlight_group': scol, }]
def branch(pl, segment_info, status_colors=False, path=None): """Return the current VCS branch in specified directory. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. :param string path: determines which directory will be watched. current directory will be set if this is None. Default: None. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. """ if path is None: path = segment_info["getcwd"]() repo = guess(path=path) if repo is not None: branch = repo.branch() scol = ["branch"] if status_colors: status = tree_status(repo, pl) scol.insert(0, "branch_dirty" if status and status.strip() else "branch_clean") return [{"contents": branch, "highlight_group": scol}]
def branch(pl, segment_info, create_watcher, status_colors=False): """Return the current working branch. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. Divider highlight group used: ``branch:divider``. """ name = segment_info["buffer"].name skip = not (name and (not vim_getbufoption(segment_info, "buftype"))) if not skip: repo = guess(path=name, create_watcher=create_watcher) if repo is not None: branch = repo.branch() scol = ["branch"] if status_colors: status = tree_status(repo, pl) scol.insert(0, "branch_dirty" if status and status.strip() else "branch_clean") return [{"contents": branch, "highlight_group": scol, "divider_highlight_group": "branch:divider"}]
def branch(pl, segment_info, create_watcher, status_colors=False): '''Return the current VCS branch. :param bool status_colors: determines whether repository status will be used to determine highlighting. Default: False. Highlight groups used: ``branch_clean``, ``branch_dirty``, ``branch``. ''' name = segment_info['getcwd']() repo = guess(path=name, create_watcher=create_watcher) if repo is not None: branch = repo.branch() scol = ['branch'] if status_colors: try: status = tree_status(repo, pl) except Exception as e: pl.exception('Failed to compute tree status: {0}', str(e)) status = '?' scol.insert(0, 'branch_dirty' if status and status.strip() else 'branch_clean') return [{ 'contents': branch, 'highlight_group': scol, }]