Skip to content
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

How to show buffer number with filename? #58

Closed
ayutheos opened this issue Mar 21, 2014 · 5 comments
Closed

How to show buffer number with filename? #58

ayutheos opened this issue Mar 21, 2014 · 5 comments

Comments

@ayutheos
Copy link

How do I make lightline display buffer number together with filename e.g. 3:filename.txt in both active and inactive windows?

@itchyny
Copy link
Owner

itchyny commented Mar 21, 2014

let g:lightline = {
    \ 'component': {
    \   'filename': '%n:%t'
    \ }
    \ }

@ayutheos
Copy link
Author

Thanks for the quick reply. I forgot to add that I'm using your sample setting with named components. What do I need to modify to add the buffer number?

function! MyFilename()
  let fname = expand('%:t')
  return fname == 'ControlP' ? g:lightline.ctrlp_item :
        \ ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
        \ ('' != fname ? fname : '[No Name]') .
        \ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction

@itchyny
Copy link
Owner

itchyny commented Mar 21, 2014

function! MyFilename()
  let fname = expand('%:t')
  let nr = bufnr('')
  return nr . ':' . (fname == 'ControlP' ? g:lightline.ctrlp_item :
        \ ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
        \ ('' != fname ? fname : '[No Name]') .
        \ ('' != MyModified() ? ' ' . MyModified() : ''))
endfunction

@ayutheos
Copy link
Author

Thanks! :)

@itchyny itchyny closed this as completed Mar 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@itchyny @ayutheos and others