Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Customizable icon prefix for branch name #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
drootang wants to merge 3 commits into itchyny:master from drootang:icon
Closed

Customizable icon prefix for branch name #4

drootang wants to merge 3 commits into itchyny:master from drootang:icon

Conversation

Copy link

@drootang drootang commented May 29, 2018

Using component_function in lightline has the advantage that if the returned value is empty, lightline automatically excludes the field and separator. Using a component to implement a custom function that wraps gitbranch#name to add the icon as a prefix, but returns an empty string when there is no branch name, results in an extra separator in the statusline.

This patch adds gitbranch#icon_and_name with a customizable g:gitbranch_icon variable to return: " <branch_name>"

Copy link
Owner

itchyny commented May 29, 2018

This plugin provides the branch name and does not care how it is used, where it is displayed. Prefixing an icon is not what this plugin should provide. You can create your own component function of lightline. That's what the configurability of lightline is.

let g:lightline = {
 \ 'active': {
 \ 'left': [ [ 'mode', 'paste' ],
 \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
 \ },
 \ 'component_function': {
 \ 'gitbranch': 'LightlineGitbranch'
 \ },
 \ }
let g:gitbranch_icon = '↝'
function! LightlineGitbranch()
	let l:bname = gitbranch#name()
	return l:bname != '' ? g:gitbranch_icon . ' ' . l:bname : ''
endfunction
pineapplegiant reacted with heart emoji

Copy link
Author

Thanks. I'm not sure why I was convinced a simple function wrapper wouldn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /