예제 #1
0
def webdevicons(pl, segment_info):
	webdevicons = vim_get_func('WebDevIconsGetFileTypeSymbol')
	name = buffer_name(segment_info)
	return [] if not webdevicons else [{
		'contents': webdevicons(name),
		'highlight_groups': ['webdevicons', 'file_name'],
		}]
예제 #2
0
파일: vim.py 프로젝트: nhannguyen/powerline
def file_directory(pl,
                   segment_info,
                   shorten_user=True,
                   shorten_cwd=True,
                   shorten_home=False):
    '''Return file directory (head component of the file path).

	:param bool shorten_user:
		shorten ``$HOME`` directory to :file:`~/`

	:param bool shorten_cwd:
		shorten current directory to :file:`./`

	:param bool shorten_home:
		shorten all directories in :file:`/home/` to :file:`~user/` instead of :file:`/home/user/`.
	'''
    name = buffer_name(segment_info['buffer'])
    if not name:
        return None
    file_directory = vim_funcs['fnamemodify'](
        name,
        (':~' if shorten_user else '') + (':.' if shorten_cwd else '') + ':h')
    if not file_directory:
        return None
    if shorten_home and file_directory.startswith('/home/'):
        file_directory = b'~' + file_directory[6:]
    file_directory = file_directory.decode('utf-8',
                                           'powerline_vim_strtrans_error')
    return file_directory + os.sep
예제 #3
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 = buffer_name(segment_info)
    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',
            }]
예제 #4
0
def file_directory(pl,
                   segment_info,
                   shorten_user=True,
                   shorten_cwd=True,
                   shorten_home=False):
    '''Return file directory (head component of the file path).

	:param bool shorten_user:
		shorten ``$HOME`` directory to :file:`~/`

	:param bool shorten_cwd:
		shorten current directory to :file:`./`

	:param bool shorten_home:
		shorten all directories in :file:`/home/` to :file:`~user/` instead of :file:`/home/user/`.
	'''
    name = buffer_name(segment_info['buffer'])
    if not name:
        return None
    file_directory = vim_funcs['fnamemodify'](
        name,
        (':~' if shorten_user else '') + (':.' if shorten_cwd else '') + ':h')
    if not file_directory:
        return None
    if shorten_home and file_directory.startswith('/home/'):
        file_directory = b'~' + file_directory[6:]
    file_directory = file_directory.decode('utf-8',
                                           'powerline_vim_strtrans_error')
    return file_directory + os.sep
예제 #5
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 = buffer_name(segment_info)
	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',
			}]
예제 #6
0
def file_mtime(pl, segment_info):
	'''Return file mtime.
	'''
	name = buffer_name(segment_info)
	if os.path.isfile(name):
		return [{
			'contents': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(os.stat(name).st_mtime)),
			'highlight_group': ['file_mtime', 'file_size']
			}]
	else:
		return None
예제 #7
0
def file_mtime(pl, segment_info):
    '''Return file mtime.
	'''
    name = buffer_name(segment_info)
    if os.path.isfile(name):
        return [{
            'contents':
            time.strftime('%Y-%m-%d %H:%M:%S',
                          time.localtime(os.stat(name).st_mtime)),
            'highlight_group': ['file_mtime', 'file_size']
        }]
    else:
        return None
예제 #8
0
파일: vim.py 프로젝트: nhannguyen/powerline
def file_name(pl, segment_info, display_no_file=False, no_file_text="[No file]"):
    """Return file name (tail component of the file path).

	:param bool display_no_file:
		display a string if the buffer is missing a file name
	:param str no_file_text:
		the string to display if the buffer is missing a file name

	Highlight groups used: ``file_name_no_file`` or ``file_name``, ``file_name``.
	"""
    name = buffer_name(segment_info["buffer"])
    if not name:
        if display_no_file:
            return [{"contents": no_file_text, "highlight_group": ["file_name_no_file", "file_name"]}]
        else:
            return None
    return os.path.basename(name).decode("utf-8", "powerline_vim_strtrans_error")
