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 use and customize eleline without forking the repo? #45

Open
renkam opened this issue Jun 10, 2021 · 1 comment
Open

How to use and customize eleline without forking the repo? #45

renkam opened this issue Jun 10, 2021 · 1 comment

Comments

@renkam
Copy link

renkam commented Jun 10, 2021

Is there a way to define some magic variable like let g:eleline_custom_status_func = "MyStatusLine" or something similar?

@rockyzhang24
Copy link
Contributor

rockyzhang24 commented Aug 27, 2021

I think the best way to customize eleline is to fork it and tweak it. The code is very straightforward and clear.

For example, if you want to add an item on the statusline, you just need a few steps:

  1. Define a function say ElelineItem() that returns the contents you want to show on the statusline
function! ElelineItem() abort
  ...
  return "abc"
endfunction
  1. Colorize it by calling s:def('ElelineItem') in s:StatusLine().
function! s:StatusLine() abort
  ...
  let l:item = s:def('ElelineItem')
  ...
endfunction
  1. Finally, insert it to the return
function! s:StatusLine() abort
  ...
  let l:item = s:def('ElelineItem')
  ...
  return l:prefix . l:tot . '%<' . l:fsize . l:common . l:item
        \ .'%='.l:m_r_f.l:pos.l:enc.l:ff.l:pct
endfunction

You can also refer to my customization here if you want. I attached the effect of my customization below.

image

Hope this is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants