GithubHelp home page GithubHelp logo

zchee / vim-crystalline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rbong/vim-crystalline

0.0 2.0 0.0 61 KB

Functions for taking the monotony out of building your own fancy statusline in Vim

Ruby 0.60% Vim Script 99.40%

vim-crystalline's Introduction

vim-crystalline

Build Status

Want a nice statusline in vim? vim-airline too slow? lightline.vim too verbose? vim-crystalline is for you.

vim-crystalline lets you build your own statusline and tabline in a vanilla vim style. It also comes with a bufferline!

Obligatory Colorful Theme Screenshots

default

img

badwolf

img

dracula

img

gruvbox (dark)

img

gruvbox (light)

img

hybrid (dark)

img

hybrid (light)

img

jellybeans

img

molokai

img

onedark

img

papercolor

img

solarized (dark)

img

solarized (light)

img

Making your own theme

To make your own theme, see :help crystalline-themes. If you'd like to port an airline theme, see Porting Airline Themes on the wiki.

Installation

Using vim-plug, put this in your .vimrc between plug#begin() and plug#end():

Plug 'rbong/vim-crystalline'

Now run :PlugInstall after restarting vim. Refer to your plugin manager of choice's documentation if you don't use vim-plug.

Examples

Jump straight to the last example if you just want to see everything crystalline can do. All examples go in your .vimrc before vim-crystalline is loaded.

See :help statusline for more information on the statusline syntax used in these examples.

Basic Vim Syntax

function! StatusLine()
  return ' %f%h%w%m%r '
endfunction
set statusline=%!StatusLine()
set laststatus=2

Statusline Mode Colors

function! StatusLine(...)
  return crystalline#mode() . ' %f%h%w%m%r '
endfunction
let g:crystalline_statusline_fn = 'StatusLine'
let g:crystalline_theme = 'default'
set laststatus=2

Hiding Sections In Inactive Windows

function! StatusLine(current)
  return ' %f%h%w%m%r '
        \ . (a:current ? '%= %{&ft}[%{&enc}][%{&ffs}] %l/%L %c%V %P ' : '')
endfunction
let g:crystalline_statusline_fn = 'StatusLine'
set laststatus=2

Using Themes

function! StatusLine(...)
  return '%#Crystalline# %f%h%w%m%r %#CrystallineFill#'
        \ . '%=%#Crystalline# %{&ft}[%{&enc}][%{&ffs}] %l/%L %c%V %P '
endfunction
let g:crystalline_statusline_fn = 'StatusLine'
let g:crystalline_theme = 'default'
set laststatus=2

Adding More Statusline Information

function! StatusLine(...)
  return ' %f%h%w%m%r %{fugitive#head()} %{&paste ?"PASTE ":""}%{&spell?"SPELL ":""}'
endfunction
let g:crystalline_statusline_fn = 'StatusLine'
set laststatus=2

Hiding Sections Based on Window Width

function! StatusLine(current, width)
  return ' %f%h%w%m%r '
        \ . (a:width > 80 ? '%= %{&ft}[%{&enc}][%{&ffs}] %l/%L %c%V %P ' : '')
endfunction
let g:crystalline_statusline_fn = 'StatusLine'
set laststatus=2

Adding Powerline-Style Separators Between Sections

function! StatusLine(...)
  return crystalline#mode() . crystalline#right_mode_sep('')
        \ . ' %f%h%w%m%r ' . crystalline#right_sep('', 'Fill') . '%='
        \ . crystalline#left_sep('', 'Fill') . ' %{&ft}[%{&enc}][%{&ffs}] %l/%L %c%V %P '
endfunction
let g:crystalline_enable_sep = 1
let g:crystalline_statusline_fn = 'StatusLine'
let g:crystalline_theme = 'default'
set laststatus=2

The strings passed to separator functions are groups from :help crystalline-highlight-groups with Crystalline omitted.

Using the Bufferline

set tabline=%!crystalline#bufferline()
set showtabline=2

Enabling the Bufferline in Gvim

set tabline=%!crystalline#bufferline()
set showtabline=2
set guioptions-=e

Bufferline Current Tab Mode Colors

function! TabLine()
  return crystalline#bufferline(0, 0, 1)
endfunction
let g:crystalline_tabline_fn = 'TabLine'
set showtabline=2

Adding More Tabline Information

function! TabLine()
  let l:vimlabel = has('nvim') ?  ' NVIM ' : ' VIM '
  return crystalline#bufferline(2, len(l:vimlabel), 1) . '%=%#CrystallineTab# ' . l:vimlabel
endfunction
let g:crystalline_tabline_fn = 'TabLine'
set showtabline=2

The first two options to the bufferline indicate the number of % items used and the character width used.

Full Example

function! StatusLine(current, width)
  let l:s = ''

  if a:current
    let l:s .= crystalline#mode() . crystalline#right_mode_sep('')
  else
    let l:s .= '%#CrystallineInactive#'
  endif
  let l:s .= ' %f%h%w%m%r '
  if a:current
    let l:s .= crystalline#right_sep('', 'Fill') . ' %{fugitive#head()}'
  endif

  let l:s .= '%='
  if a:current
    let l:s .= crystalline#left_sep('', 'Fill') . ' %{&paste ?"PASTE ":""}%{&spell?"SPELL ":""}'
    let l:s .= crystalline#left_mode_sep('')
  endif
  if a:width > 80
    let l:s .= ' %{&ft}[%{&enc}][%{&ffs}] %l/%L %c%V %P '
  else
    let l:s .= ' '
  endif

  return l:s
endfunction

function! TabLine()
  let l:vimlabel = has('nvim') ?  ' NVIM ' : ' VIM '
  return crystalline#bufferline(2, len(l:vimlabel), 1) . '%=%#CrystallineTab# ' . l:vimlabel
endfunction

let g:crystalline_enable_sep = 1
let g:crystalline_statusline_fn = 'StatusLine'
let g:crystalline_tabline_fn = 'TabLine'
let g:crystalline_theme = 'default'

set showtabline=2
set guioptions-=e
set laststatus=2

More Info

See :help crystalline for more information.

Don't hesitate to post an issue if you have any questions, suggestions, or bugs.

Feel free to make a pull request if you'd like to to contribute. It's much appreciated.

vim-crystalline's People

Contributors

rbong avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.