示例#1
0
 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,
             }]
示例#2
0
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',
            }]
示例#3
0
	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,
				}]
示例#4
0
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',
			}]
示例#5
0
文件: common.py 项目: yewton/dotfiles
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,
		}]
示例#6
0
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,
        }]
示例#7
0
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,
        }]
示例#8
0
 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)
示例#9
0
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}]
示例#10
0
文件: common.py 项目: tomef/vim
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,
		}]
示例#11
0
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}]
示例#12
0
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"}]
示例#13
0
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,
		}]