1
0
Fork 0
mirror of synced 2024-11-22 08:45:34 -05:00

Updated all the plugins. Removed powerline. Added vim-airline (replacement for powerline). Added vim-fugitive.

This commit is contained in:
amix 2013-11-16 19:45:48 +00:00
parent 351979d3e0
commit 86f4456be1
239 changed files with 14942 additions and 8068 deletions

View file

@ -64,7 +64,6 @@ I recommend reading the docs of these plugins to understand them better. Each of
* [bufexplorer.zip](https://github.com/vim-scripts/bufexplorer.zip): Buffer Explorer / Browser. This plugin can be opened with `<leader+o>` * [bufexplorer.zip](https://github.com/vim-scripts/bufexplorer.zip): Buffer Explorer / Browser. This plugin can be opened with `<leader+o>`
* [NERD Tree](https://github.com/scrooloose/nerdtree): A tree explorer plugin for vim * [NERD Tree](https://github.com/scrooloose/nerdtree): A tree explorer plugin for vim
* [ack.vim](github.com/mileszs/ack.vim): Vim plugin for the Perl module / CLI script 'ack' * [ack.vim](github.com/mileszs/ack.vim): Vim plugin for the Perl module / CLI script 'ack'
* [vim-powerline](https://github.com/Lokaltog/vim-powerline): The ultimate vim statusline utility
* [ctrlp.vim](https://github.com/kien/ctrlp.vim): Fuzzy file, buffer, mru and tag finder. In my config it's mapped to `<Ctrl+F>`, because `<Ctrl+P>` is used by YankRing * [ctrlp.vim](https://github.com/kien/ctrlp.vim): Fuzzy file, buffer, mru and tag finder. In my config it's mapped to `<Ctrl+F>`, because `<Ctrl+P>` is used by YankRing
* [mru.vim](https://github.com/vim-scripts/mru.vim): Plugin to manage Most Recently Used (MRU) files. Includes my own fork which adds syntax highlighting to MRU. This plugin can be opened with `<leader+f>` * [mru.vim](https://github.com/vim-scripts/mru.vim): Plugin to manage Most Recently Used (MRU) files. Includes my own fork which adds syntax highlighting to MRU. This plugin can be opened with `<leader+f>`
* [open_file_under_cursor.vim](https://github.com/amix/open_file_under_cursor.vim): Open file under cursor when pressing `gf` * [open_file_under_cursor.vim](https://github.com/amix/open_file_under_cursor.vim): Open file under cursor when pressing `gf`
@ -73,6 +72,8 @@ I recommend reading the docs of these plugins to understand them better. Each of
* [taglist.vim](https://github.com/vim-scripts/taglist.vim): Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc) * [taglist.vim](https://github.com/vim-scripts/taglist.vim): Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)
* [vim-multiple-cursors](https://github.com/terryma/vim-multiple-cursors): Sublime Text style multiple selections for Vim, CTRL+N is remapped to CTRL+S (due to YankRing) * [vim-multiple-cursors](https://github.com/terryma/vim-multiple-cursors): Sublime Text style multiple selections for Vim, CTRL+N is remapped to CTRL+S (due to YankRing)
* [vim-expand-region](https://github.com/terryma/vim-expand-region): Allows you to visually select increasingly larger regions of text using the same key combination. * [vim-expand-region](https://github.com/terryma/vim-expand-region): Allows you to visually select increasingly larger regions of text using the same key combination.
* [vim-airline](https://github.com/bling/vim-airline): Lean & mean status/tabline for vim that's light as air (replacing powerline)
* [vim-fugitive](https://github.com/tpope/vim-fugitive): A Git wrapper so awesome, it should be illegal
## What color schemes are included? ## What color schemes are included?

File diff suppressed because one or more lines are too long

View file

@ -1,107 +0,0 @@
=================
Powerline for vim
=================
:Author: Kim Silkebækken (kim.silkebaekken+vim@gmail.com)
:Source: https://github.com/Lokaltog/vim-powerline
:Version: β
Introduction
------------
Powerline is a utility plugin which allows you to create better-looking,
more functional vim statuslines. See the screenshots below for
a demonstration of the plugin's capabilities.
It's recommended that you install the plugin using Pathogen_ or Vundle_.
After the plugin is installed update your help tags and see ``:help
Powerline`` for instructions on how to enable and configure the plugin.
See the `Troubleshooting`_ section below if you're having any issues with
the plugin or the font patcher.
**Note:** You need a patched font to be able to use the symbols in the
statusline. An experimental Python/fontforge-based font patcher is included
in the ``fontpatcher`` directory. See ``fontpatcher/README.rst`` for usage
instructions.
.. _Pathogen: https://github.com/tpope/vim-pathogen
.. _Vundle: https://github.com/gmarik/vundle
Screenshots
-----------
.. image:: http://i.imgur.com/MsuIB.png
Troubleshooting
---------------
I can't see the fancy symbols, what's wrong?
Make sure that you have ``let g:Powerline_symbols = 'fancy'`` in your
``vimrc`` file. The settings may be loaded too late if you have this in
``gvimrc``, so always put this in your ``vimrc``.
Clear the cache using ``:PowerlineClearCache`` and restart vim.
Make sure that you've configured gvim or your terminal emulator to use
a patched font.
Make sure that vim is compiled with the ``--with-features=big`` flag.
The fancy symbols look a bit blurry or "off"!
Make sure that you have patched all variants of your font (i.e. both the
regular and the bold font files).
I'm unable to patch my font, what should I do?
Font patching is only known to work on most Linux and OS X machines. If
you have followed the instructions in the fontpatcher README and still
have problems, please submit an issue on GitHub.
You can download some community-contributed patched fonts from the
`Powerline wiki`_ if you don't want to mess around with the font
patcher.
The Syntastic/Fugitive statusline flags don't work!
These flags should work without any configuration. If you installed
either plugin after Powerline, you'll have to clear the cache using
``:PowerlineClearCache`` and restart vim.
The colors are weird in the default OS X Terminal app!
The default OS X Terminal app is known to have some issues with the
Powerline colors. Please use another terminal emulator. iTerm2 should
work fine.
The arrows may have the wrong colors if you have changed the "minimum
contrast" slider in the color tab of your OS X settings.
The statusline has strange characters like ``^B`` in it!
Please add ``set encoding=utf-8`` to your ``vimrc``.
You may also need to set your ``LANG`` and ``LC_*`` environment
variables to a UTF-8 locale (e.g. ``LANG=en_US.utf8``). Consult your
Linux distro's documentation for information about setting these
variables correctly.
The statusline has a lot of ``^`` or underline characters in it!
You need to configure the ``fillchars`` setting to disable statusline
fillchars (see ``:h fillchars`` for details). Add this to your
``vimrc`` to solve this issue::
set fillchars+=stl:\ ,stlnc:\
The statusline is hidden/only appears in split windows!
Make sure that you have ``set laststatus=2`` in your ``vimrc``.
I'm using tmux and Powerline looks like crap, what's wrong?
You need to tell tmux that it has 256-color capabilities. Add this to
your ``.tmux.conf`` to solve this issue::
set -g default-terminal "screen-256color"
If you use iTerm2, make sure that you have enabled the setting 'Set
locale variables automatically' in Profiles > Terminal > Environment.
If you have any other issues and you can't find the answer in the docs,
please submit an issue on GitHub.
.. _`Powerline wiki`: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts

View file

@ -1,183 +0,0 @@
" Powerline - The ultimate statusline utility
"
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
" Source repository: https://github.com/Lokaltog/vim-powerline
" Script variables {{{
let g:Pl#OLD_STL = ''
let g:Pl#THEME = []
let g:Pl#THEME_CALLBACKS = []
let g:Pl#HL = []
" Cache revision, this must be incremented whenever the cache format is changed
let s:CACHE_REVISION = 7
" }}}
" Script initialization {{{
function! Pl#LoadCache() " {{{
if filereadable(g:Powerline_cache_file) && g:Powerline_cache_enabled
exec 'source' escape(g:Powerline_cache_file, ' \')
if ! exists('g:Powerline_cache_revision') || g:Powerline_cache_revision != s:CACHE_REVISION
" Cache revision differs, cache is invalid
unlet! g:Powerline_cache_revision
return 0
endif
" Create highlighting groups
for hi_cmd in g:Pl#HL
exec hi_cmd
endfor
" Run theme callbacks
for callback in g:Pl#THEME_CALLBACKS
" Substitute {{NEWLINE}} with newlines (strings must be
" stored without newlines characters to avoid vim errors)
exec substitute(callback[0], "{{NEWLINE}}", "\n", 'g')
exec substitute(callback[1], "{{NEWLINE}}", "\n", 'g')
endfor
return 1
endif
return 0
endfunction " }}}
function! Pl#ClearCache() " {{{
if filereadable(g:Powerline_cache_file)
" Delete the cache file
call delete(g:Powerline_cache_file)
endif
echo 'Powerline cache cleared. Please restart vim for the changes to take effect.'
endfunction " }}}
function! Pl#ReloadColorscheme() " {{{
call Pl#ClearCache()
" The colorscheme and theme files must be manually sourced because
" vim won't reload previously autoloaded files
"
" This is a bit hackish, but it works
unlet! g:Powerline#Colorschemes#{g:Powerline_colorscheme}#colorscheme
exec "source" split(globpath(&rtp, 'autoload/Powerline/Colorschemes/'. g:Powerline_colorscheme .'.vim', 1), '\n')[0]
unlet! g:Powerline#Themes#{g:Powerline_theme}#theme
exec "source" split(globpath(&rtp, 'autoload/Powerline/Themes/'. g:Powerline_theme .'.vim', 1), '\n')[0]
let g:Pl#THEME = []
call Pl#Load()
endfunction " }}}
function! Pl#Load() " {{{
if empty(g:Pl#OLD_STL)
" Store old statusline
let g:Pl#OLD_STL = &statusline
endif
if ! Pl#LoadCache()
try
" Autoload the theme dict first
let raw_theme = g:Powerline#Themes#{g:Powerline_theme}#theme
catch
echom 'Invalid Powerline theme! Please check your theme and colorscheme settings.'
return
endtry
" Create list with parsed statuslines
for buffer_statusline in raw_theme
unlet! mode_statuslines
let mode_statuslines = Pl#Parser#GetStatusline(buffer_statusline.segments)
if ! empty(buffer_statusline.callback)
" The callback function passes its arguments on to
" Pl#StatuslineCallback along with the normal/current mode
" statusline.
let s:cb_func = "function! PowerlineStatuslineCallback_". buffer_statusline.callback[1] ."(...)\n"
let s:cb_func .= "return Pl#StatuslineCallback(". string(mode_statuslines['n']) .", a:000)\n"
let s:cb_func .= "endfunction"
" The callback expression should be used to initialize any
" variables that will use the callback function. The
" expression requires a %s which will be replaced by the
" callback function name.
let s:cb_expr = printf(buffer_statusline.callback[2], 'PowerlineStatuslineCallback_'. buffer_statusline.callback[1])
exec s:cb_func
exec s:cb_expr
" Newlines must be substituted with another character
" because vim doesn't like newlines in strings
call add(g:Pl#THEME_CALLBACKS, [substitute(s:cb_func, "\n", "{{NEWLINE}}", 'g'), substitute(s:cb_expr, "\n", "{{NEWLINE}}", 'g')])
unlet! s:cb_func s:cb_expr
continue
endif
" Store the statuslines for matching specific buffers
call add(g:Pl#THEME, {
\ 'matches': buffer_statusline.matches,
\ 'mode_statuslines': mode_statuslines
\ })
endfor
if ! g:Powerline_cache_enabled
" Don't cache anything if caching is disabled or cache file isn't writeable
return
endif
" Prepare commands and statuslines for caching
let cache = [
\ 'let g:Powerline_cache_revision = '. string(s:CACHE_REVISION),
\ 'let g:Pl#HL = '. string(g:Pl#HL),
\ 'let g:Pl#THEME = '. string(g:Pl#THEME),
\ 'let g:Pl#THEME_CALLBACKS = '. string(g:Pl#THEME_CALLBACKS),
\ ]
call writefile(cache, g:Powerline_cache_file)
endif
endfunction " }}}
" }}}
" Statusline updater {{{
function! Pl#Statusline(statusline, current) " {{{
let mode = mode()
if ! a:current
let mode = 'N' " Normal (non-current)
elseif mode =~# '\v(v|V|)'
let mode = 'v' " Visual mode
elseif mode =~# '\v(s|S|)'
let mode = 's' " Select mode
elseif mode =~# '\vi'
let mode = 'i' " Insert mode
elseif mode =~# '\v(R|Rv)'
let mode = 'r' " Replace mode
else
" Fallback to normal mode
let mode = 'n' " Normal (current)
endif
return g:Pl#THEME[a:statusline].mode_statuslines[mode]
endfunction " }}}
function! Pl#StatuslineCallback(statusline, args) " {{{
" Replace %1, %2, etc. in the statusline with the callback args
return substitute(
\ a:statusline,
\ '\v\%(\d+)',
\ '\=a:args[submatch(1)]',
\ 'g')
endfunction " }}}
function! Pl#UpdateStatusline(current) " {{{
if empty(g:Pl#THEME)
" Load statuslines if they aren't loaded yet
call Pl#Load()
endif
for i in range(0, len(g:Pl#THEME) - 1)
if Pl#Match#Validate(g:Pl#THEME[i])
" Update window-local statusline
let &l:statusline = '%!Pl#Statusline('. i .','. a:current .')'
endif
endfor
endfunction " }}}
" }}}

View file

@ -1,145 +0,0 @@
function! Pl#Colorscheme#Init(hi) " {{{
let colorscheme = {}
for hi in a:hi
" Ensure that the segments are a list
let segments = type(hi[0]) == type('') ? [ hi[0] ] : hi[0]
let mode_hi_dict = hi[1]
for segment in segments
let colorscheme[segment] = mode_hi_dict
endfor
endfor
return colorscheme
endfunction " }}}
function! Pl#Colorscheme#Apply(colorscheme, buffer_segments) " {{{
" Set color parameters for all segments in a:buffer_segments
" TODO This function should be recursive and work on both segments and groups
" TODO We could probably handle the NS stuff here...
try
let colorscheme = g:Powerline#Colorschemes#{a:colorscheme}#colorscheme
catch
echom 'Color scheme "'. a:colorscheme .'" doesn''t exist!'
return
endtry
let buffer_segments = a:buffer_segments
" This is a bit complex, I'll walk you through exactly what happens here...
"
" First of all we loop through the buffer_segments, which are the segments that
" this specific buffer will have.
for buffer_segment in buffer_segments
" The buffer_segment consists of a 'matches' list and a 'segments' list.
" The 'matches' list has conditions to limit this statusline to specific buffers/windows.
" The 'segments' list has each segment and segment group for this buffer
for segment in buffer_segment.segments
let type = get(segment, 'type', '')
if type == 'segment_group'
" We're going to handle segment groups different from single segments. Segment groups
" have child segments which may have their own highlighting (e.g. fileinfo.flags),
" and these child segments may be grouped (e.g. fileinfo.flags.ro) to provide very
" specific highlighting. So here we'll handle all that:
" Set the default/fallback colors for this group
for i in range(len(segment.variants), 0, -1)
" Check for available highlighting for the main group segment
"
" This works like the segment highlighting below
" TODO Create a function for this
let seg_variants = join(segment.variants[0:i], '.')
let seg_name = i > 0 ? segment.name .'.'. seg_variants : segment.name
let seg_ns_name = len(segment.ns) > 0 ? segment.ns .':'. seg_name : seg_name
if has_key(colorscheme, seg_ns_name)
" We have a namespaced highlight group
let segment.colors = colorscheme[seg_ns_name]
break
elseif has_key(colorscheme, seg_name)
" We have a non-namespaced group
let segment.colors = colorscheme[seg_name]
break
endif
endfor
" The reason why we need to deepcopy the group's segments is that the child segments
" all point to the same base segments and that screws up highlighting if we highlight
" some child segments with different namespaced colors
let segment.segments = deepcopy(segment.segments)
" Apply colors to each child segment
for child_segment in segment.segments
" Check if this child segment is grouped (e.g. fileinfo.flags.group.subgroup)
" We're going to prioritize the most specific grouping and then work back to the
" most common group (e.g. fileinfo.flags)
" FIXME We don't have the variants from before because group children aren't run through Pl#Segment#Get
let child_segment.variants = [seg_name] + split(child_segment.name, '\.')
" Use the parent group's namespace
let child_segment.ns = segment.ns
for i in range(len(child_segment.variants), 0, -1)
" Check for available highlighting for the main group segment
let child_seg_name = join(child_segment.variants[0:i], '.')
let child_seg_ns_name = len(child_segment.ns) > 0 ? child_segment.ns .':'. child_seg_name : child_seg_name
if has_key(colorscheme, child_seg_ns_name)
" We have a namespaced highlight group
let child_segment.colors = colorscheme[child_seg_ns_name]
break
elseif has_key(colorscheme, child_seg_name)
" We have a non-namespaced group
let child_segment.colors = colorscheme[child_seg_name]
break
endif
endfor
endfor
elseif type == 'segment'
for i in range(len(segment.variants), 0, -1)
" Check for available highlighting
"
" This is done in the following manner, using the segment gundo:static_filename.text.buffer as an example:
"
" * Look for the hl group: gundo:static_filename.text.buffer
" * Look for the hl group: static_filename.text.buffer
" * Look for the hl group: gundo:static_filename.text
" * Look for the hl group: static_filename.text
" * Look for the hl group: gundo:static_filename
" * Look for the hl group: static_filename
" * Return the segment without highlighting, causing an error in the parser
let seg_variants = join(segment.variants[0:i], '.')
let seg_name = i > 0 ? segment.name .'.'. seg_variants : segment.name
let seg_ns_name = len(segment.ns) > 0 ? segment.ns .':'. seg_name : seg_name
if has_key(colorscheme, seg_ns_name)
" We have a namespaced highlight group
let segment.colors = colorscheme[seg_ns_name]
break
elseif has_key(colorscheme, seg_name)
" We have a non-namespaced group
let segment.colors = colorscheme[seg_name]
break
endif
endfor
endif
unlet! segment
endfor
endfor
" Good luck parsing this return value
"
" It's a huge dict with all segments for all buffers with their respective syntax highlighting.
" It will be parsed by the main Powerline code, where all the data will be shortened to a simple
" array consiting of a statusline for each mode, with generated highlighting groups and dividers.
return buffer_segments
endfunction " }}}

View file

@ -1,140 +0,0 @@
" cterm -> gui color dict {{{
let s:cterm2gui_dict = {
\ 16: 0x000000, 17: 0x00005f, 18: 0x000087, 19: 0x0000af, 20: 0x0000d7, 21: 0x0000ff,
\ 22: 0x005f00, 23: 0x005f5f, 24: 0x005f87, 25: 0x005faf, 26: 0x005fd7, 27: 0x005fff,
\ 28: 0x008700, 29: 0x00875f, 30: 0x008787, 31: 0x0087af, 32: 0x0087d7, 33: 0x0087ff,
\ 34: 0x00af00, 35: 0x00af5f, 36: 0x00af87, 37: 0x00afaf, 38: 0x00afd7, 39: 0x00afff,
\ 40: 0x00d700, 41: 0x00d75f, 42: 0x00d787, 43: 0x00d7af, 44: 0x00d7d7, 45: 0x00d7ff,
\ 46: 0x00ff00, 47: 0x00ff5f, 48: 0x00ff87, 49: 0x00ffaf, 50: 0x00ffd7, 51: 0x00ffff,
\ 52: 0x5f0000, 53: 0x5f005f, 54: 0x5f0087, 55: 0x5f00af, 56: 0x5f00d7, 57: 0x5f00ff,
\ 58: 0x5f5f00, 59: 0x5f5f5f, 60: 0x5f5f87, 61: 0x5f5faf, 62: 0x5f5fd7, 63: 0x5f5fff,
\ 64: 0x5f8700, 65: 0x5f875f, 66: 0x5f8787, 67: 0x5f87af, 68: 0x5f87d7, 69: 0x5f87ff,
\ 70: 0x5faf00, 71: 0x5faf5f, 72: 0x5faf87, 73: 0x5fafaf, 74: 0x5fafd7, 75: 0x5fafff,
\ 76: 0x5fd700, 77: 0x5fd75f, 78: 0x5fd787, 79: 0x5fd7af, 80: 0x5fd7d7, 81: 0x5fd7ff,
\ 82: 0x5fff00, 83: 0x5fff5f, 84: 0x5fff87, 85: 0x5fffaf, 86: 0x5fffd7, 87: 0x5fffff,
\ 88: 0x870000, 89: 0x87005f, 90: 0x870087, 91: 0x8700af, 92: 0x8700d7, 93: 0x8700ff,
\ 94: 0x875f00, 95: 0x875f5f, 96: 0x875f87, 97: 0x875faf, 98: 0x875fd7, 99: 0x875fff,
\ 100: 0x878700, 101: 0x87875f, 102: 0x878787, 103: 0x8787af, 104: 0x8787d7, 105: 0x8787ff,
\ 106: 0x87af00, 107: 0x87af5f, 108: 0x87af87, 109: 0x87afaf, 110: 0x87afd7, 111: 0x87afff,
\ 112: 0x87d700, 113: 0x87d75f, 114: 0x87d787, 115: 0x87d7af, 116: 0x87d7d7, 117: 0x87d7ff,
\ 118: 0x87ff00, 119: 0x87ff5f, 120: 0x87ff87, 121: 0x87ffaf, 122: 0x87ffd7, 123: 0x87ffff,
\ 124: 0xaf0000, 125: 0xaf005f, 126: 0xaf0087, 127: 0xaf00af, 128: 0xaf00d7, 129: 0xaf00ff,
\ 130: 0xaf5f00, 131: 0xaf5f5f, 132: 0xaf5f87, 133: 0xaf5faf, 134: 0xaf5fd7, 135: 0xaf5fff,
\ 136: 0xaf8700, 137: 0xaf875f, 138: 0xaf8787, 139: 0xaf87af, 140: 0xaf87d7, 141: 0xaf87ff,
\ 142: 0xafaf00, 143: 0xafaf5f, 144: 0xafaf87, 145: 0xafafaf, 146: 0xafafd7, 147: 0xafafff,
\ 148: 0xafd700, 149: 0xafd75f, 150: 0xafd787, 151: 0xafd7af, 152: 0xafd7d7, 153: 0xafd7ff,
\ 154: 0xafff00, 155: 0xafff5f, 156: 0xafff87, 157: 0xafffaf, 158: 0xafffd7, 159: 0xafffff,
\ 160: 0xd70000, 161: 0xd7005f, 162: 0xd70087, 163: 0xd700af, 164: 0xd700d7, 165: 0xd700ff,
\ 166: 0xd75f00, 167: 0xd75f5f, 168: 0xd75f87, 169: 0xd75faf, 170: 0xd75fd7, 171: 0xd75fff,
\ 172: 0xd78700, 173: 0xd7875f, 174: 0xd78787, 175: 0xd787af, 176: 0xd787d7, 177: 0xd787ff,
\ 178: 0xd7af00, 179: 0xd7af5f, 180: 0xd7af87, 181: 0xd7afaf, 182: 0xd7afd7, 183: 0xd7afff,
\ 184: 0xd7d700, 185: 0xd7d75f, 186: 0xd7d787, 187: 0xd7d7af, 188: 0xd7d7d7, 189: 0xd7d7ff,
\ 190: 0xd7ff00, 191: 0xd7ff5f, 192: 0xd7ff87, 193: 0xd7ffaf, 194: 0xd7ffd7, 195: 0xd7ffff,
\ 196: 0xff0000, 197: 0xff005f, 198: 0xff0087, 199: 0xff00af, 200: 0xff00d7, 201: 0xff00ff,
\ 202: 0xff5f00, 203: 0xff5f5f, 204: 0xff5f87, 205: 0xff5faf, 206: 0xff5fd7, 207: 0xff5fff,
\ 208: 0xff8700, 209: 0xff875f, 210: 0xff8787, 211: 0xff87af, 212: 0xff87d7, 213: 0xff87ff,
\ 214: 0xffaf00, 215: 0xffaf5f, 216: 0xffaf87, 217: 0xffafaf, 218: 0xffafd7, 219: 0xffafff,
\ 220: 0xffd700, 221: 0xffd75f, 222: 0xffd787, 223: 0xffd7af, 224: 0xffd7d7, 225: 0xffd7ff,
\ 226: 0xffff00, 227: 0xffff5f, 228: 0xffff87, 229: 0xffffaf, 230: 0xffffd7, 231: 0xffffff,
\ 232: 0x080808, 233: 0x121212, 234: 0x1c1c1c, 235: 0x262626, 236: 0x303030, 237: 0x3a3a3a,
\ 238: 0x444444, 239: 0x4e4e4e, 240: 0x585858, 241: 0x626262, 242: 0x6c6c6c, 243: 0x767676,
\ 244: 0x808080, 245: 0x8a8a8a, 246: 0x949494, 247: 0x9e9e9e, 248: 0xa8a8a8, 249: 0xb2b2b2,
\ 250: 0xbcbcbc, 251: 0xc6c6c6, 252: 0xd0d0d0, 253: 0xdadada, 254: 0xe4e4e4, 255: 0xeeeeee
\ }
" }}}
" Allocated color dict {{{
let s:allocated_colors = {
\ 'NONE': 'NONE',
\ }
" }}}
function! s:Cterm2GUI(cterm) " {{{
if toupper(a:cterm) == 'NONE'
return 'NONE'
endif
if ! has_key(s:cterm2gui_dict, a:cterm)
return 0xff0000
endif
return s:cterm2gui_dict[a:cterm]
endfunction " }}}
function! Pl#Hi#Segments(segments, mode_colors) " {{{
let mode_translate = {
\ 'normal': 'n',
\ 'noncurrent': 'N',
\ 'insert': 'i',
\ 'visual': 'v',
\ 'replace': 'r',
\ 'select': 's',
\ }
let attributes = ['bold', 'italic', 'underline']
let segments = a:segments
let mode_hi_dict = {}
" Mode dict
for [mode, colors] in items(a:mode_colors)
if has_key(mode_translate, mode)
let mode = mode_translate[mode]
endif
unlet! fg
let fg = s:allocated_colors[colors[0]]
let hi = {
\ 'cterm': [fg['cterm'], ''],
\ 'gui' : [fg['gui'], ''],
\ 'attr' : []
\ }
if exists('colors[1]')
if type(colors[1]) == type([])
" We don't have a BG color, but we have attributes
let hi.attr = colors[1]
else
" The second parameter is the background color
unlet! bg
let bg = s:allocated_colors[colors[1]]
let hi.cterm[1] = bg['cterm']
let hi.gui[1] = bg['gui']
endif
endif
if exists('colors[2]') && type(colors[2]) == type([])
" The third parameter is always an attribute list
let hi.attr = colors[2]
endif
let mode_hi_dict[mode] = {
\ 'ctermfg': (empty(hi['cterm'][0]) ? '' : (string(hi['cterm'][0]) == 'NONE' ? 'NONE' : hi['cterm'][0])),
\ 'ctermbg': (empty(hi['cterm'][1]) ? '' : (string(hi['cterm'][1]) == 'NONE' ? 'NONE' : hi['cterm'][1])),
\ 'guifg' : (empty(hi['gui'][0]) ? '' : (string(hi['gui'][0]) == 'NONE' ? 'NONE' : hi['gui'][0])),
\ 'guibg' : (empty(hi['gui'][1]) ? '' : (string(hi['gui'][1]) == 'NONE' ? 'NONE' : hi['gui'][1])),
\ 'attr' : (! len(hi['attr']) ? 'NONE' : join(hi['attr'], ','))
\ }
endfor
return [segments, mode_hi_dict]
endfunction " }}}
function! Pl#Hi#Allocate(colors) " {{{
for [key, color] in items(a:colors)
if type(color) == type(0)
" Only terminal color
let cterm = color
let gui = s:Cterm2GUI(color)
elseif type(color) == type([]) && len(color) == 2
" Terminal and GUI colors
let cterm = color[0]
let gui = color[1]
endif
let s:allocated_colors[key] = {
\ 'cterm': cterm,
\ 'gui': gui,
\ }
unlet! color
endfor
endfunction " }}}

View file

@ -1,43 +0,0 @@
function! Pl#Match#Add(pat, expr) " {{{
return [a:pat, a:expr]
endfunction " }}}
function! Pl#Match#Any(...) " {{{
let matches = []
for match_name in a:000
if empty(match_name)
" Skip empty match parameters
continue
endif
if has_key(g:Powerline#Matches#matches, match_name)
call add(matches, g:Powerline#Matches#matches[match_name])
endif
unlet! match_name
endfor
return ['match', 'any', matches]
endfunction " }}}
function! Pl#Match#Validate(theme) " {{{
let match = a:theme.matches[1]
if match == 'none'
return 0
elseif match == 'any'
let matches = a:theme.matches[2]
if ! len(matches)
" Empty match array matches everything
return 1
endif
for [eval, re] in matches
if match(eval(eval), '\v'. re) != -1
return 1
endif
endfor
return 0
endif
endfunction " }}}

View file

@ -1,40 +0,0 @@
let s:segment_mods = []
function! Pl#Mod#AddSegmentMod(action, properties) " {{{
call add(s:segment_mods, [a:action, a:properties])
endfunction " }}}
function! Pl#Mod#ApplySegmentMods(theme) " {{{
let theme = deepcopy(a:theme)
for mod in s:segment_mods
let [action, properties] = mod
" We have to loop through the segments instead of using index() because some
" segments are lists!
let target_seg_idx = -1
for i in range(0, len(theme) - 1)
unlet! segment
let segment = theme[i]
if type(segment) == type(properties.target_segment) && segment == properties.target_segment
let target_seg_idx = i
break
endif
endfor
if action == 'insert_segment'
" Insert segment
if target_seg_idx != -1
call insert(theme, properties.new_segment, (properties.where == 'before' ? target_seg_idx : target_seg_idx + 1))
endif
elseif action == 'remove_segment'
" Remove segment
if target_seg_idx != -1
call remove(theme, target_seg_idx)
endif
endif
endfor
return theme
endfunction " }}}

View file

@ -1,371 +0,0 @@
let g:Pl#Parser#Symbols = {
\ 'compatible': {
\ 'dividers': [ '', [0x2502], '', [0x2502] ]
\ , 'symbols' : {
\ 'BRANCH': 'BR:'
\ , 'RO' : 'RO'
\ , 'FT' : 'FT'
\ , 'LINE' : 'LN'
\ }
\ },
\ 'unicode': {
\ 'dividers': [ [0x25b6], [0x276f], [0x25c0], [0x276e] ]
\ , 'symbols' : {
\ 'BRANCH': [0x26a1]
\ , 'RO' : [0x2613]
\ , 'FT' : [0x2691]
\ , 'LINE' : [0x204b]
\ },
\ },
\ 'fancy': {
\ 'dividers': [ [0x2b80], [0x2b81], [0x2b82], [0x2b83] ]
\ , 'symbols' : {
\ 'BRANCH': [0x2b60]
\ , 'RO' : [0x2b64]
\ , 'FT' : [0x2b62, 0x2b63]
\ , 'LINE' : [0x2b61]
\ }
\ }
\ }
" Handle symbol overrides
for [s:key, s:value] in items(g:Powerline_symbols_override)
let g:Pl#Parser#Symbols[g:Powerline_symbols].symbols[s:key] = s:value
unlet! s:key s:value
endfor
" Handle divider overrides
if len(g:Powerline_dividers_override) == 4
let g:Pl#Parser#Symbols[g:Powerline_symbols].dividers = g:Powerline_dividers_override
endif
let s:LEFT_SIDE = 0
let s:RIGHT_SIDE = 2
let s:PADDING = 1
let s:EMPTY_SEGMENT = { 'type': 'empty' }
let s:HARD_DIVIDER = 0
let s:SOFT_DIVIDER = 1
function! Pl#Parser#GetStatusline(segments) " {{{
let statusline = {
\ 'n': ''
\ , 'N': ''
\ , 'v': ''
\ , 'i': ''
\ , 'r': ''
\ , 's': ''
\ }
" Run through the different modes and create the statuslines
for mode in keys(statusline)
" Create an empty statusline list
let stl = []
call extend(stl, s:ParseSegments(mode, s:LEFT_SIDE, a:segments))
let statusline[mode] .= join(stl, '')
endfor
return statusline
endfunction " }}}
function! Pl#Parser#ParseChars(arg) " {{{
" Handles symbol arrays which can be either an array of hex values,
" or a string. Will convert the hex array to a string, or return the
" string as-is.
let arg = a:arg
if type(arg) == type([])
" Hex array
call map(arg, 'nr2char(v:val)')
return join(arg, '')
endif
" Anything else, just return it as it is
return arg
endfunction " }}}
function! s:ParseSegments(mode, side, segments, ...) " {{{
let mode = a:mode
let side = a:side
let segments = a:segments
let level = exists('a:1') ? a:1 : 0
let base_color = exists('a:2') ? a:2 : {}
let ret = []
for i in range(0, len(segments) - 1)
unlet! seg_prev seg_curr seg_next
" Prepare some resources (fetch previous, current and next segment)
let seg_curr = deepcopy(get(segments, i))
" Find previous segment
let seg_prev = s:EMPTY_SEGMENT
" If we're currently at i = 0 we have to start on 0 or else we will start on the last segment (list[-1])
let range_start = (i == 0 ? i : i - 1)
for j in range(range_start, 0, -1)
let seg = deepcopy(get(segments, j))
if get(seg, 'name') ==# 'TRUNCATE'
" Skip truncate segments
continue
endif
" Look ahead for another segment that's visible in this mode
if index(get(seg, 'modes'), mode) != -1
" Use this segment
let seg_prev = seg
break
endif
endfor
"" Find next segment
let seg_next = s:EMPTY_SEGMENT
" If we're currently at i = len(segments) - 1 we have to start on i or else we will get an error because the index doesn't exist
let range_start = (i == len(segments) - 1 ? i : i + 1)
for j in range(range_start, len(segments) - 1, 1)
let seg = deepcopy(get(segments, j))
if get(seg, 'name') ==# 'TRUNCATE'
" Skip truncate segments
continue
endif
" Look ahead for another segment that's visible in this mode
if index(get(seg, 'modes'), mode) != -1
" Use this segment
let seg_next = seg
break
endif
endfor
if index(get(seg_curr, 'modes', []), mode) == -1
" The segment is invisible in this mode, skip it
" FIXME When two segments after each other are hidden, a gap appears where the segments would be, this is probably due to segment padding
continue
endif
" Handle the different segment types
if seg_curr.type == 'segment'
if seg_curr.name ==# 'TRUNCATE'
" Truncate statusline
call add(ret, '%<')
elseif seg_curr.name ==# 'SPLIT'
" Split statusline
" Switch sides
let side = s:RIGHT_SIDE
" Handle highlighting
let mode_colors = get(seg_curr.colors, mode, seg_curr.colors['n'])
let hl_group = s:HlCreate(mode_colors)
" Add segment text
call add(ret, '%#'. hl_group .'#%=')
else
" Add segment text
let text = seg_curr.text
" Decide on whether to use the group's colors or the segment's colors
let colors = get(seg_curr, 'colors', base_color)
" Fallback to normal (current) highlighting if we don't have mode-specific highlighting
let mode_colors = get(colors, mode, get(colors, 'n', {}))
if empty(mode_colors)
echom 'Segment doesn''t have any colors! NS: "'. seg_curr.ns .'" SEG: "'. seg_curr.name .'"'
continue
endif
" Check if we're in a group (level > 0)
if level > 0
" If we're in a group we don't have dividers between
" segments, so we should only pad one side, but only pad
" if the segment doesn't have Pl#Segment#NoPadding() set
let padding_right = (seg_curr.padding && side == s:LEFT_SIDE ? repeat(' ', s:PADDING) : '')
let padding_left = (seg_curr.padding && side == s:RIGHT_SIDE ? repeat(' ', s:PADDING) : '')
" Check if we lack a bg/fg color for this segment
" If we do, use the bg/fg color from base_color
let base_color_mode = ! has_key(base_color, mode) ? base_color['n'] : base_color[mode]
for col in ['ctermbg', 'ctermfg', 'guibg', 'guifg']
if empty(mode_colors[col])
let mode_colors[col] = base_color_mode[col]
endif
endfor
else
"" If we're outside a group we have dividers and must pad both sides
let padding_left = repeat(' ', s:PADDING)
let padding_right = repeat(' ', s:PADDING)
endif
" Get main hl group for segment
let hl_group = s:HlCreate(mode_colors)
" Prepare segment text
let text = '%(%#'. hl_group .'#'. padding_left . text . padding_right . '%)'
if level == 0
" Add divider to single segments
let text = s:AddDivider(text, side, mode, colors, seg_prev, seg_curr, seg_next)
endif
call add(ret, text)
endif
elseif seg_curr.type == 'segment_group'
" Recursively parse segment group
let func_params = [mode, side, seg_curr.segments, level + 1]
if has_key(seg_curr, 'colors')
" Pass the base colors on to the child segments
call add(func_params, seg_curr.colors)
endif
" Get segment group string
let text = join(call('s:ParseSegments', func_params), '')
" Pad on the opposite side of the divider
let padding_right = (side == s:RIGHT_SIDE ? repeat(' ', s:PADDING) : '')
let padding_left = (side == s:LEFT_SIDE ? repeat(' ', s:PADDING) : '')
let text = s:AddDivider(padding_left . text . padding_right, side, mode, seg_curr.colors, seg_prev, seg_curr, seg_next)
call add(ret, text)
endif
endfor
return ret
endfunction " }}}
function! s:HlCreate(hl) " {{{
" Create a short and unique highlighting group name
" It uses the hex values of all the color properties and an attribute flag at the end
" NONE colors are translated to NN for cterm and NNNNNN for gui colors
let hi_group = printf('Pl%s%s%s%s%s'
\ , (a:hl['ctermfg'] == 'NONE' ? 'NN' : printf('%02x', a:hl['ctermfg']))
\ , (a:hl['guifg'] == 'NONE' ? 'NNNNNN' : printf('%06x', a:hl['guifg'] ))
\ , (a:hl['ctermbg'] == 'NONE' ? 'NN' : printf('%02x', a:hl['ctermbg']))
\ , (a:hl['guibg'] == 'NONE' ? 'NNNNNN' : printf('%06x', a:hl['guibg'] ))
\ , substitute(a:hl['attr'], '\v([a-zA-Z])[a-zA-Z]*,?', '\1', 'g')
\ )
if ! s:HlExists(hi_group)
let ctermbg = a:hl['ctermbg'] == 'NONE' ? 'NONE' : printf('%d', a:hl['ctermbg'])
if (has('win32') || has('win64')) && !has('gui_running') && ctermbg != 'NONE' && ctermbg > 128
let ctermbg -= 128
endif
let hi_cmd = printf('hi %s ctermfg=%s ctermbg=%s cterm=%s guifg=%s guibg=%s gui=%s'
\ , hi_group
\ , a:hl['ctermfg'] == 'NONE' ? 'NONE' : printf('%d', a:hl['ctermfg'])
\ , ctermbg
\ , a:hl['attr']
\ , (a:hl['guifg'] == 'NONE' ? 'NONE' : printf('#%06x', a:hl['guifg']))
\ , (a:hl['guibg'] == 'NONE' ? 'NONE' : printf('#%06x', a:hl['guibg']))
\ , a:hl['attr']
\ )
exec hi_cmd
" Add command to Pl#HL list for caching
call add(g:Pl#HL, hi_cmd)
endif
" Return only the highlighting group name
return hi_group
endfunction " }}}
function! s:HlExists(hl) " {{{
if ! hlexists(a:hl)
return 0
endif
redir => hlstatus
silent exec 'hi' a:hl
redir END
return (hlstatus !~ 'cleared')
endfunction " }}}
function! s:AddDivider(text, side, mode, colors, prev, curr, next) " {{{
let seg_prev = a:prev
let seg_curr = a:curr
let seg_next = a:next
" Set default color/type for the divider
let div_colors = get(a:colors, a:mode, a:colors['n'])
let div_type = s:SOFT_DIVIDER
" Define segment to compare
let cmp_seg = a:side == s:LEFT_SIDE ? seg_next : seg_prev
let cmp_all_colors = get(cmp_seg, 'colors', {})
let cmp_colors = get(cmp_all_colors, a:mode, get(cmp_all_colors, 'n', {}))
if ! empty(cmp_colors)
" Compare the highlighting groups
"
" If the background color for cterm is equal, use soft divider with the current segment's highlighting
" If not, use hard divider with a new highlighting group
"
" Note that if the previous/next segment is the split, a hard divider is always used
if get(div_colors, 'ctermbg') != get(cmp_colors, 'ctermbg') || get(seg_next, 'name') ==# 'SPLIT' || get(seg_prev, 'name') ==# 'SPLIT'
let div_type = s:HARD_DIVIDER
" Create new highlighting group
if div_colors['attr'] =~ 'reverse' && cmp_colors['attr'] =~ 'reverse'
" Use FG = CURRENT FG, BG = CMP FG
let div_colors['ctermbg'] = get(cmp_colors, 'ctermfg')
let div_colors['guibg'] = get(cmp_colors, 'guifg')
let div_colors['attr'] = div_colors['attr'] =~ 'bold' ? 'bold' : 'NONE'
elseif div_colors['attr'] =~ 'reverse'
" Use FG = CURRENT FG, BG = CMP BG
let div_colors['ctermbg'] = get(cmp_colors, 'ctermbg')
let div_colors['guibg'] = get(cmp_colors, 'guibg')
let div_colors['attr'] = div_colors['attr'] =~ 'bold' ? 'bold' : 'NONE'
elseif cmp_colors['attr'] =~ 'reverse'
" Use FG = CMP FG, BG = CURRENT BG : reversed
let div_colors['ctermfg'] = get(cmp_colors, 'ctermfg')
let div_colors['guifg'] = get(cmp_colors, 'guifg')
let div_colors['attr'] = 'reverse'
else
" Use FG = CURRENT BG, BG = CMP BG
let div_colors['ctermfg'] = get(div_colors, 'ctermbg')
let div_colors['guifg'] = get(div_colors, 'guibg')
let div_colors['ctermbg'] = get(cmp_colors, 'ctermbg')
let div_colors['guibg'] = get(cmp_colors, 'guibg')
let div_colors['attr'] = 'NONE'
endif
endif
endif
" Prepare divider
let divider_raw = deepcopy(g:Pl#Parser#Symbols[g:Powerline_symbols].dividers[a:side + div_type])
let divider = Pl#Parser#ParseChars(divider_raw)
" Don't add dividers for segments adjacent to split (unless it's a hard divider)
if ((get(seg_next, 'name') ==# 'SPLIT' || get(seg_prev, 'name') ==# 'SPLIT') && div_type != s:HARD_DIVIDER)
return ''
endif
if a:side == s:LEFT_SIDE
" Left side
" Divider to the right
return printf('%%(%s%%#%s#%s%%)', a:text, s:HlCreate(div_colors), divider)
else
" Right side
" Divider to the left
return printf('%%(%%#%s#%s%s%%)', s:HlCreate(div_colors), divider, a:text)
endif
endfunction " }}}

View file

@ -1,188 +0,0 @@
let s:default_modes = ['n', 'N', 'v', 'i', 'r', 's']
function! s:CheckConditions(params) " {{{
" Check conditions for a segment/group
" Integer parameters are always conditions
for param in a:params
if type(param) == type(0) && param == 0
" Break here if it's an integer parameter and it's false (0)
return 0
endif
unlet! param
endfor
return 1
endfunction " }}}
function! Pl#Segment#Create(name, ...) " {{{
" Check condition parameters
if ! s:CheckConditions(a:000)
return {}
endif
let name = a:name
let modes = s:default_modes
let padding = 1
let segments = []
for param in a:000
" Lookup modes for this segment/group
if type(param) == type([]) && param[0] == 'modes'
let modes = param[1]
elseif type(param) == type([]) && param[0] == 'nopadding'
let padding = 0
elseif type(a:1) == type([]) && a:1[0] == 'segment'
call add(segments, param[1])
endif
unlet! param
endfor
if type(a:1) == type([]) && a:1[0] == 'segment'
" This is a segment group
return ['segment_group', {
\ 'type': 'segment_group'
\ , 'name': name
\ , 'segments': segments
\ , 'modes': modes
\ , 'padding': padding
\ }]
else
" This is a single segment
let text = a:1
" Search/replace symbols
for [key, symbol] in items(g:Pl#Parser#Symbols[g:Powerline_symbols].symbols)
let text = substitute(
\ text,
\ '\v\$('. key .')',
\ '\=Pl#Parser#ParseChars(g:Pl#Parser#Symbols[g:Powerline_symbols].symbols[submatch(1)])',
\ 'g')
unlet! key symbol
endfor
return ['segment', {
\ 'type': 'segment'
\ , 'name': name
\ , 'text': text
\ , 'modes': modes
\ , 'padding': padding
\ }]
endif
endfunction " }}}
function! Pl#Segment#Init(params) " {{{
" Check condition parameters
if ! s:CheckConditions(a:params)
return {}
endif
let segments = {}
let ns = ''
for param in a:params
if type(param) == type('')
" String parameters is the namespace
let ns = param
elseif type(param) == type([])
" The data dict is in param[1]
" By default we don't have a namespace for the segment
let segment = param[1]
if ! empty(ns)
" Update segment so that it includes the namespace
" Add the namespace to the segment dict key
let segment.ns = ns
let segment.name = join([segment.ns, segment.name], ':')
endif
let key = segment.name
let segments[key] = segment
endif
unlet! param
endfor
return segments
endfunction " }}}
function! Pl#Segment#Modes(modes) " {{{
" Handle modes for both segments and groups
let modes = split(a:modes, '\zs')
if modes[0] == '!'
" Filter modes (e.g. "!nr" will ignore the segment in normal and replace modes)
let modes = filter(deepcopy(s:default_modes), 'v:val !~# "['. join(modes[1:]) .']"')
endif
return ['modes', modes]
endfunction " }}}
function! Pl#Segment#NoPadding() " {{{
return ['nopadding']
endfunction " }}}
function! Pl#Segment#Split(...) " {{{
return a:0 ? a:1 .':SPLIT' : 'SPLIT'
endfunction " }}}
function! Pl#Segment#Truncate() " {{{
return 'TRUNCATE'
endfunction " }}}
function! Pl#Segment#Get(name) " {{{
" Return a segment data dict
let args = []
" Check for printf segments (lists)
if type(a:name) == type([])
" We're dealing with a segment with printf arguments
let seg_orig_name = a:name[0]
let args = a:name[1:]
else
let seg_orig_name = a:name
endif
" Fetch namespace and variants for storing in the segment dict
let seg_ns = ''
let seg_variants = []
" Retrieve color scheme variants
let seg_name_split = split(seg_orig_name, '\v\.')
if len(seg_name_split) > 1
let seg_variants = seg_name_split[1:]
endif
" Retrieve segment name and namespace
" Use the first piece of the split string, we can't have variants in the final segment name
let seg_name_split = split(seg_name_split[0], '\v:')
let seg_name = seg_name_split[0]
if len(seg_name_split) > 1
let seg_ns = seg_name_split[0]
let seg_name = seg_name_split[-1]
endif
try
" If we have a namespace, try to use the namespaced segment first (i.e. search for the segment in the namespaced file first)
let return_segment = deepcopy(g:Powerline#Segments#{seg_ns}#segments[seg_ns .':'. seg_name])
catch
try
" We didn't find a namespaced segment, fall back to common segments
let return_segment = deepcopy(g:Powerline#Segments#segments[seg_name])
catch
" Didn't find the segment among the common segments either, just skip it
return {}
endtry
endtry
if len(args) && has_key(return_segment, 'text')
" Handle segment printf arguments
" printf doesn't accept lists as its second argument, so we have to work around that
let return_segment.text = call('printf', [ return_segment.text ] + args)
endif
" Assign namespace, name and variants
let return_segment.ns = seg_ns
let return_segment.name = seg_name
let return_segment.orig_name = seg_orig_name
let return_segment.variants = seg_variants
return return_segment
endfunction " }}}

View file

@ -1,100 +0,0 @@
function! Pl#Theme#Create(...) " {{{
let buffer_segments = []
for buffer_segment in a:000
" Remove empty segments (e.g. 'Pl#Theme#Function's)
if empty(buffer_segment)
continue
endif
call add(buffer_segments, buffer_segment)
endfor
let buffer_segments = Pl#Colorscheme#Apply(g:Powerline_colorscheme, buffer_segments)
return buffer_segments
endfunction " }}}
function! Pl#Theme#Callback(name, expr) " {{{
return ['callback', a:name, a:expr]
endfunction " }}}
function! Pl#Theme#Buffer(ns, ...) " {{{
let segments = []
let ns = ! empty(a:ns) ? a:ns .':' : ''
" Match namespace parameter by default
let matches = Pl#Match#Any(a:ns)
let callback = []
let args = a:000
let args = Pl#Mod#ApplySegmentMods(args)
" Fetch segment data dicts
for item in args
if type(item) == type([])
if item[0] == 'match'
" Match item, overrides default namespace match
let matches = item
unlet! item
continue
elseif item[0] == 'callback'
" Store the item as a callback expression
let matches = ['match', 'none']
let callback = [a:ns, item[1], item[2]]
unlet! item
continue
endif
" printf segment, append ns to first item in list
let item[0] = ns . item[0]
else
let item = ns . item
endif
let segment = Pl#Segment#Get(item)
if ! empty(segment)
" Skip empty (possible disabled) segments
call add(segments, segment)
endif
unlet! item
endfor
return {
\ 'matches': matches
\ , 'callback': callback
\ , 'segments': segments
\ }
endfunction " }}}
function! Pl#Theme#InsertSegment(new_segment, where, target_segment) " {{{
" It's very important to NOT refer to the theme dict until everything's loaded!
"
" Because these functions are called from the vimrc, we need to put the
" actions in a list which will be parsed later.
"
" These functions don't accept a name parameter, because they work on the
" currently selected theme (will change any selected theme)
call Pl#Mod#AddSegmentMod('insert_segment', {
\ 'new_segment': a:new_segment,
\ 'where': a:where,
\ 'target_segment': a:target_segment
\ })
endfunction " }}}
function! Pl#Theme#RemoveSegment(target_segment) " {{{
" It's very important to NOT refer to the theme dict until everything's loaded!
"
" Because these functions are called from the vimrc, we need to put the
" actions in a list which will be parsed later.
"
" These functions don't accept a name parameter, because they work on the
" currently selected theme (will change any selected theme)
call Pl#Mod#AddSegmentMod('remove_segment', {
\ 'target_segment': a:target_segment
\ })
endfunction " }}}
function! Pl#Theme#ReplaceSegment(old_segment, new_segment) " {{{
call Pl#Theme#InsertSegment(a:new_segment, 'after', a:old_segment)
call Pl#Theme#RemoveSegment(a:old_segment)
endfunction " }}}

View file

@ -1,166 +0,0 @@
call Pl#Hi#Allocate({
\ 'black' : 16,
\ 'white' : 231,
\
\ 'darkestgreen' : 22,
\ 'darkgreen' : 28,
\ 'mediumgreen' : 70,
\ 'brightgreen' : 148,
\
\ 'darkestcyan' : 23,
\ 'mediumcyan' : 117,
\
\ 'darkestblue' : 24,
\ 'darkblue' : 31,
\
\ 'darkestred' : 52,
\ 'darkred' : 88,
\ 'mediumred' : 124,
\ 'brightred' : 160,
\ 'brightestred' : 196,
\
\ 'darkestpurple' : 55,
\ 'mediumpurple' : 98,
\ 'brightpurple' : 189,
\
\ 'brightorange' : 208,
\ 'brightestorange': 214,
\
\ 'gray0' : 233,
\ 'gray1' : 235,
\ 'gray2' : 236,
\ 'gray3' : 239,
\ 'gray4' : 240,
\ 'gray5' : 241,
\ 'gray6' : 244,
\ 'gray7' : 245,
\ 'gray8' : 247,
\ 'gray9' : 250,
\ 'gray10' : 252,
\ })
let g:Powerline#Colorschemes#default#colorscheme = Pl#Colorscheme#Init([
\ Pl#Hi#Segments(['SPLIT'], {
\ 'n': ['white', 'gray2'],
\ 'N': ['white', 'gray0'],
\ 'i': ['white', 'darkestblue'],
\ }),
\
\ Pl#Hi#Segments(['mode_indicator'], {
\ 'n': ['gray10', 'gray0', ['bold']],
\ 'i': ['darkestcyan', 'white', ['bold']],
\ 'v': ['white', 'darkestblue', ['bold']],
\ 'r': ['white', 'brightred', ['bold']],
\ 's': ['white', 'gray5', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['branch', 'scrollpercent', 'raw', 'filesize'], {
\ 'n': ['gray9', 'gray4'],
\ 'N': ['gray4', 'gray1'],
\ 'i': ['mediumcyan', 'darkblue'],
\ }),
\
\ Pl#Hi#Segments(['fileinfo', 'filename'], {
\ 'n': ['white', 'gray4', ['bold']],
\ 'N': ['gray7', 'gray0', ['bold']],
\ 'i': ['white', 'darkblue', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['fileinfo.filepath'], {
\ 'n': ['gray10'],
\ 'N': ['gray5'],
\ 'i': ['mediumcyan'],
\ }),
\
\ Pl#Hi#Segments(['static_str'], {
\ 'n': ['white', 'gray4'],
\ 'N': ['gray7', 'gray1'],
\ 'i': ['white', 'darkblue'],
\ }),
\
\ Pl#Hi#Segments(['fileinfo.flags'], {
\ 'n': ['brightestred', ['bold']],
\ 'N': ['darkred'],
\ 'i': ['brightestred', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['currenttag', 'fullcurrenttag', 'fileformat', 'fileencoding', 'pwd', 'filetype', 'rvm:string', 'rvm:statusline', 'virtualenv:statusline', 'charcode', 'currhigroup'], {
\ 'n': ['gray8', 'gray2'],
\ 'i': ['mediumcyan', 'darkestblue'],
\ }),
\
\ Pl#Hi#Segments(['lineinfo'], {
\ 'n': ['gray2', 'gray10', ['bold']],
\ 'N': ['gray7', 'gray1', ['bold']],
\ 'i': ['darkestcyan', 'mediumcyan', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['errors'], {
\ 'n': ['brightestorange', 'gray2', ['bold']],
\ 'i': ['brightestorange', 'darkestblue', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['lineinfo.line.tot'], {
\ 'n': ['gray6'],
\ 'N': ['gray5'],
\ 'i': ['darkestcyan'],
\ }),
\
\ Pl#Hi#Segments(['paste_indicator', 'ws_marker'], {
\ 'n': ['white', 'brightred', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['gundo:static_str.name', 'command_t:static_str.name'], {
\ 'n': ['white', 'mediumred', ['bold']],
\ 'N': ['brightred', 'darkestred', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['gundo:static_str.buffer', 'command_t:raw.line'], {
\ 'n': ['white', 'darkred'],
\ 'N': ['brightred', 'darkestred'],
\ }),
\
\ Pl#Hi#Segments(['gundo:SPLIT', 'command_t:SPLIT'], {
\ 'n': ['white', 'darkred'],
\ 'N': ['white', 'darkestred'],
\ }),
\
\ Pl#Hi#Segments(['lustyexplorer:static_str.name', 'minibufexplorer:static_str.name', 'nerdtree:raw.name', 'tagbar:static_str.name'], {
\ 'n': ['white', 'mediumgreen', ['bold']],
\ 'N': ['mediumgreen', 'darkestgreen', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['lustyexplorer:static_str.buffer', 'tagbar:static_str.buffer'], {
\ 'n': ['brightgreen', 'darkgreen'],
\ 'N': ['mediumgreen', 'darkestgreen'],
\ }),
\
\ Pl#Hi#Segments(['lustyexplorer:SPLIT', 'minibufexplorer:SPLIT', 'nerdtree:SPLIT', 'tagbar:SPLIT'], {
\ 'n': ['white', 'darkgreen'],
\ 'N': ['white', 'darkestgreen'],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:focus', 'ctrlp:byfname'], {
\ 'n': ['brightpurple', 'darkestpurple'],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:prev', 'ctrlp:next', 'ctrlp:pwd'], {
\ 'n': ['white', 'mediumpurple'],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:item'], {
\ 'n': ['darkestpurple', 'white', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:marked'], {
\ 'n': ['brightestred', 'darkestpurple', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:count'], {
\ 'n': ['darkestpurple', 'white'],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:SPLIT'], {
\ 'n': ['white', 'darkestpurple'],
\ }),
\ ])

View file

@ -1,192 +0,0 @@
" This theme is based on Solarized-dark colors, combined
" with Powerline native colors
call Pl#Hi#Allocate({
\ 'black' : 16,
\ 'white' : 231,
\
\ 'darkestgreen' : 22,
\ 'darkgreen' : 28,
\ 'mediumgreen' : 70,
\ 'brightgreen' : 148,
\
\ 'darkestcyan' : 23,
\ 'mediumcyan' : 117,
\
\ 'darkestblue' : 24,
\ 'darkblue' : 31,
\
\ 'darkestred' : 52,
\ 'darkred' : 88,
\ 'mediumred' : 124,
\ 'brightred' : 160,
\ 'brightestred' : 196,
\
\ 'darkestpurple' : 55,
\ 'mediumpurple' : 98,
\ 'brightpurple' : 189,
\
\ 'brightorange' : 208,
\ 'brightestorange': 214,
\
\ 'gray0' : 233,
\ 'gray1' : 235,
\ 'gray2' : 236,
\ 'gray3' : 239,
\ 'gray4' : 240,
\ 'gray5' : 241,
\ 'gray6' : 244,
\ 'gray7' : 245,
\ 'gray8' : 247,
\ 'gray9' : 250,
\ 'gray10' : 252,
\
\ 'base00' : [241, 0x657b83],
\ 'base01' : [240, 0x586e75],
\ 'base02' : [0, 0x073642],
\ 'base03' : [234, 0x002b36],
\ 'base0' : [244, 0x839496],
\ 'base1' : [245, 0x93a1a1],
\ 'base2' : [254, 0xeee8d5],
\ 'base3' : [230, 0xfdf6e3],
\ 'yellow' : [136, 0xb58900],
\ 'orange' : [166, 0xcb4b16],
\ 'red' : [160, 0xdc322f],
\ 'magenta' : [125, 0xd33682],
\ 'violet' : [61, 0x6c71c4],
\ 'blue' : [33, 0x268bd2],
\ 'cyan' : [37, 0x2aa198],
\ 'green' : [64, 0x859900],
\ })
let g:Powerline#Colorschemes#skwp#colorscheme = Pl#Colorscheme#Init([
\ Pl#Hi#Segments(['SPLIT'], {
\ 'n': ['white', 'base02'],
\ 'N': ['white', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['mode_indicator'], {
\ 'n': ['darkestgreen', 'brightgreen', ['bold']],
\ 'i': ['darkestcyan', 'white', ['bold']],
\ 'v': ['red', 'brightorange', ['bold']],
\ 'r': ['white', 'violet', ['bold']],
\ 's': ['white', 'gray5', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['branch', 'raw', 'filesize'], {
\ 'n': ['base03', 'blue'],
\ 'N': ['gray5', 'base03'],
\ }),
\
\ Pl#Hi#Segments(['scrollpercent'], {
\ 'n': ['gray7', 'gray2'],
\ 'N': ['base2', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['fileinfo', 'filename', 'filepath'], {
\ 'n': ['base2', 'darkestblue', ['bold']],
\ 'N': ['base1', 'base02', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['fileinfo.filepath'], {
\ 'n': ['gray10'],
\ 'N': ['gray5'],
\ 'i': ['mediumcyan'],
\ }),
\
\ Pl#Hi#Segments(['static_str'], {
\ 'n': ['base3', 'violet'],
\ 'N': ['base1', 'base02'],
\ 'i': ['white', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['fileinfo.flags'], {
\ 'n': ['base03', ['bold']],
\ 'N': ['gray5'],
\ 'i': ['base03', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['currenttag', 'fullcurrenttag', 'fileformat', 'fileencoding', 'pwd', 'filetype', 'rvm:string', 'rvm:statusline', 'virtualenv:statusline', 'charcode', 'currhigroup'], {
\ 'n': ['gray5', 'gray2'],
\ 'i': ['mediumcyan', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['lineinfo'], {
\ 'n': ['gray2', 'gray10', ['bold']],
\ 'N': ['gray7', 'gray1', ['bold']],
\ 'i': ['darkestcyan', 'mediumcyan', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['errors'], {
\ 'n': ['orange', 'base02', ['bold']],
\ 'N': ['gray5', 'base03', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['lineinfo.line.tot'], {
\ 'n': ['gray6'],
\ 'N': ['gray5'],
\ 'i': ['darkestcyan'],
\ }),
\
\ Pl#Hi#Segments(['paste_indicator', 'ws_marker'], {
\ 'n': ['base3', 'red', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['gundo:static_str.name', 'command_t:static_str.name'], {
\ 'n': ['base3', 'darkblue', ['bold']],
\ 'N': ['base1', 'base03', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['gundo:static_str.buffer', 'command_t:raw.line'], {
\ 'n': ['white', 'base02'],
\ 'N': ['gray5', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['gundo:SPLIT', 'command_t:SPLIT'], {
\ 'n': ['white', 'base02'],
\ 'N': ['white', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['lustyexplorer:static_str.name', 'minibufexplorer:static_str.name', 'nerdtree:raw.name', 'tagbar:static_str.name'], {
\ 'n': ['gray10', 'darkestblue', ['bold']],
\ 'N': ['gray3', 'base02', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['lustyexplorer:static_str.buffer', 'tagbar:static_str.buffer'], {
\ 'n': ['base3', 'blue'],
\ 'N': ['gray5', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['lustyexplorer:SPLIT', 'minibufexplorer:SPLIT', 'nerdtree:SPLIT', 'tagbar:SPLIT'], {
\ 'n': ['gray3', 'base02'],
\ 'N': ['gray3', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:focus', 'ctrlp:byfname'], {
\ 'n': ['green', 'base03'],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:prev', 'ctrlp:next', 'ctrlp:pwd'], {
\ 'n': ['green', 'base02'],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:item'], {
\ 'n': ['base2', 'darkestblue', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:marked'], {
\ 'n': ['brightgreen', 'base03', ['bold']],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:count'], {
\ 'n': ['base0', 'base03'],
\ }),
\
\ Pl#Hi#Segments(['ctrlp:SPLIT'], {
\ 'n': ['white', 'base03'],
\ }),
\
\ Pl#Hi#Segments(['status'], {
\ 'n': ['green', 'base02'],
\ 'N': ['gray5', 'base02'],
\ }),
\ ])

View file

@ -1,141 +0,0 @@
" Recalculate the trailing whitespace warning when idle, and after saving
autocmd CursorHold,BufWritePost,InsertLeave * unlet! b:statusline_trailing_space_warning
function! Powerline#Functions#GetFilepath() " {{{
" Recalculate the filepath when cwd changes.
let cwd = getcwd()
if exists("b:Powerline_cwd") && cwd != b:Powerline_cwd
unlet! b:Powerline_filepath
endif
let b:Powerline_cwd = cwd
if exists('b:Powerline_filepath')
return b:Powerline_filepath
endif
let dirsep = has('win32') && ! &shellslash ? '\' : '/'
let filepath = expand('%:p')
if empty(filepath)
return ''
endif
let ret = ''
if g:Powerline_stl_path_style == 'short'
" Display a short path where the first directory is displayed with its
" full name, and the subsequent directories are shortened to their
" first letter, i.e. "/home/user/foo/foo/bar/baz.vim" becomes
" "~/foo/f/b/baz.vim"
"
" This displays the shortest possible path, relative to ~ or the
" current directory.
let mod = (exists('+acd') && &acd) ? ':~:h' : ':~:.:h'
let fpath = split(fnamemodify(filepath, mod), dirsep)
let fpath_shortparts = map(fpath[1:], 'v:val[0]')
let ret = join(extend([fpath[0]], fpath_shortparts), dirsep) . dirsep
elseif g:Powerline_stl_path_style == 'relative'
" Display a relative path, similar to the %f statusline item
let ret = fnamemodify(filepath, ':~:.:h') . dirsep
elseif g:Powerline_stl_path_style == 'full'
" Display the full path, similar to the %F statusline item
let ret = fnamemodify(filepath, ':h') . dirsep
endif
if ret == ('.' . dirsep)
let ret = ''
endif
let b:Powerline_filepath = ret
return ret
endfunction " }}}
function! Powerline#Functions#GetShortPath(threshold) " {{{
let fullpath = split(substitute(expand('%:p:h'), $HOME, '~', 'g'), '/')
if len(fullpath) > a:threshold
let fullpath = [fullpath[0], '…'] + fullpath[-a:threshold + 1 :]
endif
return join(fullpath, '/')
endfunction " }}}
function! Powerline#Functions#GetMode() " {{{
let mode = mode()
if mode ==# 'v'
let mode = get(g:, "Powerline_mode_v", "VISUAL")
elseif mode ==# 'V'
let mode = get(g:, "Powerline_mode_V", "V⋅LINE")
elseif mode ==# ''
let mode = get(g:, "Powerline_mode_cv", "V⋅BLOCK")
elseif mode ==# 's'
let mode = get(g:, "Powerline_mode_s", "SELECT")
elseif mode ==# 'S'
let mode = get(g:, "Powerline_mode_S", "S⋅LINE")
elseif mode ==# ''
let mode = get(g:, "Powerline_mode_cs", "S⋅BLOCK")
elseif mode =~# '\vi'
let mode = get(g:, "Powerline_mode_i", "INSERT")
elseif mode =~# '\v(R|Rv)'
let mode = get(g:, "Powerline_mode_R", "REPLACE")
else
" Fallback to normal mode
let mode = get(g:, "Powerline_mode_n", "NORMAL")
endif
return mode
endfunction " }}}
function! Powerline#Functions#GetFilesize() " {{{
let bytes = getfsize(expand("%:p"))
if bytes <= 0
return ''
endif
if bytes < 1024
return bytes . 'B'
else
return (bytes / 1024) . 'kB'
endif
endfunction "}}}
function! Powerline#Functions#GetCharCode() " {{{
" Get the output of :ascii
redir => ascii
silent! ascii
redir END
if match(ascii, 'NUL') != -1
return 'NUL'
endif
" Zero pad hex values
let nrformat = '0x%02x'
let encoding = (&fenc == '' ? &enc : &fenc)
if encoding == 'utf-8'
" Zero pad with 4 zeroes in unicode files
let nrformat = '0x%04x'
endif
" Get the character and the numeric value from the return value of :ascii
" This matches the two first pieces of the return value, e.g.
" "<F> 70" => char: 'F', nr: '70'
let [str, char, nr; rest] = matchlist(ascii, '\v\<(.{-1,})\>\s*([0-9]+)')
" Format the numeric value
let nr = printf(nrformat, nr)
return "'". char ."' ". nr
endfunction "}}}
function! Powerline#Functions#GetWSMarker() " {{{
" Return '...' if trailing white space is detected
" Return '' otherwise
if ! exists("b:statusline_trailing_space_warning")
if search('\s$', 'nw') != 0
let b:statusline_trailing_space_warning = ' … '
else
let b:statusline_trailing_space_warning = ''
endif
endif
return b:statusline_trailing_space_warning
endfunction " }}}

View file

@ -1,12 +0,0 @@
function! Powerline#Functions#ft_man#GetName() " {{{
let matches = matchlist(getline(1), '\v^([a-zA-Z_\.\-]+)\((\d+)\)')
if ! len(matches)
return 'n/a'
endif
let file = tolower(matches[1])
let num = matches[2]
return file
endfunction " }}}

View file

@ -1,7 +0,0 @@
function! Powerline#Functions#fugitive#GetBranch(symbol) " {{{
let ret = fugitive#statusline()
let ret = substitute(ret, '\c\v\[?GIT\(([a-z0-9\-_\./:]+)\)\]?', a:symbol .' \1', 'g')
return ret
endfunction " }}}

View file

@ -1,17 +0,0 @@
function! Powerline#Functions#hgrev#Status(symbol) " {{{
if ! exists('*HGRev')
" HGRev hasn't been loaded yet
return ''
endif
if !exists("b:statusline_hg_status")
silent execute "RefreshMercurialRev"
endif
let b:statusline_hg_status=HGRev()
if b:statusline_hg_status != '-'
let ret = "\u26A1". '' . substitute(b:statusline_hg_status, '^[^ ]*', '\1', 'g')
let ret=substitute(ret,' M$','+','g')
else
let ret=''
endif
return ret
endfunction " }}}

View file

@ -1,16 +0,0 @@
function! Powerline#Functions#syntastic#GetErrors(line_symbol) " {{{
if ! exists('g:syntastic_stl_format')
" Syntastic hasn't been loaded yet
return ''
endif
" Temporarily change syntastic output format
let old_stl_format = g:syntastic_stl_format
let g:syntastic_stl_format = '%E{ ERRORS (%e) '. a:line_symbol .' %fe }%W{ WARNINGS (%w) '. a:line_symbol .' %fw }'
let ret = SyntasticStatuslineFlag()
let g:syntastic_stl_format = old_stl_format
return ret
endfunction " }}}

View file

@ -1,13 +0,0 @@
let g:Powerline#Matches#matches = {
\ 'command_t' : Pl#Match#Add('bufname("%")', 'GoToFile'),
\ 'bt_help' : Pl#Match#Add('&bt' , 'help'),
\ 'ft_man' : Pl#Match#Add('&ft' , 'man'),
\ 'ft_qf' : Pl#Match#Add('&ft' , 'qf'),
\ 'ft_vimpager' : Pl#Match#Add('&ft' , 'vimpager'),
\ 'gundo_preview' : Pl#Match#Add('bufname("%")', '__Gundo_Preview__'),
\ 'gundo_tree' : Pl#Match#Add('bufname("%")', '__Gundo__'),
\ 'lustyexplorer' : Pl#Match#Add('bufname("%")', '\[LustyExplorer-Buffers\]'),
\ 'minibufexplorer' : Pl#Match#Add('bufname("%")', '\-MiniBufExplorer\-'),
\ 'tagbar' : Pl#Match#Add('&ft' , 'tagbar'),
\ 'nerdtree' : Pl#Match#Add('&ft' , 'nerdtree'),
\ }

View file

@ -1,30 +0,0 @@
let g:Powerline#Segments#segments = Pl#Segment#Init([
\ Pl#Segment#Create('SPLIT' , '__split__'),
\ Pl#Segment#Create('TRUNCATE', '__truncate__'),
\
\ Pl#Segment#Create('paste_indicator' , '%{&paste ? "PASTE" : ""}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('mode_indicator' , '%{Powerline#Functions#GetMode()}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('fileinfo',
\ Pl#Segment#Create('flags.ro' , '%{&readonly ? "$RO" : ""}'),
\ Pl#Segment#Create('filepath' , '%{Powerline#Functions#GetFilepath()}', Pl#Segment#NoPadding()),
\ Pl#Segment#Create('filename' , '%t'),
\ Pl#Segment#Create('flags.mod' , '%M'),
\ Pl#Segment#Create('flags.type' , '%H%W'),
\ ),
\ Pl#Segment#Create('filename' , '%t'),
\ Pl#Segment#Create('filesize' , '%{Powerline#Functions#GetFilesize()}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('pwd' , '%{substitute(getcwd(), expand("$HOME"), "~", "g")}'),
\ Pl#Segment#Create('static_str' , '%%{"%s"}'),
\ Pl#Segment#Create('raw' , '%s'),
\ Pl#Segment#Create('fileformat' , '%{&fileformat}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('fileencoding' , '%{(&fenc == "" ? &enc : &fenc)}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('filetype' , '%{strlen(&ft) ? &ft : "no ft"}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('scrollpercent' , '%3p%%'),
\ Pl#Segment#Create('lineinfo',
\ Pl#Segment#Create('line.cur' , '$LINE %3l'),
\ Pl#Segment#Create('line.tot' , ':%-2v', Pl#Segment#NoPadding()),
\ ),
\ Pl#Segment#Create('charcode' , '%{Powerline#Functions#GetCharCode()}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('currhigroup' , '%{synIDattr(synID(line("."), col("."), 1), "name")}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('ws_marker' , '%{Powerline#Functions#GetWSMarker()}', Pl#Segment#Modes('!N')),
\ ])

View file

@ -1,20 +0,0 @@
if !exists("g:Powerline#Segments#ctrlp#segments#focus ")
let g:Powerline#Segments#ctrlp#segments#focus = '%{"%0"}'
endif
if !exists("g:Powerline#Segments#ctrlp#segments#prev ")
let g:Powerline#Segments#ctrlp#segments#prev = '%-3{"%3"}'
endif
if !exists("g:Powerline#Segments#ctrlp#segments#next ")
let g:Powerline#Segments#ctrlp#segments#next = '%-3{"%5"}'
endif
let g:Powerline#Segments#ctrlp#segments = Pl#Segment#Init(['ctrlp'
\ , Pl#Segment#Create('focus', g:Powerline#Segments#ctrlp#segments#focus)
\ , Pl#Segment#Create('byfname', '%{"%1"}')
\ , Pl#Segment#Create('prev', g:Powerline#Segments#ctrlp#segments#prev)
\ , Pl#Segment#Create('item', '%-9{"%4"}')
\ , Pl#Segment#Create('next', g:Powerline#Segments#ctrlp#segments#next)
\ , Pl#Segment#Create('marked', '%{"%6" == " <+>" ? "" : strpart("%6", 2, len("%6") - 3)}')
\
\ , Pl#Segment#Create('count', '%-6{"%0"}')
\ ])

View file

@ -1,3 +0,0 @@
let g:Powerline#Segments#ft_man#segments = Pl#Segment#Init(['ft_man',
\ Pl#Segment#Create('filename', '%{Powerline#Functions#ft_man#GetName()}')
\ ])

View file

@ -1,5 +0,0 @@
let g:Powerline#Segments#fugitive#segments = Pl#Segment#Init(['fugitive',
\ (exists('g:loaded_fugitive') && g:loaded_fugitive == 1),
\
\ Pl#Segment#Create('branch', '%{Powerline#Functions#fugitive#GetBranch("$BRANCH")}')
\ ])

View file

@ -1,4 +0,0 @@
let g:Powerline#Segments#hgrev#segments = Pl#Segment#Init(['hgrev',
\ (exists('hgrev_loaded')),
\ Pl#Segment#Create('branch', '%{Powerline#Functions#hgrev#Status("$BRANCH")}')
\ ])

View file

@ -1,6 +0,0 @@
let g:Powerline#Segments#rvm#segments = Pl#Segment#Init(['rvm',
\ (exists('g:loaded_rvm') && g:loaded_rvm == 1),
\
\ Pl#Segment#Create('string', '%{rvm#string()}'),
\ Pl#Segment#Create('statusline', '%{rvm#statusline()}')
\ ])

View file

@ -1,5 +0,0 @@
let g:Powerline#Segments#syntastic#segments = Pl#Segment#Init(['syntastic',
\ (exists('g:loaded_syntastic_plugin') && g:loaded_syntastic_plugin == 1),
\
\ Pl#Segment#Create('errors', '%{Powerline#Functions#syntastic#GetErrors("$LINE")}', Pl#Segment#Modes('!N'))
\ ])

View file

@ -1,6 +0,0 @@
let g:Powerline#Segments#tagbar#segments = Pl#Segment#Init(['tagbar',
\ (exists(':Tagbar') > 0),
\
\ Pl#Segment#Create('currenttag', '%{tagbar#currenttag("%s", "")}', Pl#Segment#Modes('!N')),
\ Pl#Segment#Create('fullcurrenttag', '%{tagbar#currenttag("%s", "", "f")}', Pl#Segment#Modes('!N'))
\ ])

View file

@ -1,5 +0,0 @@
let g:Powerline#Segments#virtualenv#segments = Pl#Segment#Init(['virtualenv',
\ has('python') && (exists('g:virtualenv_loaded') && g:virtualenv_loaded == 1),
\
\ Pl#Segment#Create('statusline', '%{virtualenv#statusline()}')
\ ])

View file

@ -1,116 +0,0 @@
let g:Powerline#Themes#default#theme = Pl#Theme#Create(
\ Pl#Theme#Buffer(''
\ , 'paste_indicator'
\ , 'mode_indicator'
\ , 'fugitive:branch'
\ , 'hgrev:branch'
\ , 'fileinfo'
\ , 'syntastic:errors'
\ , Pl#Segment#Truncate()
\ , 'tagbar:currenttag'
\ , Pl#Segment#Split()
\ , 'rvm:string'
\ , 'virtualenv:statusline'
\ , 'fileformat'
\ , 'fileencoding'
\ , 'filetype'
\ , 'scrollpercent'
\ , 'lineinfo'
\ ),
\
\ Pl#Theme#Buffer('command_t'
\ , ['static_str.name', 'Command-T']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , ['raw.line', '%10(Match #%l%)']
\ ),
\
\ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_tree')
\ , ['static_str.name', 'Gundo']
\ , ['static_str.buffer', 'Undo tree']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_preview')
\ , ['static_str.name', 'Gundo']
\ , ['static_str.buffer', 'Diff preview']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('bt_help'
\ , ['static_str.name', 'Help']
\ , 'filename'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'scrollpercent'
\ ),
\
\ Pl#Theme#Buffer('ft_vimpager'
\ , ['static_str.name', 'Pager']
\ , 'filename'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'scrollpercent'
\ ),
\
\ Pl#Theme#Buffer('lustyexplorer'
\ , ['static_str.name', 'LustyExplorer']
\ , ['static_str.buffer', 'Buffer list']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('ft_man'
\ , ['static_str.name', 'Man page']
\ , 'filename'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'scrollpercent'
\ ),
\
\ Pl#Theme#Buffer('minibufexplorer'
\ , ['static_str.name', 'MiniBufExplorer']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('ft_qf'
\ , ['static_str.name', 'Quickfix']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('tagbar'
\ , ['static_str.name', 'Tagbar']
\ , ['static_str.buffer', 'Tree']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_main', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.main = "%s"')
\ , 'ctrlp:prev'
\ , 'ctrlp:item'
\ , 'ctrlp:next'
\ , 'ctrlp:marked'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'ctrlp:focus'
\ , 'ctrlp:byfname'
\ , 'pwd'
\ ),
\
\ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_prog', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.prog = "%s"')
\ , 'ctrlp:count'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'pwd'
\ ),
\
\ Pl#Theme#Buffer('nerdtree'
\ , ['raw.name', '%{Powerline#Functions#GetShortPath(4)}']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ )
\ )

View file

@ -1,116 +0,0 @@
" Disabled:
" Add the following line into the first theme group to see the highlight
" group
" \ , 'currhigroup'
"
" Line info taken out - I know which line number I'm on from the gutter
"\ , 'lineinfo'
let g:Powerline#Themes#skwp#theme = Pl#Theme#Create(
\ Pl#Theme#Buffer(''
\ , 'fugitive:branch'
\ , 'fileinfo'
\ , 'flags.mod'
\ , 'syntastic:errors'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'sass:status'
\ , 'rvm:string'
\ , 'paste_indicator'
\ ),
\
\ Pl#Theme#Buffer('command_t'
\ , ['static_str.name', 'Command-T']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , ['raw.line', '%10(Match #%l%)']
\ ),
\
\ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_tree')
\ , ['static_str.name', 'Gundo']
\ , ['static_str.buffer', 'Undo tree']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_preview')
\ , ['static_str.name', 'Gundo']
\ , ['static_str.buffer', 'Diff preview']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('bt_help'
\ , ['static_str.name', 'Help']
\ , 'filename'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'scrollpercent'
\ ),
\
\ Pl#Theme#Buffer('ft_vimpager'
\ , ['static_str.name', 'Pager']
\ , 'filename'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'scrollpercent'
\ ),
\
\ Pl#Theme#Buffer('lustyexplorer'
\ , ['static_str.name', 'LustyExplorer']
\ , ['static_str.buffer', 'Buffer list']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('ft_man'
\ , ['static_str.name', 'Man page']
\ , 'filename'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'scrollpercent'
\ ),
\
\ Pl#Theme#Buffer('minibufexplorer'
\ , ['static_str.name', 'MiniBufExplorer']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('ft_qf'
\ , ['static_str.name', 'Quickfix']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('tagbar'
\ , ['static_str.name', 'Tagbar']
\ , ['static_str.buffer', 'Tree']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ ),
\
\ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_main', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.main = "%s"')
\ , 'ctrlp:prev'
\ , 'ctrlp:item'
\ , 'ctrlp:next'
\ , 'ctrlp:marked'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'ctrlp:focus'
\ , 'ctrlp:byfname'
\ , 'pwd'
\ ),
\
\ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_prog', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.prog = "%s"')
\ , 'ctrlp:count'
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ , 'pwd'
\ ),
\
\ Pl#Theme#Buffer('nerdtree'
\ , ['raw.name', '%{Powerline#Functions#GetShortPath(4)}']
\ , Pl#Segment#Truncate()
\ , Pl#Segment#Split()
\ )
\ )

