vim-crystalline


Ⅰ. 插件描述

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

Ⅱ. 基本信息

创建日期:  2019-05-17
使用用户:  1
Github星:  193
插件作者:  rbong

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'rbong/vim-crystalline'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'rbong/vim-crystalline'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'rbong/vim-crystalline'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/rbong/vim-crystalline

Ⅳ. 文档说明

# 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.

The default version of vim-crystalline requires Vim 8.
To install on vim-7, use:

Plug 'rbong/vim-crystalline', { 'branch': 'vim-7' }

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}[%{&fenc!=#""?&fenc:&enc}][%{&ff}] %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}[%{&fenc!=#""?&fenc:&enc}][%{&ff}] %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}[%{&fenc!=#""?&fenc:&enc}][%{&ff}] %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}[%{&fenc!=#""?&fenc:&enc}][%{&ff}] %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}[%{&fenc!=#""?&fenc:&enc}][%{&ff}] %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.

添加新评论