예제 #9
0
파일: __init__.py 프로젝트: jcronq/linuxEnv
def file_directory(pl,
                   segment_info,
                   remove_scheme=True,
                   shorten_user=True,
                   shorten_cwd=True,
                   shorten_home=False):
    '''Return file directory (head component of the file path).

	:param bool remove_scheme:
		Remove scheme part from the segment name, if present. See documentation
		of file_scheme segment for the description of what scheme is. Also
		removes the colon.

	:param bool shorten_user:
		Shorten ``$HOME`` directory to :file:`~/`. Does not work for files with
		scheme.

	:param bool shorten_cwd:
		Shorten current directory to :file:`./`. Does not work for files with
		scheme present.

	:param bool shorten_home:
		Shorten all directories in :file:`/home/` to :file:`~user/` instead of
		:file:`/home/user/`. Does not work for files with scheme present.
	'''
    name = buffer_name(segment_info)
    if not name:
        return None
    match = SCHEME_RE.match(name)
    if match:
        if remove_scheme:
            name = name[len(match.group(0)) + 1:]  # Remove scheme and colon
        file_directory = vim_funcs['fnamemodify'](name, ':h')
    else:
        file_directory = vim_funcs['fnamemodify'](
            name, (':~' if shorten_user else '') +
            (':.' if shorten_cwd else '') + ':h')
        if not file_directory:
            return None
        if shorten_home and file_directory.startswith('/home/'):
            file_directory = b'~' + file_directory[6:]
    file_directory = file_directory.decode(segment_info['encoding'],
                                           'powerline_vim_strtrans_error')
    return file_directory + os.sep
예제 #10
0
def file_name(pl, segment_info, display_no_file=False, no_file_text='[No file]'):
	'''Return file name (tail component of the file path).

	:param bool display_no_file:
		display a string if the buffer is missing a file name
	:param str no_file_text:
		the string to display if the buffer is missing a file name

	Highlight groups used: ``file_name_no_file`` or ``file_name``, ``file_name``.
	'''
	name = buffer_name(segment_info)
	if not name:
		if display_no_file:
			return [{
				'contents': no_file_text,
				'highlight_groups': ['file_name_no_file', 'file_name'],
			}]
		else:
			return None
	return os.path.basename(name).decode(segment_info['encoding'], 'powerline_vim_strtrans_error')
예제 #11
0
def file_name(pl, segment_info, display_no_file=False, no_file_text='[No file]'):
	'''Return file name (tail component of the file path).

	:param bool display_no_file:
		display a string if the buffer is missing a file name
	:param str no_file_text:
		the string to display if the buffer is missing a file name

	Highlight groups used: ``file_name_no_file`` or ``file_name``, ``file_name``.
	'''
	name = buffer_name(segment_info)
	if not name:
		if display_no_file:
			return [{
				'contents': no_file_text,
				'highlight_groups': ['file_name_no_file', 'file_name'],
			}]
		else:
			return None
	return os.path.basename(name).decode(segment_info['encoding'], 'powerline_vim_strtrans_error')
예제 #12
0
def file_vcs_status(pl, segment_info, create_watcher):
	'''Return the VCS status for this buffer.

	Highlight groups used: ``file_vcs_status``.
	'''
	name = buffer_name(segment_info)
	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:
			status = repo.status(os.path.relpath(name, repo.directory))
			if not status:
				return None
			status = status.strip()
			ret = []
			for status in status:
				ret.append({
					'contents': status,
					'highlight_groups': ['file_vcs_status_' + status, 'file_vcs_status'],
				})
			return ret
예제 #13
0
def file_vcs_status(pl, segment_info, create_watcher):
	'''Return the VCS status for this buffer.

	Highlight groups used: ``file_vcs_status``.
	'''
	name = buffer_name(segment_info)
	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:
			status = repo.status(os.path.relpath(name, repo.directory))
			if not status:
				return None
			status = status.strip()
			ret = []
			for status in status:
				ret.append({
					'contents': status,
					'highlight_groups': ['file_vcs_status_' + status, 'file_vcs_status'],
				})
			return ret
