Lightline.vim: How to access the powerline font glyphs and further the git status?

Created on 16 May 2016  Â·  3Comments  Â·  Source: itchyny/lightline.vim

Hello itchyny,

Thank you for all of your work on these plug-ins; appreciate it. Can I ask your advice in activating the powerline glyphs in the status bar? Also, information/glyphs on the git status and read only mode; I am currently using both your lightline.vim and gitbranch.vim plugins and have the solarized theme in my terminal and vim, including the lightline colourized theme.

Thanks again.

configuration

Most helpful comment

The gitbranch.vim plugin only provides the information of the branch name. Further status of git is available with other plugins, for example, https://github.com/airblade/vim-gitgutter.
Here's an example of configuration of lightline, with gitbranch and gitgutter.

let g:lightline = {
      \ 'active': {
      \   'left': [ [ 'mode', 'paste' ], [ 'gitbranch', 'gitgutter', 'filename' ] ]
      \ },
      \ 'component_function': {
      \   'gitbranch': 'LightLineGitBranch',
      \   'gitgutter': 'LightLineGitGutter',
      \ }
      \ }

function! LightLineGitBranch()
  if exists("*gitbranch#name")
    let branch = gitbranch#name()
    return branch !=# '' ? 'â­  '.branch : ''
  endif
  return ''
endfunction

function! LightLineGitGutter()
  if exists('*GitGutterGetHunkSummary')
    let [ added, modified, removed ] = GitGutterGetHunkSummary()
    return printf('+%d ~%d -%d', added, modified, removed)
  endif
  return ''
endfunction

The font glyphs are listed in the document of lightline. See :h lightline-problem-9.

All 3 comments

The gitbranch.vim plugin only provides the information of the branch name. Further status of git is available with other plugins, for example, https://github.com/airblade/vim-gitgutter.
Here's an example of configuration of lightline, with gitbranch and gitgutter.

let g:lightline = {
      \ 'active': {
      \   'left': [ [ 'mode', 'paste' ], [ 'gitbranch', 'gitgutter', 'filename' ] ]
      \ },
      \ 'component_function': {
      \   'gitbranch': 'LightLineGitBranch',
      \   'gitgutter': 'LightLineGitGutter',
      \ }
      \ }

function! LightLineGitBranch()
  if exists("*gitbranch#name")
    let branch = gitbranch#name()
    return branch !=# '' ? 'â­  '.branch : ''
  endif
  return ''
endfunction

function! LightLineGitGutter()
  if exists('*GitGutterGetHunkSummary')
    let [ added, modified, removed ] = GitGutterGetHunkSummary()
    return printf('+%d ~%d -%d', added, modified, removed)
  endif
  return ''
endfunction

The font glyphs are listed in the document of lightline. See :h lightline-problem-9.

Superb, thank you for the pointer; your doc is really useful.

Thank you.

Was this page helpful?
0 / 5 - 0 ratings