View file

@ -1,429 +0,0 @@
*Powerline.txt* For Vim version 7.3. Last change: 2011 Nov 23
______
_________ \ /__
\_____ \______ _ _____________ / /'__' ___ ____
| ___/ _ \ \/ \/ / __ \_ ___\ / | |/ \_/ __ \
| | | (_) \ _ / ___/| | / /__| | | \ ___/
'___' \____/ \/ \/ \___ |__' /___ /'__'__| /\___ \
\/ / / \/ \/
| /
|/
'
==============================================================================
CONTENTS *Powerline-contents*
1. Introduction ....................... |Powerline-introduction|
2. Usage .............................. |Powerline-usage|
3. Requirements ....................... |Powerline-requirements|
3.1 Recommended settings ........... |Powerline-recommended-settings|
4. Configuration ...................... |Powerline-configuration|
4.1 Powerline_cache_file ........... |Powerline_cache_file|
4.1.1 Clearing the cache ....... |:PowerlineClearCache|
4.2 Powerline_cache_enabled ........ |Powerline_cache_enabled|
4.3 Powerline_symbols .............. |Powerline_symbols|
4.3.1 Compatible symbols ....... |Powerline-symbols-compatible|
4.3.2 Fancy symbols ............ |Powerline-symbols-fancy|
4.3.3 Overriding symbols ....... |Powerline_symbols_override|
4.3.4 Overriding dividers ...... |Powerline_dividers_override|
4.4 Powerline_theme ................ |Powerline_theme|
4.5 Powerline_colorscheme .......... |Powerline_colorscheme|
4.6 Powerline_stl_path_style ....... |Powerline_stl_path_style|
5. Fonts .............................. |Powerline-fonts|
6. Customization ...................... |Powerline-customization|
6.1 Basic customization ............ |Powerline-basic-customization|
6.2 Advanced customization ......... |Powerline-advanced-customization|
6.2.1 Colorschemes ............. |Powerline-cust-colorschemes|
6.2.2 Functions ................ |Powerline-cust-functions|
6.2.3 Segments ................. |Powerline-cust-segments|
6.2.4 Themes ................... |Powerline-cust-themes|
7. License ............................ |Powerline-license|
8. Known issues ....................... |Powerline-known-issues|
9. Contributing ....................... |Powerline-contributing|
==============================================================================
1. Introduction *Powerline* *Powerline-introduction*
Powerline is a utility plugin which allows you to create better-looking, more
functional Vim statuslines.
==============================================================================
2. Usage *Powerline-usage*
Powerline is automatically enabled when it's installed, either by unzipping
the provided archive or by adding it as a Pathogen/Vundle bundle.
Powerline replaces the standard Vim 'statusline' with a custom statusline made
up of Powerline segments.
Powerline ignores any 'statusline' customizations you have defined in your
|vimrc|. If you remove Powerline, your 'statusline' customizations are
restored.
==============================================================================
3. Requirements *Powerline-requirements*
Powerline has been developed and tested in Vim 7.3, but it should run without
any problems in Vim 7.2. The default configuration requires a Unix-like system
to work properly.
The plugin only works with Vim running in an 88/256-color terminal or Gvim.
Vi-compatible mode must be disabled.
------------------------------------------------------------------------------
3.1 Recommended settings *Powerline-recommended-settings*
The following configuration options should be set in your |vimrc|: >
set nocompatible " Disable vi-compatibility
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Necessary to show Unicode glyphs
Note: If you're using an 88/256-color terminal but still don't see the colored
statusline, you may have to set the following option as well: >
set t_Co=256 " Explicitly tell Vim that the terminal supports 256 colors
==============================================================================
4. Configuration *Powerline-configuration*
Powerline will work fine without any user configuration, but default behavior
can be overridden by setting configuration variables globally in your |vimrc|
file.
------------------------------------------------------------------------------
4.1 Powerline_cache_file *Powerline_cache_file*
By default Powerline caches all the statuslines and colors in a cache file in
the plugin's directory (or the Vim directory, depending on the installation
method used).
It's recommended that you enable the cache, as this dramatically improves Vim
startup time after the cache file has been generated (the plugin usually loads
within ~100ms without the cache and ~1ms with the cache).
Note: The default cache filename includes the current theme, colorscheme and
symbol settings in order to tie the cache file to your current configuration,
so the cache file will be regenerated when you change any settings. This may
leave several old cache files in your Vim folder, and these may safely be
deleted.
Defaults: "<plugin_directory>/Powerline_<theme>_<colorscheme>_<symbols>.cache"
------------------------------------------------------------------------------
4.1.1 Clearing the cache *:PowerlineClearCache*
Powerline provides a command to easily clear the cache after changing your
settings or updating your theme. Simply run the following command to clear
your cache, and restart Vim afterwards: >
:PowerlineClearCache
<
------------------------------------------------------------------------------
4.2 Powerline_cache_enabled *Powerline_cache_enabled*
It's possible to disable statusline caching by setting this option to 0. This
is mostly useful when developing statuslines.
Example: >
let g:Powerline_cache_enabled = 0
<
Default: 1
------------------------------------------------------------------------------
4.3 Powerline_symbols *Powerline_symbols*
This option defines which set of symbols and dividers you want to use. There
are currently three available options: "compatible", "unicode" and "fancy".
TYPE DESCRIPTION ~
compatible Doesn't use any special characters.
unicode Simulates icons and arrows using similar Unicode glyphs.
fancy Custom icons and arrows. Requires a patched font.
Example: >
let g:Powerline_symbols = 'fancy'
<
Default: "compatible"
Symbols can be inserted into statuslines by using the following variables
(just insert the variables as text in your segments):
VARIABLE DESCRIPTION ~
$BRANCH Inserts a branch symbol
$RO Inserts a read-only symbol
$FT Inserts a filetype symbol
$LINE Inserts a line number symbol
------------------------------------------------------------------------------
4.3.1 Compatible symbols *Powerline-symbols-compatible*
These symbols will work in any configuration, and do not require a special
font to work. This option will replace the fancy icons with plain text, and
the pointy dividers with straight lines.
------------------------------------------------------------------------------
4.3.2 Fancy symbols *Powerline-symbols-fancy*
These symbols require a custom font to work. A font patcher is provided for
adding the required symbols to any outline font and some bitmap fonts, see
|Powerline-fonts| and the provided README file for usage details.
------------------------------------------------------------------------------
4.3.3 Overriding symbols *Powerline_symbols_override*
You can override symbols by adding your symbols to the
g:Powerline_symbols_override dictionary. Example: If you want the branch
symbol to be "∓" (hex code 0x2213) and the line symbol to be "L" you can add
the following to your |vimrc|: >
let g:Powerline_symbols_override = {
\ 'BRANCH': [0x2213],
\ 'LINE': 'L',
\ }
<
------------------------------------------------------------------------------
4.3.4 Overriding dividers *Powerline_dividers_override*
If you for some reason want to override the dividers then you can set
g:Powerline_dividers_override to a list with exactly four elements:
1: Hard right-pointing arrow
2: Soft right-pointing arrow
3: Hard left-pointing arrow
4: Soft left-pointing arrow
Example: >
let g:Powerline_dividers_override = ['>>', '>', '<<', '<']
<
------------------------------------------------------------------------------
4.3.5 Overriding mode names *Powerline_mode*
You can change the names used for modes at the far left by setting some
variables in your |vimrc|. For example you can change "N" to "NORMAL" with: >
let g:Powerline_mode_n = 'NORMAL'
<
The variables are all named beginning with 'g:Powerline_mode_', as follows:
mode name default note ~
Normal n ' N ' (surrounded by spaces)
Insert i INSERT
Replace R REPLACE |Replace-mode|
Visual v VISUAL |Visual-mode|
Visual linewise V V⋅LINE
Visual blockwise cv V⋅BLOCK
Select s SELECT |Select-mode|
Select linewise S S⋅LINE
Select blockwise cs S⋅BLOCK
-----------------------------------------------------------------------------
4.4 Powerline_theme *Powerline_theme*
This option defines the theme Powerline uses. The available themes are located
in autoload/Powerline/Themes/. A theme is a pre-defined set of Powerline
segments which make up the statusline.
Example: >
let g:Powerline_theme = 'skwp'
<
Default: "default"
------------------------------------------------------------------------------
4.5 Powerline_colorscheme *Powerline_colorscheme*
This option defines the colorscheme Powerline uses. The available colorschemes
are located in autoload/Powerline/Colorschemes/.
Example: >
let g:Powerline_colorscheme = 'skwp'
<
Default: "default"
------------------------------------------------------------------------------
4.6 Powerline_stl_path_style *Powerline_stl_path_style*
There are currently four ways to display the current path and file name. The
default is to only display the file name like the %t statusline item. By
setting this configuration value you can choose from the following ways
display the current path and file name:
VALUE DESCRIPTION ~
filename Display only the file name using the %t statusline item.
short Display a short path. The home directory is substituted with
"~", the first directory is displayed with its full name, and
subsequent directories are shortened to their first letter.
I.e. "/home/user/foo/bar/baz.vim" becomes "~/f/b/baz.vim" and
"long/relative/path/foo/bar/baz.vim becomes
"long/r/p/f/b/baz.vim".
relative Display a relative path, similar to the %f statusline item.
full Display the full path, similar to the %F statusline item.
Example: >
let g:Powerline_stl_path_style = 'full'
<
Default: "relative"
==============================================================================
5. Fonts *Powerline-fonts*
TODO
==============================================================================
6. Customization *Powerline-customization*
There are currently two ways of customizing Powerline: Basic customization
using a couple of functions to insert and remove existing segments from the
statusline, and advanced customization using your own autoload files. The
customization features of Powerline allow you to create your own statuslines
without ever touching the original source code.
------------------------------------------------------------------------------
6.1 Basic customization *Powerline-basic-customization*
Powerline provides the following functions to alter the default statusline
look. These functions should be called from your |vimrc| file or another file
which is sourced at Vim startup.
Note: These functions are currently applied to all statuslines, so if you
insert a segment after a segment which is present in many statuslines (e.g.
the "filename" segment), all the statuslines will have the inserted segment.
This behavior may be changed in a future version of Powerline.
Note: Remember to clear your cache with |:PowerlineClearCache| after changing
your statusline!
Example: >
" Insert the charcode segment after the filetype segment
call Pl#Theme#InsertSegment('charcode', 'after', 'filetype')
" Replace the scrollpercent segment with the charcode segment
call Pl#Theme#ReplaceSegment('scrollpercent', 'fileinfo')
<
*Pl#Theme#InsertSegment*
Pl#Theme#InsertSegment({newsegment}, {location}, {targetsegment})
This function inserts {newsegment} before or after {targetsegment}. The
{location} parameter specifies the location of the new segment, valid values
are "before" and "after". You can see all the available segments in
autoload/Powerline/Segments.vim and the files specified in
|Powerline-cust-segments|.
Pl#Theme#RemoveSegment({targetsegment}) *Pl#Theme#RemoveSegment*
This function removes the {targetsegment} segment entirely.
Pl#Theme#ReplaceSegment({oldsegment}, {newsegment}) *Pl#Theme#ReplaceSegment*
This function replaces {oldsegment} with {newsegment}.
------------------------------------------------------------------------------
6.2 Advanced customization *Powerline-advanced-customization*
Because Powerline utilizes Vim's autoload functionality, you can easily create
your own segments, themes, functions and colorschemes without touching the
original source code. This is a bit more complex than using the utility
functions, but it allows you to do a lot more with your statusline.
Your custom autoload files should be stored in your |runtimepath| (usually in
"~/.vim/autoload/Powerline/*").
Note: Remember to clear your cache with |:PowerlineClearCache| after changing
your statusline!
6.2.1 Colorschemes *Powerline-cust-colorschemes*
------------------------------------------------------------------------------
Colorschemes should be stored as separate files in
{runtimepath}/autoload/Powerline/Colorschemes/.
SYNTAX ~
TODO
EXAMPLE ~
TODO
6.2.2 Functions *Powerline-cust-functions*
------------------------------------------------------------------------------
Functions should be stored as separate files in
{runtimepath}/autoload/Powerline/Functions/.
SYNTAX ~
TODO
EXAMPLE ~
TODO
6.2.3 Segments *Powerline-cust-segments*
------------------------------------------------------------------------------
Segments should be stored as separate files in
{runtimepath}/autoload/Powerline/Segments/.
SYNTAX ~
TODO
EXAMPLE ~
TODO
6.2.4 Themes *Powerline-cust-themes*
------------------------------------------------------------------------------
Themes should be stored as separate files in
{runtimepath}/autoload/Powerline/Themes/.
SYNTAX ~
TODO
EXAMPLE ~
TODO
==============================================================================
7. License *Powerline-license*
Creative Commons Attribution-ShareAlike 3.0 Unported
http://creativecommons.org/licenses/by-sa/3.0/
==============================================================================
8. Known issues *Powerline-known-issues*
See the issue tracker at
https://github.com/Lokaltog/vim-powerline/issues
==============================================================================
9. Contributing *Powerline-contributing*
If you experience any bugs or have feature requests, please open an issue on
GitHub. Fork the source repository on GitHub and send a pull request if you
have any code improvements.
Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
Source repository: https://github.com/Lokaltog/vim-powerline
==============================================================================
vim:tw=78:sw=4:ts=8:ft=help:norl:

View file

@ -1,34 +0,0 @@
:PowerlineClearCache Powerline.txt /*:PowerlineClearCache*
Pl#Theme#InsertSegment Powerline.txt /*Pl#Theme#InsertSegment*
Pl#Theme#RemoveSegment Powerline.txt /*Pl#Theme#RemoveSegment*
Pl#Theme#ReplaceSegment Powerline.txt /*Pl#Theme#ReplaceSegment*
Powerline Powerline.txt /*Powerline*
Powerline-advanced-customization Powerline.txt /*Powerline-advanced-customization*
Powerline-basic-customization Powerline.txt /*Powerline-basic-customization*
Powerline-configuration Powerline.txt /*Powerline-configuration*
Powerline-contents Powerline.txt /*Powerline-contents*
Powerline-contributing Powerline.txt /*Powerline-contributing*
Powerline-cust-colorschemes Powerline.txt /*Powerline-cust-colorschemes*
Powerline-cust-functions Powerline.txt /*Powerline-cust-functions*
Powerline-cust-segments Powerline.txt /*Powerline-cust-segments*
Powerline-cust-themes Powerline.txt /*Powerline-cust-themes*
Powerline-customization Powerline.txt /*Powerline-customization*
Powerline-fonts Powerline.txt /*Powerline-fonts*
Powerline-introduction Powerline.txt /*Powerline-introduction*
Powerline-known-issues Powerline.txt /*Powerline-known-issues*
Powerline-license Powerline.txt /*Powerline-license*
Powerline-recommended-settings Powerline.txt /*Powerline-recommended-settings*
Powerline-requirements Powerline.txt /*Powerline-requirements*
Powerline-symbols-compatible Powerline.txt /*Powerline-symbols-compatible*
Powerline-symbols-fancy Powerline.txt /*Powerline-symbols-fancy*
Powerline-usage Powerline.txt /*Powerline-usage*
Powerline.txt Powerline.txt /*Powerline.txt*
Powerline_cache_enabled Powerline.txt /*Powerline_cache_enabled*
Powerline_cache_file Powerline.txt /*Powerline_cache_file*
Powerline_colorscheme Powerline.txt /*Powerline_colorscheme*
Powerline_dividers_override Powerline.txt /*Powerline_dividers_override*
Powerline_mode Powerline.txt /*Powerline_mode*
Powerline_stl_path_style Powerline.txt /*Powerline_stl_path_style*
Powerline_symbols Powerline.txt /*Powerline_symbols*
Powerline_symbols_override Powerline.txt /*Powerline_symbols_override*
Powerline_theme Powerline.txt /*Powerline_theme*

View file

@ -1,319 +0,0 @@
SplineFontDB: 3.0
FontName: PowerlineSymbols
FullName: PowerlineSymbols
FamilyName: PowerlineSymbols
Weight: Medium
Copyright:
UComments: "2011-11-21: Created."
Version: 001.000
ItalicAngle: 0
UnderlinePosition: -98.6328
UnderlineWidth: 48.8281
Ascent: 800
Descent: 200
LayerCount: 2
Layer: 0 0 "Back" 1
Layer: 1 0 "Fore" 0
XUID: [1021 211 26716215 11021609]
FSType: 0
OS2Version: 0
OS2_WeightWidthSlopeOnly: 0
OS2_UseTypoMetrics: 1
CreationTime: 1321867751
ModificationTime: 1326665029
OS2TypoAscent: 0
OS2TypoAOffset: 1
OS2TypoDescent: 0
OS2TypoDOffset: 1
OS2TypoLinegap: 90
OS2WinAscent: 0
OS2WinAOffset: 1
OS2WinDescent: 0
OS2WinDOffset: 1
HheadAscent: 0
HheadAOffset: 1
HheadDescent: 0
HheadDOffset: 1
OS2Vendor: 'PfEd'
MarkAttachClasses: 1
DEI: 91125
Encoding: UnicodeFull
Compacted: 1
UnicodeInterp: none
NameList: Adobe Glyph List
DisplaySize: -24
AntiAlias: 1
FitToEm: 1
WinInfo: 0 31 18
BeginPrivate: 0
EndPrivate
BeginChars: 1114112 9
StartChar: uni2B80
Encoding: 11136 11136 0
Width: 621
Flags: HMW
LayerCount: 2
Fore
SplineSet
0 1000 m 1
621 379 l 1
0 -243 l 1
0 1000 l 1
EndSplineSet
EndChar
StartChar: uni2B81
Encoding: 11137 11137 1
Width: 621
Flags: HMW
LayerCount: 2
Fore
SplineSet
10 991 m 0
16 997 23 1000 32 1000 c 0
41 1000 48 996 54 990 c 2
613 400 l 2
619 394 621 386 621 378 c 0
621 370 618 362 613 357 c 2
54 -233 l 2
48 -239 41 -242 32 -242 c 0
23 -242 16 -240 10 -234 c 0
4 -228 0 -221 0 -212 c 0
0 -203 3 -196 8 -190 c 2
547 379 l 1
8 948 l 2
3 954 0 961 0 970 c 0
0 979 4 985 10 991 c 0
EndSplineSet
EndChar
StartChar: uni2B82
Encoding: 11138 11138 2
Width: 621
Flags: HMW
LayerCount: 2
Fore
SplineSet
621 1000 m 5
621 -243 l 5
0 379 l 5
621 1000 l 5
EndSplineSet
EndChar
StartChar: uni2B83
Encoding: 11139 11139 3
Width: 621
Flags: HMW
LayerCount: 2
Fore
SplineSet
612 991 m 0
618 985 621 979 621 970 c 0
621 961 619 954 613 948 c 2
74 379 l 1
613 -190 l 2
619 -196 621 -203 621 -212 c 0
621 -221 618 -228 612 -234 c 0
606 -240 598 -242 589 -242 c 0
580 -242 574 -239 568 -233 c 2
8 357 l 2
3 362 0 370 0 378 c 0
0 386 3 394 8 400 c 2
568 990 l 2
574 996 580 1000 589 1000 c 0
598 1000 606 997 612 991 c 0
EndSplineSet
EndChar
StartChar: uni2B61
Encoding: 11105 11105 4
Width: 555
VWidth: 0
Flags: HMW
LayerCount: 2
Fore
SplineSet
0 800 m 5
92 800 l 5
92 513 l 5
253 513 l 5
253 444 l 5
0 444 l 5
0 800 l 5
236 312 m 5
339 312 l 5
468 67 l 5
468 312 l 5
555 312 l 5
555 -44 l 5
453 -44 l 5
323 200 l 5
323 -44 l 5
236 -44 l 5
236 312 l 5
EndSplineSet
EndChar
StartChar: uni2B60
Encoding: 11104 11104 5
Width: 676
Flags: HMW
LayerCount: 2
Fore
SplineSet
0 197 m 1
94 207 419 279 419 384 c 2
419 537 l 1
278 501 l 1
478 794 l 1
677 501 l 1
536 537 l 1
536 384 l 2
536 196 208 126 208 21 c 2
208 -244 l 1
0 -244 l 1
0 197 l 1
0 288 m 1
0 405 0 944 0 944 c 1
208 944 l 1
208 944 208 451 208 334 c 1
185 311 12 288 0 288 c 1
EndSplineSet
EndChar
StartChar: uni2B62
Encoding: 11106 11106 6
Width: 428
VWidth: 0
Flags: HMW
LayerCount: 2
Fore
SplineSet
88 677 m 2
429 677 l 1
429 589 l 1
88 589 l 1
88 162 l 1
198 162 l 1
198 343 l 1
374 343 l 1
374 427 l 1
198 427 l 1
198 506 l 1
429 506 l 1
429 274 l 1
416 263 391 255 374 255 c 2
286 255 l 1
286 162 l 2
286 114 246 74 198 74 c 2
88 74 l 2
40 74 0 114 0 162 c 2
0 589 l 2
0 637 40 677 88 677 c 2
EndSplineSet
EndChar
StartChar: uni2B63
Encoding: 11107 11107 7
Width: 428
VWidth: 0
Flags: HMW
LayerCount: 2
Fore
SplineSet
0 677 m 5
341 677 l 6
389 677 429 637 429 589 c 6
429 506 l 6
429 458 389 418 341 418 c 6
287 418 l 5
287 162 l 6
287 114 247 74 199 74 c 6
89 74 l 6
41 74 1 114 1 162 c 6
1 274 l 6
0 274 l 6
0 506 l 5
89 506 l 5
89 162 l 5
199 162 l 5
199 506 l 5
341 506 l 5
341 589 l 5
0 589 l 5
0 677 l 5
EndSplineSet
EndChar
StartChar: uni2B64
Encoding: 11108 11108 8
Width: 546
VWidth: 0
Flags: HMW
LayerCount: 2
Fore
SplineSet
273 733 m 4
429 733 430 538 430 538 c 5
430 420 l 5
547 420 l 5
547 303 l 5
547 303 546 -9 273 -9 c 4
0 -9 0 303 0 303 c 5
0 420 l 5
117 420 l 5
117 538 l 5
117 538 117 733 273 733 c 4
273 655 m 4
195 655 195 576 195 420 c 5
352 420 l 5
352 576 351 655 273 655 c 4
273 342 m 4
195 342 195 147 273 147 c 4
351 147 351 342 273 342 c 4
EndSplineSet
EndChar
EndChars
BitmapFont: 10 10 8 2 1
BDFChar: 0 11136 6 0 4 -2 7
JAC+4q"X@:^jlCb
BDFChar: 1 11137 6 0 4 -2 7
J3Y4g#RCta5_&h7
BDFChar: 2 11138 6 1 5 -2 7
#T,OGq"T(n(^L*A
BDFChar: 3 11139 6 1 5 -2 7
#S8+DJ:Km-&-r79
BDFChar: 4 11105 6 1 4 -1 7
J:N1>!0GR3O8o7\
BDFChar: 5 11104 7 0 5 -2 7
^rY<PaN2`d^q]pM
BDFChar: 6 11106 4 1 5 -1 6
G^u0KJ=)F+
BDFChar: 7 11107 4 0 5 -1 6
p]QtGOH>Q3
BDFChar: 8 11108 5 0 5 0 6
0M"b4bku\c
EndBitmapFont
BitmapFont: 12 10 10 2 1
BDFChar: 0 11136 7 0 6 -2 11
!!%Pbi:-O>r:od>^jlCb
BDFChar: 1 11137 7 0 6 -3 11
!!%O7+:ne]":,P]5_&h7
BDFChar: 2 11138 7 0 6 -2 11
!!!-1*'AWHr-UUH$j6P1
BDFChar: 3 11139 7 0 6 -2 11
!!!--&0O5gJ3Y4g#Qt,-
BDFChar: 4 11105 7 0 5 0 8
J:N1>!$jBP,QIfE
BDFChar: 5 11104 8 0 8 -3 11
z^];.Ma8juqa8j9]a8jQehuLOm^];.Mz
BDFChar: 6 11106 5 1 6 0 8
!-j$]R"1Qc?iU0,
BDFChar: 7 11107 5 0 5 0 7
p]QtGOH>Q3
BDFChar: 8 11108 7 0 5 0 8
0M"`*r63C_GQ7^D
EndBitmapFont
EndSplineFont

View file

@ -1,164 +0,0 @@
======================
Powerline font patcher
======================
:Author: Kim Silkebækken (kim.silkebaekken+vim@gmail.com)
Description
-----------
This font patcher creates dividers and symbols for use with Powerline. The
script requires Python 2 and FontForge compiled with Python bindings.
Patched fonts are renamed by default (" for Powerline" is added to the font
name) so they don't conflict with existing fonts. Use the ``--no-rename``
option to disable font renaming.
Glyph table
-----------
All the glyphs are stored in the ``U+2B60``-``U+2BFF`` range ("Misc symbols
and arrows").
+------------+-------------------+
| Code point | Description |
+============+===================+
| ``U+2B60`` | Branch symbol |
+------------+-------------------+
| ``U+2B61`` | LN (line) symbol |
+------------+-------------------+
| ``U+2B62`` | FT symbol, part 1 |
+------------+-------------------+
| ``U+2B63`` | FT symbol, part 2 |
+------------+-------------------+
| ``U+2B64`` | Padlock (closed) |
+------------+-------------------+
| ``U+2B80`` | Hard right arrow |
+------------+-------------------+
| ``U+2B81`` | Soft right arrow |
+------------+-------------------+
| ``U+2B82`` | Hard left arrow |
+------------+-------------------+
| ``U+2B83`` | Soft left arrow |
+------------+-------------------+
===================
Font patching guide
===================
There's a `GitHub wiki page`_ dedicated to community-contributed patched
fonts. You may download one of the fonts on that page if you don't want to
patch the fonts yourself.
If you do patch a font that's not included in the wiki (and you have
permission to distribute it), please include it on the wiki page.
**Note:** The fonts in the wiki may be outdated, and may have different
glyphs than the ones provided in the latest version of Powerline. It's
recommended that you always patch your fonts yourself if you have the
required software.
.. _`GitHub wiki page`: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts
Linux
-----
1. Install fontforge with Python bindings. For Ubuntu users the required
package is ``python-fontforge``, for Arch Linux users the required
package is ``fontforge``. It should be something similar for other
distros.
2. Run the font patcher::
$ /path/to/fontpatcher MyFontFile.ttf
3. Copy the font file into ``~/.fonts`` (or another X font directory)::
$ cp MyFontFile-Powerline.otf ~/.fonts
**Note:** If the font is a pure bitmap font (e.g. a PCF font) it will be
stored in the BDF format. This is usually not a problem, and you may
convert the font back to the PCF format using ``bdftopcf`` if you want
to. All other fonts will be stored in the OTF format regardless of the
original format.
4. Update your font cache::
$ sudo fc-cache -vf
**Note:** If you use vim in rxvt-unicode in the client/daemon mode, you
may need to close all running terminals as well for the font to be
updated.
5. **For gvim users:** Update the GUI font in your ``vimrc`` file::
set guifont=MyFont\ for\ Powerline
**For terminal users:** Update your terminal configuration to use the
patched font.
6. Update your ``vimrc`` configuration to use the new symbols::
let g:Powerline_symbols = 'fancy'
7. Make sure that the cache file is deleted::
$ rm /tmp/Powerline.cache
8. Start vim and enjoy your new statusline!
OS X
----
1. Check if you have a FontForge version with Python support by running
``fontforge -version``. You should see something like this::
$ fontforge -version
Copyright (c) 2000-2011 by George Williams.
Executable based on sources from 13:48 GMT 22-Feb-2011-D.
Library based on sources from 13:48 GMT 22-Feb-2011.
fontforge 20110222
libfontforge 20110222
Make sure that the executable version number doesn't have ``NoPython`` in
it. If everything looks OK, skip ahead to step 4.
2. If you have FontForge but with ``NoPython`` in the version number, please
try to update to a later version::
$ brew uninstall fontforge
$ brew update
$ brew install --use-gcc fontforge
**Note:** You may have to use ``--use-clang`` instead of ``--use-gcc``
when compiling FontForge.
3. If you don't have FontForge, install it with Homebrew::
$ brew update
$ brew install --use-gcc fontforge
4. Patch your fonts by passing the ``fontpatcher`` script as a parameter to
FontForge::
$ fontforge -script /path/to/fontpatcher MyFontFile.ttf
5. Install the font by double-clicking the font file in Finder and click
"Install this font" from the preview window.
6. **For gvim users:** Update the GUI font in your ``vimrc`` file::
set guifont=MyFont\ for\ Powerline
**For terminal users:** Update your terminal configuration to use the
patched font.
7. Update your ``vimrc`` configuration to use the new symbols::
let g:Powerline_symbols = 'fancy'
8. Make sure that the cache file is deleted::
$ rm /tmp/Powerline.cache
9. Start vim and enjoy your new statusline!

View file

@ -1,240 +0,0 @@
#!/usr/bin/env python
"""Font patcher for Powerline.
Creates dividers and symbols for use with Powerline. Requires FontForge with Python bindings.
Stores glyphs in the 2b60-2bff Unicode range ("Misc symbols and arrows").
[2b60] Branch symbol
[2b61] LN (line) symbol
[2b62] FT symbol 1
[2b63] FT symbol 2
[2b64] Padlock (closed) symbol
[2b80] Hard right arrow
[2b81] Soft right arrow
[2b82] Hard left arrow
[2b83] Soft left arrow
"""
from __future__ import division
import argparse
import os
import sys
import re
try:
import fontforge
import psMat
except ImportError:
sys.stderr.write('The required FontForge modules could not be loaded.\n\n')
if sys.version_info.major > 2:
sys.stderr.write('FontForge only supports Python 2. Please run this script with the Python 2 executable - e.g. "python2 {0}"\n'.format(sys.argv[0]))
else:
sys.stderr.write('You need FontForge with Python bindings for this script to work.\n')
sys.exit(1)
# Handle command-line arguments
parser = argparse.ArgumentParser(description='Font patcher for Powerline. Creates dividers and symbols in FontForge-compatible font files. Requires FontForge with Python bindings. Stores glyphs in the U+2B80-U+2BFF range ("Miscellaneous symbols and arrows"). Stores the patched font as a new, renamed font file by default.')
parser.add_argument('fonts', help='font file to patch', metavar='font', nargs='+')
parser.add_argument('--no-rename', help='don\'t add " for Powerline" to the font name', default=True, action='store_false', dest='rename')
parser.add_argument('--symbol-font', help='font file with symbols', metavar='font', dest='symbol_font', default='{0}/PowerlineSymbols.sfd'.format(sys.path[0]))
parser.add_argument('--fix-mono', help='fixes some mono-fonts which have glyphs of 0 widths', default=False, action='store_true', dest='fixmono')
parser.add_argument('--fix-win', help='modifies font names such that Windows correctly recognizes font families', default=False, action='store_true', dest='fixwin')
args = parser.parse_args()
SYM_ATTR = {
# Right/left-aligned glyphs will have their advance width reduced in order to overlap the next glyph slightly
0x2b60: { 'align': 'c', 'stretch': 'y' , 'overlap': False },
0x2b61: { 'align': 'c', 'stretch': '' , 'overlap': False },
0x2b62: { 'align': 'r', 'stretch': '' , 'overlap': False },
0x2b63: { 'align': 'l', 'stretch': '' , 'overlap': False },
0x2b64: { 'align': 'c', 'stretch': '' , 'overlap': False },
0x2b80: { 'align': 'l', 'stretch': 'xy', 'overlap': True },
0x2b81: { 'align': 'l', 'stretch': 'xy', 'overlap': True },
0x2b82: { 'align': 'r', 'stretch': 'xy', 'overlap': True },
0x2b83: { 'align': 'r', 'stretch': 'xy', 'overlap': True },
}
# Open symbol font
try:
symbols = fontforge.open(args.symbol_font)
except EnvironmentError:
sys.exit(1)
# Patch provided fonts
for font_path in args.fonts:
try:
font = fontforge.open(font_path)
except EnvironmentError:
sys.exit(1)
# Rename font
if args.rename:
font.familyname += ' for Powerline'
font.fullname += ' for Powerline'
font.fontname += 'ForPowerline'
font.appendSFNTName('English (US)', 'Preferred Family', font.familyname)
font.appendSFNTName('English (US)', 'Compatible Full', font.fullname)
if args.fixwin:
font.fontname = re.sub(r'\W', '', font.familyname)
# Force the em size to be equal
symbols.em = font.em
# Initial font dimensions
font_dim = {
'xmin' : 0,
'ymin' : -font.descent,
'xmax' : 0,
'ymax' : font.ascent,
'width' : 0,
'height': 0,
}
# Find the biggest char width and height
#
# 0x00-0x17f is the Latin Extended-A range
# 0x2500-0x2600 is the box drawing range
for glyph in range(0x00, 0x17f) + range(0x2500, 0x2600):
try:
(xmin, ymin, xmax, ymax) = font[glyph].boundingBox()
except TypeError:
continue
if font_dim['width'] == 0:
font_dim['width'] = font[glyph].width
if ymin < font_dim['ymin']: font_dim['ymin'] = ymin
if ymax > font_dim['ymax']: font_dim['ymax'] = ymax
if xmax > font_dim['xmax']: font_dim['xmax'] = xmax
# Calculate font height
font_dim['height'] = abs(font_dim['ymin']) + font_dim['ymax']
# Update the font encoding to ensure that the Unicode glyphs are available
font.encoding = 'ISO10646'
# Fetch this property before adding outlines
onlybitmaps = font.onlybitmaps
def get_dim(glyph):
bbox = glyph.boundingBox()
return {
'xmin' : bbox[0],
'ymin' : bbox[1],
'xmax' : bbox[2],
'ymax' : bbox[3],
'width' : bbox[2] + (-bbox[0]),
'height': bbox[3] + (-bbox[1]),
}
# Create glyphs from symbol font
for sym_glyph in symbols.glyphs():
sym_attr = SYM_ATTR[sym_glyph.unicode]
# Prepare symbol glyph dimensions
sym_dim = get_dim(sym_glyph)
# Select and copy symbol from its encoding point
symbols.selection.select(sym_glyph.encoding)
symbols.copy()
# Select and paste symbol to its unicode code point
font.selection.select(sym_glyph.unicode)
font.paste()
# Now that we have copy/pasted the glyph, it's time to scale and move it
# Handle glyph stretching
if 'x' in sym_attr['stretch']:
# Stretch the glyph horizontally
scale_ratio = font_dim['width'] / sym_dim['width']
font.transform(psMat.scale(scale_ratio, 1))
if 'y' in sym_attr['stretch']:
# Stretch the glyph vertically
scale_ratio = font_dim['height'] / sym_dim['height']
font.transform(psMat.scale(1, scale_ratio))
# Use the dimensions from the pasted and stretched glyph
sym_dim = get_dim(font[sym_glyph.unicode])
# Center-align the glyph vertically
font_ycenter = font_dim['height'] / 2
sym_ycenter = sym_dim['height'] / 2
# First move it to the ymax (top)
font.transform(psMat.translate(0, font_dim['ymax'] - sym_dim['ymax']))
# Then move it the y center difference
font.transform(psMat.translate(0, sym_ycenter - font_ycenter))
# Ensure that the glyph doesn't extend outside the font's bounding box
if sym_dim['width'] > font_dim['width']:
# The glyph is too wide, scale it down to fit
scale_matrix = psMat.scale(font_dim['width'] / sym_dim['width'], 1)
font.transform(scale_matrix)
# Use the dimensions from the stretched glyph
sym_dim = get_dim(font[sym_glyph.unicode])
# Handle glyph alignment
if sym_attr['align'] == 'c':
# Center align
align_matrix = psMat.translate(font_dim['width'] / 2 - sym_dim['width'] / 2 , 0)
elif sym_attr['align'] == 'r':
# Right align
align_matrix = psMat.translate(font_dim['width'] - sym_dim['width'], 0)
else:
# No alignment (left alignment)
align_matrix = psMat.translate(0, 0)
font.transform(align_matrix)
if sym_attr['overlap'] is True:
overlap_width = font.em / 48
# Stretch the glyph slightly horizontally if it should overlap
font.transform(psMat.scale((sym_dim['width'] + overlap_width) / sym_dim['width'], 1))
if sym_attr['align'] == 'l':
# The glyph should be left-aligned, so it must be moved overlap_width to the left
# This only applies to left-aligned glyphs because the glyph is scaled to the right
font.transform(psMat.translate(-overlap_width, 0))
# Ensure the font is considered monospaced on Windows
font[sym_glyph.unicode].width = font_dim['width']
if font.bitmapSizes and not onlybitmaps:
# If this is an outline font with bitmaps, regenerate bitmaps for the changed glyphs
font.selection.changed()
for size in font.bitmapSizes:
font.regenBitmaps((size, ))
output_name, extension = os.path.split(font_path)[1].rsplit('.', 1)
if extension.lower() not in ['ttf', 'otf']:
# Default to OpenType if input is not TrueType/OpenType
extension = 'otf'
if args.fixmono:
for glyph in font.glyphs():
if glyph.width == 0: glyph.width = font_dim['width']
if onlybitmaps:
# Generate BDF font
font.generate('{0}-Powerline.bdf'.format(output_name, bitmap_type='bdf'))
else:
# Generate OTF/TTF font
font.generate('{0}-Powerline.{1}'.format(output_name, extension))

View file

@ -1,69 +0,0 @@
" Powerline - The ultimate statusline utility
"
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
" Source repository: https://github.com/Lokaltog/vim-powerline
" Script initialization {{{
if exists('g:Powerline_loaded') || &compatible || version < 702
finish
endif
let g:Powerline_loaded = 1
" }}}
" Commands {{{
command! PowerlineClearCache call Pl#ClearCache()
command! PowerlineReloadColorscheme call Pl#ReloadColorscheme()
" }}}
" Set default options {{{
for [s:key, s:value] in items({
\ 'theme' : 'default'
\ , 'colorscheme' : 'default'
\ , 'symbols' : 'compatible'
\ , 'symbols_override' : {}
\ , 'dividers_override': []
\ , 'stl_path_style' : 'relative'
\ , 'cache_enabled' : 1
\ })
if ! exists('g:Powerline_' . s:key)
exec printf('let g:Powerline_%s = %s', s:key, string(s:value))
endif
unlet! s:key s:value
endfor
if ! exists('g:Powerline_cache_file')
exec 'let g:Powerline_cache_file = '. string(printf('%s/Powerline_%s_%s_%s.cache'
\ , simplify(expand('<sfile>:p:h') .'/..')
\ , g:Powerline_theme
\ , g:Powerline_colorscheme
\ , g:Powerline_symbols
\ ))
endif
" }}}
" Autocommands {{{
function! s:CreateAutocmds()
augroup PowerlineMain
autocmd!
" Reload statuslines when changing color scheme
autocmd ColorScheme *
\ call Pl#Load()
autocmd BufEnter,WinEnter,FileType,BufUnload *
\ call Pl#UpdateStatusline(1)
autocmd BufLeave,WinLeave *
\ call Pl#UpdateStatusline(0)
autocmd BufWritePost */autoload/Powerline/Colorschemes/*.vim
\ :PowerlineReloadColorscheme
augroup END
endfunction
augroup PowerlineStartup
autocmd!
autocmd VimEnter * call s:CreateAutocmds() | call Pl#UpdateStatusline(1)
augroup END
" }}}

View file

@ -3,10 +3,9 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-07-17. " @Created: 2007-07-17.
" @Last Change: 2010-01-03. " @Last Change: 2013-09-25.
" @Revision: 0.0.7 " @Revision: 0.0.12
" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile " :nodefault:
TLet g:tlib#debug = 0
" Dummy file for backwards compatibility.

View file

@ -3,11 +3,11 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-11-25. " @Created: 2008-11-25.
" @Last Change: 2012-09-26. " @Last Change: 2013-09-25.
" @Revision: 0.0.90 " @Revision: 0.0.92
let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2 let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2
let s:prototype.highlight = g:tlib_inputlist_higroup let s:prototype.highlight = g:tlib#input#higroup
" The search pattern for |tlib#input#List()| is in conjunctive normal " The search pattern for |tlib#input#List()| is in conjunctive normal
" form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... " form: (P1 OR P2 ...) AND (P3 OR P4 ...) ...
@ -33,7 +33,7 @@ endf
" :nodoc: " :nodoc:
function! s:prototype.Help(world) dict "{{{3 function! s:prototype.Help(world) dict "{{{3
call a:world.PushHelp( call a:world.PushHelp(
\ printf('"%s", "%s", "%sWORD"', g:tlib_inputlist_and, g:tlib_inputlist_or, g:tlib_inputlist_not), \ printf('"%s", "%s", "%sWORD"', g:tlib#input#and, g:tlib#input#or, g:tlib#input#not),
\ 'AND, OR, NOT') \ 'AND, OR, NOT')
endf endf

View file

@ -3,11 +3,11 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-11-25. " @Created: 2008-11-25.
" @Last Change: 2012-09-20. " @Last Change: 2013-09-25.
" @Revision: 0.0.50 " @Revision: 0.0.51
let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2 let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2
let s:prototype.highlight = g:tlib_inputlist_higroup let s:prototype.highlight = g:tlib#input#higroup
" The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. " The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'.

View file

@ -2,11 +2,11 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-11-25. " @Created: 2008-11-25.
" @Last Change: 2012-09-20. " @Last Change: 2013-09-25.
" @Revision: 0.0.61 " @Revision: 0.0.62
let s:prototype = tlib#Filter_cnfd#New({'_class': ['Filter_cnfx'], 'name': 'cnfx'}) "{{{2 let s:prototype = tlib#Filter_cnfd#New({'_class': ['Filter_cnfx'], 'name': 'cnfx'}) "{{{2
let s:prototype.highlight = g:tlib_inputlist_higroup let s:prototype.highlight = g:tlib#input#higroup
" A character that should be expanded to '\.\{-}'. " A character that should be expanded to '\.\{-}'.

View file

@ -3,11 +3,11 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-11-25. " @Created: 2008-11-25.
" @Last Change: 2012-09-20. " @Last Change: 2013-09-25.
" @Revision: 0.0.46 " @Revision: 0.0.47
let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2 let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2
let s:prototype.highlight = g:tlib_inputlist_higroup let s:prototype.highlight = g:tlib#input#higroup
" Support for "fuzzy" pattern matching in |tlib#input#List()|. " Support for "fuzzy" pattern matching in |tlib#input#List()|.

View file

@ -3,14 +3,34 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-05-01. " @Created: 2007-05-01.
" @Last Change: 2012-10-03. " @Last Change: 2013-09-26.
" @Revision: 0.1.1203 " @Revision: 0.1.1297
" :filedoc: " :filedoc:
" A prototype used by |tlib#input#List|. " A prototype used by |tlib#input#List|.
" Inherits from |tlib#Object#New|. " Inherits from |tlib#Object#New|.
" Size of the input list window (in percent) from the main size (of &lines).
" See |tlib#input#List()|.
TLet g:tlib_inputlist_pct = 50
" Size of filename columns when listing filenames.
" See |tlib#input#List()|.
TLet g:tlib_inputlist_width_filename = '&co / 3'
" TLet g:tlib_inputlist_width_filename = 25
" If true, |tlib#input#List()| will show some indicators about the
" status of a filename (e.g. buflisted(), bufloaded() etc.).
" This is disabled by default because vim checks also for the file on
" disk when doing this.
TLet g:tlib_inputlist_filename_indicators = 0
" If not null, display only a short info about the filter.
TLet g:tlib_inputlist_shortmessage = 0
" Known keys & values: " Known keys & values:
" scratch_split ... See |tlib#scratch#UseScratch()| " scratch_split ... See |tlib#scratch#UseScratch()|
let s:prototype = tlib#Object#New({ let s:prototype = tlib#Object#New({
@ -19,6 +39,7 @@ let s:prototype = tlib#Object#New({
\ 'allow_suspend': 1, \ 'allow_suspend': 1,
\ 'base': [], \ 'base': [],
\ 'bufnr': -1, \ 'bufnr': -1,
\ 'buffer_local': 1,
\ 'cache_var': '', \ 'cache_var': '',
\ 'display_format': '', \ 'display_format': '',
\ 'fileencoding': &fileencoding, \ 'fileencoding': &fileencoding,
@ -40,22 +61,26 @@ let s:prototype = tlib#Object#New({
\ 'key_handlers': [], \ 'key_handlers': [],
\ 'list': [], \ 'list': [],
\ 'matcher': {}, \ 'matcher': {},
\ 'next_agent': '',
\ 'next_eval': '',
\ 'next_state': '', \ 'next_state': '',
\ 'numeric_chars': tlib#var#Get('tlib_numeric_chars', 'bg'), \ 'numeric_chars': g:tlib#input#numeric_chars,
\ 'offset': 1, \ 'offset': 1,
\ 'offset_horizontal': 0, \ 'offset_horizontal': 0,
\ 'on_leave': [], \ 'on_leave': [],
\ 'pick_last_item': tlib#var#Get('tlib_pick_last_item', 'bg'), \ 'pick_last_item': tlib#var#Get('tlib#input#pick_last_item', 'bg'),
\ 'post_handlers': [], \ 'post_handlers': [],
\ 'query': '', \ 'query': '',
\ 'resize': 0, \ 'resize': 0,
\ 'resize_vertical': 0, \ 'resize_vertical': 0,
\ 'restore_from_cache': [], \ 'restore_from_cache': [],
\ 'filtered_items': [],
\ 'retrieve_eval': '', \ 'retrieve_eval': '',
\ 'return_agent': '', \ 'return_agent': '',
\ 'rv': '', \ 'rv': '',
\ 'scratch': '__InputList__', \ 'scratch': '__InputList__',
\ 'scratch_filetype': 'tlibInputList', \ 'scratch_filetype': 'tlibInputList',
\ 'scratch_hidden': g:tlib#scratch#hidden,
\ 'scratch_vertical': 0, \ 'scratch_vertical': 0,
\ 'scratch_split': 1, \ 'scratch_split': 1,
\ 'sel_idx': [], \ 'sel_idx': [],
@ -63,6 +88,7 @@ let s:prototype = tlib#Object#New({
\ 'state': 'display', \ 'state': 'display',
\ 'state_handlers': [], \ 'state_handlers': [],
\ 'sticky': 0, \ 'sticky': 0,
\ 'temp_lines': [],
\ 'temp_prompt': [], \ 'temp_prompt': [],
\ 'timeout': 0, \ 'timeout': 0,
\ 'timeout_resolution': 2, \ 'timeout_resolution': 2,
@ -77,7 +103,7 @@ let s:prototype = tlib#Object#New({
function! tlib#World#New(...) function! tlib#World#New(...)
let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
call object.SetMatchMode(tlib#var#Get('tlib_inputlist_match', 'g', 'cnf')) call object.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'g', 'cnf'))
return object return object
endf endf
@ -113,7 +139,7 @@ if g:tlib#input#format_filename == 'r'
function! s:prototype.FormatFilename(file) dict "{{{3 function! s:prototype.FormatFilename(file) dict "{{{3
if !has_key(self.fmt_options, 'maxlen') if !has_key(self.fmt_options, 'maxlen')
let maxco = &co - len(len(self.base)) - eval(g:tlib#input#filename_padding_r) let maxco = &co - len(len(self.base)) - eval(g:tlib#input#filename_padding_r)
let maxfi = max(map(copy(self.base), 'len(v:val)')) let maxfi = max(map(copy(self.base), 'strwidth(v:val)'))
let self.fmt_options.maxlen = min([maxco, maxfi]) let self.fmt_options.maxlen = min([maxco, maxfi])
" TLogVAR maxco, maxfi, self.fmt_options.maxlen " TLogVAR maxco, maxfi, self.fmt_options.maxlen
endif endif
@ -135,11 +161,11 @@ else
let self.width_filename = min([ let self.width_filename = min([
\ get(self, 'width_filename', &co), \ get(self, 'width_filename', &co),
\ empty(g:tlib#input#filename_max_width) ? &co : eval(g:tlib#input#filename_max_width), \ empty(g:tlib#input#filename_max_width) ? &co : eval(g:tlib#input#filename_max_width),
\ max(map(copy(self.base), 'len(fnamemodify(v:val, ":t"))')) \ max(map(copy(self.base), 'strwidth(fnamemodify(v:val, ":t"))'))
\ ]) \ ])
" TLogVAR self.width_filename " TLogVAR self.width_filename
exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir' exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir'
exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename'
exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir' exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir'
hi def link TLibMarker Special hi def link TLibMarker Special
hi def link TLibDir Directory hi def link TLibDir Directory
@ -154,10 +180,11 @@ else
" :nodoc: " :nodoc:
function! s:prototype.FormatFilename(file) dict "{{{3 function! s:prototype.FormatFilename(file) dict "{{{3
" TLogVAR a:file
let width = self.width_filename let width = self.width_filename
let split = match(a:file, '[/\\]\zs[^/\\]\+$') let split = match(a:file, '[/\\]\zs[^/\\]\+$')
if split == -1 if split == -1
let fname = '' let fname = a:file
let dname = a:file let dname = a:file
else else
let fname = strpart(a:file, split) let fname = strpart(a:file, split)
@ -167,15 +194,17 @@ else
if strwidth(fname) > width if strwidth(fname) > width
let fname = strpart(fname, 0, width - 3) .'...' let fname = strpart(fname, 0, width - 3) .'...'
endif endif
let dnmax = &co - max([width, len(fname)]) - 10 - self.index_width - &fdc let dnmax = &co - max([width, strwidth(fname)]) - 10 - self.index_width - &fdc
if g:tlib_inputlist_filename_indicators if g:tlib_inputlist_filename_indicators
let dnmax -= 2 let dnmax -= 2
endif endif
if len(dname) > dnmax if strwidth(dname) > dnmax
let dname = '...'. strpart(dname, len(dname) - dnmax) let dname = '...'. strpart(dname, len(dname) - dnmax)
endif endif
let marker = [] let marker = []
if g:tlib_inputlist_filename_indicators let use_indicators = g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators')
" TLogVAR use_indicators
if use_indicators
call insert(marker, '[') call insert(marker, '[')
let bnr = bufnr(a:file) let bnr = bufnr(a:file)
" TLogVAR a:file, bnr, self.bufnr " TLogVAR a:file, bnr, self.bufnr
@ -194,14 +223,24 @@ else
" if !buflisted(bnr) " if !buflisted(bnr)
" call add(marker, 'u') " call add(marker, 'u')
" endif " endif
else " echom "DBG" a:file string(get(self,'filename_indicators'))
endif
if has_key(self, 'filename_indicators') && has_key(self.filename_indicators, a:file)
if len(marker) > 1
call add(marker, '|')
endif
call add(marker, self.filename_indicators[a:file])
endif
if len(marker) <= 1
call add(marker, ' ') call add(marker, ' ')
endif endif
call add(marker, ']') call add(marker, ']')
else else
call add(marker, '|') call add(marker, '|')
endif endif
return printf("%-". self.width_filename ."s %s %s", fname, join(marker, ''), dname) return printf("%-*s %s %s",
\ self.width_filename + len(fname) - strwidth(fname),
\ fname, join(marker, ''), dname)
endf endf
endif endif
@ -250,6 +289,26 @@ function! s:InsertSelectedItems(rv, current) "{{{3
endf endf
" :nodoc:
function! s:prototype.SelectItemsByNames(mode, items) dict "{{{3
for item in a:items
let bi = index(self.base, item) + 1
" TLogVAR item, bi
if bi > 0
let si = index(self.sel_idx, bi)
" TLogVAR self.sel_idx
" TLogVAR si
if si == -1
call add(self.sel_idx, bi)
elseif a:mode == 'toggle'
call remove(self.sel_idx, si)
endif
endif
endfor
return 1
endf
" :nodoc: " :nodoc:
function! s:prototype.SelectItem(mode, index) dict "{{{3 function! s:prototype.SelectItem(mode, index) dict "{{{3
let bi = self.GetBaseIdx(a:index) let bi = self.GetBaseIdx(a:index)
@ -292,7 +351,7 @@ function! s:prototype.GetRx0(...) dict "{{{3
" TLogVAR filter " TLogVAR filter
let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|')
" TLogVAR rx " TLogVAR rx
if !empty(rx) && (negative ? rx[0] == g:tlib_inputlist_not : rx[0] != g:tlib_inputlist_not) if !empty(rx) && (negative ? rx[0] == g:tlib#input#not : rx[0] != g:tlib#input#not)
call add(rx0, rx) call add(rx0, rx)
endif endif
endfor endfor
@ -478,7 +537,7 @@ function! s:prototype.SetFilter() dict "{{{3
let mrx1 = mrx let mrx1 = mrx
endif endif
" TLogVAR rx " TLogVAR rx
if rx[0] == g:tlib_inputlist_not if rx[0] == g:tlib#input#not
if len(rx) > 1 if len(rx) > 1
call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)') call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)')
endif endif
@ -513,7 +572,7 @@ function! s:prototype.SetMatchMode(match_mode) dict "{{{3
let self.matcher = tlib#Filter_{a:match_mode}#New() let self.matcher = tlib#Filter_{a:match_mode}#New()
call self.matcher.Init(self) call self.matcher.Init(self)
catch /^Vim\%((\a\+)\)\=:E117/ catch /^Vim\%((\a\+)\)\=:E117/
throw 'tlib: Unknown mode for tlib_inputlist_match: '. a:match_mode throw 'tlib: Unknown mode for tlib#input#filter_mode: '. a:match_mode
endtry endtry
endif endif
endf endf
@ -542,18 +601,21 @@ function! s:prototype.BuildTableList() dict "{{{3
" TLogVAR time0 " TLogVAR time0
call self.SetFilter() call self.SetFilter()
" TLogVAR self.filter_neg, self.filter_pos " TLogVAR self.filter_neg, self.filter_pos
if empty(self.filter_pos) && empty(self.filter_neg) let self.table = range(1, len(self.base))
let self.table = range(1, len(self.base)) " TLogVAR self.filtered_items
let copy_base = 1
if !empty(self.filtered_items)
let self.table = filter(self.table, 'index(self.filtered_items, v:val) != -1')
let copy_base = 0
endif
if !empty(self.filter_pos) || !empty(self.filter_neg)
let self.table = filter(self.table, 'self.MatchBaseIdx(v:val)')
let copy_base = 0
endif
if copy_base
let self.list = copy(self.base) let self.list = copy(self.base)
else else
" let time1 = str2float(reltimestr(reltime())) " DBG
" TLogVAR time1, time1 - time0
let self.table = filter(range(1, len(self.base)), 'self.MatchBaseIdx(v:val)')
" let time2 = str2float(reltimestr(reltime())) " DBG
" TLogVAR time2, time2 - time0
let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)') let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)')
" let time3 = str2float(reltimestr(reltime())) " DBG
" TLogVAR time3, time3 - time0
endif endif
endf endf
@ -634,7 +696,18 @@ endf
" :nodoc: " :nodoc:
function! s:prototype.UseScratch() dict "{{{3 function! s:prototype.UseScratch() dict "{{{3
keepalt return tlib#scratch#UseScratch(self) " if type(self.scratch) != 0 && get(self, 'buffer_local', 1)
" if self.scratch != fnamemodify(self.scratch, ':p')
" let self.scratch = tlib#file#Join([expand('%:p:h'), self.scratch])
" " TLogVAR self.scratch
" endif
" " let self.scratch_hidden = 'wipe'
" endif
keepjumps keepalt let rv = tlib#scratch#UseScratch(self)
" if expand('%:t') == self.scratch
let b:tlib_world = self
" endif
return rv
endf endf
@ -828,12 +901,12 @@ function! s:prototype.PushHelp(...) dict "{{{3
" TLogVAR a:000 " TLogVAR a:000
if a:0 == 1 if a:0 == 1
if type(a:1) == 3 if type(a:1) == 3
let self._help += a:1 let self.temp_lines += a:1
else else
call add(self._help, a:1) call add(self.temp_lines, a:1)
endif endif
elseif a:0 == 2 elseif a:0 == 2
call add(self._help, a:000) call add(self.temp_lines, a:000)
else else
throw "TLIB: PushHelp: Wrong number of arguments: ". string(a:000) throw "TLIB: PushHelp: Wrong number of arguments: ". string(a:000)
endif endif
@ -843,7 +916,7 @@ endf
" :nodoc: " :nodoc:
function! s:prototype.DisplayHelp() dict "{{{3 function! s:prototype.DisplayHelp() dict "{{{3
let self._help = self.InitHelp() let self.temp_lines = self.InitHelp()
call self.PushHelp('<Esc>', self.key_mode == 'default' ? 'Abort' : 'Reset keymap') call self.PushHelp('<Esc>', self.key_mode == 'default' ? 'Abort' : 'Reset keymap')
call self.PushHelp('Enter, <cr>', 'Pick the current item') call self.PushHelp('Enter, <cr>', 'Pick the current item')
call self.PushHelp('<M-Number>', 'Pick an item') call self.PushHelp('<M-Number>', 'Pick an item')
@ -861,14 +934,15 @@ function! s:prototype.DisplayHelp() dict "{{{3
call self.PushHelp('<C-o>', 'Switch to origin') call self.PushHelp('<C-o>', 'Switch to origin')
endif endif
if stridx(self.type, 'm') != -1 if stridx(self.type, 'm') != -1
call self.PushHelp('<S-up/down>', '(Un)Select items') call self.PushHelp('<S-Up/Down>', '(Un)Select items')
call self.PushHelp('#, <C-Space>', '(Un)Select the current item') call self.PushHelp('#, <C-Space>', '(Un)Select the current item')
call self.PushHelp('<C|M-a>', '(Un)Select all items') call self.PushHelp('<C|M-a>', '(Un)Select all items')
call self.PushHelp('<F9>', '(Un)Restrict view to selection')
" \ '<c-\> ... Show only selected', " \ '<c-\> ... Show only selected',
endif endif
endif endif
" TLogVAR len(self._help) " TLogVAR len(self.temp_lines)
call self.matcher.Help(self) call self.matcher.Help(self)
" TLogVAR self.key_mode " TLogVAR self.key_mode
@ -893,20 +967,24 @@ function! s:prototype.DisplayHelp() dict "{{{3
call self.PushHelp(self.help_extra) call self.PushHelp(self.help_extra)
endif endif
" TLogVAR len(self._help) " TLogVAR len(self.temp_lines)
call self.PushHelp([ call self.PushHelp([
\ '', \ '',
\ 'Matches at word boundaries are prioritized.', \ 'Matches at word boundaries are prioritized.',
\ ]) \ ])
let self._help = s:FormatHelp(self._help) let self.temp_lines = s:FormatHelp(self.temp_lines)
call self.PrintLines()
endf
function! s:prototype.PrintLines() dict "{{{3
let self.temp_prompt = ['Press any key to continue.', 'Question'] let self.temp_prompt = ['Press any key to continue.', 'Question']
" call tlib#normal#WithRegister('gg"tdG', 't')
call tlib#buffer#DeleteRange('1', '$') call tlib#buffer#DeleteRange('1', '$')
call append(0, self._help) call append(0, self.temp_lines)
" call tlib#normal#WithRegister('G"tddgg', 't')
call tlib#buffer#DeleteRange('$', '$') call tlib#buffer#DeleteRange('$', '$')
1 1
call self.Resize(len(self._help), 0) call self.Resize(len(self.temp_lines), 0)
let self.temp_lines = []
endf endf
@ -914,12 +992,14 @@ endf
function! s:prototype.Resize(hsize, vsize) dict "{{{3 function! s:prototype.Resize(hsize, vsize) dict "{{{3
" TLogVAR self.scratch_vertical, a:hsize, a:vsize " TLogVAR self.scratch_vertical, a:hsize, a:vsize
let world_resize = '' let world_resize = ''
let winpos = ''
let scratch_split = get(self, 'scratch_split', 1) let scratch_split = get(self, 'scratch_split', 1)
" TLogVAR scratch_split " TLogVAR scratch_split
if scratch_split > 0 if scratch_split > 0
if self.scratch_vertical if self.scratch_vertical
if a:vsize if a:vsize
let world_resize = 'vert resize '. a:vsize let world_resize = 'vert resize '. a:vsize
let winpos = tlib#fixes#Winpos()
" let w:winresize = {'v': a:vsize} " let w:winresize = {'v': a:vsize}
setlocal winfixwidth setlocal winfixwidth
endif endif
@ -932,8 +1012,11 @@ function! s:prototype.Resize(hsize, vsize) dict "{{{3
endif endif
endif endif
if !empty(world_resize) if !empty(world_resize)
" TLogVAR world_resize " TLogVAR world_resize, winpos
exec world_resize exec world_resize
if !empty(winpos)
exec winpos
endif
" redraw! " redraw!
endif endif
endf endf
@ -971,6 +1054,9 @@ function! s:prototype.DisplayList(...) dict "{{{3
elseif self.state == 'help' elseif self.state == 'help'
call self.DisplayHelp() call self.DisplayHelp()
call self.SetStatusline(query) call self.SetStatusline(query)
elseif self.state == 'printlines'
call self.PrintLines()
call self.SetStatusline(query)
else else
" TLogVAR query " TLogVAR query
" let ll = len(list) " let ll = len(list)
@ -1042,6 +1128,13 @@ function! s:prototype.SetStatusline(query) dict "{{{3
if self.key_mode != 'default' if self.key_mode != 'default'
call add(options, 'map:'. self.key_mode) call add(options, 'map:'. self.key_mode)
endif endif
if !empty(self.filtered_items)
if g:tlib_inputlist_shortmessage
call add(options, 'R')
else
call add(options, 'restricted')
endif
endif
if !empty(options) if !empty(options)
let sopts = printf('[%s]', join(options, ', ')) let sopts = printf('[%s]', join(options, ', '))
" let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts " let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts

View file

@ -3,13 +3,16 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-24. " @Created: 2007-06-24.
" @Last Change: 2012-10-03. " @Last Change: 2013-09-26.
" @Revision: 0.1.208 " @Revision: 0.1.240
" :filedoc: " :filedoc:
" Various agents for use as key handlers in tlib#input#List() " Various agents for use as key handlers in tlib#input#List()
" Number of items to move when pressing <c-up/down> in the input list window.
TLet g:tlib_scroll_lines = 10
" General {{{1 " General {{{1
@ -111,6 +114,36 @@ function! tlib#agent#Reset(world, selected) "{{{3
endf endf
function! tlib#agent#ToggleRestrictView(world, selected) "{{{3
if empty(a:world.filtered_items)
return tlib#agent#RestrictView(a:world, a:selected)
else
return tlib#agent#UnrestrictView(a:world, a:selected)
endif
endf
function! tlib#agent#RestrictView(world, selected) "{{{3
" TLogVAR a:selected
let filtered_items = map(copy(a:selected), 'index(a:world.base, v:val) + 1')
" TLogVAR 1, filtered_items
let filtered_items = filter(filtered_items, 'v:val > 0')
" TLogVAR 2, filtered_items
if !empty(filtered_items)
let a:world.filtered_items = filtered_items
endif
let a:world.state = 'display'
return a:world
endf
function! tlib#agent#UnrestrictView(world, selected) "{{{3
let a:world.filtered_items = []
let a:world.state = 'display'
return a:world
endf
function! tlib#agent#Input(world, selected) "{{{3 function! tlib#agent#Input(world, selected) "{{{3
let flt0 = a:world.CleanFilter(a:world.filter[0][0]) let flt0 = a:world.CleanFilter(a:world.filter[0][0])
let flt1 = input('Filter: ', flt0) let flt1 = input('Filter: ', flt0)
@ -401,7 +434,11 @@ function! tlib#agent#EditFileInVSplit(world, selected) "{{{3
call a:world.CloseScratch() call a:world.CloseScratch()
" call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world)
" call tlib#file#With('vertical split', 'vertical sbuffer', a:selected[1:-1], a:world) " call tlib#file#With('vertical split', 'vertical sbuffer', a:selected[1:-1], a:world)
let winpos = tlib#fixes#Winpos()
call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world) call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world)
if !empty(winpos)
exec winpos
endif
return tlib#agent#Exit(a:world, a:selected) return tlib#agent#Exit(a:world, a:selected)
endf endf
@ -419,19 +456,18 @@ function! tlib#agent#ToggleScrollbind(world, selected) "{{{3
return a:world return a:world
endf endf
function! tlib#agent#ShowInfo(world, selected) function! tlib#agent#ShowInfo(world, selected)
let lines = []
for f in a:selected for f in a:selected
if filereadable(f) if filereadable(f)
let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)] let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)]
echo fnamemodify(f, ':t') .':' call add(lines, fnamemodify(f, ':t') .':')
echo ' '. join(desc, '; ') call add(lines, ' '. join(desc, '; '))
endif endif
endfor endfor
echohl MoreMsg let a:world.temp_lines = lines
echo 'Press any key to continue' let a:world.state = 'printlines'
echohl NONE
call getchar()
let a:world.state = 'redisplay'
return a:world return a:world
endf endf
@ -530,8 +566,8 @@ function! tlib#agent#ExecAgentByName(world, selected) "{{{3
let agent_names[def.help] = def.agent let agent_names[def.help] = def.agent
endif endif
endfor endfor
let s:agent_names = join(sort(keys(agent_names)), "\n") let s:agent_names = sort(keys(agent_names))
let command = input('Command: ', '', 'custom,tlib#agent#CompleteAgentNames') let command = input('Command: ', '', 'customlist,tlib#agent#CompleteAgentNames')
" TLogVAR command " TLogVAR command
if !has_key(agent_names, command) if !has_key(agent_names, command)
" TLogVAR command " TLogVAR command
@ -558,6 +594,6 @@ endf
function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos)
return s:agent_names return filter(copy(s:agent_names), 'stridx(v:val, a:ArgLead) != -1')
endf endf

View file

@ -2,13 +2,7 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-08-19. " @Revision: 7
" @Last Change: 2010-01-05.
" @Revision: 0.0.6
let s:save_cpo = &cpo
set cpo&vim
augroup TLib augroup TLib
autocmd! autocmd!
@ -18,6 +12,3 @@ augroup END
function! tlib#autocmdgroup#Init() "{{{3 function! tlib#autocmdgroup#Init() "{{{3
endf endf
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -4,7 +4,7 @@
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2010-08-30. " @Created: 2010-08-30.
" @Last Change: 2010-09-05. " @Last Change: 2010-09-05.
" @Revision: 23 " @Revision: 27
function! tlib#balloon#Register(expr) "{{{3 function! tlib#balloon#Register(expr) "{{{3
@ -37,10 +37,12 @@ endf
function! tlib#balloon#Expr() "{{{3 function! tlib#balloon#Expr() "{{{3
" TLogVAR exists('b:tlib_balloons')
if !exists('b:tlib_balloons') if !exists('b:tlib_balloons')
return '' return ''
endif endif
let text = map(copy(b:tlib_balloons), 'eval(v:val)') let text = map(copy(b:tlib_balloons), 'eval(v:val)')
" TLogVAR b:tlib_balloons, text
call filter(text, '!empty(v:val)') call filter(text, '!empty(v:val)')
if has('balloon_multiline') if has('balloon_multiline')
return join(text, "\n----------------------------------\n") return join(text, "\n----------------------------------\n")

View file

@ -0,0 +1,141 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Revision: 124
function! tlib#bitwise#Num2Bits(num) "{{{3
if type(a:num) <= 1 || type(a:num) == 5
let bits = reverse(tlib#number#ConvertBase(a:num, 2, 'list'))
elseif type(a:num) == 3
let bits = copy(a:num)
else
throw "tlib#bitwise#Num2Bits: Must be number of list: ". string(a:num)
endif
return bits
endf
function! tlib#bitwise#Bits2Num(bits, ...) "{{{3
let base = a:0 >= 1 ? a:1 : 10
" TLogVAR a:bits
let num = 0.0
for i in range(len(a:bits))
if get(a:bits, i, 0)
let num += pow(2, i)
endif
endfor
" TLogVAR num
if base == 10
if type(base) == 5
return num
else
return float2nr(num)
endif
else
return tlib#number#ConvertBase(num, base)
endif
endf
function! tlib#bitwise#AND(num1, num2, ...) "{{{3
let rtype = a:0 >= 1 ? a:1 : 'num'
return s:BitwiseComparison(a:num1, a:num2, rtype,
\ 'get(bits1, v:val) && get(bits2, v:val)')
endf
function! tlib#bitwise#OR(num1, num2, ...) "{{{3
let rtype = a:0 >= 1 ? a:1 : 'num'
return s:BitwiseComparison(a:num1, a:num2, rtype,
\ 'get(bits1, v:val) || get(bits2, v:val)')
endf
function! tlib#bitwise#XOR(num1, num2, ...) "{{{3
let rtype = a:0 >= 1 ? a:1 : 'num'
return s:BitwiseComparison(a:num1, a:num2, rtype,
\ 'get(bits1, v:val) ? !get(bits2, v:val) : get(bits2, v:val)')
endf
function! s:BitwiseComparison(num1, num2, rtype, expr) "{{{3
let bits1 = tlib#bitwise#Num2Bits(a:num1)
let bits2 = tlib#bitwise#Num2Bits(a:num2)
let range = range(max([len(bits1), len(bits2)]))
let bits = map(range, a:expr)
if a:rtype == 'num' || (a:rtype == 'auto' && type(a:num1) <= 1)
return tlib#bitwise#Bits2Num(bits)
else
return bits
endif
endf
function! tlib#bitwise#ShiftRight(bits, n) "{{{3
let bits = a:bits[a:n : -1]
if empty(bits)
let bits = [0]
endif
return bits
endf
function! tlib#bitwise#ShiftLeft(bits, n) "{{{3
let bits = repeat([0], a:n) + a:bits
return bits
endf
function! tlib#bitwise#Add(num1, num2, ...) "{{{3
let rtype = a:0 >= 1 ? a:1 : 'num'
let bits1 = tlib#bitwise#Num2Bits(a:num1)
let bits2 = tlib#bitwise#Num2Bits(a:num2)
let range = range(max([len(bits1), len(bits2)]))
" TLogVAR bits1, bits2, range
let carry = 0
let bits = []
for i in range
let sum = get(bits1, i) + get(bits2, i) + carry
if sum == 3
let bit = 1
let carry = 1
elseif sum == 2
let bit = 0
let carry = 1
elseif sum == 1
let bit = 1
let carry = 0
elseif sum == 0
let bit = 0
let carry = 0
endif
call add(bits, bit)
" TLogVAR i, bits, bit
endfor
if carry == 1
call add(bits, carry)
endif
if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1)
return tlib#bitwise#Bits2Num(bits)
else
return bits
endif
endf
function! tlib#bitwise#Sub(num1, num2, ...) "{{{3
let rtype = a:0 >= 1 ? a:1 : 'num'
let bits1 = tlib#bitwise#Num2Bits(a:num1)
let bits2 = tlib#bitwise#Num2Bits(a:num2)
let range = range(max([len(bits1), len(bits2)]))
let bits2 = map(range, '!get(bits2, v:val)')
let bits2 = tlib#bitwise#Add(bits2, [1], 'bits')
let bits3 = tlib#bitwise#Add(bits1, bits2, 'bits')
let bits = bits3[0 : -2]
if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1)
return tlib#bitwise#Bits2Num(bits)
else
return bits
endif
endf

View file

@ -3,8 +3,13 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-30. " @Created: 2007-06-30.
" @Last Change: 2012-02-09. " @Last Change: 2013-09-25.
" @Revision: 0.0.351 " @Revision: 0.0.352
" Where to display the line when using |tlib#buffer#ViewLine|.
" For possible values for position see |scroll-cursor|.
TLet g:tlib_viewline_position = 'zz'
let s:bmru = [] let s:bmru = []

View file

@ -3,10 +3,16 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-30. " @Created: 2007-06-30.
" @Last Change: 2012-05-11. " @Last Change: 2013-09-25.
" @Revision: 0.1.192 " @Revision: 0.1.220
" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'.
" You might want to delete old files from this directory from time to
" time with a command like: >
" find ~/vimfiles/cache/ -atime +31 -type f -print -delete
TLet g:tlib_cache = ''
" |tlib#cache#Purge()|: Remove cache files older than N days. " |tlib#cache#Purge()|: Remove cache files older than N days.
TLet g:tlib#cache#purge_days = 31 TLet g:tlib#cache#purge_days = 31
@ -24,15 +30,21 @@ TLet g:tlib#cache#script_encoding = &enc
" 2 ... Yes " 2 ... Yes
TLet g:tlib#cache#run_script = 1 TLet g:tlib#cache#run_script = 1
" If non-nil, don't display a message that files were deleted from the " Verbosity level:
" cache. " 0 ... Be quiet
TLet g:tlib#cache#silent = 0 " 1 ... Display informative message
" 2 ... Display detailed messages
TLet g:tlib#cache#verbosity = 1
" A list of regexps that are matched against partial filenames of the " A list of regexps that are matched against partial filenames of the
" cached files. If a regexp matches, the file won't be removed by " cached files. If a regexp matches, the file won't be removed by
" |tlib#cache#Purge()|. " |tlib#cache#Purge()|.
TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$'] TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$']
" If the cache filename is longer than N characters, use
" |pathshorten()|.
TLet g:tlib#cache#max_filename = 200
" :display: tlib#cache#Dir(?mode = 'bg') " :display: tlib#cache#Dir(?mode = 'bg')
" The default cache directory. " The default cache directory.
@ -49,7 +61,8 @@ endf
" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') " :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='')
function! tlib#cache#Filename(type, ...) "{{{3 function! tlib#cache#Filename(type, ...) "{{{3
" TLogDBG 'bufname='. bufname('.') " TLogDBG 'bufname='. bufname('.')
let dir = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir() let dir0 = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir()
let dir = dir0
if a:0 >= 1 && !empty(a:1) if a:0 >= 1 && !empty(a:1)
let file = a:1 let file = a:1
else else
@ -73,18 +86,23 @@ function! tlib#cache#Filename(type, ...) "{{{3
" TLogVAR dir " TLogVAR dir
let file = fnamemodify(file, ':t') let file = fnamemodify(file, ':t')
" TLogVAR file, dir, mkdir " TLogVAR file, dir, mkdir
if mkdir && !isdirectory(dir)
try
call mkdir(dir, 'p')
catch /^Vim\%((\a\+)\)\=:E739:/
if filereadable(dir) && !isdirectory(dir)
echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir
" call delete(dir)
" call mkdir(dir, 'p')
endif
endtry
endif
let cache_file = tlib#file#Join([dir, file]) let cache_file = tlib#file#Join([dir, file])
if len(cache_file) > g:tlib#cache#max_filename
let shortfilename = pathshorten(file) .'_'. tlib#hash#Adler32(file)
let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0)
else
if mkdir && !isdirectory(dir)
try
call mkdir(dir, 'p')
catch /^Vim\%((\a\+)\)\=:E739:/
if filereadable(dir) && !isdirectory(dir)
echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir
" call delete(dir)
" call mkdir(dir, 'p')
endif
endtry
endif
endif
" TLogVAR cache_file " TLogVAR cache_file
return cache_file return cache_file
endf endf
@ -101,6 +119,22 @@ function! tlib#cache#Get(cfile) "{{{3
endf endf
" Get a cached value from cfile. If it is outdated (compared to ftime)
" or does not exist, create it calling a generator function.
function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3
if !filereadable(a:cfile) || (a:ftime != 0 && getftime(a:cfile) < a:ftime)
let args = a:0 >= 1 ? a:1 : []
let val = call(a:generator, args)
" TLogVAR a:generator, args, val
call tlib#cache#Save(a:cfile, {'val': val})
return val
else
let val = tlib#cache#Get(a:cfile)
return val.val
endif
endf
" Call |tlib#cache#Purge()| if the last purge was done before " Call |tlib#cache#Purge()| if the last purge was done before
" |g:tlib#cache#purge_every_days|. " |g:tlib#cache#purge_every_days|.
function! tlib#cache#MaybePurge() "{{{3 function! tlib#cache#MaybePurge() "{{{3
@ -144,7 +178,7 @@ endf
function! tlib#cache#Purge() "{{{3 function! tlib#cache#Purge() "{{{3
let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift
let dir = tlib#cache#Dir('g') let dir = tlib#cache#Dir('g')
if !g:tlib#cache#silent if g:tlib#cache#verbosity >= 1
echohl WarningMsg echohl WarningMsg
echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir
echohl NONE echohl NONE
@ -165,7 +199,7 @@ function! tlib#cache#Purge() "{{{3
if getftime(file) < threshold if getftime(file) < threshold
if delete(file) if delete(file)
call add(msg, "TLib: Could not delete cache file: ". file) call add(msg, "TLib: Could not delete cache file: ". file)
else elseif g:tlib#cache#verbosity >= 2
call add(msg, "TLib: Delete cache file: ". file) call add(msg, "TLib: Delete cache file: ". file)
endif endif
else else
@ -176,7 +210,7 @@ function! tlib#cache#Purge() "{{{3
finally finally
let &more = more let &more = more
endtry endtry
if !empty(msg) && !g:tlib#cache#silent if !empty(msg) && g:tlib#cache#verbosity >= 1
echo join(msg, "\n") echo join(msg, "\n")
endif endif
if !empty(deldir) if !empty(deldir)
@ -202,12 +236,14 @@ function! tlib#cache#Purge() "{{{3
call writefile(script, scriptfile) call writefile(script, scriptfile)
call inputsave() call inputsave()
if g:tlib#cache#run_script == 0 if g:tlib#cache#run_script == 0
echohl WarningMsg if g:tlib#cache#verbosity >= 1
if g:tlib#cache#silent echohl WarningMsg
echom "TLib: Purged cache. Need to run script to delete directories" if g:tlib#cache#verbosity >= 2
echom "TLib: Purged cache. Need to run script to delete directories"
endif
echom "TLib: Please review and execute: ". scriptfile
echohl NONE
endif endif
echom "TLib: Please review and execute: ". scriptfile
echohl NONE
else else
try try
let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no') let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no')

View file

@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-08-23. " @Created: 2007-08-23.
" @Last Change: 2012-02-10. " @Last Change: 2013-05-14.
" @Revision: 0.0.35 " @Revision: 0.0.46
if &cp || exists("loaded_tlib_cmd_autoload") if &cp || exists("loaded_tlib_cmd_autoload")
finish finish
@ -17,12 +17,20 @@ let g:tlib#cmd#last_output = []
function! tlib#cmd#OutputAsList(command) "{{{3 function! tlib#cmd#OutputAsList(command) "{{{3
" TLogVAR a:command " TLogVAR a:command
" let lines = '' if exists('s:redir_lines')
redir => lines redir END
let cache = s:redir_lines
endif
let s:redir_lines = ''
redir =>> s:redir_lines
silent! exec a:command silent! exec a:command
redir END redir END
" TLogVAR lines let g:tlib#cmd#last_output = split(s:redir_lines, '\n')
let g:tlib#cmd#last_output = split(lines, '\n') unlet s:redir_lines
if exists('cache')
let s:redir_lines = cache
redir =>> s:redir_lines
endif
return g:tlib#cmd#last_output return g:tlib#cmd#last_output
endf endf

View file

@ -3,14 +3,18 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-30. " @Created: 2007-06-30.
" @Last Change: 2009-08-04. " @Last Change: 2013-09-25.
" @Revision: 0.0.32 " @Revision: 0.0.37
if &cp || exists("loaded_tlib_dir_autoload") if &cp || exists("loaded_tlib_dir_autoload")
finish finish
endif endif
let loaded_tlib_dir_autoload = 1 let loaded_tlib_dir_autoload = 1
" TLet g:tlib#dir#sep = '/'
TLet g:tlib#dir#sep = exists('+shellslash') && !&shellslash ? '\' : '/'
let s:dir_stack = [] let s:dir_stack = []
" EXAMPLES: > " EXAMPLES: >
@ -18,12 +22,25 @@ let s:dir_stack = []
" => 'foo/bar/' " => 'foo/bar/'
function! tlib#dir#CanonicName(dirname) "{{{3 function! tlib#dir#CanonicName(dirname) "{{{3
if a:dirname !~ '[/\\]$' if a:dirname !~ '[/\\]$'
return a:dirname . g:tlib_filename_sep return a:dirname . g:tlib#dir#sep
endif endif
return a:dirname return a:dirname
endf endf
" EXAMPLES: >
" tlib#dir#NativeName('foo/bar/')
" On Windows:
" => 'foo\bar\'
" On Linux:
" => 'foo/bar/'
function! tlib#dir#NativeName(dirname) "{{{3
let sep = tlib#rx#EscapeReplace(g:tlib#dir#sep)
let dirname = substitute(a:dirname, '[\/]', sep, 'g')
return dirname
endf
" EXAMPLES: > " EXAMPLES: >
" tlib#dir#PlainName('foo/bar/') " tlib#dir#PlainName('foo/bar/')
" => 'foo/bar' " => 'foo/bar'
@ -33,7 +50,7 @@ function! tlib#dir#PlainName(dirname) "{{{3
let dirname = dirname[0 : -2] let dirname = dirname[0 : -2]
endwh endwh
return dirname return dirname
" return substitute(a:dirname, tlib#rx#Escape(g:tlib_filename_sep).'\+$', '', '') " return substitute(a:dirname, tlib#rx#Escape(g:tlib#dir#sep).'\+$', '', '')
endf endf

View file

@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-30. " @Created: 2007-06-30.
" @Last Change: 2012-03-23. " @Last Change: 2013-09-25.
" @Revision: 0.0.106 " @Revision: 0.0.141
if &cp || exists("loaded_tlib_file_autoload") if &cp || exists("loaded_tlib_file_autoload")
finish finish
@ -42,13 +42,15 @@ endf
" => 'foo/bar/filename.txt' " => 'foo/bar/filename.txt'
function! tlib#file#Join(filename_parts, ...) "{{{3 function! tlib#file#Join(filename_parts, ...) "{{{3
TVarArg 'strip_slashes' TVarArg 'strip_slashes'
" TLogVAR a:filename_parts, strip_slashes
if strip_slashes if strip_slashes
" let rx = tlib#rx#Escape(g:tlib_filename_sep) .'$' " let rx = tlib#rx#Escape(g:tlib#dir#sep) .'$'
let rx = '[/\\]$' let rx = '[/\\]\+$'
let parts = map(copy(a:filename_parts), 'substitute(v:val, rx, "", "")') let parts = map(copy(a:filename_parts), 'substitute(v:val, rx, "", "")')
return join(parts, g:tlib_filename_sep) " TLogVAR parts
return join(parts, g:tlib#dir#sep)
else else
return join(a:filename_parts, g:tlib_filename_sep) return join(a:filename_parts, g:tlib#dir#sep)
endif endif
endf endf
@ -60,14 +62,14 @@ function! tlib#file#Relative(filename, basedir) "{{{3
" TLogVAR a:filename, a:basedir " TLogVAR a:filename, a:basedir
" TLogDBG getcwd() " TLogDBG getcwd()
" TLogDBG expand('%:p') " TLogDBG expand('%:p')
let f0 = fnamemodify(a:filename, ':p') let b0 = tlib#file#Absolute(a:basedir)
let b = tlib#file#Split(b0)
" TLogVAR b
let f0 = tlib#file#Absolute(a:filename)
let fn = fnamemodify(f0, ':t') let fn = fnamemodify(f0, ':t')
let fd = fnamemodify(f0, ':h') let fd = fnamemodify(f0, ':h')
let f = tlib#file#Split(fd) let f = tlib#file#Split(fd)
" TLogVAR f " TLogVAR f0, fn, fd, f
let b0 = fnamemodify(a:basedir, ':p')
let b = tlib#file#Split(b0)
" TLogVAR b
if f[0] != b[0] if f[0] != b[0]
let rv = f0 let rv = f0
else else
@ -78,6 +80,7 @@ function! tlib#file#Relative(filename, basedir) "{{{3
call remove(f, 0) call remove(f, 0)
call remove(b, 0) call remove(b, 0)
endwh endwh
" TLogVAR f, b
let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn]) let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn])
endif endif
" TLogVAR rv " TLogVAR rv
@ -85,6 +88,21 @@ function! tlib#file#Relative(filename, basedir) "{{{3
endf endf
function! tlib#file#Absolute(filename, ...) "{{{3
if filereadable(a:filename)
let filename = fnamemodify(a:filename, ':p')
elseif a:filename =~ '^\(/\|[^\/]\+:\)'
let filename = a:filename
else
let cwd = a:0 >= 1 ? a:1 : getcwd()
let filename = tlib#file#Join([cwd, a:filename])
endif
let filename = substitute(filename, '\(^\|[\/]\)\zs\.[\/]', '', 'g')
let filename = substitute(filename, '[\/]\zs[^\/]\+[\/]\.\.[\/]', '', 'g')
return filename
endf
function! s:SetScrollBind(world) "{{{3 function! s:SetScrollBind(world) "{{{3
let sb = get(a:world, 'scrollbind', &scrollbind) let sb = get(a:world, 'scrollbind', &scrollbind)
if sb != &scrollbind if sb != &scrollbind
@ -118,7 +136,7 @@ function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3
if filereadable(f) if filereadable(f)
if !empty(a:fcmd) if !empty(a:fcmd)
" TLogDBG a:fcmd .' '. tlib#arg#Ex(f) " TLogDBG a:fcmd .' '. tlib#arg#Ex(f)
exec 'autocmd TLibFileRead BufRead' escape(f, ' ') 'let s:bufread=expand("<afile>:p")' exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand("<afile>:p")'
try try
exec a:fcmd .' '. tlib#arg#Ex(f) exec a:fcmd .' '. tlib#arg#Ex(f)
finally finally

View file

@ -0,0 +1,14 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Last Change: 2013-02-22.
" @Revision: 3
function! tlib#fixes#Winpos() "{{{3
if has('gui_win32')
return 'winpos '. getwinposx() .' '. getwinposy()
else
return ''
endif
endf

View file

@ -0,0 +1,38 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Last Change: 2013-10-16.
" @Revision: 31
function! tlib#grep#Do(cmd, rx, files) "{{{3
" TLogVAR a:cmd, a:rx, a:files
let files = join(map(copy(a:files), 'tlib#arg#Ex(v:val, "")'), ' ')
let rx = '/'. escape(a:rx, '/') .'/j'
" TLogVAR rx, files
silent exec a:cmd rx files
endf
function! tlib#grep#LocList(rx, files) "{{{3
return tlib#grep#Do('noautocmd lvimgrep', a:rx, a:files)
endf
function! tlib#grep#QuickFixList(rx, files) "{{{3
return tlib#grep#Do('noautocmd vimgrep', a:rx, a:files)
endf
function! tlib#grep#List(rx, files) "{{{3
call setqflist([])
call tlib#grep#Do('noautocmd vimgrepadd', a:rx, a:files)
let qfl = getqflist()
" TLogVAR qfl
" try
silent! colder
" catch
" call setqflist([], 'r')
" endtry
return qfl
endf

View file

@ -0,0 +1,145 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Revision: 276
if !exists('g:tlib#hash#use_crc32')
let g:tlib#hash#use_crc32 = '' "{{{2
endif
if !exists('g:tlib#hash#use_adler32')
let g:tlib#hash#use_adler32 = '' "{{{2
endif
function! tlib#hash#CRC32B(chars) "{{{3
if !empty(g:tlib#hash#use_crc32)
let use = g:tlib#hash#use_crc32
elseif has('ruby')
let use = 'ruby'
else
let use = 'vim'
endif
if exists('*tlib#hash#CRC32B_'. use)
return tlib#hash#CRC32B_{use}(a:chars)
else
throw "Unknown version of tlib#hash#CRC32B: ". use
endif
endf
function! tlib#hash#CRC32B_ruby(chars) "{{{3
if has('ruby')
let rv = ''
if !exists('s:loaded_ruby_zlib')
ruby require 'zlib'
let s:loaded_ruby_zlib = 1
endif
ruby VIM::command('let rv = "%08X"' % Zlib.crc32(VIM::evaluate("a:chars")))
return rv
else
throw "tlib#hash#CRC32B_ruby not supported in this version of vim"
endif
endf
function! tlib#hash#CRC32B_vim(chars) "{{{3
if !exists('s:crc_table')
let cfile = tlib#persistent#Filename('tlib', 'crc_table', 1)
let s:crc_table = tlib#persistent#Value(cfile, 'tlib#hash#CreateCrcTable', 0)
endif
let xFFFF_FFFF = repeat([1], 32)
let crc = tlib#bitwise#XOR([0], xFFFF_FFFF, 'bits')
for char in split(a:chars, '\zs')
let octet = char2nr(char)
let r1 = tlib#bitwise#ShiftRight(crc, 8)
let i0 = tlib#bitwise#AND(crc, xFFFF_FFFF, 'bits')
let i1 = tlib#bitwise#XOR(i0, octet, 'bits')
let i2 = tlib#bitwise#Bits2Num(tlib#bitwise#AND(i1, 0xff, 'bits'))
let r2 = s:crc_table[i2]
let crc = tlib#bitwise#XOR(r1, r2, 'bits')
endfor
let crc = tlib#bitwise#XOR(crc, xFFFF_FFFF, 'bits')
let rv = tlib#bitwise#Bits2Num(crc, 16)
if len(rv) < 8
let rv = repeat('0', 8 - len(rv)) . rv
endif
return rv
endf
" :nodoc:
function! tlib#hash#CreateCrcTable() "{{{3
let sum = 0.0
for exponent in [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32]
let exp = tlib#bitwise#Bits2Num(repeat([0], 32 - exponent) + [1], 10.0)
let sum += exp
endfor
let divisor = tlib#bitwise#Num2Bits(sum)
let crc_table = []
for octet in range(256)
let remainder = tlib#bitwise#Num2Bits(octet)
for i in range(8)
if get(remainder, i) != 0
let remainder = tlib#bitwise#XOR(remainder, tlib#bitwise#ShiftLeft(divisor, i), "bits")
endif
endfor
let remainder = tlib#bitwise#ShiftRight(remainder, 8)
call add(crc_table, remainder)
endfor
return crc_table
endf
function! tlib#hash#Adler32(chars) "{{{3
if !empty(g:tlib#hash#use_adler32)
let use = g:tlib#hash#use_adler32
elseif exists('*or')
let use = 'vim'
else
let use = 'tlib'
endif
if exists('*tlib#hash#Adler32_'. use)
return tlib#hash#Adler32_{use}(a:chars)
else
throw "Unknown version of tlib#hash#Adler32_: ". use
endif
endf
function! tlib#hash#Adler32_vim(chars) "{{{3
if exists('*or')
let mod_adler = 65521
let a = 1
let b = 0
for index in range(len(a:chars))
let c = char2nr(a:chars[index])
let a = (a + c) % mod_adler
let b = (b + a) % mod_adler
endfor
let bb = b * float2nr(pow(2, 16))
let checksum = or(bb, a)
" TLogVAR checksum, a, b, bb
return printf("%08X", checksum)
else
throw "TLIB: Vim version doesn't support bitwise or()"
endif
endf
function! tlib#hash#Adler32_tlib(chars) "{{{3
let mod_adler = 65521
let a = 1
let b = 0
for index in range(len(a:chars))
let c = char2nr(a:chars[index])
let a = (a + c) % mod_adler
let b = (b + a) % mod_adler
endfor
let bb = tlib#bitwise#ShiftLeft(tlib#bitwise#Num2Bits(b), 16)
let checksum = tlib#bitwise#OR(bb, a, "bits")
return printf('%08s', tlib#bitwise#Bits2Num(checksum, 16))
endf

View file

@ -3,13 +3,188 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-30. " @Created: 2007-06-30.
" @Last Change: 2012-10-01. " @Last Change: 2013-09-30.
" @Revision: 0.0.966 " @Revision: 0.0.1262
" :filedoc: " :filedoc:
" Input-related, select from a list etc. " Input-related, select from a list etc.
" If a list is bigger than this value, don't try to be smart when
" selecting an item. Be slightly faster instead.
" See |tlib#input#List()|.
TLet g:tlib#input#sortprefs_threshold = 200
" If a list contains more items, |tlib#input#List()| does not perform an
" incremental "live search" but uses |input()| to query the user for a
" filter. This is useful on slower machines or with very long lists.
TLet g:tlib#input#livesearch_threshold = 1000
" Determine how |tlib#input#List()| and related functions work.
" Can be "cnf", "cnfd", "cnfx", "seq", or "fuzzy". See:
" cnfx ... Like cnfd but |g:tlib#Filter_cnfx#expander| is interpreted
" as a wildcard (this is the default method)
" - A plus character ("+") acts as a wildcard as if ".\{-}" (see
" |/\{-|) were entered.
" - Examples:
" - "f+o" matches "fo", "fxo", and "fxxxoo", but doesn't match
" "far".
" - Otherwise it is a derivate of the cnf method (see below).
" - See also |tlib#Filter_cnfx#New()|.
" cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is
" expanded to "\.\{-}"
" - A period character (".") acts as a wildcard as if ".\{-}" (see
" |/\{-|) were entered.
" - Examples:
" - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match
" "far".
" - Otherwise it is a derivate of the cnf method (see below).
" - See also |tlib#Filter_cnfd#New()|.
" cnf .... Match substrings
" - A blank creates an AND conjunction, i.e. the next pattern has to
" match too.
" - A pipe character ("|") creates an OR conjunction, either this or
" the next next pattern has to match.
" - Patterns are very 'nomagic' |regexp| with a |\V| prefix.
" - A pattern starting with "-" makes the filter exclude items
" matching that pattern.
" - Examples:
" - "foo bar" matches items that contain the strings "foo" AND
" "bar".
" - "foo|bar boo|far" matches items that contain either ("foo" OR
" "bar") AND ("boo" OR "far").
" - See also |tlib#Filter_cnf#New()|.
" seq .... Match sequences of characters
" - |tlib#Filter_seq#New()|
" fuzzy .. Match fuzzy character sequences
" - |tlib#Filter_fuzzy#New()|
TLet g:tlib#input#filter_mode = 'cnfx'
" The highlight group to use for showing matches in the input list
" window.
" See |tlib#input#List()|.
TLet g:tlib#input#higroup = 'IncSearch'
" When 1, automatically select the last remaining item only if the list
" had only one item to begin with.
" When 2, automatically select a last remaining item after applying
" any filters.
" See |tlib#input#List()|.
TLet g:tlib_pick_last_item = 1
" :doc:
" Keys for |tlib#input#List|~
TLet g:tlib#input#and = ' '
TLet g:tlib#input#or = '|'
TLet g:tlib#input#not = '-'
" When editing a list with |tlib#input#List|, typing these numeric chars
" (as returned by getchar()) will select an item based on its index, not
" based on its name. I.e. in the default setting, typing a "4" will
" select the fourth item, not the item called "4".
" In order to make keys 0-9 filter the items in the list and make
" <m-[0-9]> select an item by its index, remove the keys 48 to 57 from
" this dictionary.
" Format: [KEY] = BASE ... the number is calculated as KEY - BASE.
" :nodefault:
TLet g:tlib#input#numeric_chars = {
\ 176: 176,
\ 177: 176,
\ 178: 176,
\ 179: 176,
\ 180: 176,
\ 181: 176,
\ 182: 176,
\ 183: 176,
\ 184: 176,
\ 185: 176,
\}
" \ 48: 48,
" \ 49: 48,
" \ 50: 48,
" \ 51: 48,
" \ 52: 48,
" \ 53: 48,
" \ 54: 48,
" \ 55: 48,
" \ 56: 48,
" \ 57: 48,
" :nodefault:
" The default key bindings for single-item-select list views. If you
" want to use <c-j>, <c-k> to move the cursor up and down, add these two
" lines to after/plugin/02tlib.vim: >
"
" let g:tlib#input#keyagents_InputList_s[10] = 'tlib#agent#Down' " <c-j>
" let g:tlib#input#keyagents_InputList_s[11] = 'tlib#agent#Up' " <c-k>
TLet g:tlib#input#keyagents_InputList_s = {
\ "\<PageUp>": 'tlib#agent#PageUp',
\ "\<PageDown>": 'tlib#agent#PageDown',
\ "\<Up>": 'tlib#agent#Up',
\ "\<Down>": 'tlib#agent#Down',
\ "\<c-Up>": 'tlib#agent#UpN',
\ "\<c-Down>": 'tlib#agent#DownN',
\ "\<Left>": 'tlib#agent#ShiftLeft',
\ "\<Right>": 'tlib#agent#ShiftRight',
\ 18: 'tlib#agent#Reset',
\ 242: 'tlib#agent#Reset',
\ 17: 'tlib#agent#Input',
\ 241: 'tlib#agent#Input',
\ 27: 'tlib#agent#Exit',
\ 26: 'tlib#agent#Suspend',
\ 250: 'tlib#agent#Suspend',
\ 15: 'tlib#agent#SuspendToParentWindow',
\ 63: 'tlib#agent#Help',
\ "\<F1>": 'tlib#agent#Help',
\ "\<F10>": 'tlib#agent#ExecAgentByName',
\ "\<S-Esc>": 'tlib#agent#ExecAgentByName',
\ "\<bs>": 'tlib#agent#ReduceFilter',
\ "\<del>": 'tlib#agent#ReduceFilter',
\ "\<c-bs>": 'tlib#agent#PopFilter',
\ "\<m-bs>": 'tlib#agent#PopFilter',
\ "\<c-del>": 'tlib#agent#PopFilter',
\ "\<m-del>": 'tlib#agent#PopFilter',
\ "\<s-space>": 'tlib#agent#Wildcard',
\ 191: 'tlib#agent#Debug',
\ char2nr(g:tlib#input#or): 'tlib#agent#OR',
\ char2nr(g:tlib#input#and): 'tlib#agent#AND',
\ }
" :nodefault:
TLet g:tlib#input#keyagents_InputList_m = {
\ 35: 'tlib#agent#Select',
\ "\<s-up>": 'tlib#agent#SelectUp',
\ "\<s-down>": 'tlib#agent#SelectDown',
\ 1: 'tlib#agent#SelectAll',
\ 225: 'tlib#agent#SelectAll',
\ "\<F9>": 'tlib#agent#ToggleRestrictView',
\ }
" "\<c-space>": 'tlib#agent#Select'
" :nodefault:
TLet g:tlib#input#handlers_EditList = [
\ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '<c-e>', 'help': 'Edit item'},
\ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '<c-d>', 'help': 'Delete item(s)'},
\ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '<c-n>', 'help': 'New item'},
\ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '<c-x>', 'help': 'Cut item(s)'},
\ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '<c-c>', 'help': 'Copy item(s)'},
\ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '<c-v>', 'help': 'Paste item(s)'},
\ {'pick_last_item': 0},
\ {'return_agent': 'tlib#agent#EditReturnValue'},
\ {'help_extra': [
\ 'Submit changes by pressing ENTER or <c-s> or <c-w><cr>',
\ 'Cancel editing by pressing <c-w>c'
\ ]},
\ ]
" If true, define a popup menu for |tlib#input#List()| and related " If true, define a popup menu for |tlib#input#List()| and related
" functions. " functions.
@ -40,7 +215,7 @@ TLet g:tlib#input#filename_max_width = '&co / 2'
" of selected elements or its indexes. " of selected elements or its indexes.
" "
" By default, typing numbers will select an item by its index. See " By default, typing numbers will select an item by its index. See
" |g:tlib_numeric_chars| to find out how to change this. " |g:tlib#input#numeric_chars| to find out how to change this.
" "
" The item is automatically selected if the numbers typed equals the " The item is automatically selected if the numbers typed equals the
" number of digits of the list length. I.e. if a list contains 20 items, " number of digits of the list length. I.e. if a list contains 20 items,
@ -58,7 +233,7 @@ TLet g:tlib#input#filename_max_width = '&co / 2'
" mi ... Return a list of indexes " mi ... Return a list of indexes
" "
" Several pattern matching styles are supported. See " Several pattern matching styles are supported. See
" |g:tlib_inputlist_match|. " |g:tlib#input#filter_mode|.
" "
" EXAMPLES: > " EXAMPLES: >
" echo tlib#input#List('s', 'Select one item', [100,200,300]) " echo tlib#input#List('s', 'Select one item', [100,200,300])
@ -110,7 +285,7 @@ function! tlib#input#List(type, ...) "{{{3
let world.pick_last_item = tlib#list#Find(handlers, 'has_key(v:val, "pick_last_item")', let world.pick_last_item = tlib#list#Find(handlers, 'has_key(v:val, "pick_last_item")',
\ tlib#var#Get('tlib_pick_last_item', 'bg'), 'v:val.pick_last_item') \ tlib#var#Get('tlib_pick_last_item', 'bg'), 'v:val.pick_last_item')
let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")', let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")',
\ tlib#var#Get('tlib_numeric_chars', 'bg'), 'v:val.numeric_chars') \ g:tlib#input#numeric_chars, 'v:val.numeric_chars')
let world.key_handlers = filter(copy(handlers), 'has_key(v:val, "key")') let world.key_handlers = filter(copy(handlers), 'has_key(v:val, "key")')
let filter = tlib#list#Find(handlers, 'has_key(v:val, "filter")', '', 'v:val.filter') let filter = tlib#list#Find(handlers, 'has_key(v:val, "filter")', '', 'v:val.filter')
if !empty(filter) if !empty(filter)
@ -157,10 +332,12 @@ function! tlib#input#ListW(world, ...) "{{{3
let &l:scrolloff = 0 let &l:scrolloff = 0
let @/ = '' let @/ = ''
let dlist = [] let dlist = []
let post_keys = ''
" let &laststatus = 2 " let &laststatus = 2
try try
while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base)) while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base))
let post_keys = ''
" TLogDBG 'while' " TLogDBG 'while'
" TLogVAR world.state " TLogVAR world.state
" let time01 = str2float(reltimestr(reltime())) " DBG " let time01 = str2float(reltimestr(reltime())) " DBG
@ -249,7 +426,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogVAR world.idx, world.llen, world.state " TLogVAR world.idx, world.llen, world.state
" TLogDBG world.FilterIsEmpty() " TLogDBG world.FilterIsEmpty()
if world.state == 'display' if world.state == 'display'
if world.idx == '' && world.llen < g:tlib_sortprefs_threshold && !world.FilterIsEmpty() if world.idx == '' && world.llen < g:tlib#input#sortprefs_threshold && !world.FilterIsEmpty()
call world.SetPrefIdx() call world.SetPrefIdx()
else else
let world.prefidx = world.idx == '' ? world.initial_index : world.idx let world.prefidx = world.idx == '' ? world.initial_index : world.idx
@ -333,7 +510,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" let world.prefidx = world.offset " let world.prefidx = world.offset
" endif " endif
call world.DisplayList() call world.DisplayList()
if world.state == 'help' if world.state == 'help' || world.state == 'printlines'
let world.state = 'display' let world.state = 'display'
else else
let world.state = '' let world.state = ''
@ -343,7 +520,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" TAssert IsNotEmpty(world.scratch) " TAssert IsNotEmpty(world.scratch)
let world.list_wnr = winnr() let world.list_wnr = winnr()
" TLogVAR world.next_state, world.state " TLogVAR world.state, world.next_state
if !empty(world.next_state) if !empty(world.next_state)
let world.state = world.next_state let world.state = world.next_state
let world.next_state = '' let world.next_state = ''
@ -354,11 +531,49 @@ function! tlib#input#ListW(world, ...) "{{{3
continue continue
endif endif
" TLogVAR world.timeout if world.state =~ '\<eval\>'
let c = tlib#char#Get(world.timeout, world.timeout_resolution) let query = matchstr(world.state, '\<eval\[\zs.\{-}\ze\]')
" TLogVAR c, has_key(world.key_map[world.key_mode],c) if empty(query)
let query = 'Waiting for input ... Press ESC to continue'
endif
if has('gui_win32')
let exec_cmd = input(query, '')
" TLogVAR exec_cmd
if exec_cmd == ''
let world.state = 'redisplay'
else
exec exec_cmd
endif
elseif has('gui_gtk') || has('gui_gtk2')
let c = getchar()
let cmod = getcharmod()
" TLogVAR c, cmod
if c !~ '\D' && c > 0 && cmod != 0
let c = printf("<%s-%s>", cmod, c)
endif
endif
else
" TLogVAR world.timeout
let c = tlib#char#Get(world.timeout, world.timeout_resolution)
" TLogVAR c, has_key(world.key_map[world.key_mode],c)
let cmod = getcharmod()
endif
" TLogVAR c, cmod
" TLogDBG string(sort(keys(world.key_map[world.key_mode]))) " TLogDBG string(sort(keys(world.key_map[world.key_mode])))
if world.state != ''
" TLogVAR world.next_agent, world.next_eval
if !empty(world.next_agent)
let nagent = world.next_agent
let world.next_agent = ''
let world = call(nagent, [world, world.GetSelectedItems(world.CurrentItem())])
call s:CheckAgentReturnValue(nagent, world)
elseif !empty(world.next_eval)
let selected = world.GetSelectedItems(world.CurrentItem())
let neval = world.next_eval
let world.next_eval = ''
exec neval
call s:CheckAgentReturnValue(neval, world)
elseif world.state != ''
" continue " continue
elseif has_key(world.key_map[world.key_mode], c) elseif has_key(world.key_map[world.key_mode], c)
let sr = @/ let sr = @/
@ -382,35 +597,53 @@ function! tlib#input#ListW(world, ...) "{{{3
let world.state = 'exit empty' let world.state = 'exit empty'
endif endif
elseif c == "\<LeftMouse>" elseif c == "\<LeftMouse>"
let world.prefidx = world.GetLineIdx(v:mouse_lnum) if v:mouse_win == world.list_wnr
" let world.offset = world.prefidx
" TLogVAR v:mouse_lnum, world.prefidx
if empty(world.prefidx)
" call feedkeys(c, 't')
let c = tlib#char#Get(world.timeout)
let world.state = 'help'
continue
endif
throw 'pick'
elseif c == "\<RightMouse>"
if g:tlib#input#use_popup && world.has_menu
" if v:mouse_lnum != line('.')
" endif
let world.prefidx = world.GetLineIdx(v:mouse_lnum) let world.prefidx = world.GetLineIdx(v:mouse_lnum)
let world.state = 'redisplay' " let world.offset = world.prefidx
call world.DisplayList() if empty(world.prefidx)
if line('w$') - v:mouse_lnum < 6 " call feedkeys(c, 't')
popup ]TLibInputListPopupMenu let c = tlib#char#Get(world.timeout)
let world.state = 'help'
continue
endif
throw 'pick'
else
let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c
if world.allow_suspend
let world = tlib#agent#SuspendToParentWindow(world, world.rv)
else else
popup! ]TLibInputListPopupMenu let world.state = 'exit empty'
endif
endif
elseif c == "\<RightMouse>"
if v:mouse_win == world.list_wnr
call s:BuildMenu(world)
let world.state = 'redisplay'
if s:PopupmenuExists() == 1
" if v:mouse_lnum != line('.')
" endif
let world.prefidx = world.GetLineIdx(v:mouse_lnum)
let world.next_state = 'eval[Waiting for popup menu ... Press ESC to continue]'
call world.DisplayList()
if line('w$') - v:mouse_lnum < 6
popup ]TLibInputListPopupMenu
else
popup! ]TLibInputListPopupMenu
endif
endif endif
else else
let world.state = 'redisplay' let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c
if world.allow_suspend
let world = tlib#agent#SuspendToParentWindow(world, world.rv)
else
let world.state = 'exit empty'
endif
endif endif
" TLogVAR world.prefidx, world.state " TLogVAR world.prefidx, world.state
elseif has_key(world.key_map[world.key_mode], 'unknown_key') elseif has_key(world.key_map[world.key_mode], 'unknown_key')
let agent = world.key_map[world.key_mode].unknown_key.agent let agent = world.key_map[world.key_mode].unknown_key.agent
let world = call(agent, [world, c]) let world = call(agent, [world, c])
call s:CheckAgentReturnValue(agent, world)
elseif c >= 32 elseif c >= 32
let world.state = 'display' let world.state = 'display'
let numbase = get(world.numeric_chars, c, -99999) let numbase = get(world.numeric_chars, c, -99999)
@ -425,7 +658,7 @@ function! tlib#input#ListW(world, ...) "{{{3
else else
let world.idx = '' let world.idx = ''
" TLogVAR world.filter " TLogVAR world.filter
if world.llen > g:tlib_inputlist_livesearch_threshold if world.llen > g:tlib#input#livesearch_threshold
let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c)) let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c))
if empty(pattern) if empty(pattern)
let world.state = 'exit empty' let world.state = 'exit empty'
@ -552,9 +785,8 @@ function! tlib#input#ListW(world, ...) "{{{3
" let &laststatus = laststatus " let &laststatus = laststatus
silent! let @/ = lastsearch silent! let @/ = lastsearch
let &l:scrolloff = scrolloff let &l:scrolloff = scrolloff
if g:tlib#input#use_popup && world.has_menu if s:PopupmenuExists() == 1
silent! aunmenu ]TLibInputListPopupMenu silent! aunmenu ]TLibInputListPopupMenu
let world.has_menu = 0
endif endif
" TLogDBG 'finally 2' " TLogDBG 'finally 2'
@ -589,6 +821,10 @@ function! tlib#input#ListW(world, ...) "{{{3
" endfor " endfor
echo echo
redraw! redraw!
if !empty(post_keys)
" TLogVAR post_keys
call feedkeys(post_keys)
endif
endtry endtry
endf endf
@ -612,7 +848,7 @@ function! s:Init(world, cmd) "{{{3
" TLogVAR a:world.initialized, a:world.win_wnr, a:world.bufnr " TLogVAR a:world.initialized, a:world.win_wnr, a:world.bufnr
let a:world.filetype = &filetype let a:world.filetype = &filetype
let a:world.fileencoding = &fileencoding let a:world.fileencoding = &fileencoding
call a:world.SetMatchMode(tlib#var#Get('tlib_inputlist_match', 'wb')) call a:world.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'wb'))
call a:world.Initialize() call a:world.Initialize()
if !has_key(a:world, 'key_mode') if !has_key(a:world, 'key_mode')
let a:world.key_mode = 'default' let a:world.key_mode = 'default'
@ -623,18 +859,19 @@ function! s:Init(world, cmd) "{{{3
if has_key(a:world.key_map, a:world.key_mode) if has_key(a:world.key_map, a:world.key_mode)
let a:world.key_map[a:world.key_mode] = extend( let a:world.key_map[a:world.key_mode] = extend(
\ a:world.key_map[a:world.key_mode], \ a:world.key_map[a:world.key_mode],
\ copy(g:tlib_keyagents_InputList_s), \ copy(g:tlib#input#keyagents_InputList_s),
\ 'keep') \ 'keep')
else else
let a:world.key_map[a:world.key_mode] = copy(g:tlib_keyagents_InputList_s) let a:world.key_map[a:world.key_mode] = copy(g:tlib#input#keyagents_InputList_s)
endif endif
else else
let a:world.key_map = { let a:world.key_map = {
\ a:world.key_mode : copy(g:tlib_keyagents_InputList_s) \ a:world.key_mode : copy(g:tlib#input#keyagents_InputList_s)
\ } \ }
endif endif
" TLogVAR a:world.type
if stridx(a:world.type, 'm') != -1 if stridx(a:world.type, 'm') != -1
call extend(a:world.key_map[a:world.key_mode], g:tlib_keyagents_InputList_m, 'force') call extend(a:world.key_map[a:world.key_mode], g:tlib#input#keyagents_InputList_m, 'force')
endif endif
for key_mode in keys(a:world.key_map) for key_mode in keys(a:world.key_map)
let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}') let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}')
@ -652,7 +889,6 @@ function! s:Init(world, cmd) "{{{3
let a:world.state .= ' '. a:cmd let a:world.state .= ' '. a:cmd
endif endif
endif endif
call s:BuildMenu(a:world)
" TLogVAR a:world.state, a:world.sticky " TLogVAR a:world.state, a:world.sticky
endf endf
@ -667,40 +903,133 @@ function! s:ExtendKeyMap(world, key_mode, key_handlers) "{{{3
endf endf
function s:PopupmenuExists()
if !g:tlib#input#use_popup
\ || exists(':popup') != 2
\ || !(has('gui_win32') || has('gui_gtk') || has('gui_gtk2'))
" \ || !has('gui_win32')
let rv = -1
else
try
let rv = 1
silent amenu ]TLibInputListPopupMenu
catch
let rv = 0
endtry
endif
" TLogVAR rv
return rv
endf
function! s:BuildMenu(world) "{{{3 function! s:BuildMenu(world) "{{{3
if g:tlib#input#use_popup if g:tlib#input#use_popup && s:PopupmenuExists() == 0
if a:world.has_menu call s:BuildItem('Pick\ selected\ item', {'key_name': '<cr>', 'eval': 'let world.state = "pick"'})
silent! aunmenu ]TLibInputListPopupMenu call s:BuildItem('Cancel', {'key_name': '<esc>', 'agent': 'tlib#agent#Exit'})
endif call s:BuildItem('Select', {'key_name': '#', 'agent': 'tlib#agent#Select'})
amenu ]TLibInputListPopupMenu.Pick\ selected\ item <cr> call s:BuildItem('Select\ all', {'key_name': '<c-a>', 'agent': 'tlib#agent#SelectAll'})
amenu ]TLibInputListPopupMenu.Select # call s:BuildItem('Reset\ list', {'key_name': '<c-r>', 'agent': 'tlib#agent#Reset'})
amenu ]TLibInputListPopupMenu.Select\ all <c-a> call s:BuildItem('-StandardEntries-', {'key': ":", 'eval': 'let world.state = "redisplay"'})
amenu ]TLibInputListPopupMenu.Reset\ list <c-r>
amenu ]TLibInputListPopupMenu.Cancel <esc>
amenu ]TLibInputListPopupMenu.-StandardEntries- :
let a:world.has_menu = 1
for [key_mode, key_handlers] in items(a:world.key_map) for [key_mode, key_handlers] in items(a:world.key_map)
let keys = sort(keys(key_handlers)) let keys = sort(keys(key_handlers))
let mitems = {}
for key in keys for key in keys
let handler = key_handlers[key] let handler = key_handlers[key]
let k = get(handler, 'key', '') let k = get(handler, 'key', '')
if !empty(k) && has_key(handler, 'help') && !empty(handler.help) if !empty(k) && has_key(handler, 'help') && !empty(handler.help)
if empty(key_mode) || key_mode == 'default' if empty(key_mode) || key_mode == 'default'
exec 'amenu ]TLibInputListPopupMenu.'. escape(handler.help, ' .\') let mname = ''
\ .' '. handler.key_name
else else
exec 'amenu ]TLibInputListPopupMenu'. let mname = escape(key_mode, ' .\') .'.'
\ '.'. escape(key_mode, ' .\')
\ '.'. escape(handler.help, ' .\')
\ .' '. handler.key_name
endif endif
if has_key(handler, 'submenu')
let submenu = escape(handler.submenu, ' .\')
else
let submenu = '~'
endif
for mfield in ['menu', 'help', 'key_name', 'agent']
if has_key(handler, mfield)
let mname .= escape(handler[mfield], ' .\')
break
endif
endfor
if !has_key(mitems, submenu)
let mitems[submenu] = {}
endif
let mitems[submenu][mname] = handler
endif endif
endfor endfor
for msubname in sort(keys(mitems))
let msubitems = mitems[msubname]
if msubname == '~'
let msubmname = ''
else
let msubmname = msubname .'.'
endif
for mname in sort(keys(msubitems))
let msname = msubmname . mname
let handler = msubitems[mname]
call s:BuildItem(msname, handler)
" if has_key(handler, 'agent')
" call s:BuildItem(msname, {'agent': handler.agent})
" else
" call s:BuildItem(msname, {'key': handler.key_name})
" endif
endfor
endfor
endfor endfor
endif endif
endf endf
function! s:BuildItem(menu, def) "{{{3
if has('gui_win32')
let key_mode = 'c'
elseif has('gui_gtk') || has('gui_gtk2')
let key_mode = 'raw'
endif
for k in ['agent', 'eval', 'key_name', 'key']
if has('gui_win32')
elseif has('gui_gtk') || has('gui_gtk')
if k == 'agent' || k == 'eval'
continue
endif
endif
try
if has_key(a:def, k)
let v = a:def[k]
if k == 'key'
if key_mode == 'c'
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"<cr>'
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"<cr>'
else
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) v
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) v
endif
elseif k == 'key_name'
if key_mode == 'c'
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"<cr>'
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"<cr>'
else
let key = v
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) key
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) key
endif
elseif k == 'agent'
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'<cr>'
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'<cr>'
elseif k == 'eval'
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'<cr>'
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'<cr>'
endif
return
endif
catch
endtry
endfor
endf
function! s:RunStateHandlers(world) "{{{3 function! s:RunStateHandlers(world) "{{{3
" Provide the variable "world" in the environment of an "exec" " Provide the variable "world" in the environment of an "exec"
" handler (ea). " handler (ea).
@ -748,7 +1077,7 @@ endf
" EXAMPLES: > " EXAMPLES: >
" echo tlib#input#EditList('Edit:', [100,200,300]) " echo tlib#input#EditList('Edit:', [100,200,300])
function! tlib#input#EditList(query, list, ...) "{{{3 function! tlib#input#EditList(query, list, ...) "{{{3
let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib_handlers_EditList let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib#input#handlers_EditList
let default = a:0 >= 2 ? a:2 : [] let default = a:0 >= 2 ? a:2 : []
let timeout = a:0 >= 3 ? a:3 : 0 let timeout = a:0 >= 3 ? a:3 : 0
" TLogVAR handlers " TLogVAR handlers
@ -767,7 +1096,7 @@ function! tlib#input#Resume(name, pick, bufnr) "{{{3
" TLogVAR a:name, a:pick " TLogVAR a:name, a:pick
echo echo
if bufnr('%') != a:bufnr if bufnr('%') != a:bufnr
if g:tlib_debug if g:tlib#debug
echohl WarningMsg echohl WarningMsg
echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%') echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%')
echohl NONE echohl NONE
@ -775,7 +1104,7 @@ function! tlib#input#Resume(name, pick, bufnr) "{{{3
let br = tlib#buffer#Set(a:bufnr) let br = tlib#buffer#Set(a:bufnr)
endif endif
if !exists('b:tlib_'. a:name) if !exists('b:tlib_'. a:name)
if g:tlib_debug if g:tlib#debug
echohl WarningMsg echohl WarningMsg
echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%') echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%')
echohl NONE echohl NONE

View file

@ -0,0 +1,30 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Revision: 14
function! tlib#number#ConvertBase(num, base, ...) "{{{3
let rtype = a:0 >= 1 ? a:1 : 'string'
" TLogVAR a:num, a:base, rtype
let rv = []
let num = 0.0 + a:num
while floor(num) > 0.0
let div = floor(num / a:base)
let num1 = float2nr(num - a:base * div)
if a:base <= 10
call insert(rv, num1)
elseif a:base == 16
let char = "0123456789ABCDEF"[num1]
call insert(rv, char)
endif
let num = num / a:base
endwh
" TLogVAR rv
if rtype == 'list'
return rv
else
return join(rv, '')
endif
endf

View file

@ -3,7 +3,7 @@
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2012-05-11. " @Created: 2012-05-11.
" @Last Change: 2012-05-11. " @Last Change: 2012-05-11.
" @Revision: 6 " @Revision: 7
" The directory for persistent data files. If empty, use " The directory for persistent data files. If empty, use
" |tlib#dir#MyRuntime|.'/share'. " |tlib#dir#MyRuntime|.'/share'.
@ -38,6 +38,10 @@ function! tlib#persistent#Get(cfile) "{{{3
endif endif
endf endf
function! tlib#persistent#Value(...) "{{{3
return call('tlib#cache#Value', a:000)
endf
function! tlib#persistent#Save(cfile, dictionary) "{{{3 function! tlib#persistent#Save(cfile, dictionary) "{{{3
if !empty(a:cfile) if !empty(a:cfile)
" TLogVAR a:dictionary " TLogVAR a:dictionary

View file

@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-07-18. " @Created: 2007-07-18.
" @Last Change: 2012-02-08. " @Last Change: 2013-10-16.
" @Revision: 0.0.167 " @Revision: 0.0.242
if &cp || exists("loaded_tlib_scratch_autoload") if &cp || exists("loaded_tlib_scratch_autoload")
finish finish
@ -12,6 +12,17 @@ endif
let loaded_tlib_scratch_autoload = 1 let loaded_tlib_scratch_autoload = 1
" Scratch window position. By default the list window is opened on the
" bottom. Set this variable to 'topleft' or '' to change this behaviour.
" See |tlib#input#List()|.
TLet g:tlib_scratch_pos = 'botright'
" If you want the scratch buffer to be fully removed, you might want to
" set this variable to 'wipe'.
" See also https://github.com/tomtom/tlib_vim/pull/16
TLet g:tlib#scratch#hidden = 'hide'
" :def: function! tlib#scratch#UseScratch(?keyargs={}) " :def: function! tlib#scratch#UseScratch(?keyargs={})
" Display a scratch buffer (a buffer with no file). See :TScratch for an " Display a scratch buffer (a buffer with no file). See :TScratch for an
" example. " example.
@ -22,23 +33,21 @@ function! tlib#scratch#UseScratch(...) "{{{3
exec tlib#arg#Let([['keyargs', {}]]) exec tlib#arg#Let([['keyargs', {}]])
" TLogDBG string(keys(keyargs)) " TLogDBG string(keys(keyargs))
let id = get(keyargs, 'scratch', '__Scratch__') let id = get(keyargs, 'scratch', '__Scratch__')
" TLogVAR id " TLogVAR id, bufwinnr(id)
" TLogDBG winnr() " TLogVAR bufnr(id), bufname(id)
" TLogDBG bufnr(id) " TLogVAR 1, winnr(), bufnr('%'), bufname("%")
" TLogDBG bufwinnr(id) if bufwinnr(id) != -1
" TLogDBG bufnr('%') " echom 'DBG noautocmd keepalt keepj' bufwinnr(id) 'wincmd w'
if id =~ '^\d\+$' && bufwinnr(id) != -1 exec 'noautocmd keepalt keepj' bufwinnr(id) 'wincmd w'
if bufnr('%') != id " TLogVAR "reuse", bufnr("%"), bufname("%")
exec 'noautocmd buffer! '. id
endif
" let ft = &ft
let ft = '*'
else else
let winpos = ''
let bn = bufnr(id) let bn = bufnr(id)
let wpos = get(keyargs, 'scratch_pos', g:tlib_scratch_pos) let wpos = get(keyargs, 'scratch_pos', g:tlib_scratch_pos)
" TLogVAR keyargs.scratch_vertical " TLogVAR keyargs.scratch_vertical
if get(keyargs, 'scratch_vertical') if get(keyargs, 'scratch_vertical')
let wpos .= ' vertical' let wpos .= ' vertical'
let winpos = tlib#fixes#Winpos()
endif endif
" TLogVAR wpos " TLogVAR wpos
let scratch_split = get(keyargs, 'scratch_split', 1) let scratch_split = get(keyargs, 'scratch_split', 1)
@ -47,7 +56,7 @@ function! tlib#scratch#UseScratch(...) "{{{3
let wn = bufwinnr(bn) let wn = bufwinnr(bn)
if wn != -1 if wn != -1
" TLogVAR wn " TLogVAR wn
exec 'noautocmd' (wn .'wincmd w') exec 'noautocmd keepalt keepj' (wn .'wincmd w')
else else
if scratch_split == 1 if scratch_split == 1
let cmd = wpos.' sbuffer!' let cmd = wpos.' sbuffer!'
@ -57,7 +66,7 @@ function! tlib#scratch#UseScratch(...) "{{{3
let cmd = 'buffer!' let cmd = 'buffer!'
endif endif
" TLogVAR cmd " TLogVAR cmd
silent exec 'noautocmd' cmd bn silent exec 'noautocmd keepalt keepj' cmd bn
endif endif
else else
" TLogVAR id " TLogVAR id
@ -69,24 +78,29 @@ function! tlib#scratch#UseScratch(...) "{{{3
let cmd = 'edit' let cmd = 'edit'
endif endif
" TLogVAR cmd " TLogVAR cmd
silent exec 'noautocmd' cmd escape(id, '%#\ ') silent exec 'noautocmd keepalt keepj' cmd escape(id, '%#\ ')
" silent exec 'split '. id " silent exec 'split '. id
endif endif
let ft = get(keyargs, 'scratch_filetype', '') let ft = get(keyargs, 'scratch_filetype', '')
" TLogVAR ft " TLogVAR ft, winpos
endif if !empty(winpos)
setlocal buftype=nofile exec winpos
setlocal bufhidden=hide endif
setlocal noswapfile setlocal buftype=nofile
setlocal nobuflisted let &l:bufhidden = get(keyargs, 'scratch_hidden', g:tlib#scratch#hidden)
setlocal foldmethod=manual setlocal noswapfile
setlocal foldcolumn=0 setlocal nobuflisted
setlocal modifiable setlocal foldmethod=manual
setlocal nospell setlocal foldcolumn=0
if &ft != '*' setlocal modifiable
let &ft = ft setlocal nospell
" TLogVAR &ft, ft
if !empty(ft)
let &l:ft = ft
endif
endif endif
let keyargs.scratch = bufnr('%') let keyargs.scratch = bufnr('%')
" TLogVAR 2, winnr(), bufnr('%'), bufname("%")
return keyargs.scratch return keyargs.scratch
endf endf
@ -106,7 +120,11 @@ function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3
if wn != -1 if wn != -1
" TLogDBG winnr() " TLogDBG winnr()
let wb = tlib#win#Set(wn) let wb = tlib#win#Set(wn)
let winpos = tlib#fixes#Winpos()
wincmd c wincmd c
if get(a:keyargs, 'scratch_vertical') && !empty(winpos)
exec winpos
endif
" exec wb " exec wb
" redraw " redraw
" TLogVAR winnr() " TLogVAR winnr()

View file

@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-11-01. " @Created: 2007-11-01.
" @Last Change: 2011-08-11. " @Last Change: 2013-09-25.
" @Revision: 0.0.56 " @Revision: 0.0.58
if &cp || exists("loaded_tlib_tag_autoload") if &cp || exists("loaded_tlib_tag_autoload")
finish finish
@ -12,6 +12,23 @@ endif
let loaded_tlib_tag_autoload = 1 let loaded_tlib_tag_autoload = 1
" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local.
TLet g:tlib_tags_extra = ''
" Filter the tag description through |substitute()| for these filetypes.
" This applies only if the tag cmd field (see |taglist()|) is used.
" :nodefault:
TLet g:tlib_tag_substitute = {
\ 'java': [['\s*{\s*$', '', '']],
\ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']],
\ 'vim': [
\ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''],
\ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''],
\ ['"\?\s*{{{\d.*$', '', ''],
\ ],
\ }
" :def: function! tlib#tag#Retrieve(rx, ?extra_tags=0) " :def: function! tlib#tag#Retrieve(rx, ?extra_tags=0)
" Get all tags matching rx. Basically, this function simply calls " Get all tags matching rx. Basically, this function simply calls
" |taglist()|, but when extra_tags is true, the list of the tag files " |taglist()|, but when extra_tags is true, the list of the tag files

File diff suppressed because it is too large Load diff

View file

@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-04-10. " @Created: 2007-04-10.
" @Last Change: 2012-10-03. " @Last Change: 2013-09-25.
" @Revision: 725 " @Revision: 746
" GetLatestVimScripts: 1863 1 tlib.vim " GetLatestVimScripts: 1863 1 tlib.vim
if &cp || exists("loaded_tlib") if &cp || exists("loaded_tlib")
@ -14,7 +14,7 @@ if v:version < 700 "{{{2
echoerr "tlib requires Vim >= 7" echoerr "tlib requires Vim >= 7"
finish finish
endif endif
let loaded_tlib = 102 let loaded_tlib = 106
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
@ -114,240 +114,5 @@ command! -nargs=0 -complete=command TBrowseScriptnames call
command! -nargs=1 -complete=command TTimeCommand call tlib#cmd#Time(<q-args>) command! -nargs=1 -complete=command TTimeCommand call tlib#cmd#Time(<q-args>)
" :doc:
" Variables~ {{{1
" When 1, automatically select the last remaining item only if the list
" had only one item to begin with.
" When 2, automatically select a last remaining item after applying
" any filters.
" See |tlib#input#List()|.
TLet g:tlib_pick_last_item = 1
" If a list is bigger than this value, don't try to be smart when
" selecting an item. Be slightly faster instead.
" See |tlib#input#List()|.
TLet g:tlib_sortprefs_threshold = 200
" Scratch window position. By default the list window is opened on the
" bottom. Set this variable to 'topleft' or '' to change this behaviour.
" See |tlib#input#List()|.
TLet g:tlib_scratch_pos = 'botright'
" Size of the input list window (in percent) from the main size (of &lines).
" See |tlib#input#List()|.
TLet g:tlib_inputlist_pct = 50
" Size of filename columns when listing filenames.
" See |tlib#input#List()|.
TLet g:tlib_inputlist_width_filename = '&co / 3'
" TLet g:tlib_inputlist_width_filename = 25
" The highlight group to use for showing matches in the input list
" window.
" See |tlib#input#List()|.
TLet g:tlib_inputlist_higroup = 'IncSearch'
" If a list contains more items, |tlib#input#List()| does not perform an
" incremental "live search" but uses |input()| to query the user for a
" filter. This is useful on slower machines or with very long lists.
TLet g:tlib_inputlist_livesearch_threshold = 1000
" If true, |tlib#input#List()| will show some indicators about the
" status of a filename (e.g. buflisted(), bufloaded() etc.).
" This is disabled by default because vim checks also for the file on
" disk when doing this.
TLet g:tlib_inputlist_filename_indicators = 0
" Determine how |tlib#input#List()| and related functions work.
" Can be "cnf", "cnfd", "cnfx", "seq", or "fuzzy". See:
" cnfx ... Like cnfd but |g:tlib#Filter_cnfx#expander| is interpreted
" as a wildcard (this is the default method)
" - A plus character ("+") acts as a wildcard as if ".\{-}" (see
" |/\{-|) were entered.
" - Examples:
" - "f+o" matches "fo", "fxo", and "fxxxoo", but doesn't match
" "far".
" - Otherwise it is a derivate of the cnf method (see below).
" - See also |tlib#Filter_cnfx#New()|.
" cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is
" expanded to "\.\{-}"
" - A period character (".") acts as a wildcard as if ".\{-}" (see
" |/\{-|) were entered.
" - Examples:
" - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match
" "far".
" - Otherwise it is a derivate of the cnf method (see below).
" - See also |tlib#Filter_cnfd#New()|.
" cnf .... Match substrings
" - A blank creates an AND conjunction, i.e. the next pattern has to
" match too.
" - A pipe character ("|") creates an OR conjunction, either this or
" the next next pattern has to match.
" - Patterns are very 'nomagic' |regexp| with a |\V| prefix.
" - A pattern starting with "-" makes the filter exclude items
" matching that pattern.
" - Examples:
" - "foo bar" matches items that contain the strings "foo" AND
" "bar".
" - "foo|bar boo|far" matches items that contain either ("foo" OR
" "bar") AND ("boo" OR "far").
" - See also |tlib#Filter_cnf#New()|.
" seq .... Match sequences of characters
" - |tlib#Filter_seq#New()|
" fuzzy .. Match fuzzy character sequences
" - |tlib#Filter_fuzzy#New()|
TLet g:tlib_inputlist_match = 'cnfx'
" If not null, display only a short info about the filter.
TLet g:tlib_inputlist_shortmessage = 0
" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local.
TLet g:tlib_tags_extra = ''
" Filter the tag description through |substitute()| for these filetypes.
" This applies only if the tag cmd field (see |taglist()|) is used.
" :nodefault:
TLet g:tlib_tag_substitute = {
\ 'java': [['\s*{\s*$', '', '']],
\ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']],
\ 'vim': [
\ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''],
\ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''],
\ ['"\?\s*{{{\d.*$', '', ''],
\ ],
\ }
" " Alternative rx for keywords, in case 'iskeyword' is inadequate for
" " the purposes of tlib but you don't want to change it's value.
" TLet g:tlib_keyword_rx = {
" \ 'vim': '\(\w\|#\)',
" \ }
TLet g:tlib_filename_sep = '/'
" TLet g:tlib_filename_sep = exists('+shellslash') && !&shellslash ? '\' : '/' " {{{2
" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'.
" You might want to delete old files from this directory from time to
" time with a command like: >
" find ~/vimfiles/cache/ -atime +31 -type f -print -delete
TLet g:tlib_cache = ''
" Where to display the line when using |tlib#buffer#ViewLine|.
" For possible values for position see |scroll-cursor|.
TLet g:tlib_viewline_position = 'zz'
" :doc:
" Keys for |tlib#input#List|~
TLet g:tlib_inputlist_and = ' '
TLet g:tlib_inputlist_or = '|'
TLet g:tlib_inputlist_not = '-'
" When editing a list with |tlib#input#List|, typing these numeric chars
" (as returned by getchar()) will select an item based on its index, not
" based on its name. I.e. in the default setting, typing a "4" will
" select the fourth item, not the item called "4".
" In order to make keys 0-9 filter the items in the list and make
" <m-[0-9]> select an item by its index, remove the keys 48 to 57 from
" this dictionary.
" Format: [KEY] = BASE ... the number is calculated as KEY - BASE.
" :nodefault:
TLet g:tlib_numeric_chars = {
\ 176: 176,
\ 177: 176,
\ 178: 176,
\ 179: 176,
\ 180: 176,
\ 181: 176,
\ 182: 176,
\ 183: 176,
\ 184: 176,
\ 185: 176,
\}
" \ 48: 48,
" \ 49: 48,
" \ 50: 48,
" \ 51: 48,
" \ 52: 48,
" \ 53: 48,
" \ 54: 48,
" \ 55: 48,
" \ 56: 48,
" \ 57: 48,
" :nodefault:
" The default key bindings for single-item-select list views. If you
" want to use <c-j>, <c-k> to move the cursor up and down, add these two
" lines to after/plugin/02tlib.vim: >
"
" let g:tlib_keyagents_InputList_s[10] = 'tlib#agent#Down' " <c-j>
" let g:tlib_keyagents_InputList_s[11] = 'tlib#agent#Up' " <c-k>
TLet g:tlib_keyagents_InputList_s = {
\ "\<PageUp>": 'tlib#agent#PageUp',
\ "\<PageDown>": 'tlib#agent#PageDown',
\ "\<Up>": 'tlib#agent#Up',
\ "\<Down>": 'tlib#agent#Down',
\ "\<c-Up>": 'tlib#agent#UpN',
\ "\<c-Down>": 'tlib#agent#DownN',
\ "\<Left>": 'tlib#agent#ShiftLeft',
\ "\<Right>": 'tlib#agent#ShiftRight',
\ 18: 'tlib#agent#Reset',
\ 242: 'tlib#agent#Reset',
\ 17: 'tlib#agent#Input',
\ 241: 'tlib#agent#Input',
\ 27: 'tlib#agent#Exit',
\ 26: 'tlib#agent#Suspend',
\ 250: 'tlib#agent#Suspend',
\ 15: 'tlib#agent#SuspendToParentWindow',
\ 63: 'tlib#agent#Help',
\ "\<F1>": 'tlib#agent#Help',
\ "\<F10>": 'tlib#agent#ExecAgentByName',
\ "\<S-Esc>": 'tlib#agent#ExecAgentByName',
\ "\<bs>": 'tlib#agent#ReduceFilter',
\ "\<del>": 'tlib#agent#ReduceFilter',
\ "\<c-bs>": 'tlib#agent#PopFilter',
\ "\<m-bs>": 'tlib#agent#PopFilter',
\ "\<c-del>": 'tlib#agent#PopFilter',
\ "\<m-del>": 'tlib#agent#PopFilter',
\ "\<s-space>": 'tlib#agent#Wildcard',
\ 191: 'tlib#agent#Debug',
\ char2nr(g:tlib_inputlist_or): 'tlib#agent#OR',
\ char2nr(g:tlib_inputlist_and): 'tlib#agent#AND',
\ }
" Number of items to move when pressing <c-up/down> in the input list window.
TLet g:tlib_scroll_lines = 10
" :nodefault:
TLet g:tlib_keyagents_InputList_m = {
\ 35: 'tlib#agent#Select',
\ "\<s-up>": 'tlib#agent#SelectUp',
\ "\<s-down>": 'tlib#agent#SelectDown',
\ 1: 'tlib#agent#SelectAll',
\ 225: 'tlib#agent#SelectAll',
\ }
" "\<c-space>": 'tlib#agent#Select'
" :nodefault:
TLet g:tlib_handlers_EditList = [
\ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '<c-e>', 'help': 'Edit item'},
\ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '<c-d>', 'help': 'Delete item(s)'},
\ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '<c-n>', 'help': 'New item'},
\ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '<c-x>', 'help': 'Cut item(s)'},
\ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '<c-c>', 'help': 'Copy item(s)'},
\ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '<c-v>', 'help': 'Paste item(s)'},
\ {'pick_last_item': 0},
\ {'return_agent': 'tlib#agent#EditReturnValue'},
\ {'help_extra': [
\ 'Submit changes by pressing ENTER or <c-s> or <c-w><cr>',
\ 'Cancel editing by pressing <c-w>c'
\ ]},
\ ]
" :nodefault:
TLet g:tlib_debug = 0
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo

View file

@ -0,0 +1,3 @@
doc/tags
*.lock
.vim-flavor

View file

@ -0,0 +1,4 @@
language: ruby
rvm:
- 1.9.3
script: rake ci

View file

@ -0,0 +1,2 @@
source 'https://rubygems.org'
gem 'vim-flavor', '~> 1.1'

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (C) 2013 Bailey Ling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,199 @@
# vim-airline [![Build Status](https://travis-ci.org/bling/vim-airline.png)](https://travis-ci.org/bling/vim-airline)
Lean &amp; mean status/tabline for vim that's light as air.
![img](https://github.com/bling/vim-airline/wiki/screenshots/demo.gif)
# Features
* Tiny core written with extensibility in mind ([open/closed principle][8]).
* Integrates with a variety of plugins, including: [vim-bufferline][6], [fugitive][4], [unite][9], [ctrlp][10], [minibufexpl][15], [gundo][16], [undotree][17], [nerdtree][18], [tagbar][19], [vim-gitgutter][29], [vim-signify][30], [syntastic][5], [eclim][34], [lawrencium][21] and [virtualenv][31].
* Looks good with regular fonts and provides configuration points so you can use unicode or powerline symbols.
* Optimized for speed; it loads in under a millisecond.
* Extensive suite of themes for popular colorschemes including [solarized][23] (dark and light), [tomorrow][24] (all variants), [base16][32] (all variants), [molokai][25], [jellybeans][26] and others; have a look at the [screenshots][14] in the wiki.
* Supports 7.2 as the minimum Vim version.
* The master branch tries to be as stable as possible, and new features are merged in only after they have gone through a [full regression test][33].
* Unit testing suite.
## Straightforward customization
If you don't like the defaults, you can replace all sections with standard `statusline` syntax. Give your statusline that you've built over the years a face lift.
![image](https://f.cloud.github.com/assets/306502/1009429/d69306da-0b38-11e3-94bf-7c6e3eef41e9.png)
## Automatic truncation
Sections and parts within sections can be configured to automatically hide when the window size shrinks.
![image](https://f.cloud.github.com/assets/306502/1060831/05c08aac-11bc-11e3-8470-a506a3037f45.png)
## Smarter tab line
Automatically displays all buffers when there's only one tab open.
![tabline](https://f.cloud.github.com/assets/306502/1072623/44c292a0-1495-11e3-9ce6-dcada3f1c536.gif)
This is disabled by default; add the following to your vimrc to enable the extension:
let g:airline#extensions#tabline#enabled = 1
Separators can be configured independently for the tabline, so here is how you can define "straight" tabs:
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
## Seamless integration
vim-airline integrates with a variety of plugins out of the box. These extensions will be lazily loaded if and only if you have the other plugins installed (and of course you can turn them off).
#### [ctrlp.vim][10]
![image](https://f.cloud.github.com/assets/306502/962258/7345a224-04ec-11e3-8b5a-f11724a47437.png)
#### [unite.vim][9]
![image](https://f.cloud.github.com/assets/306502/962319/4d7d3a7e-04ed-11e3-9d59-ab29cb310ff8.png)
#### [tagbar][19]
![image](https://f.cloud.github.com/assets/306502/962150/7e7bfae6-04ea-11e3-9e28-32af206aed80.png)
#### [csv.vim][28]
![image](https://f.cloud.github.com/assets/306502/962204/cfc1210a-04eb-11e3-8a93-42e6bcd21efa.png)
#### [syntastic][5]
![image](https://f.cloud.github.com/assets/306502/962864/9824c484-04f7-11e3-9928-da94f8c7da5a.png)
#### hunks ([vim-gitgutter][29] & [vim-signify][30])
![image](https://f.cloud.github.com/assets/306502/995185/73fc7054-09b9-11e3-9d45-618406c6ed98.png)
#### [virtualenv][31]
![image](https://f.cloud.github.com/assets/390964/1022566/cf81f830-0d98-11e3-904f-cf4fe3ce201e.png)
## Extras
vim-airline also supplies some supplementary stand-alone extensions. In addition to the tabline extension mentioned earlier, there is also:
#### whitespace
![image](https://f.cloud.github.com/assets/306502/962401/2a75385e-04ef-11e3-935c-e3b9f0e954cc.png)
## Configurable and extensible
#### Fine-tuned configuration
Every section is composed of parts, and you can reorder and reconfigure them at will.
![image](https://f.cloud.github.com/assets/306502/1073278/f291dd4c-14a3-11e3-8a83-268e2753f97d.png)
Sections can contain accents, which allows for very granular control of visuals (see configuration [here](https://github.com/bling/vim-airline/issues/299#issuecomment-25772886)).
![image](https://f.cloud.github.com/assets/306502/1195815/4bfa38d0-249d-11e3-823e-773cfc2ca894.png)
#### Extensible pipeline
Completely transform the statusline to your liking. Build out the statusline as you see fit by extracting colors from the current colorscheme's highlight groups.
![allyourbase](https://f.cloud.github.com/assets/306502/1022714/e150034a-0da7-11e3-94a5-ca9d58a297e8.png)
# Rationale
There's already [powerline][2], why yet another statusline?
* 100% vimscript; no python needed.
What about [vim-powerline][1]?
* vim-powerline has been deprecated in favor of the newer, unifying powerline, which is under active development; the new version is written in python at the core and exposes various bindings such that it can style statuslines not only in vim, but also tmux, bash, zsh, and others.
# Where did the name come from?
I wrote the initial version on an airplane, and since it's light as air it turned out to be a good name. Thanks for flying vim!
# Installation
This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers:
* [Pathogen][11]
* `git clone https://github.com/bling/vim-airline ~/.vim/bundle/vim-airline`
* [NeoBundle][12]
* `NeoBundle 'bling/vim-airline'`
* [Vundle][13]
* `Bundle 'bling/vim-airline'`
* [VAM][22]
* `call vam#ActivateAddons([ 'vim-airline' ])`
* manual
* copy all of the files into your `~/.vim` directory
# Configuration
`:help airline`
# Integrating with powerline fonts
For the nice looking powerline symbols to appear, you will need to install a patched font. Instructions can be found in the official powerline [documentation][20]. Prepatched fonts can be found in the [powerline-fonts][3] repository.
Finally, you can add the convenience variable `let g:airline_powerline_fonts = 1` to your vimrc which will automatically populate the `g:airline_symbols` dictionary with the powerline symbols.
# FAQ
Solutions to common problems can be found in the [Wiki][27].
# Screenshots
A full list of screenshots for various themes can be found in the [Wiki][14].
# Bugs
Tracking down bugs can take a very long time due to different configurations, versions, and operating systems. To ensure a timely response, please help me out by doing the following:
* Reproduce it with this [minivimrc][7] repository to rule out any configuration conflicts.
* A link to your vimrc or a gist which shows how you configured the plugin(s).
* And so I can reproduce; your `:version` of vim, and the commit of vim-airline you're using.
# Contributions
Contributions and pull requests are welcome. Please take note of the following guidelines:
* Adhere to the existing style as much as possible; notably, 2 space indents and long-form keywords.
* Keep the history clean! squash your branches before you submit a pull request. `pull --rebase` is your friend.
* Any changes to the core should be tested against Vim 7.2.
* If you submit a theme, please create a screenshot so it can be added to the [Wiki][14].
# License
MIT License. Copyright (c) 2013 Bailey Ling.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/bling/vim-airline/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[1]: https://github.com/Lokaltog/vim-powerline
[2]: https://github.com/Lokaltog/powerline
[3]: https://github.com/Lokaltog/powerline-fonts
[4]: https://github.com/tpope/vim-fugitive
[5]: https://github.com/scrooloose/syntastic
[6]: https://github.com/bling/vim-bufferline
[7]: https://github.com/bling/minivimrc
[8]: http://en.wikipedia.org/wiki/Open/closed_principle
[9]: https://github.com/Shougo/unite.vim
[10]: https://github.com/kien/ctrlp.vim
[11]: https://github.com/tpope/vim-pathogen
[12]: https://github.com/Shougo/neobundle.vim
[13]: https://github.com/gmarik/vundle
[14]: https://github.com/bling/vim-airline/wiki/Screenshots
[15]: https://github.com/techlivezheng/vim-plugin-minibufexpl
[16]: https://github.com/sjl/gundo.vim
[17]: https://github.com/mbbill/undotree
[18]: https://github.com/scrooloose/nerdtree
[19]: https://github.com/majutsushi/tagbar
[20]: https://powerline.readthedocs.org/en/latest/fontpatching.html
[21]: https://bitbucket.org/ludovicchabant/vim-lawrencium
[22]: https://github.com/MarcWeber/vim-addon-manager
[23]: https://github.com/altercation/solarized
[24]: https://github.com/chriskempson/tomorrow-theme
[25]: https://github.com/tomasr/molokai
[26]: https://github.com/nanotech/jellybeans.vim
[27]: https://github.com/bling/vim-airline/wiki/FAQ
[28]: https://github.com/chrisbra/csv.vim
[29]: https://github.com/airblade/vim-gitgutter
[30]: https://github.com/mhinz/vim-signify
[31]: https://github.com/jmcantrell/vim-virtualenv
[32]: https://github.com/chriskempson/base16-vim
[33]: https://github.com/bling/vim-airline/wiki/Test-Plan
[34]: http://eclim.org

View file

@ -0,0 +1,14 @@
#!/usr/bin/env rake
task :default => [:test]
task :ci => [:dump, :test]
task :dump do
sh 'vim --version'
end
task :test do
sh 'bundle exec vim-flavor test'
end

View file

@ -0,0 +1,170 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let g:airline_statusline_funcrefs = get(g:, 'airline_statusline_funcrefs', [])
let s:sections = ['a','b','c','gutter','x','y','z','warning']
let s:inactive_funcrefs = []
function! airline#add_statusline_func(name)
call airline#add_statusline_funcref(function(a:name))
endfunction
function! airline#add_statusline_funcref(function)
if index(g:airline_statusline_funcrefs, a:function) >= 0
echohl WarningMsg
echo 'The airline statusline funcref '.string(a:function).' has already been added.'
echohl NONE
return
endif
call add(g:airline_statusline_funcrefs, a:function)
endfunction
function! airline#remove_statusline_func(name)
let i = index(g:airline_statusline_funcrefs, function(a:name))
if i > -1
call remove(g:airline_statusline_funcrefs, i)
endif
endfunction
function! airline#add_inactive_statusline_func(name)
call add(s:inactive_funcrefs, function(a:name))
endfunction
function! airline#load_theme()
if exists('*airline#themes#{g:airline_theme}#refresh')
call airline#themes#{g:airline_theme}#refresh()
endif
let palette = g:airline#themes#{g:airline_theme}#palette
call airline#themes#patch(palette)
if exists('g:airline_theme_patch_func')
let Fn = function(g:airline_theme_patch_func)
call Fn(palette)
endif
call airline#highlighter#load_theme()
call airline#extensions#load_theme()
endfunction
function! airline#switch_theme(name)
try
let palette = g:airline#themes#{a:name}#palette "also lazy loads the theme
let g:airline_theme = a:name
catch
echohl WarningMsg | echo 'The specified theme cannot be found.' | echohl NONE
if exists('g:airline_theme')
return
else
let g:airline_theme = 'dark'
endif
endtry
let w:airline_lastmode = ''
call airline#update_statusline()
call airline#load_theme()
" this is required to prevent clobbering the startup info message, i don't know why...
call airline#check_mode(winnr())
endfunction
function! airline#switch_matching_theme()
if exists('g:colors_name')
try
let palette = g:airline#themes#{g:colors_name}#palette
call airline#switch_theme(g:colors_name)
return 1
catch
for map in items(g:airline_theme_map)
if match(g:colors_name, map[0]) > -1
call airline#switch_theme(map[1])
return 1
endif
endfor
endtry
endif
return 0
endfunction
function! airline#update_statusline()
for nr in filter(range(1, winnr('$')), 'v:val != winnr()')
call setwinvar(nr, 'airline_active', 0)
let context = { 'winnr': nr, 'active': 0, 'bufnr': winbufnr(nr) }
call s:invoke_funcrefs(context, s:inactive_funcrefs)
endfor
unlet! w:airline_render_left
unlet! w:airline_render_right
for section in s:sections
unlet! w:airline_section_{section}
endfor
let w:airline_active = 1
let context = { 'winnr': winnr(), 'active': 1, 'bufnr': winbufnr(winnr()) }
call s:invoke_funcrefs(context, g:airline_statusline_funcrefs)
endfunction
let s:contexts = {}
let s:core_funcrefs = [
\ function('airline#extensions#apply'),
\ function('airline#extensions#default#apply') ]
function! s:invoke_funcrefs(context, funcrefs)
let builder = airline#builder#new(a:context)
let err = airline#util#exec_funcrefs(a:funcrefs + s:core_funcrefs, builder, a:context)
if err == 1
let a:context.line = builder.build()
let s:contexts[a:context.winnr] = a:context
call setwinvar(a:context.winnr, '&statusline', '%!airline#statusline('.a:context.winnr.')')
endif
endfunction
function! airline#statusline(winnr)
if has_key(s:contexts, a:winnr)
return '%{airline#check_mode('.a:winnr.')}'.s:contexts[a:winnr].line
endif
" in rare circumstances this happens...see #276
return ''
endfunction
function! airline#check_mode(winnr)
let context = s:contexts[a:winnr]
if get(w:, 'airline_active', 1)
let l:m = mode()
if l:m ==# "i"
let l:mode = ['insert']
elseif l:m ==# "R"
let l:mode = ['replace']
elseif l:m =~# '\v(v|V||s|S|)'
let l:mode = ['visual']
else
let l:mode = ['normal']
endif
let w:airline_current_mode = get(g:airline_mode_map, l:m, l:m)
else
let l:mode = ['inactive']
let w:airline_current_mode = get(g:airline_mode_map, '__')
endif
if g:airline_detect_modified
if &modified
call add(l:mode, 'modified')
endif
endif
if g:airline_detect_paste && &paste
call add(l:mode, 'paste')
endif
let mode_string = join(l:mode)
if get(w:, 'airline_lastmode', '') != mode_string
call airline#highlighter#highlight_modified_inactive(context.bufnr)
call airline#highlighter#highlight(l:mode)
let w:airline_lastmode = mode_string
endif
return ''
endfunction

View file

@ -0,0 +1,74 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:prototype = {}
function! s:prototype.split(...)
let self._side = 0
let self._line .= '%#'.self._curgroup.'#'.(a:0 ? a:1 : '%=')
endfunction
function! s:prototype.add_section_spaced(group, contents)
call self.add_section(a:group, (g:airline_symbols.space).a:contents.(g:airline_symbols.space))
endfunction
function! s:prototype.add_section(group, contents)
if self._curgroup != ''
if self._curgroup == a:group
let self._line .= self._side ? self._context.left_alt_sep : self._context.right_alt_sep
else
call airline#highlighter#add_separator(self._curgroup, a:group, self._side)
let self._line .= '%#'.self._curgroup.'_to_'.a:group.'#'
let self._line .= self._side ? self._context.left_sep : self._context.right_sep
endif
endif
if self._curgroup != a:group
let self._line .= '%#'.a:group.'#'
endif
if self._context.active
let contents = []
let content_parts = split(a:contents, '__accent')
for cpart in content_parts
let accent = matchstr(cpart, '_\zs[^#]*\ze')
call add(contents, cpart)
endfor
let line = join(contents, a:group)
let line = substitute(line, '__restore__', a:group, 'g')
else
let line = substitute(a:contents, '%#__accent[^#]*#', '', 'g')
let line = substitute(line, '%#__restore__#', '', 'g')
endif
let self._line .= line
let self._curgroup = a:group
endfunction
function! s:prototype.add_raw(text)
let self._line .= a:text
endfunction
function! s:prototype.build()
if !self._context.active
let self._line = substitute(self._line, '%#.\{-}\ze#', '\0_inactive', 'g')
endif
return self._line
endfunction
function! airline#builder#new(context)
let builder = copy(s:prototype)
let builder._context = a:context
let builder._side = 1
let builder._curgroup = ''
let builder._line = ''
call extend(builder._context, {
\ 'left_sep': g:airline_left_sep,
\ 'left_alt_sep': g:airline_left_alt_sep,
\ 'right_sep': g:airline_right_sep,
\ 'right_alt_sep': g:airline_right_alt_sep,
\ }, 'keep')
return builder
endfunction

View file

@ -0,0 +1,50 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! airline#debug#profile1()
profile start airline-profile-switch.log
profile func *
profile file *
split
for i in range(1, 1000)
wincmd w
redrawstatus
endfor
profile pause
noautocmd qall!
endfunction
function! airline#debug#profile2()
profile start airline-profile-cursor.log
profile func *
profile file *
edit blank
call setline(1, 'all your base are belong to us')
call setline(2, 'all your base are belong to us')
let positions = [[1,2], [2,2], [1,2], [1,1]]
for i in range(1, 1000)
for pos in positions
call cursor(pos[0], pos[1])
redrawstatus
endfor
endfor
profile pause
noautocmd qall!
endfunction
function! airline#debug#profile3()
profile start airline-profile-mode.log
profile func *
profile file *
for i in range(1000)
startinsert
redrawstatus
stopinsert
redrawstatus
endfor
profile pause
noautocmd qall!
endfunction

View file

@ -0,0 +1,32 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! airline#deprecation#check()
if exists('g:airline_enable_fugitive') || exists('g:airline_fugitive_prefix')
echom 'The g:airline_enable_fugitive and g:airline_fugitive_prefix variables are obsolete. Please read the documentation about the branch extension.'
endif
let tests = [
\ [ 'g:airline_paste_symbol', 'g:airline_symbols.paste' ],
\ [ 'g:airline_readonly_symbol', 'g:airline_symbols.readonly' ],
\ [ 'g:airline_linecolumn_prefix', 'g:airline_symbols.linenr' ],
\ [ 'g:airline_branch_prefix', 'g:airline_symbols.branch' ],
\ [ 'g:airline_branch_empty_message', 'g:airline#extensions#branch#empty_message' ],
\ [ 'g:airline_detect_whitespace', 'g:airline#extensions#whitespace#enabled|show_message' ],
\ [ 'g:airline_enable_hunks', 'g:airline#extensions#hunks#enabled' ],
\ [ 'g:airline_enable_tagbar', 'g:airline#extensions#tagbar#enabled' ],
\ [ 'g:airline_enable_csv', 'g:airline#extensions#csv#enabled' ],
\ [ 'g:airline_enable_branch', 'g:airline#extensions#branch#enabled' ],
\ [ 'g:airline_enable_bufferline', 'g:airline#extensions#bufferline#enabled' ],
\ [ 'g:airline_enable_syntastic', 'g:airline#extensions#syntastic#enabled' ],
\ [ 'g:airline_enable_eclim', 'g:airline#extensions#eclim#enabled' ],
\ ]
for test in tests
if exists(test[0])
let max = winwidth(0) - 16
let msg = printf('The variable %s is deprecated and may not work in the future. It has been replaced with %s. Please read the documentation.', test[0], test[1])
echom msg[:max].'...'
endif
endfor
endfunction

View file

@ -0,0 +1,215 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:ext = {}
let s:ext._theme_funcrefs = []
function! s:ext.add_statusline_func(name) dict
call airline#add_statusline_func(a:name)
endfunction
function! s:ext.add_statusline_funcref(function) dict
call airline#add_statusline_funcref(a:function)
endfunction
function! s:ext.add_inactive_statusline_func(name) dict
call airline#add_inactive_statusline_func(a:name)
endfunction
function! s:ext.add_theme_func(name) dict
call add(self._theme_funcrefs, function(a:name))
endfunction
let s:script_path = tolower(resolve(expand('<sfile>:p:h')))
let s:filetype_overrides = {
\ 'netrw': [ 'netrw', '%f' ],
\ 'nerdtree': [ 'NERD', '' ],
\ 'gundo': [ 'Gundo', '' ],
\ 'diff': [ 'diff', '' ],
\ 'vimfiler': [ 'vimfiler', '%{vimfiler#get_status_string()}' ],
\ 'minibufexpl': [ 'MiniBufExplorer', '' ],
\ 'startify': [ 'startify', '' ],
\ }
let s:filetype_regex_overrides = {}
function! s:check_defined_section(name)
if !exists('w:airline_section_{a:name}')
let w:airline_section_{a:name} = g:airline_section_{a:name}
endif
endfunction
function! airline#extensions#append_to_section(name, value)
call <sid>check_defined_section(a:name)
let w:airline_section_{a:name} .= a:value
endfunction
function! airline#extensions#prepend_to_section(name, value)
call <sid>check_defined_section(a:name)
let w:airline_section_{a:name} = a:value . w:airline_section_{a:name}
endfunction
function! airline#extensions#apply_left_override(section1, section2)
let w:airline_section_a = a:section1
let w:airline_section_b = a:section2
let w:airline_section_c = airline#section#create(['readonly'])
let w:airline_render_left = 1
let w:airline_render_right = 0
endfunction
let s:active_winnr = -1
function! airline#extensions#apply(...)
let s:active_winnr = winnr()
if s:is_excluded_window()
return -1
endif
if &buftype == 'help'
call airline#extensions#apply_left_override('Help', '%f')
let w:airline_section_x = ''
let w:airline_section_y = ''
let w:airline_render_right = 1
endif
if &previewwindow
let w:airline_section_a = 'Preview'
let w:airline_section_b = ''
let w:airline_section_c = bufname(winbufnr(winnr()))
endif
if has_key(s:filetype_overrides, &ft)
let args = s:filetype_overrides[&ft]
call airline#extensions#apply_left_override(args[0], args[1])
endif
for item in items(s:filetype_regex_overrides)
if match(&ft, item[0]) >= 0
call airline#extensions#apply_left_override(item[1][0], item[1][1])
endif
endfor
endfunction
function! s:is_excluded_window()
for matchft in g:airline_exclude_filetypes
if matchft ==# &ft
return 1
endif
endfor
for matchw in g:airline_exclude_filenames
if matchstr(expand('%'), matchw) ==# matchw
return 1
endif
endfor
if g:airline_exclude_preview && &previewwindow
return 1
endif
return 0
endfunction
function! airline#extensions#load_theme()
call airline#util#exec_funcrefs(s:ext._theme_funcrefs, g:airline#themes#{g:airline_theme}#palette)
endfunction
function! s:sync_active_winnr()
if exists('#airline') && winnr() != s:active_winnr
call airline#update_statusline()
endif
endfunction
function! airline#extensions#load()
" non-trivial number of external plugins use eventignore=all, so we need to account for that
autocmd CursorMoved * call <sid>sync_active_winnr()
call airline#extensions#quickfix#init(s:ext)
if get(g:, 'loaded_unite', 0)
call airline#extensions#unite#init(s:ext)
endif
if get(g:, 'loaded_vimfiler', 0)
let g:vimfiler_force_overwrite_statusline = 0
endif
if get(g:, 'loaded_ctrlp', 0)
call airline#extensions#ctrlp#init(s:ext)
endif
if get(g:, 'command_t_loaded', 0)
call airline#extensions#commandt#init(s:ext)
endif
if exists(':UndotreeToggle')
call airline#extensions#undotree#init(s:ext)
endif
if (get(g:, 'airline#extensions#hunks#enabled', 1) && get(g:, 'airline_enable_hunks', 1))
\ && (exists('g:loaded_signify') || exists('g:loaded_gitgutter'))
call airline#extensions#hunks#init(s:ext)
endif
if (get(g:, 'airline#extensions#tagbar#enabled', 1) && get(g:, 'airline_enable_tagbar', 1))
\ && exists(':TagbarToggle')
call airline#extensions#tagbar#init(s:ext)
endif
if (get(g:, 'airline#extensions#csv#enabled', 1) && get(g:, 'airline_enable_csv', 1))
\ && (get(g:, 'loaded_csv', 0) || exists(':Table'))
call airline#extensions#csv#init(s:ext)
endif
if exists(':VimShell')
let s:filetype_overrides['vimshell'] = ['vimshell','%{vimshell#get_status_string()}']
let s:filetype_regex_overrides['^int-'] = ['vimshell','%{substitute(&ft, "int-", "", "")}']
endif
if (get(g:, 'airline#extensions#branch#enabled', 1) && get(g:, 'airline_enable_branch', 1))
\ && (exists('*fugitive#head') || exists('*lawrencium#statusline'))
call airline#extensions#branch#init(s:ext)
endif
if (get(g:, 'airline#extensions#bufferline#enabled', 1) && get(g:, 'airline_enable_bufferline', 1))
\ && exists('*bufferline#get_status_string')
call airline#extensions#bufferline#init(s:ext)
endif
if get(g:, 'virtualenv_loaded', 0) && get(g:, 'airline#extensions#virtualenv#enabled', 1)
call airline#extensions#virtualenv#init(s:ext)
endif
if (get(g:, 'airline#extensions#eclim#enabled', 1) && exists(':ProjectCreate'))
call airline#extensions#eclim#init(s:ext)
endif
if (get(g:, 'airline#extensions#syntastic#enabled', 1) && get(g:, 'airline_enable_syntastic', 1))
\ && exists(':SyntasticCheck')
call airline#extensions#syntastic#init(s:ext)
endif
if (get(g:, 'airline#extensions#whitespace#enabled', 1) && get(g:, 'airline_detect_whitespace', 1))
call airline#extensions#whitespace#init(s:ext)
endif
if get(g:, 'airline#extensions#tabline#enabled', 0)
call airline#extensions#tabline#init(s:ext)
endif
" load all other extensions not part of the default distribution
for file in split(globpath(&rtp, "autoload/airline/extensions/*.vim"), "\n")
" we have to check both resolved and unresolved paths, since it's possible
" that they might not get resolved properly (see #187)
if stridx(tolower(resolve(fnamemodify(file, ':p'))), s:script_path) < 0
\ && stridx(tolower(fnamemodify(file, ':p')), s:script_path) < 0
let name = fnamemodify(file, ':t:r')
if !get(g:, 'airline#extensions#'.name.'#enabled', 1)
continue
endif
try
call airline#extensions#{name}#init(s:ext)
catch
endtry
endif
endfor
endfunction

View file

@ -0,0 +1,76 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:has_fugitive = exists('*fugitive#head')
let s:has_fugitive_detect = exists('*fugitive#detect')
let s:has_lawrencium = exists('*lawrencium#statusline')
let s:has_vcscommand = get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine')
if !s:has_fugitive && !s:has_lawrencium && !s:has_vcscommand
finish
endif
let s:empty_message = get(g:, 'airline#extensions#branch#empty_message',
\ get(g:, 'airline_branch_empty_message', ''))
let s:symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch)
function! airline#extensions#branch#get_head()
let head = ''
if s:has_fugitive && !exists('b:mercurial_dir')
let head = fugitive#head()
if empty(head) && s:has_fugitive_detect && !exists('b:git_dir')
call fugitive#detect(getcwd())
let head = fugitive#head()
endif
endif
if empty(head)
if s:has_lawrencium
let head = lawrencium#statusline()
endif
endif
if empty(head)
if s:has_vcscommand
call VCSCommandEnableBufferSetup()
if exists('b:VCSCommandBufferInfo')
let head = get(b:VCSCommandBufferInfo, 0, '')
endif
endif
endif
return empty(head) || !s:check_in_path()
\ ? s:empty_message
\ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.(g:airline_symbols.space), head)
endfunction
function! s:check_in_path()
if !exists('b:airline_branch_path')
let root = get(b:, 'git_dir', get(b:, 'mercurial_dir', ''))
let bufferpath = resolve(fnamemodify(expand('%'), ':p:h'))
if !filereadable(root) "not a file
" if .git is a directory, it's the old submodule format
if match(root, '\.git$') >= 0
let root = expand(fnamemodify(root, ':h'))
else
" else it's the newer format, and we need to guesstimate
let pattern = '\.git\(\\\|\/\)modules\(\\\|\/\)'
if match(root, pattern) >= 0
let root = substitute(root, pattern, '', '')
endif
endif
let b:airline_file_in_root = stridx(bufferpath, root) > -1
endif
return b:airline_file_in_root
endfunction
function! airline#extensions#branch#init(ext)
call airline#parts#define_function('branch', 'airline#extensions#branch#get_head')
autocmd BufReadPost * unlet! b:airline_file_in_root
endfunction

View file

@ -0,0 +1,23 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !exists('*bufferline#get_status_string')
finish
endif
let s:overwrite = get(g:, 'airline#extensions#bufferline#overwrite_variables', 1)
function! airline#extensions#bufferline#init(ext)
if s:overwrite
highlight bufferline_selected gui=bold cterm=bold term=bold
highlight link bufferline_selected_inactive airline_c_inactive
let g:bufferline_inactive_highlight = 'airline_c'
let g:bufferline_active_highlight = 'bufferline_selected'
let g:bufferline_active_buffer_left = ''
let g:bufferline_active_buffer_right = ''
let g:bufferline_separator = g:airline_symbols.space
endif
call airline#parts#define_raw('file', '%{bufferline#refresh_status()}'.bufferline#get_status_string())
endfunction

View file

@ -0,0 +1,16 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !get(g:, 'command_t_loaded', 0)
finish
endif
function! airline#extensions#commandt#apply(...)
if bufname('%') ==# 'GoToFile'
call airline#extensions#apply_left_override('CommandT', '')
endif
endfunction
function! airline#extensions#commandt#init(ext)
call a:ext.add_statusline_func('airline#extensions#commandt#apply')
endfunction

View file

@ -0,0 +1,31 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_csv', 0) && !exists(':Table')
finish
endif
let s:column_display = get(g:, 'airline#extensions#csv#column_display', 'Number')
function! airline#extensions#csv#get_column()
if exists('*CSV_WCol')
if s:column_display ==# 'Name'
return '['.CSV_WCol('Name').CSV_WCol().']'
else
return '['.CSV_WCol().']'
endif
endif
return ''
endfunction
function! airline#extensions#csv#apply(...)
if &ft ==# "csv"
call airline#extensions#prepend_to_section('gutter',
\ g:airline_left_alt_sep.' %{airline#extensions#csv#get_column()}')
endif
endfunction
function! airline#extensions#csv#init(ext)
call a:ext.add_statusline_func('airline#extensions#csv#apply')
endfunction

View file

@ -0,0 +1,77 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_ctrlp', 0)
finish
endif
let s:color_template = get(g:, 'airline#extensions#ctrlp#color_template', 'insert')
function! airline#extensions#ctrlp#generate_color_map(dark, light, white)
return {
\ 'CtrlPdark' : a:dark,
\ 'CtrlPlight' : a:light,
\ 'CtrlPwhite' : a:white,
\ 'CtrlParrow1' : [ a:light[1] , a:white[1] , a:light[3] , a:white[3] , '' ] ,
\ 'CtrlParrow2' : [ a:white[1] , a:light[1] , a:white[3] , a:light[3] , '' ] ,
\ 'CtrlParrow3' : [ a:light[1] , a:dark[1] , a:light[3] , a:dark[3] , '' ] ,
\ }
endfunction
function! airline#extensions#ctrlp#load_theme(palette)
if exists('a:palette.ctrlp')
let theme = a:palette.ctrlp
else
let s:color_template = has_key(a:palette, s:color_template) ? s:color_template : 'insert'
let theme = airline#extensions#ctrlp#generate_color_map(
\ a:palette[s:color_template]['airline_c'],
\ a:palette[s:color_template]['airline_b'],
\ a:palette[s:color_template]['airline_a'])
endif
for key in keys(theme)
call airline#highlighter#exec(key, theme[key])
endfor
endfunction
" Arguments: focus, byfname, regexp, prv, item, nxt, marked
function! airline#extensions#ctrlp#ctrlp_airline(...)
let b = airline#builder#new({'active': 1})
if a:3
call b.add_section_spaced('CtrlPlight', 'regex')
endif
if get(g:, 'airline#extensions#ctrlp#show_adjacent_modes', 1)
call b.add_section_spaced('CtrlPlight', a:4)
call b.add_section_spaced('CtrlPwhite', a:5)
call b.add_section_spaced('CtrlPlight', a:6)
else
call b.add_section_spaced('CtrlPwhite', a:5)
endif
call b.add_section_spaced('CtrlPdark', a:7)
call b.split()
call b.add_raw('%#CtrlPdark#'.a:1.(g:airline_symbols.space))
call b.add_section_spaced('CtrlPdark', a:2)
call b.add_section_spaced('CtrlPlight', '%{getcwd()}')
return b.build()
endfunction
" Argument: len
function! airline#extensions#ctrlp#ctrlp_airline_status(...)
let len = '%#CtrlPdark# '.a:1
let dir = '%=%<%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*'
return len.dir
endfunction
function! airline#extensions#ctrlp#apply(...)
" disable statusline overwrite if ctrlp already did it
return match(&statusline, 'CtrlPwhite') >= 0 ? -1 : 0
endfunction
function! airline#extensions#ctrlp#init(ext)
let g:ctrlp_status_func = {
\ 'main': 'airline#extensions#ctrlp#ctrlp_airline',
\ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status',
\ }
call a:ext.add_statusline_func('airline#extensions#ctrlp#apply')
call a:ext.add_theme_func('airline#extensions#ctrlp#load_theme')
endfunction

View file

@ -0,0 +1,77 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:section_truncate_width = get(g:, 'airline#extensions#default#section_truncate_width', {
\ 'b': 79,
\ 'x': 60,
\ 'y': 88,
\ 'z': 45,
\ })
let s:layout = get(g:, 'airline#extensions#default#layout', [
\ [ 'a', 'b', 'c' ],
\ [ 'x', 'y', 'z', 'warning' ]
\ ])
function! s:get_section(winnr, key, ...)
if has_key(s:section_truncate_width, a:key)
if winwidth(a:winnr) < s:section_truncate_width[a:key]
return ''
endif
endif
let spc = g:airline_symbols.space
let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key})
let [prefix, suffix] = [get(a:000, 0, '%('.spc), get(a:000, 1, spc.'%)')]
return empty(text) ? '' : prefix.text.suffix
endfunction
function! s:build_sections(builder, context, keys)
for key in a:keys
if key == 'warning' && !a:context.active
continue
endif
call s:add_section(a:builder, a:context, key)
endfor
endfunction
if v:version >= 704 || (v:version >= 703 && has('patch81'))
function s:add_section(builder, context, key)
" i have no idea why the warning section needs special treatment, but it's
" needed to prevent separators from showing up
if a:key == 'warning'
call a:builder.add_raw('%(')
endif
call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key))
if a:key == 'warning'
call a:builder.add_raw('%)')
endif
endfunction
else
" older version don't like the use of %(%)
function s:add_section(builder, context, key)
if a:key == 'warning'
call a:builder.add_raw('%#airline_warning#'.s:get_section(a:context.winnr, a:key))
else
call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key))
endif
endfunction
endif
function! airline#extensions#default#apply(builder, context)
let winnr = a:context.winnr
let active = a:context.active
if airline#util#getwinvar(winnr, 'airline_render_left', active || (!active && !g:airline_inactive_collapse))
call <sid>build_sections(a:builder, a:context, s:layout[0])
else
call a:builder.add_section('airline_c'.(a:context.bufnr), ' %f%m ')
endif
call a:builder.split(s:get_section(winnr, 'gutter', '', ''))
if airline#util#getwinvar(winnr, 'airline_render_right', 1)
call <sid>build_sections(a:builder, a:context, s:layout[1])
endif
return 1
endfunction

View file

@ -0,0 +1,35 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !exists(':ProjectCreate')
finish
endif
function! airline#extensions#eclim#creat_line(...)
if &filetype == "tree"
let builder = a:1
call builder.add_section('airline_a', ' Project ')
call builder.add_section('airline_b', ' %f ')
call builder.add_section('airline_c', '')
return 1
endif
endfunction
function! airline#extensions#eclim#get_warnings()
let eclimList = eclim#display#signs#GetExisting()
if !empty(eclimList)
let errorsLine = eclimList[0]['line']
let errorsNumber = len(eclimList)
let errors = "[Eclim: line:".string(errorsLine)." (".string(errorsNumber).")]"
if !exists(':SyntasticCheck') || SyntasticStatuslineFlag() == ''
return errors.(g:airline_symbols.space)
endif
endif
return ''
endfunction
function! airline#extensions#eclim#init(ext)
call airline#parts#define_function('eclim', 'airline#extensions#eclim#get_warnings')
call a:ext.add_statusline_func('airline#extensions#eclim#creat_line')
endfunction

View file

@ -0,0 +1,54 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
" we don't actually want this loaded :P
finish
" Due to some potential rendering issues, the use of the `space` variable is
" recommended.
let s:spc = g:airline_symbols.space
" Extension specific variables can be defined the usual fashion.
if !exists('g:airline#extensions#example#number_of_cats')
let g:airline#extensions#example#number_of_cats = 42
endif
" First we define an init function that will be invoked from extensions.vim
function! airline#extensions#example#init(ext)
" Here we define a new part for the plugin. This allows users to place this
" extension in arbitrary locations.
call airline#parts#define_raw('cats', '%{airline#extensions#example#get_cats()}')
" Next up we add a funcref so that we can run some code prior to the
" statusline getting modifed.
call a:ext.add_statusline_func('airline#extensions#example#apply')
" You can also add a funcref for inactive statuslines.
" call a:ext.add_inactive_statusline_func('airline#extensions#example#unapply')
endfunction
" This function will be invoked just prior to the statusline getting modified.
function! airline#extensions#example#apply(...)
" First we check for the filetype.
if &filetype == "nyancat"
" Let's say we want to append to section_c, first we check if there's
" already a window-local override, and if not, create it off of the global
" section_c.
let w:airline_section_c = get(w:, 'airline_section_c', g:airline_section_c)
" Then we just append this extenion to it, optionally using separators.
let w:airline_section_c .= s:spc.g:airline_left_alt_sep.s:spc.'%{airline#extensions#example#get_cats()}'
endif
endfunction
" Finally, this function will be invoked from the statusline.
function! airline#extensions#example#get_cats()
let cats = ''
for i in range(1, g:airline#extensions#example#number_of_cats)
let cats .= ' (,,,)=(^.^)=(,,,) '
endfor
return cats
endfunction

View file

@ -0,0 +1,63 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0)
finish
endif
let s:non_zero_only = get(g:, 'airline#extensions#hunks#non_zero_only', 0)
let s:hunk_symbols = get(g:, 'airline#extensions#hunks#hunk_symbols', ['+', '~', '-'])
function! s:get_hunks_signify()
let hunks = sy#repo#get_stats()
if hunks[0] >= 0
return hunks
endif
return []
endfunction
function! s:get_hunks_gitgutter()
if !get(g:, 'gitgutter_enabled', 0)
return ''
endif
return GitGutterGetHunkSummary()
endfunction
function! s:get_hunks_empty()
return ''
endfunction
let s:source_func = ''
function! s:get_hunks()
if empty(s:source_func)
if get(g:, 'loaded_signify', 0)
let s:source_func = 's:get_hunks_signify'
elseif exists('*GitGutterGetHunkSummary')
let s:source_func = 's:get_hunks_gitgutter'
else
let s:source_func = 's:get_hunks_empty'
endif
endif
return {s:source_func}()
endfunction
function! airline#extensions#hunks#get_hunks()
if !get(w:, 'airline_active', 0)
return ''
endif
let hunks = s:get_hunks()
let string = ''
if !empty(hunks)
for i in [0, 1, 2]
if s:non_zero_only == 0 || hunks[i] > 0
let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i])
endif
endfor
endif
return string
endfunction
function! airline#extensions#hunks#init(ext)
call airline#parts#define_function('hunks', 'airline#extensions#hunks#get_hunks')
endfunction

View file

@ -0,0 +1,37 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let g:airline#extensions#quickfix#quickfix_text = 'Quickfix'
let g:airline#extensions#quickfix#location_text = 'Location'
function! airline#extensions#quickfix#apply(...)
if &buftype == 'quickfix'
let w:airline_section_a = s:get_text()
let w:airline_section_b = '%{get(w:, "quickfix_title", "")}'
let w:airline_section_c = ''
let w:airline_section_x = ''
endif
endfunction
function! airline#extensions#quickfix#init(ext)
call a:ext.add_statusline_func('airline#extensions#quickfix#apply')
endfunction
function! s:get_text()
redir => buffers
silent ls
redir END
let nr = bufnr('%')
for buf in split(buffers, '\n')
if match(buf, '\v^\s+'.nr) > -1
if match(buf, '\[Quickfix List\]') > -1
return g:airline#extensions#quickfix#quickfix_text
else
return g:airline#extensions#quickfix#location_text
endif
endif
endfor
return ''
endfunction

View file

@ -0,0 +1,19 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !exists(':SyntasticCheck')
finish
endif
function! airline#extensions#syntastic#get_warnings()
let errors = SyntasticStatuslineFlag()
if strlen(errors) > 0
return errors.(g:airline_symbols.space)
endif
return ''
endfunction
function! airline#extensions#syntastic#init(ext)
call airline#parts#define_function('syntastic', 'airline#extensions#syntastic#get_warnings')
endfunction

View file

@ -0,0 +1,243 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:formatter = get(g:, 'airline#extensions#tabline#formatter', 'default')
let s:excludes = get(g:, 'airline#extensions#tabline#excludes', [])
let s:tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0)
let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
let s:builder_context = {
\ 'active' : 1,
\ 'right_sep' : get(g:, 'airline#extensions#tabline#right_sep' , g:airline_right_sep),
\ 'right_alt_sep' : get(g:, 'airline#extensions#tabline#right_alt_sep', g:airline_right_alt_sep),
\ }
if get(g:, 'airline_powerline_fonts', 0)
let s:builder_context.left_sep = get(g:, 'airline#extensions#tabline#left_sep' , "\ue0b0")
let s:builder_context.left_alt_sep = get(g:, 'airline#extensions#tabline#left_alt_sep' , "\ue0b1")
else
let s:builder_context.left_sep = get(g:, 'airline#extensions#tabline#left_sep' , ' ')
let s:builder_context.left_alt_sep = get(g:, 'airline#extensions#tabline#left_alt_sep' , '|')
endif
let s:buf_min_count = get(g:, 'airline#extensions#tabline#buffer_min_count', 0)
let s:tab_min_count = get(g:, 'airline#extensions#tabline#tab_min_count', 0)
let s:spc = g:airline_symbols.space
function! airline#extensions#tabline#init(ext)
if has('gui_running')
set guioptions-=e
endif
autocmd User AirlineToggledOn call s:toggle_on()
autocmd User AirlineToggledOff call s:toggle_off()
call s:toggle_on()
call a:ext.add_theme_func('airline#extensions#tabline#load_theme')
endfunction
function! s:toggle_off()
if exists('s:original_tabline')
let &tabline = s:original_tabline
let &showtabline = s:original_showtabline
endif
endfunction
function! s:toggle_on()
let [ s:original_tabline, s:original_showtabline ] = [ &tabline, &showtabline ]
set tabline=%!airline#extensions#tabline#get()
if s:buf_min_count <= 0 && s:tab_min_count <= 1
set showtabline=2
else
augroup airline_tabline
autocmd!
if s:show_buffers == 1
autocmd CursorMoved * call <sid>on_cursormove(s:buf_min_count, len(s:get_buffer_list()))
else
autocmd TabEnter * call <sid>on_cursormove(s:tab_min_count, tabpagenr('$'))
endif
augroup END
endif
endfunction
function! airline#extensions#tabline#load_theme(palette)
let colors = get(a:palette, 'tabline', {})
let l:tab = get(colors, 'airline_tab', a:palette.normal.airline_b)
let l:tabsel = get(colors, 'airline_tabsel', a:palette.normal.airline_a)
let l:tabtype = get(colors, 'airline_tabtype', a:palette.visual.airline_a)
let l:tabfill = get(colors, 'airline_tabfill', a:palette.normal.airline_c)
let l:tabmod = get(colors, 'airline_tabmod', a:palette.insert.airline_a)
let l:tabhid = get(colors, 'airline_tabhid', a:palette.normal.airline_c)
call airline#highlighter#exec('airline_tab', l:tab)
call airline#highlighter#exec('airline_tabsel', l:tabsel)
call airline#highlighter#exec('airline_tabtype', l:tabtype)
call airline#highlighter#exec('airline_tabfill', l:tabfill)
call airline#highlighter#exec('airline_tabmod', l:tabmod)
call airline#highlighter#exec('airline_tabhid', l:tabhid)
endfunction
function! s:on_cursormove(min_count, total_count)
if a:total_count >= a:min_count
if &showtabline != 2
set showtabline=2
endif
else
if &showtabline != 0
set showtabline=0
endif
endif
endfunction
function! airline#extensions#tabline#get()
if s:show_buffers && tabpagenr('$') == 1
return s:get_buffers()
else
return s:get_tabs()
endif
endfunction
function! airline#extensions#tabline#title(n)
let buflist = tabpagebuflist(a:n)
let winnr = tabpagewinnr(a:n)
return airline#extensions#tabline#get_buffer_name(buflist[winnr - 1])
endfunction
function! airline#extensions#tabline#get_buffer_name(nr)
return airline#extensions#tabline#formatters#{s:formatter}(a:nr, get(s:, 'current_buffer_list', []))
endfunction
function! s:get_buffer_list()
let buffers = []
let cur = bufnr('%')
for nr in range(1, bufnr('$'))
if buflisted(nr) && bufexists(nr)
for ex in s:excludes
if match(bufname(nr), ex)
continue
endif
endfor
if getbufvar(nr, 'current_syntax') == 'qf'
continue
endif
call add(buffers, nr)
endif
endfor
let s:current_buffer_list = buffers
return buffers
endfunction
function! s:get_visible_buffers()
let buffers = s:get_buffer_list()
let cur = bufnr('%')
let total_width = 0
let max_width = 0
for nr in buffers
let width = len(airline#extensions#tabline#get_buffer_name(nr)) + 4
let total_width += width
let max_width = max([max_width, width])
endfor
" only show current and surrounding buffers if there are too many buffers
let position = index(buffers, cur)
let vimwidth = &columns
if total_width > vimwidth && position > -1
let buf_count = len(buffers)
" determine how many buffers to show based on the longest buffer width,
" use one on the right side and put the rest on the left
let buf_max = vimwidth / max_width
let buf_right = 1
let buf_left = max([0, buf_max - buf_right])
let start = max([0, position - buf_left])
let end = min([buf_count, position + buf_right])
" fill up available space on the right
if position < buf_left
let end += (buf_left - position)
endif
" fill up available space on the left
if end > buf_count - 1 - buf_right
let start -= max([0, buf_right - (buf_count - 1 - position)])
endif
let buffers = eval('buffers[' . start . ':' . end . ']')
if start > 0
call insert(buffers, -1, 0)
endif
if end < buf_count - 1
call add(buffers, -1)
endif
endif
return buffers
endfunction
function! s:get_buffers()
let b = airline#builder#new(s:builder_context)
let cur = bufnr('%')
let tab_bufs = tabpagebuflist(tabpagenr())
for nr in s:get_visible_buffers()
if nr < 0
call b.add_raw('%#airline_tabhid#...')
continue
endif
if cur == nr
if g:airline_detect_modified && getbufvar(nr, '&modified')
let group = 'airline_tabmod'
else
let group = 'airline_tabsel'
endif
else
if index(tab_bufs, nr) > -1
let group = 'airline_tab'
else
let group = 'airline_tabhid'
endif
endif
call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc)
endfor
call b.add_section('airline_tabfill', '')
call b.split()
call b.add_section('airline_tabtype', ' buffers ')
return b.build()
endfunction
function! s:get_tabs()
let b = airline#builder#new(s:builder_context)
for i in range(1, tabpagenr('$'))
if i == tabpagenr()
let group = 'airline_tabsel'
if g:airline_detect_modified
for bi in tabpagebuflist(i)
if getbufvar(bi, '&modified')
let group = 'airline_tabmod'
endif
endfor
endif
else
let group = 'airline_tab'
endif
let val = '%('
if s:tab_nr_type == 0
let val .= ' %{len(tabpagebuflist('.i.'))}'
else
let val .= (g:airline_symbols.space).i
endif
call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)')
endfor
call b.add_raw('%T')
call b.add_section('airline_tabfill', '')
call b.split()
call b.add_section('airline_tab', ' %999XX ')
call b.add_section('airline_tabtype', ' tabs ')
return b.build()
endfunction

View file

@ -0,0 +1,60 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1)
let s:buf_nr_format = get(g:, 'airline#extensions#tabline#buffer_nr_format', '%s: ')
let s:buf_nr_show = get(g:, 'airline#extensions#tabline#buffer_nr_show', 0)
let s:buf_modified_symbol = g:airline_symbols.modified
function! airline#extensions#tabline#formatters#default(bufnr, buffers)
let _ = ''
let name = bufname(a:bufnr)
if empty(name)
let _ .= '[No Name]'
else
if s:fnamecollapse
let _ .= substitute(fnamemodify(name, s:fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')
else
let _ .= fnamemodify(name, s:fmod)
endif
endif
return s:wrap_name(a:bufnr, _)
endfunction
function! airline#extensions#tabline#formatters#unique_tail(bufnr, buffers)
let duplicates = {}
let tails = {}
let map = {}
for nr in a:buffers
let name = bufname(nr)
if empty(name)
let map[nr] = '[No Name]'
else
let tail = fnamemodify(name, ':t')
if has_key(tails, tail)
let duplicates[nr] = nr
endif
let tails[tail] = 1
let map[nr] = s:wrap_name(nr, tail)
endif
endfor
for nr in values(duplicates)
let map[nr] = s:wrap_name(nr, fnamemodify(bufname(nr), ':p:.'))
endfor
return map[a:bufnr]
endfunction
function! s:wrap_name(bufnr, buffer_name)
let _ = s:buf_nr_show ? printf(s:buf_nr_format, a:bufnr) : ''
let _ .= a:buffer_name
if getbufvar(a:bufnr, '&modified') == 1
let _ .= s:buf_modified_symbol
endif
return _
endfunction

View file

@ -0,0 +1,39 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !exists(':TagbarToggle')
finish
endif
let s:flags = get(g:, 'airline#extensions#tagbar#flags', '')
let s:spc = g:airline_symbols.space
" Arguments: current, sort, fname
function! airline#extensions#tagbar#get_status(...)
let builder = airline#builder#new({ 'active': a:1 })
call builder.add_section('airline_a', s:spc.'Tagbar'.s:spc)
call builder.add_section('airline_b', s:spc.a:2.s:spc)
call builder.add_section('airline_c', s:spc.a:3.s:spc)
return builder.build()
endfunction
function! airline#extensions#tagbar#inactive_apply(...)
if getwinvar(a:2.winnr, '&filetype') == 'tagbar'
return -1
endif
endfunction
function! airline#extensions#tagbar#currenttag()
if get(w:, 'airline_active', 0)
return tagbar#currenttag('%s', '', s:flags)
endif
return ''
endfunction
function! airline#extensions#tagbar#init(ext)
call a:ext.add_inactive_statusline_func('airline#extensions#tagbar#inactive_apply')
let g:tagbar_status_func = 'airline#extensions#tagbar#get_status'
call airline#parts#define_function('tagbar', 'airline#extensions#tagbar#currenttag')
endfunction

View file

@ -0,0 +1,27 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !exists(':UndotreeToggle')
finish
endif
function! airline#extensions#undotree#apply(...)
if exists('t:undotree')
if &ft == 'undotree'
if exists('*t:undotree.GetStatusLine')
call airline#extensions#apply_left_override('undo', '%{t:undotree.GetStatusLine()}')
else
call airline#extensions#apply_left_override('undotree', '%f')
endif
endif
if &ft == 'diff' && exists('*t:diffpanel.GetStatusLine')
call airline#extensions#apply_left_override('diff', '%{t:diffpanel.GetStatusLine()}')
endif
endif
endfunction
function! airline#extensions#undotree#init(ext)
call a:ext.add_statusline_func('airline#extensions#undotree#apply')
endfunction

View file

@ -0,0 +1,23 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_unite', 0)
finish
endif
function! airline#extensions#unite#apply(...)
if &ft == 'unite'
call a:1.add_section('airline_a', ' Unite ')
call a:1.add_section('airline_b', ' %{get(unite#get_context(), "buffer_name", "")} ')
call a:1.add_section('airline_c', ' %{unite#get_status_string()} ')
call a:1.split()
call a:1.add_section('airline_y', ' %{get(unite#get_context(), "real_buffer_name", "")} ')
return 1
endif
endfunction
function! airline#extensions#unite#init(ext)
let g:unite_force_overwrite_statusline = 0
call a:ext.add_statusline_func('airline#extensions#unite#apply')
endfunction

View file

@ -0,0 +1,20 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !get(g:, 'virtualenv_loaded', 0)
finish
endif
let s:spc = g:airline_symbols.space
function! airline#extensions#virtualenv#init(ext)
call a:ext.add_statusline_func('airline#extensions#virtualenv#apply')
endfunction
function! airline#extensions#virtualenv#apply(...)
if &filetype =~ "python"
call airline#extensions#append_to_section('x',
\ s:spc.g:airline_right_alt_sep.s:spc.'%{virtualenv#statusline()}')
endif
endfunction

View file

@ -0,0 +1,78 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
" http://got-ravings.blogspot.com/2008/10/vim-pr0n-statusline-whitespace-flags.html
" for backwards compatibility
if exists('g:airline_detect_whitespace')
let s:show_message = g:airline_detect_whitespace == 1
else
let s:show_message = get(g:, 'airline#extensions#whitespace#show_message', 1)
endif
let s:symbol = get(g:, 'airline#extensions#whitespace#symbol', g:airline_symbols.whitespace)
let s:default_checks = ['indent', 'trailing']
let s:trailing_format = get(g:, 'airline#extensions#whitespace#trailing_format', 'trailing[%s]')
let s:mixed_indent_format = get(g:, 'airline#extensions#whitespace#mixed_indent_format', 'mixed-indent[%s]')
let s:enabled = 1
function! airline#extensions#whitespace#check()
if &readonly || !&modifiable || !s:enabled
return ''
endif
if !exists('b:airline_whitespace_check')
let b:airline_whitespace_check = ''
let checks = get(g:, 'airline#extensions#whitespace#checks', s:default_checks)
let trailing = 0
if index(checks, 'trailing') > -1
let trailing = search(' $', 'nw')
endif
let mixed = 0
if index(checks, 'indent') > -1
let indents = [search('^ \{2,}', 'nb'), search('^ \{2,}', 'n'), search('^\t', 'nb'), search('^\t', 'n')]
let mixed = indents[0] != 0 && indents[1] != 0 && indents[2] != 0 && indents[3] != 0
endif
if trailing != 0 || mixed
let b:airline_whitespace_check = s:symbol
if s:show_message
if trailing != 0
let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:trailing_format, trailing)
endif
if mixed
let mixnr = indents[0] == indents[1] ? indents[0] : indents[2]
let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:mixed_indent_format, mixnr)
endif
endif
endif
endif
return b:airline_whitespace_check
endfunction!
function! airline#extensions#whitespace#toggle()
if s:enabled
autocmd! airline_whitespace CursorHold,BufWritePost
augroup! airline_whitespace
let s:enabled = 0
else
call airline#extensions#whitespace#init()
let s:enabled = 1
endif
echo 'Whitespace checking: '.(s:enabled ? 'Enabled' : 'Disabled')
endfunction
function! airline#extensions#whitespace#init(...)
call airline#parts#define_function('whitespace', 'airline#extensions#whitespace#check')
unlet! b:airline_whitespace_check
augroup airline_whitespace
autocmd!
autocmd CursorHold,BufWritePost * unlet! b:airline_whitespace_check
augroup END
endfunction

View file

@ -0,0 +1,156 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running')
let s:separators = {}
let s:accents = {}
function! s:gui2cui(rgb, fallback)
if a:rgb == ''
return a:fallback
endif
let rgb = map(matchlist(a:rgb, '#\(..\)\(..\)\(..\)')[1:3], '0 + ("0x".v:val)')
let rgb = [rgb[0] > 127 ? 4 : 0, rgb[1] > 127 ? 2 : 0, rgb[2] > 127 ? 1 : 0]
return rgb[0]+rgb[1]+rgb[2]
endfunction
function! s:get_syn(group, what)
" need to pass in mode, known to break on 7.3.547
let mode = has('gui_running') ? 'gui' : 'cterm'
let color = synIDattr(synIDtrans(hlID(a:group)), a:what, mode)
if empty(color) || color == -1
let color = synIDattr(synIDtrans(hlID('Normal')), a:what, mode)
endif
if empty(color) || color == -1
if has('gui_running')
let color = a:what ==# 'fg' ? '#000000' : '#FFFFFF'
else
let color = a:what ==# 'fg' ? 0 : 1
endif
endif
return color
endfunction
function! s:get_array(fg, bg, opts)
let fg = a:fg
let bg = a:bg
return has('gui_running')
\ ? [ fg, bg, '', '', join(a:opts, ',') ]
\ : [ '', '', fg, bg, join(a:opts, ',') ]
endfunction
function! airline#highlighter#get_highlight(group, ...)
let fg = s:get_syn(a:group, 'fg')
let bg = s:get_syn(a:group, 'bg')
let reverse = synIDattr(synIDtrans(hlID(a:group)), 'reverse', has('gui_running') ? 'gui' : 'term')
return reverse ? s:get_array(bg, fg, a:000) : s:get_array(fg, bg, a:000)
endfunction
function! airline#highlighter#get_highlight2(fg, bg, ...)
let fg = s:get_syn(a:fg[0], a:fg[1])
let bg = s:get_syn(a:bg[0], a:bg[1])
return s:get_array(fg, bg, a:000)
endfunction
function! airline#highlighter#exec(group, colors)
let colors = a:colors
if s:is_win32term
let colors[2] = s:gui2cui(get(colors, 0, ''), get(colors, 2, ''))
let colors[3] = s:gui2cui(get(colors, 1, ''), get(colors, 3, ''))
endif
exec printf('hi %s %s %s %s %s %s %s %s',
\ a:group,
\ get(colors, 0, '') != '' ? 'guifg='.colors[0] : '',
\ get(colors, 1, '') != '' ? 'guibg='.colors[1] : '',
\ get(colors, 2, '') != '' ? 'ctermfg='.colors[2] : '',
\ get(colors, 3, '') != '' ? 'ctermbg='.colors[3] : '',
\ get(colors, 4, '') != '' ? 'gui='.colors[4] : '',
\ get(colors, 4, '') != '' ? 'cterm='.colors[4] : '',
\ get(colors, 4, '') != '' ? 'term='.colors[4] : '')
endfunction
function! s:exec_separator(dict, from, to, inverse, suffix)
let l:from = airline#themes#get_highlight(a:from.a:suffix)
let l:to = airline#themes#get_highlight(a:to.a:suffix)
let group = a:from.'_to_'.a:to.a:suffix
if a:inverse
let colors = [ l:from[1], l:to[1], l:from[3], l:to[3] ]
else
let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ]
endif
let a:dict[group] = colors
call airline#highlighter#exec(group, colors)
endfunction
function! airline#highlighter#load_theme()
for winnr in filter(range(1, winnr('$')), 'v:val != winnr()')
call airline#highlighter#highlight_modified_inactive(winbufnr(winnr))
endfor
call airline#highlighter#highlight(['inactive'])
call airline#highlighter#highlight(['normal'])
endfunction
function! airline#highlighter#add_separator(from, to, inverse)
let s:separators[a:from.a:to] = [a:from, a:to, a:inverse]
call <sid>exec_separator({}, a:from, a:to, a:inverse, '')
endfunction
function! airline#highlighter#add_accent(accent)
let s:accents[a:accent] = 1
endfunction
function! airline#highlighter#highlight_modified_inactive(bufnr)
if getbufvar(a:bufnr, '&modified')
let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c')
\ ? g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c : []
else
let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive.airline_c')
\ ? g:airline#themes#{g:airline_theme}#palette.inactive.airline_c : []
endif
if !empty(colors)
call airline#highlighter#exec('airline_c'.(a:bufnr).'_inactive', colors)
endif
endfunction
function! airline#highlighter#highlight(modes)
let p = g:airline#themes#{g:airline_theme}#palette
" draw the base mode, followed by any overrides
let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val')
let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
for mode in mapped
if exists('g:airline#themes#{g:airline_theme}#palette[mode]')
let dict = g:airline#themes#{g:airline_theme}#palette[mode]
for kvp in items(dict)
let mode_colors = kvp[1]
call airline#highlighter#exec(kvp[0].suffix, mode_colors)
for accent in keys(s:accents)
if !has_key(p.accents, accent)
continue
endif
let colors = copy(mode_colors)
if p.accents[accent][0] != ''
let colors[0] = p.accents[accent][0]
endif
if p.accents[accent][2] != ''
let colors[2] = p.accents[accent][2]
endif
if len(colors) >= 5
let colors[4] = get(p.accents[accent], 4, '')
else
call add(colors, get(p.accents[accent], 4, ''))
endif
call airline#highlighter#exec(kvp[0].suffix.'_'.accent, colors)
endfor
endfor
" TODO: optimize this
for sep in items(s:separators)
call <sid>exec_separator(dict, sep[1][0], sep[1][1], sep[1][2], suffix)
endfor
endif
endfor
endfunction

View file

@ -0,0 +1,113 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! s:check_defined(variable, default)
if !exists(a:variable)
let {a:variable} = a:default
endif
endfunction
let s:loaded = 0
function! airline#init#bootstrap()
if s:loaded
return
endif
let s:loaded = 1
let g:airline#init#bootstrapping = 1
call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b0":">")
call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b1":">")
call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b2":"<")
call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b3":"<")
call s:check_defined('g:airline_detect_modified', 1)
call s:check_defined('g:airline_detect_paste', 1)
call s:check_defined('g:airline_detect_iminsert', 0)
call s:check_defined('g:airline_inactive_collapse', 1)
call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
call s:check_defined('g:airline_exclude_filetypes', [])
call s:check_defined('g:airline_exclude_preview', 0)
call s:check_defined('g:airline_mode_map', {})
call extend(g:airline_mode_map, {
\ '__' : '------',
\ 'n' : 'NORMAL',
\ 'i' : 'INSERT',
\ 'R' : 'REPLACE',
\ 'v' : 'VISUAL',
\ 'V' : 'V-LINE',
\ 'c' : 'COMMAND',
\ '' : 'V-BLOCK',
\ 's' : 'SELECT',
\ 'S' : 'S-LINE',
\ '' : 'S-BLOCK',
\ }, 'keep')
call s:check_defined('g:airline_theme_map', {})
call extend(g:airline_theme_map, {
\ 'Tomorrow.*': 'tomorrow',
\ 'base16.*': 'base16',
\ 'mo[l|n]okai': 'molokai',
\ 'wombat.*': 'wombat',
\ '.*zenburn.*': 'zenburn',
\ '.*solarized.*': 'solarized',
\ }, 'keep')
call s:check_defined('g:airline_symbols', {})
call extend(g:airline_symbols, {
\ 'paste': get(g:, 'airline_paste_symbol', 'PASTE'),
\ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a2" : 'RO'),
\ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? "\u2739" : '!',
\ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a1" : ':' ),
\ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a0" : ''),
\ 'modified': '+',
\ 'space': ' ',
\ }, 'keep')
call airline#parts#define('mode', {
\ 'function': 'airline#parts#mode',
\ 'accent': 'bold',
\ })
call airline#parts#define_function('iminsert', 'airline#parts#iminsert')
call airline#parts#define_function('paste', 'airline#parts#paste')
call airline#parts#define_function('filetype', 'airline#parts#filetype')
call airline#parts#define('readonly', {
\ 'function': 'airline#parts#readonly',
\ 'accent': 'red',
\ })
call airline#parts#define_raw('file', '%f%m')
call airline#parts#define_raw('linenr', '%{g:airline_symbols.linenr}%#__accent_bold#%4l%#__restore__#')
call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'eclim', 'whitespace'])
unlet g:airline#init#bootstrapping
endfunction
function! airline#init#sections()
let spc = g:airline_symbols.space
if !exists('g:airline_section_a')
let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'iminsert'])
endif
if !exists('g:airline_section_b')
let g:airline_section_b = airline#section#create(['hunks', 'branch'])
endif
if !exists('g:airline_section_c')
let g:airline_section_c = airline#section#create(['%<', 'file', spc, 'readonly'])
endif
if !exists('g:airline_section_gutter')
let g:airline_section_gutter = airline#section#create(['%='])
endif
if !exists('g:airline_section_x')
let g:airline_section_x = airline#section#create_right(['tagbar', 'filetype'])
endif
if !exists('g:airline_section_y')
let g:airline_section_y = airline#section#create_right(['ffenc'])
endif
if !exists('g:airline_section_z')
let g:airline_section_z = airline#section#create(['%3p%%'.spc, 'linenr', ':%3c '])
endif
if !exists('g:airline_section_warning')
let g:airline_section_warning = airline#section#create(['syntastic', 'eclim', 'whitespace'])
endif
endfunction

View file

@ -0,0 +1,79 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:parts = {}
" PUBLIC API {{{
function! airline#parts#define(key, config)
let s:parts[a:key] = get(s:parts, a:key, {})
if exists('g:airline#init#bootstrapping')
call extend(s:parts[a:key], a:config, 'keep')
else
call extend(s:parts[a:key], a:config, 'force')
endif
endfunction
function! airline#parts#define_function(key, name)
call airline#parts#define(a:key, { 'function': a:name })
endfunction
function! airline#parts#define_text(key, text)
call airline#parts#define(a:key, { 'text': a:text })
endfunction
function! airline#parts#define_raw(key, raw)
call airline#parts#define(a:key, { 'raw': a:raw })
endfunction
function! airline#parts#define_minwidth(key, width)
call airline#parts#define(a:key, { 'minwidth': a:width })
endfunction
function! airline#parts#define_condition(key, predicate)
call airline#parts#define(a:key, { 'condition': a:predicate })
endfunction
function! airline#parts#define_accent(key, accent)
call airline#parts#define(a:key, { 'accent': a:accent })
endfunction
function! airline#parts#define_empty(keys)
for key in a:keys
call airline#parts#define_raw(key, '')
endfor
endfunction
function! airline#parts#get(key)
return get(s:parts, a:key, {})
endfunction
" }}}
function! airline#parts#mode()
return get(w:, 'airline_current_mode', '')
endfunction
function! airline#parts#paste()
return g:airline_detect_paste && &paste ? g:airline_symbols.paste : ''
endfunction
function! airline#parts#iminsert()
if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name')
return toupper(b:keymap_name)
endif
return ''
endfunction
function! airline#parts#readonly()
return &readonly ? g:airline_symbols.readonly : ''
endfunction
function! airline#parts#filetype()
return &filetype
endfunction
function! airline#parts#ffenc()
return printf('%s%s', &fenc, strlen(&ff) > 0 ? '['.&ff.']' : '')
endfunction

View file

@ -0,0 +1,73 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
call airline#init#bootstrap()
let s:spc = g:airline_symbols.space
function! s:wrap_accent(part, value)
if exists('a:part.accent')
call airline#highlighter#add_accent(a:part.accent)
return '%#__accent_'.(a:part.accent).'#'.a:value.'%#__restore__#'
endif
return a:value
endfunction
function! s:create(parts, append)
let _ = ''
for idx in range(len(a:parts))
let part = airline#parts#get(a:parts[idx])
let val = ''
if exists('part.function')
let func = (part.function).'()'
elseif exists('part.text')
let func = '"'.(part.text).'"'
else
if a:append > 0 && idx != 0
let val .= s:spc.g:airline_left_alt_sep.s:spc
endif
if a:append < 0 && idx != 0
let val = s:spc.g:airline_right_alt_sep.s:spc.val
endif
if exists('part.raw')
let _ .= s:wrap_accent(part, val.(part.raw))
continue
else
let _ .= s:wrap_accent(part, val.a:parts[idx])
continue
endif
endif
let minwidth = get(part, 'minwidth', 0)
if a:append > 0 && idx != 0
let partval = printf('%%{airline#util#append(%s,%s)}', func, minwidth)
elseif a:append < 0 && idx != len(a:parts) - 1
let partval = printf('%%{airline#util#prepend(%s,%s)}', func, minwidth)
else
let partval = printf('%%{airline#util#wrap(%s,%s)}', func, minwidth)
endif
if exists('part.condition')
let partval = substitute(partval, '{', '{'.(part.condition).' ? ', '')
let partval = substitute(partval, '}', ' : ""}', '')
endif
let val .= s:wrap_accent(part, partval)
let _ .= val
endfor
return _
endfunction
function! airline#section#create(parts)
return s:create(a:parts, 0)
endfunction
function! airline#section#create_left(parts)
return s:create(a:parts, 1)
endfunction
function! airline#section#create_right(parts)
return s:create(a:parts, -1)
endfunction

View file

@ -0,0 +1,67 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
" generates a dictionary which defines the colors for each highlight group
function! airline#themes#generate_color_map(sect1, sect2, sect3, ...)
let palette = {
\ 'airline_a': [ a:sect1[0] , a:sect1[1] , a:sect1[2] , a:sect1[3] , get(a:sect1 , 4 , '') ] ,
\ 'airline_b': [ a:sect2[0] , a:sect2[1] , a:sect2[2] , a:sect2[3] , get(a:sect2 , 4 , '') ] ,
\ 'airline_c': [ a:sect3[0] , a:sect3[1] , a:sect3[2] , a:sect3[3] , get(a:sect3 , 4 , '') ] ,
\ }
if a:0 > 0
call extend(palette, {
\ 'airline_x': [ a:1[0] , a:1[1] , a:1[2] , a:1[3] , get(a:1 , 4 , '' ) ] ,
\ 'airline_y': [ a:2[0] , a:2[1] , a:2[2] , a:2[3] , get(a:2 , 4 , '' ) ] ,
\ 'airline_z': [ a:3[0] , a:3[1] , a:3[2] , a:3[3] , get(a:3 , 4 , '' ) ] ,
\ })
else
call extend(palette, {
\ 'airline_x': [ a:sect3[0] , a:sect3[1] , a:sect3[2] , a:sect3[3] , '' ] ,
\ 'airline_y': [ a:sect2[0] , a:sect2[1] , a:sect2[2] , a:sect2[3] , '' ] ,
\ 'airline_z': [ a:sect1[0] , a:sect1[1] , a:sect1[2] , a:sect1[3] , '' ] ,
\ })
endif
return palette
endfunction
function! airline#themes#get_highlight(group, ...)
return call('airline#highlighter#get_highlight', [a:group] + a:000)
endfunction
function! airline#themes#get_highlight2(fg, bg, ...)
return call('airline#highlighter#get_highlight2', [a:fg, a:bg] + a:000)
endfunction
function! airline#themes#patch(palette)
for mode in keys(a:palette)
if !has_key(a:palette[mode], 'airline_warning')
let a:palette[mode]['airline_warning'] = [ '#000000', '#df5f00', 232, 166 ]
endif
endfor
let a:palette.accents = get(a:palette, 'accents', {})
let a:palette.accents.bold = [ '', '', '', '', 'bold' ]
let a:palette.accents.italic = [ '', '', '', '', 'italic' ]
if !has_key(a:palette.accents, 'red')
let a:palette.accents.red = [ '#ff0000' , '' , 160 , '' ]
endif
if !has_key(a:palette.accents, 'green')
let a:palette.accents.green = [ '#008700' , '' , 22 , '' ]
endif
if !has_key(a:palette.accents, 'blue')
let a:palette.accents.blue = [ '#005fff' , '' , 27 , '' ]
endif
if !has_key(a:palette.accents, 'yellow')
let a:palette.accents.yellow = [ '#dfff00' , '' , 190 , '' ]
endif
if !has_key(a:palette.accents, 'orange')
let a:palette.accents.orange = [ '#df5f00' , '' , 166 , '' ]
endif
if !has_key(a:palette.accents, 'purple')
let a:palette.accents.purple = [ '#af00df' , '' , 128 , '' ]
endif
endfunction

View file

@ -0,0 +1,52 @@
let s:N1 = [ '#141413' , '#aeee00' , 232 , 154 ] " blackestgravel & lime
let s:N2 = [ '#f4cf86' , '#45413b' , 222 , 238 ] " dirtyblonde & deepgravel
let s:N3 = [ '#8cffba' , '#242321' , 121 , 235 ] " saltwatertaffy & darkgravel
let s:N4 = [ '#666462' , 241 ] " mediumgravel
let s:I1 = [ '#141413' , '#0a9dff' , 232 , 39 ] " blackestgravel & tardis
let s:I2 = [ '#f4cf86' , '#005fff' , 222 , 27 ] " dirtyblonde & facebook
let s:I3 = [ '#0a9dff' , '#242321' , 39 , 235 ] " tardis & darkgravel
let s:V1 = [ '#141413' , '#ffa724' , 232 , 214 ] " blackestgravel & orange
let s:V2 = [ '#000000' , '#fade3e' , 16 , 221 ] " coal & dalespale
let s:V3 = [ '#000000' , '#b88853' , 16 , 137 ] " coal & toffee
let s:V4 = [ '#c7915b' , 173 ] " coffee
let s:PA = [ '#f4cf86' , 222 ] " dirtyblonde
let s:RE = [ '#ff9eb8' , 211 ] " dress
let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ]
let g:airline#themes#badwolf#palette = {}
let g:airline#themes#badwolf#palette.accents = {
\ 'red': [ '#ff2c4b' , '' , 196 , '' , '' ]
\ }
let g:airline#themes#badwolf#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
let g:airline#themes#badwolf#palette.normal_modified = {
\ 'airline_b': [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] ,
\ 'airline_c': [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] }
let g:airline#themes#badwolf#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3)
let g:airline#themes#badwolf#palette.insert_modified = {
\ 'airline_c': [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] }
let g:airline#themes#badwolf#palette.insert_paste = {
\ 'airline_a': [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] }
let g:airline#themes#badwolf#palette.replace = copy(airline#themes#badwolf#palette.insert)
let g:airline#themes#badwolf#palette.replace.airline_a = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ]
let g:airline#themes#badwolf#palette.replace_modified = g:airline#themes#badwolf#palette.insert_modified
let g:airline#themes#badwolf#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3)
let g:airline#themes#badwolf#palette.visual_modified = {
\ 'airline_c': [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] }
let g:airline#themes#badwolf#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA)
let g:airline#themes#badwolf#palette.inactive_modified = {
\ 'airline_c': [ s:V1[1] , '' , s:V1[3] , '' , '' ] }

View file

@ -0,0 +1,107 @@
if get(g:, 'airline#themes#base16#constant', 0)
let g:airline#themes#base16#palette = {}
" Color palette
let s:gui_dark_gray = '#202020'
let s:cterm_dark_gray = 234
let s:gui_med_gray_hi = '#303030'
let s:cterm_med_gray_hi = 236
let s:gui_med_gray_lo = '#3a3a3a'
let s:cterm_med_gray_lo = 237
let s:gui_light_gray = '#505050'
let s:cterm_light_gray = 239
let s:gui_green = '#99cc99'
let s:cterm_green = 151
let s:gui_blue = '#6a9fb5'
let s:cterm_blue = 67
let s:gui_purple = '#aa759f'
let s:cterm_purple = 139
let s:gui_orange = '#d28445'
let s:cterm_orange = 173
let s:gui_red = '#ac4142'
let s:cterm_red = 131
let s:gui_pink = '#d7afd7'
let s:cterm_pink = 182
" Normal mode
let s:N1 = [s:gui_dark_gray, s:gui_green, s:cterm_dark_gray, s:cterm_green]
let s:N2 = [s:gui_light_gray, s:gui_med_gray_lo, s:cterm_light_gray, s:cterm_med_gray_lo]
let s:N3 = [s:gui_green, s:gui_med_gray_hi, s:cterm_green, s:cterm_med_gray_hi]
let g:airline#themes#base16#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
let g:airline#themes#base16#palette.normal_modified = {
\ 'airline_c': [s:gui_orange, s:gui_med_gray_hi, s:cterm_orange, s:cterm_med_gray_hi, ''],
\ }
" Insert mode
let s:I1 = [s:gui_med_gray_hi, s:gui_blue, s:cterm_med_gray_hi, s:cterm_blue]
let s:I3 = [s:gui_blue, s:gui_med_gray_hi, s:cterm_blue, s:cterm_med_gray_hi]
let g:airline#themes#base16#palette.insert = airline#themes#generate_color_map(s:I1, s:N2, s:I3)
let g:airline#themes#base16#palette.insert_modified = copy(g:airline#themes#base16#palette.normal_modified)
let g:airline#themes#base16#palette.insert_paste = {
\ 'airline_a': [s:gui_dark_gray, s:gui_orange, s:cterm_dark_gray, s:cterm_orange, ''],
\ }
" Replace mode
let g:airline#themes#base16#palette.replace = {
\ 'airline_a': [s:gui_dark_gray, s:gui_red, s:cterm_dark_gray, s:cterm_red, ''],
\ 'airline_c': [s:gui_red, s:gui_med_gray_hi, s:cterm_red, s:cterm_med_gray_hi, ''],
\ }
let g:airline#themes#base16#palette.replace_modified = copy(g:airline#themes#base16#palette.insert_modified)
" Visual mode
let s:V1 = [s:gui_dark_gray, s:gui_pink, s:cterm_dark_gray, s:cterm_pink]
let s:V3 = [s:gui_pink, s:gui_med_gray_hi, s:cterm_pink, s:cterm_med_gray_hi]
let g:airline#themes#base16#palette.visual = airline#themes#generate_color_map(s:V1, s:N2, s:V3)
let g:airline#themes#base16#palette.visual_modified = copy(g:airline#themes#base16#palette.insert_modified)
" Inactive window
let s:IA = [s:gui_dark_gray, s:gui_med_gray_hi, s:cterm_dark_gray, s:cterm_med_gray_hi, '']
let g:airline#themes#base16#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA)
let g:airline#themes#base16#palette.inactive_modified = {
\ 'airline_c': [s:gui_orange, '', s:cterm_orange, '', ''],
\ }
else
function! airline#themes#base16#refresh()
let g:airline#themes#base16#palette = {}
let g:airline#themes#base16#palette.accents = {
\ 'red': airline#themes#get_highlight('Constant'),
\ }
let s:N1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['DiffText', 'fg'], 'bold')
let s:N2 = airline#themes#get_highlight('Visual')
let s:N3 = airline#themes#get_highlight('CursorLine')
let g:airline#themes#base16#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
let group = airline#themes#get_highlight('vimCommand')
let g:airline#themes#base16#palette.normal_modified = {
\ 'statusline': [ group[0], '', group[2], '', '' ]
\ }
let s:I1 = airline#themes#get_highlight2(['DiffAdded', 'bg'], ['DiffAdded', 'fg'], 'bold')
let s:I2 = airline#themes#get_highlight2(['DiffAdded', 'fg'], ['Normal', 'bg'])
let s:I3 = s:N3
let g:airline#themes#base16#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3)
let g:airline#themes#base16#palette.insert_modified = g:airline#themes#base16#palette.normal_modified
let s:R1 = airline#themes#get_highlight2(['WarningMsg', 'bg'], ['WarningMsg', 'fg'], 'bold')
let s:R2 = s:N2
let s:R3 = s:N3
let g:airline#themes#base16#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3)
let g:airline#themes#base16#palette.replace_modified = g:airline#themes#base16#palette.normal_modified
let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Constant', 'fg'], 'bold')
let s:V2 = airline#themes#get_highlight2(['Constant', 'fg'], ['Normal', 'bg'])
let s:V3 = s:N3
let g:airline#themes#base16#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3)
let g:airline#themes#base16#palette.visual_modified = g:airline#themes#base16#palette.normal_modified
let s:IA = airline#themes#get_highlight2(['NonText', 'fg'], ['CursorLine', 'bg'])
let g:airline#themes#base16#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA)
let g:airline#themes#base16#palette.inactive_modified = {
\ 'airline_c': [ group[0], '', group[2], '', '' ]
\ }
endfunction
call airline#themes#base16#refresh()
endif

View file

@ -0,0 +1,62 @@
" Color palette
let s:gui_dark_gray = '#303030'
let s:cterm_dark_gray = 236
let s:gui_med_gray_hi = '#444444'
let s:cterm_med_gray_hi = 238
let s:gui_med_gray_lo = '#3a3a3a'
let s:cterm_med_gray_lo = 237
let s:gui_light_gray = '#b2b2b2'
let s:cterm_light_gray = 249
let s:gui_green = '#afd787'
let s:cterm_green = 150
let s:gui_blue = '#87afd7'
let s:cterm_blue = 110
let s:gui_purple = '#afafd7'
let s:cterm_purple = 146
let s:gui_orange = '#d7af5f'
let s:cterm_orange = 179
let s:gui_red = '#d78787'
let s:cterm_red = 174
let s:gui_pink = '#d7afd7'
let s:cterm_pink = 182
let g:airline#themes#bubblegum#palette = {}
" Normal mode
let s:N1 = [s:gui_dark_gray, s:gui_green, s:cterm_dark_gray, s:cterm_green]
let s:N2 = [s:gui_light_gray, s:gui_med_gray_lo, s:cterm_light_gray, s:cterm_med_gray_lo]
let s:N3 = [s:gui_green, s:gui_med_gray_hi, s:cterm_green, s:cterm_med_gray_hi]
let g:airline#themes#bubblegum#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
let g:airline#themes#bubblegum#palette.normal_modified = {
\ 'airline_c': [s:gui_orange, s:gui_med_gray_hi, s:cterm_orange, s:cterm_med_gray_hi, ''],
\ }
" Insert mode
let s:I1 = [s:gui_med_gray_hi, s:gui_blue, s:cterm_med_gray_hi, s:cterm_blue]
let s:I3 = [s:gui_blue, s:gui_med_gray_hi, s:cterm_blue, s:cterm_med_gray_hi]
let g:airline#themes#bubblegum#palette.insert = airline#themes#generate_color_map(s:I1, s:N2, s:I3)
let g:airline#themes#bubblegum#palette.insert_modified = copy(g:airline#themes#bubblegum#palette.normal_modified)
let g:airline#themes#bubblegum#palette.insert_paste = {
\ 'airline_a': [s:gui_dark_gray, s:gui_orange, s:cterm_dark_gray, s:cterm_orange, ''],
\ }
" Replace mode
let g:airline#themes#bubblegum#palette.replace = {
\ 'airline_a': [s:gui_dark_gray, s:gui_red, s:cterm_dark_gray, s:cterm_red, ''],
\ 'airline_c': [s:gui_red, s:gui_med_gray_hi, s:cterm_red, s:cterm_med_gray_hi, ''],
\ }
let g:airline#themes#bubblegum#palette.replace_modified = copy(g:airline#themes#bubblegum#palette.insert_modified)
" Visual mode
let s:V1 = [s:gui_dark_gray, s:gui_pink, s:cterm_dark_gray, s:cterm_pink]
let s:V3 = [s:gui_pink, s:gui_med_gray_hi, s:cterm_pink, s:cterm_med_gray_hi]
let g:airline#themes#bubblegum#palette.visual = airline#themes#generate_color_map(s:V1, s:N2, s:V3)
let g:airline#themes#bubblegum#palette.visual_modified = copy(g:airline#themes#bubblegum#palette.insert_modified)
" Inactive window
let s:IA = [s:gui_dark_gray, s:gui_med_gray_hi, s:cterm_dark_gray, s:cterm_med_gray_hi, '']
let g:airline#themes#bubblegum#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA)
let g:airline#themes#bubblegum#palette.inactive_modified = {
\ 'airline_c': [s:gui_orange, '', s:cterm_orange, '', ''],
\ }

View file

@ -0,0 +1,102 @@
" Each theme is contained in its own file and declares variables scoped to the
" file. These variables represent the possible "modes" that airline can
" detect. The mode is the return value of mode(), which gets converted to a
" readable string. The following is a list currently supported modes: normal,
" insert, replace, visual, and inactive.
"
" Each mode can also have overrides. These are small changes to the mode that
" don't require a completely different look. "modified" and "paste" are two
" such supported overrides. These are simply suffixed to the major mode,
" separated by an underscore. For example, "normal_modified" would be normal
" mode where the current buffer is modified.
"
" The theming algorithm is a 2-pass system where the mode will draw over all
" parts of the statusline, and then the override is applied after. This means
" it is possible to specify a subset of the theme in overrides, as it will
" simply overwrite the previous colors. If you want simultaneous overrides,
" then they will need to change different parts of the statusline so they do
" not conflict with each other.
"
" First, let's define an empty dictionary and assign it to the "palette"
" variable. The # is a separator that maps with the directory structure. If
" you get this wrong, Vim will complain loudly.
let g:airline#themes#dark#palette = {}
" First let's define some arrays. The s: is just a VimL thing for scoping the
" variables to the current script. Without this, these variables would be
" declared globally. Now let's declare some colors for normal mode and add it
" to the dictionary. The array is in the format:
" [ guifg, guibg, ctermfg, ctermbg, opts ]. See "help attr-list" for valid
" values for the "opt" value.
let s:N1 = [ '#00005f' , '#dfff00' , 17 , 190 ]
let s:N2 = [ '#ffffff' , '#444444' , 255 , 238 ]
let s:N3 = [ '#9cffd3' , '#202020' , 85 , 234 ]
let g:airline#themes#dark#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
" Here we define overrides for when the buffer is modified. This will be
" applied after g:airline#themes#dark#palette.normal, hence why only certain keys are
" declared.
let g:airline#themes#dark#palette.normal_modified = {
\ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] ,
\ }
let s:I1 = [ '#00005f' , '#00dfff' , 17 , 45 ]
let s:I2 = [ '#ffffff' , '#005fff' , 255 , 27 ]
let s:I3 = [ '#ffffff' , '#000080' , 15 , 17 ]
let g:airline#themes#dark#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3)
let g:airline#themes#dark#palette.insert_modified = {
\ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] ,
\ }
let g:airline#themes#dark#palette.insert_paste = {
\ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] ,
\ }
let g:airline#themes#dark#palette.replace = copy(g:airline#themes#dark#palette.insert)
let g:airline#themes#dark#palette.replace.airline_a = [ s:I2[0] , '#af0000' , s:I2[2] , 124 , '' ]
let g:airline#themes#dark#palette.replace_modified = g:airline#themes#dark#palette.insert_modified
let s:V1 = [ '#000000' , '#ffaf00' , 232 , 214 ]
let s:V2 = [ '#000000' , '#ff5f00' , 232 , 202 ]
let s:V3 = [ '#ffffff' , '#5f0000' , 15 , 52 ]
let g:airline#themes#dark#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3)
let g:airline#themes#dark#palette.visual_modified = {
\ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] ,
\ }
let s:IA1 = [ '#4e4e4e' , '#1c1c1c' , 239 , 234 , '' ]
let s:IA2 = [ '#4e4e4e' , '#262626' , 239 , 235 , '' ]
let s:IA3 = [ '#4e4e4e' , '#303030' , 239 , 236 , '' ]
let g:airline#themes#dark#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3)
let g:airline#themes#dark#palette.inactive_modified = {
\ 'airline_c': [ '#875faf' , '' , 97 , '' , '' ] ,
\ }
" Accents are used to give parts within a section a slightly different look or
" color. Here we are defining a "red" accent, which is used by the 'readonly'
" part by default. Only the foreground colors are specified, so the background
" colors are automatically extracted from the underlying section colors. What
" this means is that regardless of which section the part is defined in, it
" will be red instead of the section's foreground color. You can also have
" multiple parts with accents within a section.
let g:airline#themes#dark#palette.accents = {
\ 'red': [ '#ff0000' , '' , 160 , '' ]
\ }
" Here we define the color map for ctrlp. We check for the g:loaded_ctrlp
" variable so that related functionality is loaded iff the user is using
" ctrlp. Note that this is optional, and if you do not define ctrlp colors
" they will be chosen automatically from the existing palette.
if !get(g:, 'loaded_ctrlp', 0)
finish
endif
let g:airline#themes#dark#palette.ctrlp = airline#extensions#ctrlp#generate_color_map(
\ [ '#d7d7ff' , '#5f00af' , 189 , 55 , '' ],
\ [ '#ffffff' , '#875fd7' , 231 , 98 , '' ],
\ [ '#5f00af' , '#ffffff' , 55 , 231 , 'bold' ])

Some files were not shown because too many files have changed in this diff Show more