예제 #14
0
def file_directory(pl, segment_info, remove_scheme=True, shorten_user=True, shorten_cwd=True, shorten_home=False):
	'''Return file directory (head component of the file path).

	:param bool remove_scheme:
		Remove scheme part from the segment name, if present. See documentation 
		of file_scheme segment for the description of what scheme is. Also 
		removes the colon.

	:param bool shorten_user:
		Shorten ``$HOME`` directory to :file:`~/`. Does not work for files with 
		scheme.

	:param bool shorten_cwd:
		Shorten current directory to :file:`./`. Does not work for files with 
		scheme present.

	:param bool shorten_home:
		Shorten all directories in :file:`/home/` to :file:`~user/` instead of 
		:file:`/home/user/`. Does not work for files with scheme present.
	'''
	name = buffer_name(segment_info)
	if not name:
		return None
	match = SCHEME_RE.match(name)
	if match:
		if remove_scheme:
			name = name[len(match.group(0)) + 1:]  # Remove scheme and colon
		file_directory = vim_funcs['fnamemodify'](name, ':h')
	else:
		file_directory = vim_funcs['fnamemodify'](
			name,
			(':~' if shorten_user else '') + (':.' if shorten_cwd else '') + ':h'
		)
		if not file_directory:
			return None
		if shorten_home and file_directory.startswith('/home/'):
			file_directory = b'~' + file_directory[6:]
	file_directory = file_directory.decode(segment_info['encoding'], 'powerline_vim_strtrans_error')
	return file_directory + os.sep
예제 #15
0
파일: __init__.py 프로젝트: jcronq/linuxEnv
def file_scheme(pl, segment_info):
    '''Return the protocol part of the file.

	Protocol is the part of the full filename just before the colon which
	starts with a latin letter and contains only latin letters, digits, plus,
	period or hyphen (refer to `RFC3986
	<http://tools.ietf.org/html/rfc3986#section-3.1>`_ for the description of
	URI scheme). If there is no such a thing ``None`` is returned, effectively
	removing segment.

	.. note::
		Segment will not check  whether there is ``//`` just after the
		colon or if there is at least one slash after the scheme. Reason: it is
		not always present. E.g. when opening file inside a zip archive file
		name will look like :file:`zipfile:/path/to/archive.zip::file.txt`.
		``file_scheme`` segment will catch ``zipfile`` part here.
	'''
    name = buffer_name(segment_info)
    if not name:
        return None
    match = SCHEME_RE.match(name)
    if match:
        return match.group(0).decode('ascii')
예제 #16
0
def file_scheme(pl, segment_info):
	'''Return the protocol part of the file.

	Protocol is the part of the full filename just before the colon which 
	starts with a latin letter and contains only latin letters, digits, plus, 
	period or hyphen (refer to `RFC3986 
	<http://tools.ietf.org/html/rfc3986#section-3.1>`_ for the description of 
	URI scheme). If there is no such a thing ``None`` is returned, effectively 
	removing segment.

	.. note::
		Segment will not check  whether there is ``//`` just after the 
		colon or if there is at least one slash after the scheme. Reason: it is 
		not always present. E.g. when opening file inside a zip archive file 
		name will look like :file:`zipfile:/path/to/archive.zip::file.txt`. 
		``file_scheme`` segment will catch ``zipfile`` part here.
	'''
	name = buffer_name(segment_info)
	if not name:
		return None
	match = SCHEME_RE.match(name)
	if match:
		return match.group(0).decode('ascii')
예제 #17
0
def repo_directory(pl, segment_info, create_watcher):
	name = buffer_name(segment_info)
	file_directory = vim_funcs['fnamemodify'](name, ':h')
	if not name:
		return None
	match = SCHEME_RE.match(name)
	if match:
		repo_directory = file_directory
	else:
		repo = guess(path=name, create_watcher=create_watcher)
		if repo is not None:
			directory_to_sub = vim_funcs['fnamemodify'](repo.directory, ':h:h') + os.sep
			repo_directory = repo.directory
		else:
			repo_directory = vim_funcs['fnamemodify'](name, ':h')
			directory_to_sub = vim_funcs['fnamemodify'](repo_directory, ':h:h')
			if directory_to_sub != '/':
				directory_to_sub = directory_to_sub + os.sep
		repo_directory = repo_directory[len(directory_to_sub):]
	repo_directory = repo_directory.decode(segment_info['encoding'], 'powerline_vim_strtrans_error')
	return [{
		'contents': repo_directory,
		'highlight_groups': ['repo_directory', 'file_name'],
		}]
예제 #18
0
파일: vim.py 프로젝트: nhannguyen/powerline
def file_directory(pl, segment_info, shorten_user=True, shorten_cwd=True, shorten_home=False):
    """Return file directory (head component of the file path).

	:param bool shorten_user:
		shorten ``$HOME`` directory to :file:`~/`

	:param bool shorten_cwd:
		shorten current directory to :file:`./`

	:param bool shorten_home:
		shorten all directories in :file:`/home/` to :file:`~user/` instead of :file:`/home/user/`.
	"""
    name = buffer_name(segment_info["buffer"])
    if not name:
        return None
    file_directory = vim_funcs["fnamemodify"](
        name, (":~" if shorten_user else "") + (":." if shorten_cwd else "") + ":h"
    )
    if not file_directory:
        return None
    if shorten_home and file_directory.startswith("/home/"):
        file_directory = b"~" + file_directory[6:]
    file_directory = file_directory.decode("utf-8", "powerline_vim_strtrans_error")
    return file_directory + os.sep
예제 #19
0
	def get_directory(segment_info):
		if vim_getbufoption(segment_info, 'buftype'):
			return None
		return buffer_name(segment_info)
예제 #20
0
def nerdtree(matcher_info):
	name = buffer_name(matcher_info)
	return name and NERD_TREE_RE.match(os.path.basename(name))
예제 #21
0
def cmdwin(matcher_info):
    name = buffer_name(matcher_info)
    return name and os.path.basename(name) == b'[Command Line]'
예제 #22
0
파일: ctrlp.py 프로젝트: namacha/dotfiles
def ctrlp(matcher_info):
    name = buffer_name(matcher_info)
    return name and os.path.basename(name) == b'ControlP'
예제 #23
0
def commandt(matcher_info):
	name = buffer_name(matcher_info)
	return name and os.path.basename(name) == b'GoToFile'
예제 #24
0
def evernote(matcher_info):
    name = buffer_name(matcher_info)
    return name and EVERNOTE_RE.match(os.path.basename(name))
예제 #25
0
파일: ctrlp.py 프로젝트: Ahed91/powerline
def ctrlp(matcher_info):
	name = buffer_name(matcher_info)
	return name and os.path.basename(name) == b'ControlP'
예제 #26
0
def commandt(matcher_info):
    name = buffer_name(matcher_info)
    return name and os.path.basename(name) == b'GoToFile'
예제 #27
0
def commandt(matcher_info):
    name = buffer_name(matcher_info)
    return (
        vim_getbufoption(matcher_info, 'filetype') == 'command-t'
        or (name and os.path.basename(name) == b'GoToFile')
    )
예제 #28
0
def commandt(matcher_info):
	name = buffer_name(matcher_info)
	return (
		vim_getbufoption(matcher_info, 'filetype') == 'command-t'
		or (name and os.path.basename(name) == b'GoToFile')
	)
예제 #29
0
def gundo(matcher_info):
	name = buffer_name(matcher_info)
	return name and os.path.basename(name) == b'__Gundo__'
예제 #30
0
def evernote_explorer(matcher_info):
    name = buffer_name(matcher_info)
    return name and EVERNOTE_EXPLORER_RE.match(os.path.basename(name))
예제 #31
0
def tagbar(matcher_info):
	name = buffer_name(matcher_info)
	return name and os.path.basename(name) == b'__Tagbar__'
예제 #32
0
파일: gundo.py 프로젝트: mickdupreez/temp
def gundo(matcher_info):
    name = buffer_name(matcher_info)
    return name and os.path.basename(name) == b'__Gundo__'
예제 #33
0
def nerdtree(matcher_info):
    name = buffer_name(matcher_info)
    return name and NERD_TREE_RE.match(os.path.basename(name))
예제 #34
0
def geeknote(matcher_info):
	name = buffer_name(matcher_info)
	return name and GEEKNOTE_RE.match(os.path.basename(name))
예제 #35
0
def cmdwin(matcher_info):
	name = buffer_name(matcher_info)
	return name and os.path.basename(name) == b'[Command Line]'
예제 #36
0
파일: __init__.py 프로젝트: jcronq/linuxEnv
 def get_directory(segment_info):
     if vim_getbufoption(segment_info, 'buftype'):
         return None
     return buffer_name(segment_info)
예제 #37
0
def geeknote_explorer(matcher_info):
	name = buffer_name(matcher_info)
	return name and GEEKNOTE_EXPLORER_RE.match(os.path.basename(name))