1
0
Fork 0
mirror of synced 2024-12-22 06:51:06 -05:00

Sync up with amix repository

Sync up with amix repository
This commit is contained in:
Daniil Gitelson 2016-09-02 11:19:35 +03:00 committed by GitHub
commit 170c9e69a5
591 changed files with 35294 additions and 24001 deletions

3
.gitignore vendored
View file

@ -1,8 +1,9 @@
temp_dirs/undodir*
temp_dirs/undodir/*
sources_non_forked/ack.vim/.netrwhist
temp_dirs/yankring_history_v2.txt
sources_forked/yankring/doc/tags
sources_non_forked/tlib/doc/tags
sources_non_forked/ctrlp.vim/doc/tags*
my_configs.vim
tags
.DS_Store

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Amir Salihefendic
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

@ -7,7 +7,7 @@ There are two versions:
* **Basic**: If you want something small just copy [basic.vim](https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim) into your ~/.vimrc and you will have a great basic setup
* **Awesome**: This includes a ton of useful plugins, color schemes and configurations
I would of course recommend using the awesome version.
I would of course recommend using the awesome version.c
## How to install the Awesome version?
The awesome version includes a lot of great plugins, configurations and color schemes that make Vim a lot better. To install it simply do following:
@ -15,8 +15,6 @@ The awesome version includes a lot of great plugins, configurations and color sc
git clone https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh
The taglist.vim plugin will require ctags (http://ctags.sourceforge.net) (Debian: apt-get install ctags)
I also recommend using [Source Code Pro font from Adobe](http://store1.adobe.com/cfusion/store/html/index.cfm?event=displayFontPackage&code=1960) (it's free and awesome font for writing and programming). The Awesome vimrc is already setup to try to use it
## How to install the Basic version?
@ -33,6 +31,10 @@ This is useful to install on remote servers where you don't need many plugins an
Use [msysgit](http://msysgit.github.com/) to checkout the repository and run the installation instructions above. No special instructions needed ;-)
## How to install on Linux
If you have vim aliased as `vi` instead of `vim`, make sure to either alias it: `alias vi=vim`. Otherwise, `apt-get install vim`
## How to update to latest version?
Simply just do a git rebase!
@ -64,26 +66,24 @@ Distraction free mode using [goyo.vim](https://github.com/junegunn/goyo.vim) and
I recommend reading the docs of these plugins to understand them better. Each of them provide a much better Vim experience!
* [pathogen.vim](https://github.com/tpope/vim-pathogen): Manages the runtime path of the plugins
* [YankRing](https://github.com/vim-scripts/YankRing.vim): Maintains a history of previous yanks, changes and deletes
* [snipMate.vim](https://github.com/garbas/vim-snipmate): snipMate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim
* [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
* [ack.vim](https://github.com/mileszs/ack.vim): Vim plugin for the Perl module / CLI script 'ack'
* [ag.vim](https://github.com/rking/ag.vim): A much faster Ack
* [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/ctrlpvim/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>`
* [open_file_under_cursor.vim](https://github.com/amix/open_file_under_cursor.vim): Open file under cursor when pressing `gf`
* [zencoding](https://github.com/mattn/emmet-vim): Expanding abbreviation like zen-coding, very useful for editing XML, HTML.
* [vim-indent-object](https://github.com/michaeljsmith/vim-indent-object): Defines a new text object representing lines of code at the same indent level. Useful for python/vim scripts
* [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-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
* [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2):
Remove all clutter and focus only on the essential. Similar to iA Writer or Write Room [Read more here](http://amix.dk/blog/post/19744)
* [vim-commentary](https://github.com/tpope/vim-commentary): Comment stuff out. Use `gcc` to comment out a line (takes a count), `gc` to comment out the target of a motion. `gcu` uncomments a set of adjacent commented lines.
* [syntastic](https://github.com/scrooloose/syntastic): Syntax checking hacks for vim
* [vim-yankstack](https://github.com/maxbrunsfeld/vim-yankstack): Maintains a history of previous yanks, changes and deletes
* [lightline.vim](https://github.com/itchyny/lightline.vim): A light and configurable statusline/tabline for Vim
## Included color schemes
@ -102,7 +102,7 @@ Remove all clutter and focus only on the essential. Similar to iA Writer or Writ
* [vim-bundle-mako](https://github.com/sophacles/vim-bundle-mako)
* [vim-markdown](https://github.com/tpope/vim-markdown)
* [nginx.vim](https://github.com/vim-scripts/nginx.vim): Highlights configuration files for nginx
* [vim-golang](https://github.com/jnwhiteh/vim-golang)
* [vim-go](https://github.com/fatih/vim-go)
## How to include your own stuff?
@ -125,42 +125,33 @@ Now you have vim-rails installed ;-)
### Plugin related mappings
Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) and see and manage the current buffers:
Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) and see and manage the current buffers (`<leader>o`):
map <leader>o :BufExplorer<cr>
Open [MRU.vim](https://github.com/vim-scripts/mru.vim) and see the recently open files:
Open [MRU.vim](https://github.com/vim-scripts/mru.vim) and see the recently open files (`<leader>f`):
map <leader>f :MRU<CR>
Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin:
Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin (`<leader>j` or `<ctrl>f`):
let g:ctrlp_map = '<c-f>'
Open [PeepOpen](https://peepcode.com/products/peepopen) plugin:
map <leader>j :PeepOpen<cr>
Managing the [NERD Tree](https://github.com/scrooloose/nerdtree) plugin:
map <leader>nn :NERDTreeToggle<cr>
map <leader>nb :NERDTreeFromBookmark
map <leader>nf :NERDTreeFind<cr>
[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping.
[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping. (`<leader>z`)
map <leader>z :Goyo<cr>
### Normal mode mappings
Fast saving of a buffer:
Fast saving of a buffer (`<leader>w`):
nmap <leader>w :w!<cr>
Treat long lines as break lines (useful when moving around in them):
map j gj
map k gk
Map `<Space>` to `/` (search) and `<Ctrl>+<Space>` to `?` (backwards search):
@ -172,14 +163,14 @@ Disable highlight when `<leader><cr>` is pressed:
map <silent> <leader><cr> :noh<cr>
Smart way to move between windows:
Smart way to move between windows (`<ctrl>j` etc.):
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
Closing of current buffer(s):
Closing of current buffer(s) (`<leader>bd` and (`<leader>ba`)):
" Close current buffer
map <leader>bd :Bclose<cr>
@ -316,14 +307,8 @@ Vimscript mappings:
map <leader>n :cn<cr>
map <leader>p :cp<cr>
## Useful blog tips regarding my Vim setup
## How to uninstall
Do following:
* Remove `~/.vim_runtime`
* Remove any lines that refernce `.vim_runtime` in your `~/.vimrc`
* [Vim: Annotate strings with gettext (the macro way)](http://amix.dk/blog/post/19678#Vim-Annotate-strings-with-gettext-the-macro-way)
* [vimgrep: Searching through multiple file extensions](http://amix.dk/blog/post/19672#vimgrep-Searching-through-multiple-file-extensions)
* [Filtering through vimgrep results using regular expressions](http://amix.dk/blog/post/19666#Filtering-through-vimgrep-results-using-regular-expressions)
* [PeepOpen - File auto completion for Mac editors](http://amix.dk/blog/post/19601#PeepOpen-File-auto-completion-for-Mac-editors)
* [Vim 7.3: Persistent undo and encryption!](http://amix.dk/blog/post/19548#Vim-7-3-Persistent-undo-and-encryption)
* [Vim tips: Visual Search](http://amix.dk/blog/post/19334#Vim-tips-Visual-Search)
* [Folding in Vim](http://amix.dk/blog/post/19132#Folding-in-Vim)
* [
Zen room for Vim: Focusing only on the essential](http://amix.dk/blog/post/19744#zenroom-for-Vim-Focsuing-only-on-the-essential)

View file

@ -77,7 +77,7 @@ if &background=='light'
hi WarningMsg guifg=#b02000 guibg=NONE gui=NONE
hi WildMenu guifg=fg guibg=#d0d090 gui=NONE
hi Folded guifg=NONE guibg=#b0e0b0 gui=NONE
hi FoldColumn guifg=fg guibg=#90e090 gui=NONE
hi FoldColumn guifg=fg guibg=NONE gui=NONE
hi DiffAdd guifg=NONE guibg=#b0b0e0 gui=NONE
hi DiffChange guifg=NONE guibg=#e0b0e0 gui=NONE
hi DiffDelete guifg=#002090 guibg=#d0d0d0 gui=NONE
@ -190,7 +190,7 @@ if &background=='light'
hi WarningMsg ctermfg=124 ctermbg=NONE cterm=NONE
hi WildMenu ctermfg=fg ctermbg=186 cterm=NONE
hi Folded ctermfg=NONE ctermbg=151 cterm=NONE
hi FoldColumn ctermfg=fg ctermbg=114 cterm=NONE
hi FoldColumn ctermfg=fg ctermbg=NONE cterm=NONE
hi DiffAdd ctermfg=NONE ctermbg=146 cterm=NONE
hi DiffChange ctermfg=NONE ctermbg=182 cterm=NONE
hi DiffDelete ctermfg=18 ctermbg=252 cterm=NONE
@ -289,7 +289,7 @@ elseif &background=='dark'
hi WarningMsg guifg=#f08060 guibg=NONE gui=NONE
hi WildMenu guifg=#000000 guibg=#d0d090 gui=NONE
hi Folded guifg=#aaaaaa guibg=#333333 gui=NONE
hi FoldColumn guifg=#202020 guibg=#202020 gui=NONE
hi FoldColumn guifg=#202020 guibg=NONE gui=NONE
hi DiffAdd guifg=NONE guibg=#000080 gui=NONE
hi DiffChange guifg=NONE guibg=#800080 gui=NONE
hi DiffDelete guifg=#6080f0 guibg=#202020 gui=NONE
@ -370,7 +370,7 @@ elseif &background=='dark'
hi Question ctermfg=Black ctermbg=DarkYellow
hi Todo ctermfg=DarkRed ctermbg=DarkYellow
hi Folded ctermfg=DarkGrey ctermbg=DarkGrey
hi FoldColumn ctermfg=DarkGrey ctermbg=DarkGrey
hi FoldColumn ctermfg=DarkGrey ctermbg=NONE
hi ModeMsg ctermfg=Grey ctermbg=DarkBlue
hi VisualNOS ctermfg=Grey ctermbg=DarkBlue
hi ErrorMsg ctermfg=DarkYellow ctermbg=DarkRed
@ -525,7 +525,7 @@ elseif &background=='dark'
hi WarningMsg ctermfg=209 ctermbg=NONE cterm=NONE
hi WildMenu ctermfg=16 ctermbg=186 cterm=NONE
hi Folded ctermfg=NONE ctermbg=DarkGrey cterm=NONE
hi FoldColumn ctermfg=DarkGrey ctermbg=DarkGrey cterm=NONE
hi FoldColumn ctermfg=DarkGrey ctermbg=NONE cterm=NONE
hi DiffAdd ctermfg=NONE ctermbg=18 cterm=NONE
hi DiffChange ctermfg=NONE ctermbg=90 cterm=NONE
hi DiffDelete ctermfg=69 ctermbg=234 cterm=NONE

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,4 +0,0 @@
[submodule "docs"]
path = docs
url = git@github.com:mattn/zencoding-vim.git
branch = gh-pages

View file

@ -1,11 +0,0 @@
all : zencoding-vim.zip
remove-zip:
-rm doc/tags
-rm zencoding-vim.zip
zencoding-vim.zip: remove-zip
zip -r zencoding-vim.zip autoload plugin doc
release: zencoding-vim.zip
vimup update-script zencoding.vim

View file

@ -1,103 +0,0 @@
# ZenCoding-vim
[zencoding-vim](http://mattn.github.com/zencoding-vim) is vim script support for expanding abbreviation like zen-coding(emmet).
## Installation
[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981):
cd ~/.vim
unzip zencoding-vim.zip
If you install pathogen.vim:
cd ~/.vim/bundle # or make directory
unzip /path/to/zencoding-vim.zip
If you get source from repository:
cd ~/.vim/bundle # or make directory
git clone http://github.com/mattn/zencoding-vim.git
or:
git clone http://github.com/mattn/zencoding-vim.git
cd zencoding-vim
cp plugin/zencoding.vim ~/.vim/plugin/
cp autoload/zencoding.vim ~/.vim/autoload/
cp -a autoload/zencoding ~/.vim/autoload/
## Quick Tutorial
Open or create New File:
vim index.html
Type ("_" is the cursor position):
html:5_
Then type "<c-y>," (Ctrl + y + ','), you should see:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
_
</body>
</html>
[More Tutorials](https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL)
## Enable in different mode
If you don't want enable zencoding in all mode,
you can use set a option in `vimrc`:
let g:user_zen_mode='n' "only enable normal mode functions.
let g:user_zen_mode='inv' "enable all functions, which is equal to
let g:user_zen_mode='a' "enable all function in all mode.
## Project Authors
[Yasuhiro Matsumoto](http://mattn.kaoriya.net/)
## Links
### zen-coding official site:
> <http://code.google.com/p/zen-coding/>
### zencoding.vim:
> <http://mattn.github.com/zencoding-vim>
### development repository:
> <https://github.com/mattn/zencoding-vim>
### my blog posts about zencoding-vim:
> <http://mattn.kaoriya.net/software/vim/20100222103327.htm>
> <http://mattn.kaoriya.net/software/vim/20100306021632.htm>
### japanese blog posts about zencoding-vim:
> <http://d.hatena.ne.jp/idesaku/20100424/1272092255>
> <http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding>
> <http://d.hatena.ne.jp/sakurako_s/20110126/1295988873>
> <http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html>
### tutorial traslated in chinese:
> <http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html>

View file

@ -1,212 +0,0 @@
Tutorial of zencoding.vim
mattn <mattn.jp@gmail.com>
1. Expand Abbreviation
Type abbreviation as 'div>p#foo$*3>a' and type '<c-y>,'.
---------------------
<div>
<p id="foo1">
<a href=""></a>
</p>
<p id="foo2">
<a href=""></a>
</p>
<p id="foo3">
<a href=""></a>
</p>
</div>
---------------------
2. Wrap with Abbreviation
Write as below.
---------------------
test1
test2
test3
---------------------
Then do visual select(line wize) and type '<c-y>,'.
If you request 'Tag:', then type 'ul>li*'.
---------------------
<ul>
<li>test1</li>
<li>test2</li>
<li>test3</li>
</ul>
---------------------
If you type tag as 'blockquote', then you'll see as following.
---------------------
<blockquote>
test1
test2
test3
</blockquote>
---------------------
3. Balance Tag Inward
type '<c-y>d' in insert mode.
4. Balance Tag Outward
type '<c-y>D' in insert mode.
5. Go to Next Edit Point
type '<c-y>n' in insert mode.
6. Go to Previous Edit Point
type '<c-y>N' in insert mode.
7. Update <img> Size
Move cursor to img tag.
---------------------
<img src="foo.png" />
---------------------
Type '<c-y>i' on img tag
---------------------
<img src="foo.png" width="32" height="48" />
---------------------
8. Merge Lines
select the lines included '<li>'
---------------------
<ul>
<li class="list1"></li>
<li class="list2"></li>
<li class="list3"></li>
</ul>
---------------------
and type '<c-y>m'
---------------------
<ul>
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
</ul>
---------------------
9. Remove Tag
Move cursor in block
---------------------
<div class="foo">
<a>cursor is here</a>
</div>
---------------------
Type '<c-y>k' in insert mode.
---------------------
<div class="foo">
</div>
---------------------
And type '<c-y>k' in there again.
---------------------
---------------------
10. Split/Join Tag
Move cursor in block
---------------------
<div class="foo">
cursor is here
</div>
---------------------
Type '<c-y>j' in insert mode.
---------------------
<div class="foo"/>
---------------------
And type '<c-y>j' in there again.
---------------------
<div class="foo">
</div>
---------------------
11. Toggle Comment
Move cursor to block
---------------------
<div>
hello world
</div>
---------------------
Type '<c-y>/' in insert mode.
---------------------
<!-- <div>
hello world
</div> -->
---------------------
Type '<c-y>/' in there again.
---------------------
<div>
hello world
</div>
---------------------
12. Make anchor from URL
Move cursor to URL
---------------------
http://www.google.com/
---------------------
Type '<c-y>a'
---------------------
<a href="http://www.google.com/">Google</a>
---------------------
13. Make quoted text from URL
Move cursor to URL
---------------------
http://github.com/
---------------------
Type '<c-y>A'
---------------------
<blockquote class="quote">
<a href="http://github.com/">Secure source code hosting and collaborative development - GitHub</a><br />
<p>How does it work? Get up and running in seconds by forking a project, pushing an existing repository...</p>
<cite>http://github.com/</cite>
</blockquote>
---------------------
14. Installing zencoding.vim for language you using.
# cd ~/.vim
# unzip zencoding-vim.zip
or if you install pathogen.vim:
# cd ~/.vim/bundle # or make directory
# unzip /path/to/zencoding-vim.zip
if you get sources from repository:
# cd ~/.vim/bundle # or make directory
# git clone http://github.com/mattn/zencoding-vim.git
15. Enable zencoding.vim for language you using.
You can customize the behavior of language you using.
---------------------
# cat >> ~/.vimrc
let g:user_zen_settings = {
\ 'php' : {
\ 'extends' : 'html',
\ 'filters' : 'c',
\ },
\ 'xml' : {
\ 'extends' : 'html',
\ },
\ 'haml' : {
\ 'extends' : 'html',
\ },
\}
---------------------

File diff suppressed because it is too large Load diff

View file

@ -1,11 +0,0 @@
let s:exists = {}
function zencoding#lang#exists(type)
if len(a:type) == 0
return 0
elseif has_key(s:exists, a:type)
return s:exists[a:type]
endif
let s:exists[a:type] = len(globpath(&rtp, 'autoload/zencoding/lang/'.a:type.'.vim')) > 0
return s:exists[a:type]
endfunction

View file

@ -1,228 +0,0 @@
function! zencoding#lang#css#findTokens(str)
return substitute(a:str, '^.*[;{]\s*', '', '')
endfunction
function! zencoding#lang#css#parseIntoTree(abbr, type)
let abbr = a:abbr
let type = a:type
let prefix = 0
let value = ''
let settings = zencoding#getSettings()
let indent = zencoding#getIndentation(type)
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
" emmet
let tokens = split(abbr, '+\ze[^)!]')
for n in range(len(tokens))
let token = tokens[n]
let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+[pe]\{0,1}-\{0,1}\|-auto\)*\)$')
if len(prop)
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
if token =~ '^-'
let prefix = 1
let token = token[1:]
endif
let value = ''
for v in split(prop[2], '\d\zs-')
if len(value) > 0
let value .= ' '
endif
if token =~ '^[z]'
" TODO
let value .= substitute(v, '[^0-9.]*$', '', '')
elseif v =~ 'p$'
let value .= substitute(v, 'p$', '%', '')
elseif v =~ 'e$'
let value .= substitute(v, 'e$', 'em', '')
elseif v =~ '\.'
let value .= v . 'em'
elseif v == 'auto'
let value .= v
else
let value .= v . 'px'
endif
endfor
endif
let tag_name = token
if tag_name =~ '.!$'
let tag_name = tag_name[:-2]
let important = 1
else
let important = 0
endif
" make default node
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': important }
let current.name = tag_name
" aliases
let aliases = zencoding#getResource(type, 'aliases', {})
if has_key(aliases, tag_name)
let current.name = aliases[tag_name]
endif
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
" snippets
let snippets = zencoding#getResource(type, 'snippets', {})
if !empty(snippets) && has_key(snippets, tag_name)
let snippet = snippets[tag_name]
if use_pipe_for_cursor
let snippet = substitute(snippet, '|', '${cursor}', 'g')
endif
let lines = split(snippet, "\n")
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
let current.snippet = join(lines, "\n")
let current.name = ''
let current.snippet = substitute(current.snippet, ';', value . ';', '')
if use_pipe_for_cursor && len(value) > 0 && stridx(value, '${cursor}') == -1
let current.snippet = substitute(current.snippet, '${cursor}', '', 'g') . '${cursor}'
endif
if n < len(tokens) - 1
let current.snippet .= "\n"
endif
endif
let current.pos = 0
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\w\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
if len(lg)
let current.name = ''
let current.snippet = printf("background-image: -webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3])
call add(root.child, deepcopy(current))
let current.snippet = printf("background-image: -webkit-linear-gradient(%s, %s);\n", lg[2], lg[3])
call add(root.child, deepcopy(current))
let current.snippet = printf("background-image: -moz-linear-gradient(%s, %s);\n", lg[2], lg[3])
call add(root.child, deepcopy(current))
let current.snippet = printf("background-image: -o-linear-gradient(%s, %s);\n", lg[2], lg[3])
call add(root.child, deepcopy(current))
let current.snippet = printf("background-image: linear-gradient(%s, %s);\n", lg[2], lg[3])
call add(root.child, deepcopy(current))
elseif prefix
let snippet = current.snippet
let current.snippet = '-webkit-' . snippet . "\n"
call add(root.child, deepcopy(current))
let current.snippet = '-moz-' . snippet . "\n"
call add(root.child, deepcopy(current))
let current.snippet = snippet
call add(root.child, current)
else
call add(root.child, current)
endif
endfor
return root
endfunction
function! zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
let current = a:current
let value = current.value[1:-2]
if zencoding#useFilter(a:filters, 'fc')
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1: \2', 'g')
else
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1:\2', 'g')
endif
if current.important
let value = substitute(value, ';', ' !important;', '')
endif
return value
endfunction
function! zencoding#lang#css#imageSize()
endfunction
function! zencoding#lang#css#encodeImage()
endfunction
function! zencoding#lang#css#parseTag(tag)
return {}
endfunction
function! zencoding#lang#css#toggleComment()
let line = getline('.')
let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
if line =~ '{\s*$'
let block = zencoding#util#searchRegion('/\*', '\*/\zs')
if zencoding#util#regionIsValid(block)
let content = zencoding#util#getContent(block)
let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
call zencoding#util#setContent(block, content)
else
let node = expand('<cword>')
if len(node)
exe "normal ciw\<c-r>='/* '.node.' */'\<cr>"
endif
endif
else
if line =~ mx
let space = substitute(matchstr(line, mx), mx, '\1', '')
let line = substitute(matchstr(line, mx), mx, '\2', '')
let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
else
let mx = '^\(\s*\)\(.*\)\s*$'
let line = substitute(line, mx, '\1/* \2 */', '')
endif
call setline('.', line)
endif
endfunction
function! zencoding#lang#css#balanceTag(flag) range
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = getpos('.')
endif
let block = zencoding#util#getVisualBlock()
if !zencoding#util#regionIsValid(block)
if a:flag > 0
let block = zencoding#util#searchRegion('^', ';')
if zencoding#util#regionIsValid(block)
call zencoding#util#selectRegion(block)
return
endif
endif
else
if a:flag > 0
let content = zencoding#util#getContent(block)
if content !~ '^{.*}$'
let block = zencoding#util#searchRegion('{', '}')
if zencoding#util#regionIsValid(block)
call zencoding#util#selectRegion(block)
return
endif
endif
else
let pos = searchpos('.*;', 'nW')
if pos[0] != 0
call setpos('.', [0, pos[0], pos[1], 0])
let block = zencoding#util#searchRegion('^', ';')
if zencoding#util#regionIsValid(block)
call zencoding#util#selectRegion(block)
return
endif
endif
endif
endif
if a:flag == -2 || a:flag == 2
silent! exe "normal! gv"
else
call setpos('.', curpos)
endif
endfunction
function! zencoding#lang#css#moveNextPrev(flag)
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
if pos == 2
startinsert!
else
silent! normal! l
startinsert
endif
endfunction
function! zencoding#lang#css#splitJoinTag()
" nothing to do
endfunction
function! zencoding#lang#css#removeTag()
" nothing to do
endfunction

View file

@ -1,310 +0,0 @@
function! zencoding#lang#haml#findTokens(str)
return zencoding#lang#html#findTokens(a:str)
endfunction
function! zencoding#lang#haml#parseIntoTree(abbr, type)
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
endfunction
function! zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings
let current = a:current
let type = a:type
let inline = a:inline
let filters = a:filters
let itemno = a:itemno
let indent = a:indent
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
let str = ""
let comment_indent = ''
let comment = ''
let current_name = current.name
if dollar_expr
let current_name = substitute(current.name, '\$$', itemno+1, '')
endif
if len(current.name) > 0
let str .= '%' . current_name
let tmp = ''
for attr in current.attrs_order
if !has_key(current.attr, attr)
continue
endif
let val = current.attr[attr]
if dollar_expr
while val =~ '\$\([^#{]\|$\)'
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
endif
let valtmp = substitute(val, '\${cursor}', '', '')
if attr == 'id' && len(valtmp) > 0
let str .= '#' . val
elseif attr == 'class' && len(valtmp) > 0
let str .= '.' . substitute(val, ' ', '.', 'g')
else
if len(tmp) > 0 | let tmp .= ',' | endif
let val = substitute(val, '\${cursor}', '', '')
let tmp .= ' :' . attr . ' => "' . val . '"'
endif
endfor
if len(tmp)
let str .= '{' . tmp . ' }'
endif
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
let str .= "/"
endif
let inner = ''
if len(current.value) > 0
let text = current.value[1:-2]
if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g')
let str = substitute(str, '\$#', text, 'g')
endif
let lines = split(text, "\n")
if len(lines) == 1
let str .= " " . text
else
for line in lines
let str .= "\n" . indent . line . " |"
endfor
endif
elseif len(current.child) == 0
let str .= '${cursor}'
endif
if len(current.child) == 1 && len(current.child[0].name) == 0
let text = current.child[0].value[1:-2]
if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g')
endif
let lines = split(text, "\n")
if len(lines) == 1
let str .= " " . text
else
for line in lines
let str .= "\n" . indent . line . " |"
endfor
endif
elseif len(current.child) > 0
for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno)
endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
let str .= "\n" . indent . inner
endif
else
let str = current.value[1:-2]
if dollar_expr
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let str = substitute(str, '\${nr}', "\n", 'g')
let str = substitute(str, '\\\$', '$', 'g')
endif
endif
let str .= "\n"
return str
endfunction
function! zencoding#lang#haml#imageSize()
let line = getline('.')
let current = zencoding#lang#haml#parseTag(line)
if empty(current) || !has_key(current.attr, 'src')
return
endif
let fn = current.attr.src
if fn =~ '^\s*$'
return
elseif fn !~ '^\(/\|http\)'
let fn = simplify(expand('%:h') . '/' . fn)
endif
let [width, height] = zencoding#util#getImageSize(fn)
if width == -1 && height == -1
return
endif
let current.attr.width = width
let current.attr.height = height
let current.attrs_order += ['width', 'height']
let haml = zencoding#toString(current, 'haml', 1)
let haml = substitute(haml, '\${cursor}', '', '')
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", "", "g"))
endfunction
function! zencoding#lang#haml#encodeImage()
endfunction
function! zencoding#lang#haml#parseTag(tag)
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] }
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
let match = matchstr(a:tag, mx)
let current.name = substitute(match, mx, '\1', 'i')
let attrs = substitute(match, mx, '\2', 'i')
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
while len(attrs) > 0
let match = matchstr(attrs, mx)
if len(match) == 0
break
endif
let attr_match = matchlist(match, mx)
let name = attr_match[1]
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
let current.attr[name] = value
let current.attrs_order += [name]
let attrs = attrs[stridx(attrs, match) + len(match):]
endwhile
return current
endfunction
function! zencoding#lang#haml#toggleComment()
let line = getline('.')
let space = matchstr(line, '^\s*')
if line =~ '^\s*-#'
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
elseif line =~ '^\s*%[a-z]'
call setline('.', space . '-# ' . line[len(space):])
endif
endfunction
function! zencoding#lang#haml#balanceTag(flag) range
let block = zencoding#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = getpos('.')
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
if a:flag > 0
if a:flag == 1 || !zencoding#util#regionIsValid(block)
let n = line('.')
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
if l > 0 && l < ml
let ml = l
break
endif
let n -= 1
endwhile
endif
let sn = n
if n == 0
let ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
call setpos('.', [0, n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
if l > 0 && l > ml
let ml = l
break
endif
let n += 1
endwhile
let sn = n
if n == 0
let ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
call setpos('.', [0, n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
endif
endfunction
function! zencoding#lang#haml#moveNextPrev(flag)
let pos = search('""', a:flag ? 'Wb' : 'W')
if pos != 0
silent! normal! l
startinsert
endif
endfunction
function! zencoding#lang#haml#splitJoinTag()
let n = line('.')
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
while n > 0
if getline(n) =~ '^\s*\ze%[a-z]'
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
break
endif
let line = getline(n)
call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
let sn = n
let n += 1
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
if len(matchstr(getline(n), '^\s*')) > ml
while n <= line('$')
let l = len(matchstr(getline(n), '^\s*'))
if l <= ml
break
endif
exe n "delete"
endwhile
call setpos('.', [0, sn, 1, 0])
else
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
let spaces = matchstr(getline(sn), '^\s*')
let settings = zencoding#getSettings()
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
call append(sn, spaces . ' ')
call setpos('.', [0, sn+1, 1, 0])
else
call setpos('.', [0, sn, 1, 0])
endif
startinsert!
endif
break
endif
let n -= 1
endwhile
endfunction
function! zencoding#lang#haml#removeTag()
let n = line('.')
let ml = 0
while n > 0
if getline(n) =~ '^\s*\ze[a-z]'
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
break
endif
let n -= 1
endwhile
let sn = n
while n < line('$')
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
if sn == n
exe "delete"
else
exe sn "," (n-1) "delete"
endif
endfunction

View file

@ -1,692 +0,0 @@
let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
\ .'\((*\)\{-}\s*'
\ .'\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|{\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}[ \t\r\n}]*\)'
\ .'\('
\ .'\%('
\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)'
\ .'\|\%(\[[^\]]\+\]\)'
\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)'
\ .'\)*'
\ .'\)'
\ .'\%(\({\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}\)\)\{0,1}'
\ .'\%(\*\([0-9]\+\)\)\{0,1}'
\ .'\(\%()\%(\*[0-9]\+\)\{0,1}\)*\)'
function! zencoding#lang#html#findTokens(str)
let str = a:str
let [pos, last_pos] = [0, 0]
while 1
let tag = matchstr(str, '<[a-zA-Z].\{-}>', pos)
if len(tag) == 0
break
endif
let pos = stridx(str, tag, pos) + len(tag)
endwhile
let last_pos = pos
while len(str) > 0
let token = matchstr(str, s:mx, pos)
if token == ''
break
endif
if token =~ '^\s'
let token = matchstr(token, '^\s*\zs.*')
let last_pos = stridx(str, token, pos)
endif
let pos = stridx(str, token, pos) + len(token)
endwhile
return a:str[last_pos :-1]
endfunction
function! zencoding#lang#html#parseIntoTree(abbr, type)
let abbr = a:abbr
let type = a:type
let settings = zencoding#getSettings()
if !has_key(settings, type)
let type = 'html'
endif
if len(type) == 0 | let type = 'html' | endif
let settings = zencoding#getSettings()
let indent = zencoding#getIndentation(type)
" try 'foo' to (foo-x)
let rabbr = zencoding#getExpandos(type, abbr)
if rabbr == abbr
" try 'foo+(' to (foo-x)
let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".zencoding#getExpandos(type, submatch(1)).")".submatch(2)', 'i')
endif
let abbr = rabbr
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0, 'attrs_order': ['id', 'class'] }
let parent = root
let last = root
let pos = []
while len(abbr)
" parse line
let match = matchstr(abbr, s:mx)
let str = substitute(match, s:mx, '\0', 'ig')
let operator = substitute(match, s:mx, '\1', 'ig')
let block_start = substitute(match, s:mx, '\2', 'ig')
let tag_name = substitute(match, s:mx, '\3', 'ig')
let attributes = substitute(match, s:mx, '\4', 'ig')
let value = substitute(match, s:mx, '\5', 'ig')
let multiplier = 0 + substitute(match, s:mx, '\6', 'ig')
let block_end = substitute(match, s:mx, '\7', 'ig')
let important = 0
if len(str) == 0
break
endif
if tag_name =~ '^#'
let attributes = tag_name . attributes
let tag_name = 'div'
endif
if tag_name =~ '.!$'
let tag_name = tag_name[:-2]
let important = 1
endif
if tag_name =~ '^\.'
let attributes = tag_name . attributes
let tag_name = 'div'
endif
if multiplier <= 0 | let multiplier = 1 | endif
" make default node
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0, 'attrs_order': ['id', 'class'] }
let current.name = tag_name
let current.important = important
" aliases
let aliases = zencoding#getResource(type, 'aliases', {})
if has_key(aliases, tag_name)
let current.name = aliases[tag_name]
endif
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
" snippets
let snippets = zencoding#getResource(type, 'snippets', {})
if !empty(snippets) && has_key(snippets, tag_name)
let snippet = snippets[tag_name]
if use_pipe_for_cursor
let snippet = substitute(snippet, '|', '${cursor}', 'g')
endif
let lines = split(snippet, "\n")
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
let current.snippet = join(lines, "\n")
let current.name = ''
endif
" default_attributes
let default_attributes = zencoding#getResource(type, 'default_attributes', {})
if !empty(default_attributes)
for pat in [current.name, tag_name]
if has_key(default_attributes, pat)
if type(default_attributes[pat]) == 4
let a = default_attributes[pat]
let current.attrs_order += keys(a)
if use_pipe_for_cursor
for k in keys(a)
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
endfor
else
for k in keys(a)
let current.attr[k] = a[k]
endfor
endif
else
for a in default_attributes[pat]
let current.attrs_order += keys(a)
if use_pipe_for_cursor
for k in keys(a)
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
endfor
else
for k in keys(a)
let current.attr[k] = a[k]
endfor
endif
endfor
endif
if has_key(settings.html.default_attributes, current.name)
let current.name = substitute(current.name, ':.*$', '', '')
endif
break
endif
endfor
endif
" parse attributes
if len(attributes)
let attr = attributes
while len(attr)
let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
if len(item) == 0
break
endif
if item[0] == '#'
let current.attr.id = item[1:]
endif
if item[0] == '.'
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
endif
if item[0] == '['
let atts = item[1:-2]
while len(atts)
let amat = matchstr(atts, '\(\w\+\%(="[^"]*"\|=''[^'']*''\|[^ ''"\]]*\)\{0,1}\)')
if len(amat) == 0
break
endif
let key = split(amat, '=')[0]
let val = amat[len(key)+1:]
if val =~ '^["'']'
let val = val[1:-2]
endif
let current.attr[key] = val
if index(current.attrs_order, key) == -1
let current.attrs_order += [key]
endif
let atts = atts[stridx(atts, amat) + len(amat):]
endwhile
endif
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
endwhile
endif
" parse text
if tag_name =~ '^{.*}$'
let current.name = ''
let current.value = tag_name
else
let current.value = value
endif
let current.multiplier = multiplier
" parse step inside/outside
if !empty(last)
if operator =~ '>'
unlet! parent
let parent = last
let current.parent = last
let current.pos = last.pos + 1
else
let current.parent = parent
let current.pos = last.pos
endif
else
let current.parent = parent
let current.pos = 1
endif
if operator =~ '[<^]'
for c in range(len(operator))
let tmp = parent.parent
if empty(tmp)
break
endif
let parent = tmp
let current.parent = tmp
endfor
endif
call add(parent.child, current)
let last = current
" parse block
if block_start =~ '('
if operator =~ '>'
let last.pos += 1
endif
for n in range(len(block_start))
let pos += [last.pos]
endfor
endif
if block_end =~ ')'
for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',')
if n == ')'
if len(pos) > 0 && last.pos >= pos[-1]
for c in range(last.pos - pos[-1])
let tmp = parent.parent
if !has_key(tmp, 'parent')
break
endif
let parent = tmp
endfor
if len(pos) > 0
call remove(pos, -1)
endif
let last = parent
let last.pos += 1
endif
elseif len(n)
let cl = last.child
let cls = []
for c in range(n[1:])
let cls += cl
endfor
let last.child = cls
endif
endfor
endif
let abbr = abbr[stridx(abbr, match) + len(match):]
if g:zencoding_debug > 1
echomsg "str=".str
echomsg "block_start=".block_start
echomsg "tag_name=".tag_name
echomsg "operator=".operator
echomsg "attributes=".attributes
echomsg "value=".value
echomsg "multiplier=".multiplier
echomsg "block_end=".block_end
echomsg "abbr=".abbr
echomsg "pos=".string(pos)
echomsg "---"
endif
endwhile
return root
endfunction
function! zencoding#lang#html#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings
let current = a:current
let type = a:type
let inline = a:inline
let filters = a:filters
let itemno = a:itemno
let indent = a:indent
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
if zencoding#useFilter(filters, 'haml')
return zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
endif
if zencoding#useFilter(filters, 'slim')
return zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
endif
let comment = ''
let current_name = current.name
if dollar_expr
let current_name = substitute(current_name, '\$$', itemno+1, '')
endif
let str = ''
if len(current_name) == 0
let text = current.value[1:-2]
if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g')
endif
return text
endif
if len(current_name) > 0
let str .= '<' . current_name
for attr in current.attrs_order
if !has_key(current.attr, attr)
continue
endif
let val = current.attr[attr]
if dollar_expr
while val =~ '\$\([^#{]\|$\)'
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
endif
let str .= ' ' . attr . '="' . val . '"'
if zencoding#useFilter(filters, 'c')
if attr == 'id' | let comment .= '#' . val | endif
if attr == 'class' | let comment .= '.' . val | endif
endif
endfor
if len(comment) > 0
let str = "<!-- " . comment . " -->\n" . str
endif
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1
let str .= settings.html.empty_element_suffix
else
let str .= ">"
let text = current.value[1:-2]
if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g')
let str = substitute(str, '\("\zs$#\ze"\|\s\zs\$#"\|"\$#\ze\s\)', text, 'g')
endif
let str .= text
let nc = len(current.child)
let dr = 0
if nc > 0
for n in range(nc)
let child = current.child[n]
if child.multiplier > 1
let str .= "\n" . indent
let dr = 1
elseif len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
if nc > 1 || (len(child.name) > 0 && stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1)
let str .= "\n" . indent
let dr = 1
elseif current.multiplier == 1 && nc == 1 && len(child.name) == 0
let str .= "\n" . indent
let dr = 1
endif
endif
let inner = zencoding#toString(child, type, 0, filters, itemno)
let inner = substitute(inner, "^\n", "", 'g')
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
let str .= inner
endfor
else
let str .= '${cursor}'
endif
if dr
let str .= "\n"
endif
let str .= "</" . current_name . ">"
endif
if len(comment) > 0
let str .= "\n<!-- /" . comment . " -->"
endif
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
let str .= "\n"
endif
return str
endfunction
function! zencoding#lang#html#imageSize()
let img_region = zencoding#util#searchRegion('<img\s', '>')
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
return
endif
let content = zencoding#util#getContent(img_region)
if content !~ '^<img[^><]\+>$'
return
endif
let current = zencoding#lang#html#parseTag(content)
if empty(current) || !has_key(current.attr, 'src')
return
endif
let fn = current.attr.src
if fn =~ '^\s*$'
return
elseif fn !~ '^\(/\|http\)'
let fn = simplify(expand('%:h') . '/' . fn)
endif
let [width, height] = zencoding#util#getImageSize(fn)
if width == -1 && height == -1
return
endif
let current.attr.width = width
let current.attr.height = height
let current.attrs_order += ['width', 'height']
let html = substitute(zencoding#toString(current, 'html', 1), '\n', '', '')
let html = substitute(html, '\${cursor}', '', '')
call zencoding#util#setContent(img_region, html)
endfunction
function! zencoding#lang#html#encodeImage()
let img_region = zencoding#util#searchRegion('<img\s', '>')
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
return
endif
let content = zencoding#util#getContent(img_region)
if content !~ '^<img[^><]\+>$'
return
endif
let current = zencoding#lang#html#parseTag(content)
if empty(current) || !has_key(current.attr, 'src')
return
endif
let fn = current.attr.src
if fn !~ '^\(/\|http\)'
let fn = simplify(expand('%:h') . '/' . fn)
endif
let [width, height] = zencoding#util#getImageSize(fn)
if width == -1 && height == -1
return
endif
let current.attr.width = width
let current.attr.height = height
let html = zencoding#toString(current, 'html', 1)
call zencoding#util#setContent(img_region, html)
endfunction
function! zencoding#lang#html#parseTag(tag)
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] }
let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
let match = matchstr(a:tag, mx)
let current.name = substitute(match, mx, '\1', 'i')
let attrs = substitute(match, mx, '\2', 'i')
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
while len(attrs) > 0
let match = matchstr(attrs, mx)
if len(match) == 0
break
endif
let attr_match = matchlist(match, mx)
let name = attr_match[1]
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
let current.attr[name] = value
let current.attrs_order += [name]
let attrs = attrs[stridx(attrs, match) + len(match):]
endwhile
return current
endfunction
function! zencoding#lang#html#toggleComment()
let orgpos = getpos('.')
let curpos = getpos('.')
let mx = '<\%#[^>]*>'
while 1
let block = zencoding#util#searchRegion('<!--', '-->')
if zencoding#util#regionIsValid(block)
let block[1][1] += 2
let content = zencoding#util#getContent(block)
let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '')
call zencoding#util#setContent(block, content)
silent! call setpos('.', orgpos)
return
endif
let block = zencoding#util#searchRegion('<[^>]', '>')
if !zencoding#util#regionIsValid(block)
let pos1 = searchpos('<', 'bcW')
if pos1[0] == 0 && pos1[1] == 0
return
endif
let curpos = getpos('.')
continue
endif
let pos1 = block[0]
let pos2 = block[1]
let content = zencoding#util#getContent(block)
let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
if tag_name[0] == '/'
call setpos('.', [0, pos1[0], pos1[1], 0])
let pos2 = searchpairpos('<'. tag_name[1:] . '>', '', '</' . tag_name[1:] . '>', 'bnW')
let pos1 = searchpos('>', 'cneW')
let block = [pos2, pos1]
elseif tag_name =~ '/$'
if !zencoding#util#pointInRegion(orgpos[1:2], block)
" it's broken tree
call setpos('.', orgpos)
let block = zencoding#util#searchRegion('>', '<')
let content = '><!-- ' . zencoding#util#getContent(block)[1:-2] . ' --><'
call zencoding#util#setContent(block, content)
silent! call setpos('.', orgpos)
return
endif
else
call setpos('.', [0, pos2[0], pos2[1], 0])
let pos2 = searchpairpos('<'. tag_name . '>', '', '</' . tag_name . '>', 'nW')
call setpos('.', [0, pos2[0], pos2[1], 0])
let pos2 = searchpos('>', 'neW')
let block = [pos1, pos2]
endif
if !zencoding#util#regionIsValid(block)
silent! call setpos('.', orgpos)
return
endif
if zencoding#util#pointInRegion(curpos[1:2], block)
let content = '<!-- ' . zencoding#util#getContent(block) . ' -->'
call zencoding#util#setContent(block, content)
silent! call setpos('.', orgpos)
return
endif
endwhile
endfunction
function! zencoding#lang#html#balanceTag(flag) range
let vblock = zencoding#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = getpos('.')
endif
let settings = zencoding#getSettings()
if a:flag > 0
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
while 1
let pos1 = searchpos(mx, 'bW')
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
let pos2 = searchpos('>', 'nW')
else
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '>\zs', 'nW')
endif
let block = [pos1, pos2]
if pos1[0] == 0 && pos1[1] == 0
break
endif
if zencoding#util#pointInRegion(curpos[1:2], block) && zencoding#util#regionIsValid(block)
call zencoding#util#selectRegion(block)
return
endif
endwhile
else
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
while 1
let pos1 = searchpos(mx, 'W')
if pos1 == curpos[1:2]
let pos1 = searchpos(mx . '\zs', 'W')
let pos2 = searchpos('.\ze<', 'W')
let block = [pos1, pos2]
if zencoding#util#regionIsValid(block)
call zencoding#util#selectRegion(block)
return
endif
endif
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
let pos2 = searchpos('>', 'nW')
else
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '>\zs', 'nW')
endif
let block = [pos1, pos2]
if pos1[0] == 0 && pos1[1] == 0
break
endif
if zencoding#util#regionIsValid(block)
call zencoding#util#selectRegion(block)
return
endif
endwhile
endif
call setpos('.', curpos)
if a:flag == -2 || a:flag == 2
silent! exe "normal! gv"
endif
endfunction
function! zencoding#lang#html#moveNextPrev(flag)
let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp')
if pos == 3
startinsert!
elseif pos != 0
silent! normal! l
startinsert
endif
endfunction
function! zencoding#lang#html#splitJoinTag()
let curpos = getpos('.')
while 1
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
let pos1 = searchpos(mx, 'bcnW')
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
let content = content[:-3] . "></" . tag_name . '>'
call zencoding#util#setContent(block, content)
call setpos('.', [0, block[0][0], block[0][1], 0])
return
else
if tag_name[0] == '/'
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
call setpos('.', [0, pos1[0], pos1[1], 0])
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
else
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
endif
let block = [pos1, pos2]
let content = zencoding#util#getContent(block)
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
let content = matchstr(content, mx)[:-2] . '/>'
call zencoding#util#setContent(block, content)
call setpos('.', [0, block[0][0], block[0][1], 0])
return
else
if block[0][0] > 0
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
else
call setpos('.', curpos)
return
endif
endif
endif
endwhile
endfunction
function! zencoding#lang#html#removeTag()
let curpos = getpos('.')
while 1
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
let pos1 = searchpos(mx, 'bcnW')
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '')
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
call zencoding#util#setContent(block, '')
call setpos('.', [0, block[0][0], block[0][1], 0])
return
else
if tag_name[0] == '/'
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
call setpos('.', [0, pos1[0], pos1[1], 0])
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
else
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
endif
let block = [pos1, pos2]
let content = zencoding#util#getContent(block)
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
call zencoding#util#setContent(block, '')
call setpos('.', [0, block[0][0], block[0][1], 0])
return
else
if block[0][0] > 0
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
else
call setpos('.', curpos)
return
endif
endif
endif
endwhile
endfunction

View file

@ -1,158 +0,0 @@
function! zencoding#lang#sass#findTokens(str)
return zencoding#lang#html#findTokens(a:str)
endfunction
function! zencoding#lang#sass#parseIntoTree(abbr, type)
if a:abbr =~ '>'
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
else
return zencoding#lang#css#parseIntoTree(a:abbr, a:type)
endif
endfunction
function! zencoding#lang#sass#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings
let current = a:current
let type = a:type
let inline = a:inline
let filters = a:filters
let itemno = a:itemno
let indent = a:indent
let str = ""
let current_name = current.name
let current_name = substitute(current.name, '\$$', itemno+1, '')
if len(current.name) > 0
let str .= current_name
let tmp = ''
for attr in keys(current.attr)
let val = current.attr[attr]
while val =~ '\$\([^#{]\|$\)'
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
if attr == 'id'
let str .= '#' . val
elseif attr == 'class'
let str .= '.' . val
else
let tmp .= attr . ': ' . val
endif
endfor
if len(tmp) > 0
let str .= "\n"
for line in split(tmp, "\n")
let str .= indent . line . "\n"
endfor
else
let str .= "\n"
endif
let inner = ''
for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno)
endfor
let inner = substitute(inner, "\n", "\n" . indent, 'g')
let inner = substitute(inner, "\n" . indent . "$", "", 'g')
let str .= indent . inner
else
let text = zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
let text = substitute(text, '\${cursor}', '', 'g')
let text = substitute(text, '\s*;$', '', '')
return text
endif
return str
endfunction
function! zencoding#lang#sass#imageSize()
endfunction
function! zencoding#lang#sass#encodeImage()
endfunction
function! zencoding#lang#sass#parseTag(tag)
endfunction
function! zencoding#lang#sass#toggleComment()
endfunction
function! zencoding#lang#sass#balanceTag(flag) range
let block = zencoding#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = getpos('.')
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
if a:flag > 0
if a:flag == 1 || !zencoding#util#regionIsValid(block)
let n = line('.')
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
if l > 0 && l < ml
let ml = l
break
endif
let n -= 1
endwhile
endif
let sn = n
if n == 0
let ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
call setpos('.', [0, n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
if l > 0 && l > ml
let ml = l
break
endif
let n += 1
endwhile
let sn = n
if n == 0
let ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
call setpos('.', [0, n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
endif
endfunction
function! zencoding#lang#sass#moveNextPrev(flag)
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if pos == 2
startinsert!
elseif pos != 0
silent! normal! l
startinsert
endif
endfunction
function! zencoding#lang#sass#splitJoinTag()
endfunction
function! zencoding#lang#sass#removeTag()
endfunction

View file

@ -1,121 +0,0 @@
function! zencoding#lang#scss#findTokens(str)
return zencoding#lang#html#findTokens(a:str)
endfunction
function! zencoding#lang#scss#parseIntoTree(abbr, type)
if a:abbr =~ '>'
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
else
return zencoding#lang#css#parseIntoTree(a:abbr, a:type)
endif
endfunction
function! zencoding#lang#scss#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings
let current = a:current
let type = a:type
let inline = a:inline
let filters = a:filters
let itemno = a:itemno
let indent = a:indent
let str = ""
let current_name = substitute(current.name, '\$$', itemno+1, '')
if len(current.name) > 0
let str .= current_name
let tmp = ''
for attr in keys(current.attr)
let val = current.attr[attr]
while val =~ '\$\([^#{]\|$\)'
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
if attr == 'id'
let str .= '#' . val
elseif attr == 'class'
let str .= '.' . val
else
let tmp .= attr . ': ' . val . ';'
endif
endfor
if len(tmp) > 0
let str .= " {\n"
for line in split(tmp, "\n")
let str .= indent . line . "\n"
endfor
else
let str .= " {\n"
endif
let inner = ''
for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno)
endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
let str .= indent . inner . "\n}\n"
else
return zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
endif
return str
endfunction
function! zencoding#lang#scss#imageSize()
call zencoding#lang#css#imageSize()
endfunction
function! zencoding#lang#scss#encodeImage()
return zencoding#lang#css#encodeImage()
endfunction
function! zencoding#lang#scss#parseTag(tag)
return zencoding#lang#css#parseTag(a:tag)
endfunction
function! zencoding#lang#scss#toggleComment()
call zencoding#lang#css#toggleComment()
endfunction
function! zencoding#lang#scss#balanceTag(flag) range
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
call setpos('.', curpos)
else
let curpos = getpos('.')
endif
if a:flag < 0
let ret = searchpair('}', '', '.\zs{')
else
let ret = searchpair('{', '', '}', 'bW')
endif
if ret > 0
let pos1 = getpos('.')[1:2]
if a:flag < 0
let pos2 = searchpairpos('{', '', '}')
else
let pos2 = searchpairpos('{', '', '}')
endif
let block = [pos1, pos2]
if zencoding#util#regionIsValid(block)
call zencoding#util#selectRegion(block)
return
endif
endif
if a:flag == -2 || a:flag == 2
silent! exe "normal! gv"
else
call setpos('.', curpos)
endif
endfunction
function! zencoding#lang#scss#moveNextPrev(flag)
call zencoding#lang#css#moveNextPrev(a:flag)
endfunction
function! zencoding#lang#scss#splitJoinTag()
call zencoding#lang#css#splitJoinTag()
endfunction
function! zencoding#lang#scss#removeTag()
call zencoding#lang#ss#removeTag()
endfunction

View file

@ -1,276 +0,0 @@
function! zencoding#lang#slim#findTokens(str)
return zencoding#lang#html#findTokens(a:str)
endfunction
function! zencoding#lang#slim#parseIntoTree(abbr, type)
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
endfunction
function! zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
let settings = a:settings
let current = a:current
let type = a:type
let inline = a:inline
let filters = a:filters
let itemno = a:itemno
let indent = a:indent
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
let str = ""
let comment_indent = ''
let comment = ''
let current_name = current.name
if dollar_expr
let current_name = substitute(current.name, '\$$', itemno+1, '')
endif
if len(current.name) > 0
let str .= current_name
for attr in current.attrs_order
if !has_key(current.attr, attr)
continue
endif
let val = current.attr[attr]
if dollar_expr
while val =~ '\$\([^#{]\|$\)'
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
endwhile
endif
let attr = substitute(attr, '\$$', itemno+1, '')
let str .= ' ' . attr . '="' . val . '"'
endfor
let inner = ''
if len(current.value) > 0
let str .= "\n"
let text = current.value[1:-2]
if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g')
let str = substitute(str, '\$#', text, 'g')
endif
for line in split(text, "\n")
let str .= indent . "| " . line . "\n"
endfor
elseif len(current.child) == 0
let str .= '${cursor}'
endif
if len(current.child) == 1 && len(current.child[0].name) == 0
let str .= "\n"
let text = current.child[0].value[1:-2]
if dollar_expr
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g')
endif
for line in split(text, "\n")
let str .= indent . "| " . line . "\n"
endfor
elseif len(current.child) > 0
for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno)
endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
let str .= "\n" . indent . inner
endif
else
let str = current.value[1:-2]
if dollar_expr
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
let str = substitute(str, '\${nr}', "\n", 'g')
let str = substitute(str, '\\\$', '$', 'g')
endif
endif
if str !~ "\n$"
let str .= "\n"
endif
return str
endfunction
function! zencoding#lang#slim#imageSize()
let line = getline('.')
let current = zencoding#lang#slim#parseTag(line)
if empty(current) || !has_key(current.attr, 'src')
return
endif
let fn = current.attr.src
if fn =~ '^\s*$'
return
elseif fn !~ '^\(/\|http\)'
let fn = simplify(expand('%:h') . '/' . fn)
endif
let [width, height] = zencoding#util#getImageSize(fn)
if width == -1 && height == -1
return
endif
let current.attr.width = width
let current.attr.height = height
let current.attrs_order += ['width', 'height']
let slim = zencoding#toString(current, 'slim', 1)
let slim = substitute(slim, '\${cursor}', '', '')
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", "", "g"))
endfunction
function! zencoding#lang#slim#encodeImage()
endfunction
function! zencoding#lang#slim#parseTag(tag)
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'attrs_order': [] }
let mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
let match = matchstr(a:tag, mx)
let current.name = substitute(match, mx, '\1', 'i')
let attrs = substitute(match, mx, '\2', 'i')
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
while len(attrs) > 0
let match = matchstr(attrs, mx)
if len(match) == 0
break
endif
let attr_match = matchlist(match, mx)
let name = attr_match[1]
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
let current.attr[name] = value
let current.attrs_order += [name]
let attrs = attrs[stridx(attrs, match) + len(match):]
endwhile
return current
endfunction
function! zencoding#lang#slim#toggleComment()
let line = getline('.')
let space = matchstr(line, '^\s*')
if line =~ '^\s*/'
call setline('.', space . line[len(space)+1:])
elseif line =~ '^\s*[a-z]'
call setline('.', space . '/' . line[len(space):])
endif
endfunction
function! zencoding#lang#slim#balanceTag(flag) range
let block = zencoding#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = getpos('.')
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
if a:flag > 0
if a:flag == 1 || !zencoding#util#regionIsValid(block)
let n = line('.')
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
if l > 0 && l < ml
let ml = l
break
endif
let n -= 1
endwhile
endif
let sn = n
if n == 0
let ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
call setpos('.', [0, n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
if l > 0 && l > ml
let ml = l
break
endif
let n += 1
endwhile
let sn = n
if n == 0
let ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
call setpos('.', [0, n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
endif
endfunction
function! zencoding#lang#slim#moveNextPrev(flag)
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if pos == 2
startinsert!
elseif pos != 0
silent! normal! l
startinsert
endif
endfunction
function! zencoding#lang#slim#splitJoinTag()
let n = line('.')
while n > 0
if getline(n) =~ '^\s*\ze[a-z]'
let sn = n
let n += 1
if getline(n) =~ '^\s*|'
while n <= line('$')
if getline(n) !~ '^\s*|'
break
endif
exe n "delete"
endwhile
call setpos('.', [0, sn, 1, 0])
else
let spaces = matchstr(getline(sn), '^\s*')
call append(sn, spaces . ' | ')
call setpos('.', [0, sn+1, 1, 0])
startinsert!
endif
break
endif
let n -= 1
endwhile
endfunction
function! zencoding#lang#slim#removeTag()
let n = line('.')
let ml = 0
while n > 0
if getline(n) =~ '^\s*\ze[a-z]'
let ml = len(matchstr(getline(n), '^\s*[a-z]'))
break
endif
let n -= 1
endwhile
let sn = n
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
if sn == n
exe "delete"
else
exe sn "," (n-1) "delete"
endif
endfunction

View file

@ -1,249 +0,0 @@
"==============================================================================
" region utils
"==============================================================================
" deleteContent : delete content in region
" if region make from between '<foo>' and '</foo>'
" --------------------
" begin:<foo>
" </foo>:end
" --------------------
" this function make the content as following
" --------------------
" begin::end
" --------------------
function! zencoding#util#deleteContent(region)
let lines = getline(a:region[0][0], a:region[1][0])
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]])
endfunction
" change_content : change content in region
" if region make from between '<foo>' and '</foo>'
" --------------------
" begin:<foo>
" </foo>:end
" --------------------
" and content is
" --------------------
" foo
" bar
" baz
" --------------------
" this function make the content as following
" --------------------
" begin:foo
" bar
" baz:end
" --------------------
function! zencoding#util#setContent(region, content)
let newlines = split(a:content, '\n', 1)
let oldlines = getline(a:region[0][0], a:region[1][0])
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
if len(newlines) == 0
let tmp = ''
if a:region[0][1] > 1
let tmp = oldlines[0][:a:region[0][1]-2]
endif
if a:region[1][1] >= 1
let tmp .= oldlines[-1][a:region[1][1]:]
endif
call setline(line('.'), tmp)
elseif len(newlines) == 1
if a:region[0][1] > 1
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
endif
if a:region[1][1] >= 1
let newlines[0] .= oldlines[-1][a:region[1][1]:]
endif
call setline(line('.'), newlines[0])
else
if a:region[0][1] > 1
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
endif
if a:region[1][1] >= 1
let newlines[-1] .= oldlines[-1][a:region[1][1]:]
endif
call setline(line('.'), newlines[0])
call append(line('.'), newlines[1:])
endif
endfunction
" select_region : select region
" this function make a selection of region
function! zencoding#util#selectRegion(region)
call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
normal! v
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
endfunction
" point_in_region : check point is in the region
" this function return 0 or 1
function! zencoding#util#pointInRegion(point, region)
if !zencoding#util#regionIsValid(a:region) | return 0 | endif
if a:region[0][0] > a:point[0] | return 0 | endif
if a:region[1][0] < a:point[0] | return 0 | endif
if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif
return 1
endfunction
" cursor_in_region : check cursor is in the region
" this function return 0 or 1
function! zencoding#util#cursorInRegion(region)
if !zencoding#util#regionIsValid(a:region) | return 0 | endif
let cur = getpos('.')[1:2]
return zencoding#util#pointInRegion(cur, a:region)
endfunction
" region_is_valid : check region is valid
" this function return 0 or 1
function! zencoding#util#regionIsValid(region)
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
return 1
endfunction
" search_region : make region from pattern which is composing start/end
" this function return array of position
function! zencoding#util#searchRegion(start, end)
return [searchpairpos(a:start, '', a:end, 'bcnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
endfunction
" get_content : get content in region
" this function return string in region
function! zencoding#util#getContent(region)
if !zencoding#util#regionIsValid(a:region)
return ''
endif
let lines = getline(a:region[0][0], a:region[1][0])
if a:region[0][0] == a:region[1][0]
let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1]
else
let lines[0] = lines[0][a:region[0][1]-1:]
let lines[-1] = lines[-1][:a:region[1][1]-1]
endif
return join(lines, "\n")
endfunction
" region_in_region : check region is in the region
" this function return 0 or 1
function! zencoding#util#regionInRegion(outer, inner)
if !zencoding#util#regionIsValid(a:inner) || !zencoding#util#regionIsValid(a:outer)
return 0
endif
return zencoding#util#pointInRegion(a:inner[0], a:outer) && zencoding#util#pointInRegion(a:inner[1], a:outer)
endfunction
" get_visualblock : get region of visual block
" this function return region of visual block
function! zencoding#util#getVisualBlock()
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
endfunction
"==============================================================================
" html utils
"==============================================================================
function! zencoding#util#getContentFromURL(url)
let res = system(printf("%s %s", g:zencoding_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
let s1 = len(split(res, '?'))
let utf8 = iconv(res, 'utf-8', &encoding)
let s2 = len(split(utf8, '?'))
return (s2 == s1 || s2 >= s1 * 2) ? utf8 : res
endfunction
function! zencoding#util#getTextFromHTML(buf)
let threshold_len = 100
let threshold_per = 0.1
let buf = a:buf
let buf = strpart(buf, stridx(buf, '</head>'))
let buf = substitute(buf, '<style[^>]*>.\{-}</style>', '', 'g')
let buf = substitute(buf, '<script[^>]*>.\{-}</script>', '', 'g')
let res = ''
let max = 0
let mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
let m = split(buf, mx)
for str in m
let c = split(str, '<[^>]*?>')
let str = substitute(str, '<[^>]\{-}>', ' ', 'g')
let str = substitute(str, '&gt;', '>', 'g')
let str = substitute(str, '&lt;', '<', 'g')
let str = substitute(str, '&quot;', '"', 'g')
let str = substitute(str, '&apos;', "'", 'g')
let str = substitute(str, '&nbsp;', ' ', 'g')
let str = substitute(str, '&yen;', '\&#65509;', 'g')
let str = substitute(str, '&amp;', '\&', 'g')
let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '')
let str = substitute(str, '\s\+', ' ', 'g')
let l = len(str)
if l > threshold_len
let per = (l+0.0) / len(c)
if max < l && per > threshold_per
let max = l
let res = str
endif
endif
endfor
let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g')
return res
endfunction
function! zencoding#util#getImageSize(fn)
let fn = a:fn
if zencoding#util#isImageMagickInstalled()
return zencoding#util#imageSizeWithImageMagick(fn)
endif
if filereadable(fn)
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
else
let hex = substitute(system(g:zencoding_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
endif
let [width, height] = [-1, -1]
if hex =~ '^89504e470d0a1a0a'
let width = eval('0x'.hex[32:39])
let height = eval('0x'.hex[40:47])
endif
if hex =~ '^ffd8'
let pos = 4
while pos < len(hex)
let bs = hex[pos+0:pos+3]
let pos += 4
if bs == 'ffc0' || bs == 'ffc2'
let pos += 6
let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
let pos += 4
let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
break
elseif bs =~ 'ffd[9a]'
break
elseif bs =~ 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2
endif
endwhile
endif
if hex =~ '^47494638'
let width = eval('0x'.hex[14:15].hex[12:13])
let height = eval('0x'.hex[18:19].hex[16:17])
endif
return [width, height]
endfunction
function! zencoding#util#imageSizeWithImageMagick(fn)
let img_info = system('identify -format "%wx%h" "'.a:fn.'"')
let img_size = split(substitute(img_info, '\n', '', ''), 'x')
let width = img_size[0]
let height = img_size[1]
return [width, height]
endfunction
function! zencoding#util#isImageMagickInstalled()
if !get(s:, 'zencoding_use_identify', 1)
return 0
endif
return executable('identify')
endfunction

View file

@ -1,438 +0,0 @@
*zencoding.txt* ZenCoding for Vim
-------------------------------------------------------
ZenCoding: vim plugins for HTML and CSS hi-speed coding
-------------------------------------------------------
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
WebSite: http://mattn.kaoriya.net/
Repository: http://github.com/mattn/zencoding-vim
Site: http://mattn.github.com/zencoding-vim
License: BSD style license
==============================================================================
CONTENTS *zencoding-contents*
Introduction |zencoding-introduction|
Install |zencoding-install|
Tutorial |zencoding-tutorial|
1. Expand Abbreviation |zencoding-expandabbr|
2. Wrap with Abbreviation |zencoding-wrap-wtih-abbreviation|
3. Balance Tag Inward |zencoding-balance-tag-inward|
4. Balance Tag Outward |zencoding-balance-tag-outward|
5. Go to Next Edit Point |zencoding-goto-next-point| |<C-Y>n|
6. Go to Previous Edit Point |zencoding-goto-previous-point|
7. Update <img> Size |zencoding-update-image-size|
8. Merge Lines |zencoding-merge-lines|
9. Remove Tag |zencoding-remove-tag|
10. Split/Join Tag |zencoding-split-join-tag|
11. Toggle Comment |zencoding-toggle-comment|
12. Make anchor from URL |zencoding-make-anchor-url|
13. Make quoted text from URL |zencoding-quoted-text-url|
14. Code Pretty |zencoding-code-pretty|
Customize |zencoding-customize|
1. Key Mappings |zencoding-customize-keymappings|
2. Indent Size |zencoding-indent-size|
3. Define Tag's Behavior |zencoding-define-tags-behavior|
4. Complete Tag |zencoding-complete-tag|
Links |zencoding-links|
ToDo |zencoding-todo|
==============================================================================
INTRODUCTION *zencoding-introduction* *zencoding*
|ZenCoding| is an editor plugin for high-speed HTML, XML, XSL (or any other
structured code format) coding and editing. The core of this plugin is a
powerful abbreviation engine which allows you to expand expressions?similar to
CSS selectors?into HTML code:
>
div#page>div.logo+ul#navigation>li*5>a
<
...can be expanded into:
>
<div id="page">
<div class="logo"></div>
<ul id="navigation">
<li><a href=""></a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
</div>
<
Read more about current Zen Coding syntax
http://code.google.com/p/zen-coding/wiki/ZenHTMLSelectorsEn
Abbreviation engine has a modular structure which allows you to expand
abbreviations into different languages. Zen Coding currently supports CSS,
HTML, XML/XSL and HAML, Slim languages via filters.
==============================================================================
INSTALL *zencoding-install*
Install the distributed files into Vim runtime directory which is usually
~/.vim/, or $HOME/vimfiles on Windows.
If you install pathogen that provided from Tim Pope, you should extract the
file into 'bundle' directory.
==============================================================================
TUTORIAL *zencoding-tutorial*
If you are seeing this file as :help, then you can't edit this file.
You should copy this section and create new buffer, paste and write as
'zencoding-tutor.txt'. Formally, open the file to start tutorial.
1. Expand Abbreviation *zencoding-expandabbr* *<C-Y>,*
Type abbreviation as 'div>p#foo$*3>a' and type |<C-Y>,|.
>
<div>
<p id="foo1">
<a href=""></a>
</p>
<p id="foo2">
<a href=""></a>
</p>
<p id="foo3">
<a href=""></a>
</p>
</div>
<
2. Wrap with Abbreviation *zencoding-wrap-wtih-abbreviation* *v_<C-Y>,*
Write as below.
>
test1
test2
test3
<
Then do visual select(line wize) and type |<C-Y>,|.
If you request 'Tag:', then type 'ul>li*'.
>
<ul>
<li>test1</li>
<li>test2</li>
<li>test3</li>
</ul>
<
If you type tag as 'blockquote', then you'll see as following.
>
<blockquote>
test1
test2
test3
</blockquote>
<
3. Balance Tag Inward *zencoding-balance-tag-inward* *<C-Y>d*
To select inward of ul tag, type |<C-Y>d| in insert mode.
>
<ul>
* <li class="list1"></li>
<li class="list2"></li>
<li class="list3"></li>
</ul>
<
If cursor is at '*', |<C-Y>d| select from begin of <ul> to end of </ul>.
If cursor is at first of <li>, it select <li class="list1"></li>.
4. Balance Tag Outward *zencoding-balance-tag-outward* *<C-Y>D*
To select outward of ul tag, insert mode, type <C-Y>D in insert mode.
>
<ul>
* <li class="list1"></li>
<li class="list2"></li>
<li class="list3"></li>
</ul>
<
If cursor is at '*', |<C-Y>D| select from next letter of <ul> to previous
letter of </ul>.
If cursor is at first of <li>, it select <li class="list1"></li>.
5. Go to Next Edit Point *zencoding-goto-next-point* *<C-Y>n*
To jump next point that need to edit, type |<C-Y>n| in insert mode.
>
* <div id="foo" class="">foo</div>
<div id="bar" class="bar"></li>
<
If cursor is at '*', |<C-Y>n| move a cursor into attribute value of div
specified id as 'foo'. And type again |<C-Y>n| move a cursor into inner of
div specified id as 'bar'.
6. Go to Previous Edit Point *zencoding-goto-previous-point* *<C-Y>N*
To jump previous point that need to edit, type |<C-Y>N| in insert mode.
>
<div id="foo" class="">foo</div>
<div id="bar" class="bar"></li> *
<
If cursor is at '*', |<C-Y>N| move a cursor into div specified id as 'bar'.
And type again |<C-Y>N| move a cursor into attribute value of 'foo'.
7. Update <img> Size *zencoding-update-image-size* *<C-Y>i*
To expand or update size of image, type |<C-Y>i| on img tag
>
<img src="foo.png" />
<
Type '<c-y>i' on img tag
>
<img src="foo.png" width="32" height="32" />
<
If you change image, then type it again. it will be following.
>
<img src="foo-48.png" width="32" height="48" />
<
8. Merge Lines *zencoding-merge-lines*
To join multi line text like following, type |J|.
>
<ul>
<li class="list1"></li>
<li class="list2"></li>
<li class="list3"></li>
</ul>
<
If you select part of line include <li> and type |<C-Y>m|, it will be
following.
>
<ul>
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
</ul>
<
9. Remove Tag *zencoding-remove-tag* *<C-Y>k*
To remove tag in the block, type |<C-Y>k|.
>
<div class="foo">
<a>cursor is here</a>
</div>
<
Type |<C-Y>k| in insert mode, then
>
<div class="foo">
</div>
<
And type |<C-Y>k| in there again, then div will be removed.
10. Split/Join Tag *zencoding-split-join-tag* *<C-Y>j*
To join block, type |<C-Y>j|.
>
<div class="foo">
cursor is here
</div>
<
Type |<C-Y>j| in insert mode. then,
>
<div class="foo"/>
<
And type |<C-Y>j| in there again.
>
<div class="foo">
</div>
<
11. Toggle Comment *zencoding-toggle-comment* *<C-Y>/*
Move cursor to block
>
<div>
hello world
</div>
<
Type '<c-y>/' in insert mode.
>
<!-- <div>
hello world
</div> -->
<
Type '<c-y>/' in there again.
>
<div>
hello world
</div>
<
12. Make anchor from URL *zencoding-make-anchor-url* *<C-Y>a*
Move cursor to URL
>
http://www.google.com/
<
Type |<C-Y>a|
>
<a href="http://www.google.com/">Google</a>
<
13. Make quoted text from URL *zencoding-quoted-text-url* *<C-Y>A*
Move cursor to URL
>
http://github.com/
<
Type |<C-Y>A|
>
<blockquote class="quote">
<a href="http://github.com/">Secure source code hosting and collaborative development - GitHub</a><br />
<p>How does it work? Get up and running in seconds by forking a project, pushing an existing repository...</p>
<cite>http://github.com/</cite>
</blockquote>
<
14. Code Pretty *zencoding-code-pretty* *<C-Y>c*
Select code block, for example select following code from "int main()".
>
<p>Writing in C language</p>
int main() {
puts("hello world");
}
<
Type |<C-Y>c|
>
<p>Writing in C language</p>
<span class="Type">int</span>&nbsp;main() {<br />
&nbsp;&nbsp;puts(<span class="Constant">&quot;hello world&quot;</span>);<br />
}<br />
<
==============================================================================
CUSTOMIZE *zencoding-customize*
1. Key Mapping *zencoding-customize-keymappings*
To specify leading key for expanding or balance tag, or for all,
Add this line in your vimrc: >
>
let g:user_zen_leader_key = '<c-y>'
<
Or if you prefer to map for each actions, then you set each variables.
'user_zen_expandabbr_key'
'user_zen_expandword_key'
'user_zen_balancetaginward_key'
'user_zen_balancetagoutward_key'
'user_zen_next_key'
'user_zen_prev_key'
'user_zen_imagesize_key'
'user_zen_togglecomment_key'
'user_zen_splitjointag_key'
'user_zen_removetag_key'
'user_zen_anchorizeurl_key'
'user_zen_anchorizesummary_key'
2. Indent Size *zencoding-indent-size*
To change indent size of html, add this code in your vimrc.
>
let g:user_zen_settings = {
\ 'html' : {
\ 'indentation' : ' '
\ },
\}
<
If you prefer to change global indent size then add this.
>
let g:user_zen_settings = {
\ 'indentation' : ' '
\}
<
3. Define Tag's Behavior *zencoding-define-tags-behavior*
zencoding.vim can change behavior of expanding abbreviation for each
filetypes as |Dictionary|. for details, see official site of zencoding.
for example, vimmer can add following.
>
let g:user_zen_settings = {
\ 'lang' : 'ja',
\ 'html' : {
\ 'filters' : 'html',
\ 'indentation' : ' '
\ },
\ 'perl' : {
\ 'indentation' : ' ',
\ 'aliases' : {
\ 'req' : "require '|'"
\ },
\ 'snippets' : {
\ 'use' : "use strict\nuse warnings\n\n",
\ 'w' : "warn \"${cursor}\";",
\ },
\ },
\ 'php' : {
\ 'extends' : 'html',
\ 'filters' : 'html,c',
\ },
\ 'css' : {
\ 'filters' : 'fc',
\ },
\ 'javascript' : {
\ 'snippets' : {
\ 'jq' : "$(function() {\n\t${cursor}${child}\n});",
\ 'jq:each' : "$.each(arr, function(index, item)\n\t${child}\n});",
\ 'fn' : "(function() {\n\t${cursor}\n})();",
\ 'tm' : "setTimeout(function() {\n\t${cursor}\n}, 100);",
\ },
\ },
\ 'java' : {
\ 'indentation' : ' ',
\ 'snippets' : {
\ 'main': "public static void main(String[] args) {\n\t|\n}",
\ 'println': "System.out.println(\"|\");",
\ 'class': "public class | {\n}\n",
\ },
\ },
\}
<
4. Complete Tag *zencoding-complete-tag*
If you want to complete tags using |omnifunc| then add this.
>
let g:use_zen_complete_tag = 1
<
5. Enable functions in different mode
If you want to use zencoding only in some modes, set an mode option:
let g:user_zen_mode='n' "only enable normal mode functions, or
let g:user_zen_mode='inv' "enable all functions, which is equal to
let g:user_zen_mode='a' "enable all function in all mode.
==============================================================================
LINKS *zencoding-links*
zen-coding official site:
http://code.google.com/p/zen-coding/
zencoding.vim:
http://mattn.github.com/zencoding-vim
development repository:
https://github.com/mattn/zencoding-vim
my blog posts about zencoding-vim:
http://mattn.kaoriya.net/software/vim/20100222103327.htm
http://mattn.kaoriya.net/software/vim/20100306021632.htm
japanese blog posts about zencoding-vim:
http://d.hatena.ne.jp/idesaku/20100424/1272092255
http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding
http://d.hatena.ne.jp/sakurako_s/20110126/1295988873
http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html
tutorial traslated in chinese:
http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html
==============================================================================
TODO *zencoding-todo*
* wrapping inline selected.
* more documents.
* more contributor.
* more time to improve zencodig.vim.
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:

View file

@ -1,215 +0,0 @@
"=============================================================================
" File: zencoding.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 13-Feb-2013.
" Version: 0.75
" WebPage: http://github.com/mattn/zencoding-vim
" Description: vim plugins for HTML and CSS hi-speed coding.
" SeeAlso: http://code.google.com/p/zen-coding/
" Usage:
"
" This is vim script support expanding abbreviation like zen-coding.
" ref: http://code.google.com/p/zen-coding/
"
" Type abbreviation
" +-------------------------------------
" | html:5_
" +-------------------------------------
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
" NOTE: Don't worry about key map. you can change it easily.
" +-------------------------------------
" | <!DOCTYPE HTML>
" | <html lang="en">
" | <head>
" | <title></title>
" | <meta charset="UTF-8">
" | </head>
" | <body>
" | _
" | </body>
" | </html>
" +-------------------------------------
" Type following
" +-------------------------------------
" | div#foo$*2>div.bar
" +-------------------------------------
" And type "<c-y>,"
" +-------------------------------------
" |<div id="foo1">
" | <div class="bar">_</div>
" |</div>
" |<div id="foo2">
" | <div class="bar"></div>
" |</div>
" +-------------------------------------
"
" Tips:
"
" You can customize behavior of expanding with overriding config.
" This configuration will be marged at loading plugin.
"
" let g:user_zen_settings = {
" \ 'indentation' : ' ',
" \ 'perl' : {
" \ 'aliases' : {
" \ 'req' : 'require '
" \ },
" \ 'snippets' : {
" \ 'use' : "use strict\nuse warnings\n\n",
" \ 'warn' : "warn \"|\";",
" \ }
" \ }
" \}
"
" You can set language attribute in html using 'zen_settings.lang'.
"
" GetLatestVimScripts: 2981 1 :AutoInstall: zencoding.vim
" script type: plugin
if &cp || (exists('g:loaded_zencoding_vim') && g:loaded_zencoding_vim)
finish
endif
let g:loaded_zencoding_vim = 1
let s:save_cpo = &cpo
set cpo&vim
if !exists('g:zencoding_debug')
let g:zencoding_debug = 0
endif
if !exists('g:zencoding_curl_command')
let g:zencoding_curl_command = 'curl -s -L -A Mozilla/5.0'
endif
if exists('g:use_zen_complete_tag') && g:use_zen_complete_tag
setlocal omnifunc=zencoding#CompleteTag
endif
if !exists('g:user_zen_leader_key')
let g:user_zen_leader_key = '<c-y>'
endif
function! s:install_plugin_i()
for item in [
\ {'mode': 'i', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandAbbr', 'func': '<c-g>u<esc>:call zencoding#expandAbbr(0,"")<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_expandword_key', 'key': ';', 'plug': 'ZenCodingExpandWord', 'func': '<c-g>u<esc>:call zencoding#expandAbbr(1,"")<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardInsert', 'func': '<esc>:call zencoding#balanceTag(1)<cr>'},
\ {'mode': 'i', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardInsert', 'func': '<esc>:call zencoding#balanceTag(-1)<cr>'},
\ {'mode': 'i', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': '<esc>:call zencoding#moveNextPrev(0)<cr>'},
\ {'mode': 'i', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': '<esc>:call zencoding#moveNextPrev(1)<cr>'},
\ {'mode': 'i', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': '<esc>:call zencoding#imageSize()<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': '<esc>:call zencoding#toggleComment()<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagInsert', 'func': '<esc>:call zencoding#splitJoinTag()<cr>'},
\ {'mode': 'i', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': '<esc>:call zencoding#removeTag()<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': '<esc>:call zencoding#anchorizeURL(0)<cr>a'},
\ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': '<esc>:call zencoding#anchorizeURL(1)<cr>a'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_zen_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
function! s:install_plugin_n()
for item in [
\ {'mode': 'n', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandNormal', 'func': ':call zencoding#expandAbbr(3,"")<cr>'},
\ {'mode': 'n', 'var': 'user_zen_expandword_key', 'key': ',', 'plug': 'ZenCodingExpandWord', 'func': ':call zencoding#expandAbbr(1,"")<cr>'},
\ {'mode': 'n', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardNormal', 'func': ':call zencoding#balanceTag(1)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardNormal', 'func': ':call zencoding#balanceTag(-1)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()<cr>'},
\ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()<cr>'},
\ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagNormal', 'func': ':call zencoding#splitJoinTag()<cr>'},
\ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()<cr>'},
\ {'mode': 'n', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)<cr>'},
\ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)<cr>'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_zen_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
function! s:install_plugin_v()
for item in [
\ {'mode': 'v', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandVisual', 'func': ':call zencoding#expandAbbr(2,"")<cr>'},
\ {'mode': 'v', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardVisual', 'func': ':call zencoding#balanceTag(2)<cr>'},
\ {'mode': 'v', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardVisual', 'func': ':call zencoding#balanceTag(-2)<cr>'},
\ {'mode': 'v', 'var': 'user_zen_mergelines_key', 'key': 'm', 'plug': 'ZenCodingMergeLines', 'func': ':call zencoding#mergeLines()<cr>'},
\ {'mode': 'v', 'var': 'user_zen_codepretty_key', 'key': 'c', 'plug': 'ZenCodingCodePretty', 'func': ':call zencoding#codePretty()<cr>'},
\]
if !hasmapto('<plug>'.item.plug, item.mode)
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
endif
if !exists('g:' . item.var)
endif
if exists('g:' . item.var)
let key = eval('g:' . item.var)
else
let key = g:user_zen_leader_key . item.key
endif
if len(maparg(key, item.mode)) == 0
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
endif
endfor
endfunction
if exists('g:user_zen_mode')
let imode = matchstr(g:user_zen_mode, '[ai]')
let nmode = matchstr(g:user_zen_mode, '[an]')
let vmode = matchstr(g:user_zen_mode, '[av]')
if !empty(imode)
call s:install_plugin_i()
endif
if !empty(nmode)
call s:install_plugin_n()
endif
if !empty(vmode)
call s:install_plugin_v()
endif
else
call s:install_plugin_i()
call s:install_plugin_n()
call s:install_plugin_v()
endif
delfunction s:install_plugin_i
delfunction s:install_plugin_n
delfunction s:install_plugin_v
command! -nargs=1 Zen call zencoding#expandAbbr(4, <q-args>)
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et:

View file

@ -1,794 +0,0 @@
let s:sfile = expand('<sfile>')
function! s:reload(d)
exe "so" a:d."/plugin/zencoding.vim"
for f in split(globpath(a:d, 'autoload/**/*.vim'), "\n")
silent! exe "so" f
endfor
endfunction
function! s:show_type(type)
echohl Search | echon "[" a:type "]\n" | echohl None
echo "\r"
endfunction
function! s:show_category(category)
echohl MatchParen | echon "[" a:category "]\n" | echohl None
echo "\r"
endfunction
function! s:show_pass(pass)
echohl Title | echo "pass".a:pass."\n" | echohl None
endfunction
function! s:show_done()
echohl IncSearch | echo "done" | echohl None
endfunction
function! s:escape(str)
let str = a:str
let str = substitute(str, "\n", '\\n', 'g')
let str = substitute(str, "\t", '\\t', 'g')
return str
endfunction
function! s:show_title(no, title)
let title = s:escape(a:title)
let width = &columns - 23
echohl MoreMsg | echon "\rtesting #".printf("%03d", a:no)
echohl None | echon ": " . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
endfunction
function! s:show_skip(no, title)
let title = s:escape(a:title)
let width = &columns - 23
echohl WarningMsg | echon "\rskipped #".printf("%03d", a:no)
echohl None | echon ": " . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
echo ""
endfunction
function! s:show_ok()
echohl Title | echon "ok\n" | echohl None
echo ""
endfunction
function! s:show_ng(no, expect, got)
echohl WarningMsg | echon "ng\n" | echohl None
echohl ErrorMsg | echo "failed test #".a:no | echohl None
set more
echohl WarningMsg | echo printf("expect(%d):", len(a:expect)) | echohl None
echo join(split(a:expect, "\n", 1), "|\n")
echohl WarningMsg | echo printf("got(%d):", len(a:got)) | echohl None
echo join(split(a:got, "\n", 1), "|\n")
let cs = split(a:expect, '\zs')
for c in range(len(cs))
if c < len(a:got)
if a:expect[c] != a:got[c]
echohl WarningMsg | echo "differ at:" | echohl None
echo a:expect[c :-1]
break
endif
endif
endfor
echo ""
throw "stop"
endfunction
function! s:test(...)
let type = get(a:000, 0, '')
let name = get(a:000, 1, '')
let index = get(a:000, 2, '')
let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
for testgroup in testgroups
if len(type) > 0 && testgroup.type != type | continue | endif
call s:show_type(testgroup.type)
for category in testgroup.categories
if len(name) > 0 && substitute(category.name,' ','_','g') != name | continue | endif
call s:show_category(category.name)
let tests = category.tests
let start = reltime()
for n in range(len(tests))
if len(index) > 0 && n != index | continue | endif
let query = tests[n].query
let result = tests[n].result
if has_key(tests[n], 'skip') && tests[n].skip != 0
call s:show_skip(n+1, query)
continue
endif
if stridx(query, '$$$$') != -1
silent! 1new
silent! exe "setlocal ft=".testgroup.type
silent! let key = matchstr(query, '.*\$\$\$\$\zs.*\ze\$\$\$\$')
if len(key) > 0
exe printf('let key = "%s"', key)
else
let key = "\<c-y>,"
endif
silent! let query = substitute(query, '\$\$\$\$.*\$\$\$\$', '$$$$', '')
silent! call setline(1, split(query, "\n"))
let cmd = "normal gg0/\\$\\$\\$\\$\ri\<del>\<del>\<del>\<del>".key
if stridx(result, '$$$$') != -1
let cmd .= '$$$$'
endif
silent! exe cmd
unlet! res | let res = join(getline(1, line('$')), "\n")
silent! bw!
call s:show_title(n+1, query)
else
call s:show_title(n+1, query)
unlet! res | let res = zencoding#ExpandWord(query, testgroup.type, 0)
endif
if stridx(result, '$$$$') != -1
if res ==# result
call s:show_ok()
else
call s:show_ng(n+1, result, res)
endif
else
if res ==# result
call s:show_ok()
else
call s:show_ng(n+1, result, res)
endif
endif
endfor
call s:show_pass(reltimestr(reltime(start)))
endfor
endfor
endfunction
function! s:do_tests(...)
try
if exists('g:user_zen_settings')
let s:old_user_zen_settings = g:user_zen_settings
let g:user_zen_settings = { 'indentation': "\t" }
endif
let oldmore = &more
call s:reload(fnamemodify(s:sfile, ':h'))
let &more = 0
call call('s:test', a:000)
call s:show_done()
catch
echohl ErrorMsg | echomsg v:exception | echohl None
finally
let &more=oldmore
if exists('g:user_zen_settings')
let g:user_zen_settings = s:old_user_zen_settings
endif
endtry
endfunction
function! g:zencoding_unittest_complete(arglead, cmdline, cmdpos)
let args = split(a:cmdline, '\s\+', 1)
let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
try
if len(args) == 2
return filter(map(testgroups, 'v:val.type'), 'stridx(v:val,args[1])!=-1')
elseif len(args) == 3
return map(filter(testgroups, 'v:val.type==args[1]')[0].categories, 'substitute(v:val.name," ","_","g")')
endif
catch
endtry
return []
endfunction
command! -nargs=* -complete=customlist,g:zencoding_unittest_complete ZenCodingUnitTest call s:do_tests(<f-args>)
if s:sfile == expand('%:p')
ZenCodingUnitTest
endif
finish
[
{
'type': "html",
'categories': [
{
'name': 'expand abbreviation',
'tests': [
{
'query': "div",
'result': "<div></div>\n",
},
{
'query': "div#wrapper",
'result': "<div id=\"wrapper\"></div>\n",
},
{
'query': "div.box",
'result': "<div class=\"box\"></div>\n",
},
{
'query': "a[title=TITLE]",
'result': "<a href=\"\" title=\"TITLE\"></a>\n",
},
{
'query': "div#wrapper.box",
'result': "<div id=\"wrapper\" class=\"box\"></div>\n",
},
{
'query': "div#wrapper.box.current",
'result': "<div id=\"wrapper\" class=\"box current\"></div>\n",
},
{
'query': "div#wrapper.box.current[title=TITLE rel]",
'result': "<div id=\"wrapper\" class=\"box current\" title=\"TITLE\" rel=\"\"></div>\n",
},
{
'query': "div#main+div#sub",
'result': "<div id=\"main\"></div>\n<div id=\"sub\"></div>\n",
},
{
'query': "div#main>div#sub",
'result': "<div id=\"main\">\n\t<div id=\"sub\"></div>\n</div>\n",
},
{
'query': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
'result': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" />\n\t<title></title>\n</head>\n<body>\n\t<div id=\"header\">\n\t\t<div id=\"logo\"></div>\n\t\t<ul id=\"nav\">\n\t\t\t<li class=\"item-1\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-2\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-3\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-4\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-5\"><a href=\"\"></a></li>\n\t\t</ul>\n\t</div>\n\t\n</body>\n</html>",
},
{
'query': "ol>li*2",
'result': "<ol>\n\t<li></li>\n\t<li></li>\n</ol>\n",
},
{
'query': "a",
'result': "<a href=\"\"></a>\n",
},
{
'query': "obj",
'result': "<object data=\"\" type=\"\"></object>\n",
},
{
'query': "cc:ie6>p+blockquote#sample$.so.many.classes*2",
'result': "<!--[if lte IE 6]>\n\t<p></p>\n\t<blockquote id=\"sample1\" class=\"so many classes\"></blockquote>\n\t<blockquote id=\"sample2\" class=\"so many classes\"></blockquote>\n\t\n<![endif]-->",
},
{
'query': "html:4t>div#wrapper>div#header+div#contents+div#footer",
'result': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html lang=\"en\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n\t<title></title>\n</head>\n<body>\n\t<div id=\"wrapper\">\n\t\t<div id=\"header\"></div>\n\t\t<div id=\"contents\"></div>\n\t\t<div id=\"footer\"></div>\n\t</div>\n\t\n</body>\n</html>",
},
{
'query': "a[href=http://www.google.com/].foo#hoge",
'result': "<a id=\"hoge\" class=\"foo\" href=\"http://www.google.com/\"></a>\n",
},
{
'query': "a[href=http://www.google.com/]{Google}",
'result': "<a href=\"http://www.google.com/\">Google</a>\n",
},
{
'query': "{ZenCoding}",
'result': "ZenCoding",
},
{
'query': "a+b",
'result': "<a href=\"\"></a>\n<b></b>\n",
},
{
'query': "a>b>i<b",
'result': "<a href=\"\"><b><i></i></b><b></b></a>\n",
},
{
'query': "a>b>i^b",
'result': "<a href=\"\"><b><i></i></b><b></b></a>\n",
},
{
'query': "a>b>i<<b",
'result': "<a href=\"\"><b><i></i></b></a>\n<b></b>\n",
},
{
'query': "a>b>i^^b",
'result': "<a href=\"\"><b><i></i></b></a>\n<b></b>\n",
},
{
'query': "blockquote>b>i<<b",
'result': "<blockquote><b><i></i></b></blockquote>\n<b></b>\n",
},
{
'query': "blockquote>b>i^^b",
'result': "<blockquote><b><i></i></b></blockquote>\n<b></b>\n",
},
{
'query': "a[href=foo][class=bar]",
'result': "<a class=\"bar\" href=\"foo\"></a>\n",
},
{
'query': "a[a=b][b=c=d][e]{foo}*2",
'result': "<a href=\"\" a=\"b\" b=\"c=d\" e=\"\">foo</a>\n<a href=\"\" a=\"b\" b=\"c=d\" e=\"\">foo</a>\n",
},
{
'query': "a[a=b][b=c=d][e]*2{foo}",
'result': "<a href=\"\" a=\"b\" b=\"c=d\" e=\"\"></a>\n<a href=\"\" a=\"b\" b=\"c=d\" e=\"\"></a>\nfoo",
},
{
'query': "a*2{foo}a",
'result': "<a href=\"\"></a>\n<a href=\"\"></a>\nfoo<a href=\"\"></a>\n",
},
{
'query': "a{foo}*2>b",
'result': "<a href=\"\">foo<b></b></a>\n<a href=\"\">foo<b></b></a>\n",
},
{
'query': "a*2{foo}>b",
'result': "<a href=\"\"></a>\n<a href=\"\"></a>\nfoo",
},
{
'query': "table>tr>td.name#foo+td*3",
'result': "<table>\n\t<tr>\n\t\t<td id=\"foo\" class=\"name\"></td>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n</table>\n",
},
{
'query': "div#header + div#footer",
'result': "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n",
},
{
'query': "#header + div#footer",
'result': "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n",
},
{
'query': "#header > ul > li < p{Footer}",
'result': "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n",
},
{
'query': "#header > ul > li ^ p{Footer}",
'result': "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n",
},
{
'query': "a#foo$$$*3",
'result': "<a id=\"foo001\" href=\"\"></a>\n<a id=\"foo002\" href=\"\"></a>\n<a id=\"foo003\" href=\"\"></a>\n",
},
{
'query': "ul+",
'result': "<ul>\n\t<li></li>\n</ul>\n",
},
{
'query': "table+",
'result': "<table>\n\t<tr>\n\t\t<td></td>\n\t</tr>\n</table>\n",
},
{
'query': "#header>li<#content",
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
},
{
'query': "#header>li^#content",
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
},
{
'query': "(#header>li)<#content",
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
},
{
'query': "(#header>li)^#content",
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
},
{
'query': "a>b>i<<div",
'result': "<a href=\"\"><b><i></i></b></a>\n<div></div>\n",
},
{
'query': "a>b>i^^div",
'result': "<a href=\"\"><b><i></i></b></a>\n<div></div>\n",
},
{
'query': "(#header>h1)+#content+#footer",
'result': "<div id=\"header\">\n\t<h1></h1>\n</div>\n<div id=\"content\"></div>\n<div id=\"footer\"></div>\n",
},
{
'query': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)",
'result': "<div id=\"header\">\n\t<h1></h1>\n</div>\n<div id=\"content\">\n\t<div id=\"main\">\n\t\t<h2></h2>\n\t\t<div id=\"entry1\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry2\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry3\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry4\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry5\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div id=\"utilities\"></div>\n</div>\n<div id=\"footer\">\n\t<address></address>\n</div>\n",
},
{
'query': "(div>(ul*2)*2)+(#utilities)",
'result': "<div>\n\t<ul></ul>\n\t<ul></ul>\n\t<ul></ul>\n\t<ul></ul>\n</div>\n<div id=\"utilities\"></div>\n",
},
{
'query': "table>(tr>td*3)*4",
'result': "<table>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n</table>\n",
},
{
'query': "(((a#foo+a#bar)*2)*3)",
'result': "<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n",
},
{
'query': "div#box$*3>h3+p*2",
'result': "<div id=\"box1\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n"
},
{
'query': "div#box.foo$$$.bar$$$*3",
'result': "<div id=\"box\" class=\"foo001 bar001\"></div>\n<div id=\"box\" class=\"foo002 bar002\"></div>\n<div id=\"box\" class=\"foo003 bar003\"></div>\n",
},
{
'query': "div#box$*3>h3+p.bar*2|e",
'result': "&lt;div id=\"box1\"&gt;\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n&lt;/div&gt;\n&lt;div id=\"box2\"&gt;\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n&lt;/div&gt;\n&lt;div id=\"box3\"&gt;\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n&lt;/div&gt;\n",
},
{
'query': "div>div#page>p.title+p|c",
'result': "<div>\n\t<!-- #page -->\n\t<div id=\"page\">\n\t\t<!-- .title -->\n\t\t<p class=\"title\"></p>\n\t\t<!-- /.title -->\n\t\t<p></p>\n\t</div>\n\t<!-- /#page -->\n</div>\n",
},
{
'query': "link:css",
'result': "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" media=\"all\" />\n",
},
{
'query': "a[title=\"Hello', world\" rel]",
'result': "<a href=\"\" title=\"Hello', world\" rel=\"\"></a>\n",
},
{
'query': "div>a#foo{bar}",
'result': "<div><a id=\"foo\" href=\"\">bar</a></div>\n",
},
{
'query': ".content{Hello!}",
'result': "<div class=\"content\">Hello!</div>\n",
},
{
'query': "div.logo+(div#navigation)+(div#links)",
'result': "<div class=\"logo\"></div>\n<div id=\"navigation\"></div>\n<div id=\"links\"></div>\n",
},
{
'query': "h1{header}+{Text}+a[href=http://link.org]{linktext}+{again some text}+a[href=http://anoterlink.org]{click me!}+{some final text}",
'result': "<h1>header</h1>\nText<a href=\"http://link.org\">linktext</a>\nagain some text<a href=\"http://anoterlink.org\">click me!</a>\nsome final text",
},
{
'query': "a{&}+div{&&}",
'result': "<a href=\"\">&</a>\n<div>&&</div>\n",
},
{
'query': "<foo/>span$$$$\\<c-y>,$$$$",
'result': "<foo/><span></span>",
},
{
'query': "foo span$$$$\\<c-y>,$$$$",
'result': "foo <span></span>",
},
{
'query': "foo span$$$$\\<c-y>,$$$$ bar",
'result': "foo <span></span> bar",
},
{
'query': "foo $$$$\\<c-o>ve\\<c-y>,p\\<cr>$$$$bar baz",
'result': "foo <p>bar</p> baz",
},
{
'query': "foo $$$$\\<c-o>vee\\<c-y>,p\\<cr>$$$$bar baz",
'result': "foo <p>bar baz</p>",
},
{
'query': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$",
'result': "f <div class=\"boxes\">\n\t<article class=\"box2\">\n\t\t<header>\n\t\t\t<hgroup>\n\t\t\t\t<h2>aaa</h2>\n\t\t\t\t<h3>bbb</h3>\n\t\t\t</hgroup>\n\t\t\t<p>ccc</p>\n\t\t</header>\n\t</article>\n</div>",
},
{
'query': "div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})",
'result': "<div class=\"boxes\">\n\t<div class=\"box2\">\n\t\t<section>\n\t\t\t<h2>a</h2>\n\t\t\t<p>b</p>\n\t\t</section>\n\t</div>\n\t<div class=\"box1\">\n\t\t<section>\n\t\t\t<h2>c</h2>\n\t\t\t<p>d</p>\n\t\t\t<p>e</p>\n\t\t\t<blockquote>\n\t\t\t\t<h2>f</h2>\n\t\t\t\t<h3>g</h3>\n\t\t\t</blockquote>\n\t\t\t<p>h</p>\n\t\t</section>\n\t</div>\n</div>\n",
},
{
'query': "(div>(label+input))+div",
'result': "<div>\n\t<label for=\"\"></label>\n\t<input type=\"\" />\n</div>\n<div></div>\n",
},
{
'query': "test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,ul>li>span*>a\\<cr>$$$$",
'result': "<ul>\n\t<li>\n\t\t<span><a href=\"\">test1</a></span>\n\t\t<span><a href=\"\">test2</a></span>\n\t\t<span><a href=\"\">test3</a></span>\n\t</li>\n</ul>",
},
{
'query': "test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,input[type=input value=$#]*\\<cr>$$$$",
'result': "<input type=\"input\" value=\"test1\" />\n<input type=\"input\" value=\"test2\" />\n<input type=\"input\" value=\"test3\" />",
},
{
'query': "div#id-$*5>div#id2-$",
'result': "<div id=\"id-1\">\n\t<div id=\"id2-1\"></div>\n</div>\n<div id=\"id-2\">\n\t<div id=\"id2-2\"></div>\n</div>\n<div id=\"id-3\">\n\t<div id=\"id2-3\"></div>\n</div>\n<div id=\"id-4\">\n\t<div id=\"id2-4\"></div>\n</div>\n<div id=\"id-5\">\n\t<div id=\"id2-5\"></div>\n</div>\n",
},
{
'query': "{test case $ }*3",
'result': "test case 1 test case 2 test case 3 ",
},
{
'query': "{test case $${nr}}*3",
'result': "test case 1\ntest case 2\ntest case 3\n",
},
{
'query': "{test case \\$ }*3",
'result': "test case $ test case $ test case $ ",
},
{
'query': "{test case $$$ }*3",
'result': "test case 001 test case 002 test case 003 ",
},
{
'query': "a[title=$#]{foo}",
'result': "<a href=\"\" title=\"foo\">foo</a>\n",
},
],
},
{
'name': 'split join tag',
'tests': [
{
'query': "<div>\n\t<span>$$$$\\<c-y>j$$$$</span>\n</div>",
'result': "<div>\n\t<span/>\n</div>",
},
{
'query': "<div>\n\t<span$$$$\\<c-y>j$$$$/>\n</div>",
'result': "<div>\n\t<span></span>\n</div>",
},
],
},
{
'name': 'toggle comment',
'tests': [
{
'query': "<div>\n\t<span>$$$$\\<c-y>/$$$$</span>\n</div>",
'result': "<div>\n\t<!-- <span></span> -->\n</div>",
},
{
'query': "<div>\n\t<!-- <span>$$$$\\<c-y>/$$$$</span> -->\n</div>",
'result': "<div>\n\t<span></span>\n</div>",
},
],
},
{
'name': 'image size',
'tests': [
{
'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"96\" height=\"96\" />",
},
{
'query': "img[src=/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
'result': "<img src=\"/logo.png\" alt=\"\" />",
},
],
},
{
'name': 'move next prev',
'tests': [
{
'query': "foo+bar+baz[dankogai=\"\"]$$$$\\<c-y>,\\<esc>gg0\\<c-y>n\\<c-y>n\\<c-y>n\\<esc>Byw:%d _\\<cr>p$$$$",
'result': "dankogai",
},
],
},
],
},
{
'type': 'css',
'categories': [
{
'name': 'expand abbreviation',
'tests': [
{
'query': "@i",
'result': "@import url();",
},
{
'query': "fs:n",
'result': "font-style: normal;",
},
{
'query': "fl:l|fc",
'result': "float: left;",
},
{
'query': "bg+$$$$",
'result': "background: #FFF url($$$$) 0 0 no-repeat;",
},
{
'query': "bg+!$$$$",
'result': "background: #FFF url($$$$) 0 0 no-repeat !important;",
},
{
'query': "m$$$$",
'result': "margin: $$$$;",
},
{
'query': "m0.1p$$$$",
'result': "margin: 0.1%;",
},
{
'query': "m1.0$$$$",
'result': "margin: 1.0em;",
},
{
'query': "m2$$$$",
'result': "margin: 2px;",
},
{
'query': "bdrs10$$$$",
'result': "border-radius: 10px;",
},
{
'query': "-bdrs20$$$$",
'result': "-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\nborder-radius: 20px;",
},
{
'query': "lg(top,#fff,#000)$$$$",
'result': "background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n",
},
{
'query': "m10-5-0$$$$",
'result': "margin: 10px 5px 0px;",
},
{
'query': "m-10--5$$$$",
'result': "margin: -10px -5px;",
},
{
'query': "m10-auto$$$$",
'result': "margin: 10px auto;",
},
{
'query': "w100p$$$$",
'result': "width: 100%;",
},
{
'query': "h50e$$$$",
'result': "height: 50em;",
},
{
'query': "(bg+)+c$$$$",
'result': "background: #FFF url($$$$) 0 0 no-repeat;\ncolor: #000;",
},
],
},
],
},
{
'type': 'haml',
'categories': [
{
'name': 'expand abbreviation',
'tests': [
{
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
'result': "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n",
},
{
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml",
'result': "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n",
},
{
'query': "a*3|haml",
'result': "%a{ :href => \"\" }\n%a{ :href => \"\" }\n%a{ :href => \"\" }\n",
},
{
'query': ".content{Hello!}|haml",
'result': "%div.content Hello!\n",
},
{
'query': "a[title=$#]{foo}",
'result': "%a{ :href => \"\", :title => \"foo\" } foo\n",
},
],
},
{
'name': 'expand abbreviation',
'tests': [
{
'query': "%a foo\n bar$$$$\\<c-y>j$$$$",
'result': "%a ",
},
{
'query': "$$$$\\<c-y>j$$$$%a ",
'result': "%a $$$$",
},
],
},
{
'name': 'toggle comment',
'tests': [
{
'query': "%a{ :href => \"http://www.google.com\"$$$$\\<c-y>/$$$$ } hello",
'result': "-# %a{ :href => \"http://www.google.com\" } hello",
},
{
'query': "-# %a{ :href => \"http://www.google.com\"$$$$\\<c-y>/$$$$ } hello",
'result': "%a{ :href => \"http://www.google.com\" } hello",
},
],
},
],
},
{
'type': 'slim',
'categories': [
{
'name': 'expand abbreviation',
'tests': [
{
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
'result': "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n",
},
{
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|slim",
'result': "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n",
},
{
'query': "a*3|slim",
'result': "a href=\"\"\na href=\"\"\na href=\"\"\n",
},
{
'query': ".content{Hello!}|slim",
'result': "div class=\"content\"\n | Hello!\n",
},
{
'query': "a[title=$#]{foo}",
'result': "a href=\"\" title=\"foo\"\n | foo\n",
},
],
},
{
'name': 'split join tag',
'tests': [
{
'query': "a\n | foo$$$$\\<c-y>j$$$$",
'result': "a",
},
{
'query': "a$$$$\\<c-y>j$$$$",
'result': "a\n | $$$$",
},
],
},
{
'name': 'toggle comment',
'tests': [
{
'query': "a href=\"http://www.google.com\"$$$$\\<c-y>/$$$$\n | hello",
'result': "/a href=\"http://www.google.com\"\n | hello",
},
{
'query': "/a href=\"http://www.google.com\"$$$$\\<c-y>/$$$$\n | hello",
'result': "a href=\"http://www.google.com\"\n | hello",
},
],
},
],
},
{
'type': 'xsl',
'categories': [
{
'name': 'expand abbreviation',
'tests': [
{
'query': "vari",
'result': "<xsl:variable name=\"\"></xsl:variable>\n",
},
{
'query': "ap>wp",
'result': "<xsl:apply-templates select=\"\" mode=\"\">\n\t<xsl:with-param name=\"\" select=\"\"></xsl:with-param>\n</xsl:apply-templates>\n",
},
],
},
],
},
{
'type': 'xsd',
'categories': [
{
'name': 'expand abbreviation',
'tests': [
{
'query': "xsd:w3c",
'result': "<?xml version=\"1.0\"?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n\t<xsd:element name=\"\" type=\"\"/>\n</xsd:schema>",
},
],
},
],
},
{
'type': 'mustache',
'categories': [
{
'name': 'expand abbreviation',
'tests': [
{
'query': "div#{{foo}}",
'result': "<div id=\"{{foo}}\"></div>\n",
},
{
'query': "div.{{foo}}",
'result': "<div class=\"{{foo}}\"></div>\n",
},
],
},
],
},
]
" vim:set et:

View file

@ -1,265 +0,0 @@
script_name: ZenCoding.vim
script_id: '2981'
script_type: utility
script_package: zencoding-vim.zip
script_version: '0.80'
required_vim_version: '7.0'
summary: vim plugins for HTML and CSS hi-speed coding.
detailed_description: |
This is vim script support expanding abbreviation like zen-coding.
ref: http://code.google.com/p/zen-coding/
There is a movie using zencoding.vim
ref: http://mattn.github.com/zencoding-vim
Source Repository.
ref: http://github.com/mattn/zencoding-vim
Type abbreviation
+-------------------------------------
| html:5_
+-------------------------------------
"_" is a cursor position. and type "<c-y>," (Ctrl + y and Comma)
NOTE: Don't worry about key map. you can change it easily.
+-------------------------------------
| <!DOCTYPE HTML>
| <html lang="en">
| <head>
| <title></title>
| <meta charset="UTF-8">
| </head>
| <body>
| _
| </body>
| </html>
+-------------------------------------
Type following
+-------------------------------------
| div#foo$*2>div.bar
+-------------------------------------
And type "<c-y>,"
+-------------------------------------
|<div id="foo1">
| <div class="bar">_</div>
|</div>
|<div id="foo2">
| <div class="bar"></div>
|</div>
| _
+-------------------------------------
Tutorial:
http://github.com/mattn/zencoding-vim/raw/master/TUTORIAL
How work this:
http://mattn.github.com/zencoding-vim
Tips:
You can customize behavior of expanding with overriding config.
This configuration will be marged at loading plugin.
let g:user_zen_settings = {
\ 'indentation' : ' ',
\ 'perl' : {
\ 'aliases' : {
\ 'req' : 'require '
\ },
\ 'snippets' : {
\ 'use' : "use strict\nuse warnings\n\n",
\ 'warn' : "warn \"|\";",
\ }
\ }
\}
let g:user_zen_expandabbr_key = '<c-e>'
let g:use_zen_complete_tag = 1
You can set language attribute in html using zen_settings['lang'].
install_details: |
# cd ~/.vim
# unzip zencoding-vim.zip
or if you install pathogen.vim:
# cd ~/.vim/bundle # or make directory
# unzip /path/to/zencoding-vim.zip
if you get sources from repository:
# cd ~/.vim/bundle # or make directory
# git clone http://github.com/mattn/zencoding-vim.git
versions:
- '0.80': |
This is an upgrade for ZenCoding.vim: add emmet features.
- '0.74': |
This is an upgrade for ZenCoding.vim: many bug fixes.
- '0.73': |
This is an upgrade for ZenCoding.vim: many bug fixes. and support slim format (experimental).
- '0.72': |
This is an upgrade for ZenCoding.vim:
[fix] fix finding tokens.
- '0.71': |
This is an upgrade for ZenCoding.vim:
[fix] fix finding begin of tokens.
- '0.70': |
This is an upgrade for ZenCoding.vim:
[mod] Changed behavior of expanding. "div div>a|" should keep first div element.
[add] Supported slim formatter.
- '0.60': |
This is an upgrade for ZenCoding.vim:
[fix] fixed expanding {{}}.
- '0.59': |
This is an upgrade for ZenCoding.vim:
[fix] fixed toggleComment and mny bugs.
- '0.58': |
This is an upgrade for ZenCoding.vim:
[fix] fixed 'foo+' style expandos.
- '0.57': |
This is an upgrade for ZenCoding.vim:
[fix] fixed expandos that don't work 'choose' in xsl.
- '0.56': |
This is an upgrade for ZenCoding.vim:
[fix] fixed contents parser.
- '0.55': |
uploaded again: sorry, files was old.
- '0.54': |
[add] support sass, xsd.
[fix] expanding with html tag.
uploaded again: sorry, fileformat was DOS.
- '0.53': |
[fix] gif width/height was swapped.
- '0.52': |
[fix] broken wrap expanding.
- '0.51': |
This is an upgrade for ZenCoding.vim:
[fix] wrap expanding with '&'.
[fix] expand .content to class="content".
[fix] haml expanding.
[fix] bg+ snippet
- '0.50': |
This is an upgrade for ZenCoding.vim:
[fix] fixed parsing '#{{foo}}' and '.{{bar}}'.
- '0.49': |
This is an upgrade for ZenCoding.vim:
[doc] add help manual.
- '0.48': |
This is an upgrade for ZenCoding.vim:
[fix] install mappings to global.
- '0.47': |
This is an upgrade for ZenCoding.vim:
[drastic changes] enable autoload. you should whole replace older files.
package was empty. upload again.
- '0.46': |
This is an upgrade for ZenCoding.vim:
[drastic changes] enable autoload. you should whole replace older files.
- '0.45': |
This is an upgrade for ZenCoding.vim:
fixed attribute parsing like: a[href="hello', world" rel].
- '0.44': |
This is an upgrade for ZenCoding.vim:
fixed checking whether have mapping using maparg() / hasmapto().
- '0.43': |
This is an upgrade for ZenCoding.vim:
fixed behavior for nested block. like "html:5>#page>(header#globalHeader>(hgroup>h1+h2)+(nav>ul>li*3>a)+(form>p.siteSearch>input+input[type=button]))+(#contents>(#main>(section>h2+p*5)+p.pagetop>a[href=#page])+(#sub>p+(nav>ul>li>a)))+(footer#globalFoooter>(ul>li>a)+(p.copyright>small))"
- '0.42': |
This is an upgrade for ZenCoding.vim:
fixed select/option indent.
- '0.41': |
This is an upgrade for ZenCoding.vim:
fixed default filter. when using 'e' filter, output become empty.
- '0.40': |
This is an upgrade for ZenCoding.vim:
add the pure vimscript code for 'get image size'. you can use it without perl interface just now.
change key assign of ZenCodingExpandWord from ',' to ';'. it don't effect to most users.
- '0.39': |
This is an upgrade for ZenCoding.vim: fixed problem about 'selection'. see http://github.com/mattn/zencoding-vim/issues/#issue/2
- '0.38': |
This is an upgrade for ZenCoding.vim: use v7h"_s instead of v7hs for backspace.
- '0.37': |
This is an upgrade for ZenCoding.vim: fixed problem that won't working with some 'backspace' options.
- '0.36': |
This is an upgrade for ZenCoding.vim: fixed problem that filter does not work.
- '0.35': |
This is an upgrade for ZenCoding.vim: enable zencoding for other languages. (meaning php also)
- '0.34': |
This is an upgrade for ZenCoding.vim: enable zencoding for xsl. (you should add ~/.vim/ftplugin/xslt/zencoding.vim)
- '0.33': |
This is an upgrade for ZenCoding.vim: fixed problem breaking multibyte when cursor is in a part of line. enabled zencoding for javascript in html.
- '0.32': |
This is an upgrade for ZenCoding.vim: fixed indentation. supported extends so that you can enable zencoding for php/xhtml/haml other's section 14 in http://github.com/mattn/zencoding-vim/raw/master/TUTORIAL
- '0.31': |
This is an upgrade for ZenCoding.vim: fixed indentation and $$$ problem. fixed about missing support multiple classes.
- '0.30': |
This is an upgrade for ZenCoding.vim: Fixed key assign.
- '0.29': |
This is an upgrade for ZenCoding.vim: Changed leading key to '<c-y>' from '<c-z>'.
- '0.28': |
This is an upgrade for ZenCoding.vim: supported 'Balance Tag Inward/Outward', 'Go to Next/Previous Edit Point', 'Update <img> Size', 'Remove Tag', 'Split/Join Tag', 'Toggle Comment'
- '0.27': |
This is an upgrade for ZenCoding.vim: fixed problem that can't work on the part of multibyte characters. fixed inline elements behavior.
- '0.26': |
This is an upgrade for ZenCoding.vim: The count of '(((a#foo + a#bar)*2)*3)' should be 12.
- '0.25': |
This is an upgrade for ZenCoding.vim: store undo before working. good luck about 'table>(tr>td*3)*4'.
- '0.24': |
This is an upgrade for ZenCoding.vim: fixed behavior of parsing area of visual selection.
- '0.23': |
This is an upgrade for ZenCoding.vim: pre-expand '#header>li<#content' to 'div#header>li<div#content'. support () expression.
- '0.22': |
This is an upgrade for ZenCoding.vim: expand 'ul+' to 'ul>li'. fix undo ring. support visual selection. when type trigger key on visual select, it request you leader like 'ul>li'. if you give 'ul>li*' as leader, you'll get each separate 'ul>li' tags. and when you give 'blockquote' as leader, you'll get blocked text.
- '0.21': |
This is an upgrade for ZenCoding.vim: treat xhtml as html.
- '0.20': |
This is an upgrade for ZenCoding.vim: add option use_zen_complete_tag for complete abbr.
- '0.19': |
This is an upgrade for ZenCoding.vim: fixed problem that couldn't expand 'link:css' correctly.
- '0.18': |
This is an upgrade for ZenCoding.vim: ignore duplicate key map.
- '0.17': |
This is an upgrade for ZenCoding.vim: fixed key map.
- '0.16': |
This is an upgrade for ZenCoding.vim: fixed problem 'endless loop'.
- '0.15': |
This is an upgrade for ZenCoding.vim: set default filetype to 'html'.
- '0.14': |
This is an upgrade for ZenCoding.vim: fixed tag name like 'fs:n' in 'css'.
- '0.14': |
This is an upgrade for ZenCoding.vim: indentation for each languages.
- '0.13': |
This is an upgrade for ZenCoding.vim: user key map.
- '0.12': |
This is an upgrade for ZenCoding.vim: few extensive notation.
- '0.11': |
This is an upgrade for ZenCoding.vim: fixed indent.
- '0.10': |
This is an upgrade for ZenCoding.vim: fixed behavior of '+' operator
- '0.9': |
This is an upgrade for ZenCoding.vim: fixed single line behavior
- '0.8': |
This is an upgrade for ZenCoding.vim: support 'a[href=http://www.google.com]{Google}'
- '0.7': |
This is an upgrade for ZenCoding.vim: fixed behavior in 'a+b'.
- '0.6': |
This is an upgrade for ZenCoding.vim: fixed strange behavior about '<a href="">b_</a>'.
- '0.5': |
This is an upgrade for ZenCoding.vim: recover rest part in line.
- '0.4': |
This is an upgrade for ZenCoding.vim: fixed cursor position. fixed ${lang} replacement.
- '0.3': |
This is an upgrade for ZenCoding.vim: fixed line expanding.
- '0.2': |
This is an upgrade for ZenCoding.vim: fixed problem that moving cursor with expanding.
- '0.1': |
Initial upload
# __END__
# vim: filetype=yaml

View file

@ -0,0 +1,89 @@
ack.vim is distributed under the same license terms as Vim itself, which you
can find in full with `:help license` within Vim, or copied in full herein.
Copyright (c) 2007-2015 Antoine Imbert <antoine.imbert+ackvim@gmail.com>
and contributors.
Maintainers may be contacted via GitHub Issues at:
https://github.com/mileszs/ack.vim/issues
VIM LICENSE
I) There are no restrictions on distributing unmodified copies of Vim except
that they must include this license text. You can also distribute
unmodified parts of Vim, likewise unrestricted except that they must
include this license text. You are also allowed to include executables
that you made from the unmodified Vim sources, plus your own usage
examples and Vim scripts.
II) It is allowed to distribute a modified (or extended) version of Vim,
including executables and/or source code, when the following four
conditions are met:
1) This license text must be included unmodified.
2) The modified Vim must be distributed in one of the following five ways:
a) If you make changes to Vim yourself, you must clearly describe in
the distribution how to contact you. When the maintainer asks you
(in any way) for a copy of the modified Vim you distributed, you
must make your changes, including source code, available to the
maintainer without fee. The maintainer reserves the right to
include your changes in the official version of Vim. What the
maintainer will do with your changes and under what license they
will be distributed is negotiable. If there has been no negotiation
then this license, or a later version, also applies to your changes.
The current maintainer is Bram Moolenaar <Bram@vim.org>. If this
changes it will be announced in appropriate places (most likely
vim.sf.net, www.vim.org and/or comp.editors). When it is completely
impossible to contact the maintainer, the obligation to send him
your changes ceases. Once the maintainer has confirmed that he has
received your changes they will not have to be sent again.
b) If you have received a modified Vim that was distributed as
mentioned under a) you are allowed to further distribute it
unmodified, as mentioned at I). If you make additional changes the
text under a) applies to those changes.
c) Provide all the changes, including source code, with every copy of
the modified Vim you distribute. This may be done in the form of a
context diff. You can choose what license to use for new code you
add. The changes and their license must not restrict others from
making their own changes to the official version of Vim.
d) When you have a modified Vim which includes changes as mentioned
under c), you can distribute it without the source code for the
changes if the following three conditions are met:
- The license that applies to the changes permits you to distribute
the changes to the Vim maintainer without fee or restriction, and
permits the Vim maintainer to include the changes in the official
version of Vim without fee or restriction.
- You keep the changes for at least three years after last
distributing the corresponding modified Vim. When the maintainer
or someone who you distributed the modified Vim to asks you (in
any way) for the changes within this period, you must make them
available to him.
- You clearly describe in the distribution how to contact you. This
contact information must remain valid for at least three years
after last distributing the corresponding modified Vim, or as long
as possible.
e) When the GNU General Public License (GPL) applies to the changes,
you can distribute the modified Vim under the GNU GPL version 2 or
any later version.
3) A message must be added, at least in the output of the ":version"
command and in the intro screen, such that the user of the modified Vim
is able to see that it was modified. When distributing as mentioned
under 2)e) adding the message is only required for as far as this does
not conflict with the license used for the changes.
4) The contact information as required under 2)a) and 2)d) must not be
removed or changed, except that the person himself can make
corrections.
III) If you distribute a modified version of Vim, you are encouraged to use
the Vim license for your changes and make them available to the
maintainer, including the source code. The preferred way to do this is
by e-mail or by uploading the files to a server and e-mailing the URL.
If the number of changes is small (e.g., a modified Makefile) e-mailing a
context diff will do. The e-mail address to be used is
<maintainer@vim.org>
IV) It is not allowed to remove this license from the distribution of the Vim
sources, parts of it or from a modified version. You may use this
license for previous Vim releases instead of the license that they came
with, at your option.

View file

@ -122,6 +122,19 @@ nice code clean-up (which ack.vim is now hopefully getting), and ack.vim picked
up a few features that haven't made their way to ag.vim, like `:AckWindow`,
optional background search execution with [vim-dispatch], and auto-previewing.
#### I don't want to jump to the first result automatically. ####
Use `:Ack!`, with bang. If you want this behavior most of the time, you might
like an abbreviation or mapping in your personal config, something like these:
```vim
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
```
Most of the `:[L]Ack*` commands support this. Note that this behavior follows
the convention of Vim's built-in `:grep` and `:make` commands.
[The Silver Searcher]: https://github.com/ggreer/the_silver_searcher
[sadface]: https://github.com/mileszs/ack.vim/commit/d97090fb502d40229e6976dfec0e06636ba227d5#commitcomment-5771145
@ -129,15 +142,6 @@ optional background search execution with [vim-dispatch], and auto-previewing.
Please see [the Github releases page][releases].
### 1.0.9 (unreleased)
* Fix location list and layout of quickfix when using Dispatch (#154)
* Fix the quick help overlay clobbering the list mappings
* Fix `:AckFile` when using Dispatch
* Restore original `'makeprg'` and `'errorformat'` when using Dispatch
* Arrow keys also work for auto-preview (#158)
* Internal refactoring and clean-up
## Credits
This plugin is derived from Antoine Imbert's blog post [Ack and Vim

View file

@ -1,3 +1,7 @@
if exists('g:autoloaded_ack') || &cp
finish
endif
if exists('g:ack_use_dispatch')
if g:ack_use_dispatch && !exists(':Dispatch')
call s:Warn('Dispatch not loaded! Falling back to g:ack_use_dispatch = 0.')
@ -5,7 +9,7 @@ if exists('g:ack_use_dispatch')
endif
else
let g:ack_use_dispatch = 0
end
endif
"-----------------------------------------------------------------------------
" Public API
@ -26,9 +30,23 @@ function! ack#Ack(cmd, args) "{{{
let l:grepformat = '%f'
endif
" Check user policy for blank searches
if empty(a:args)
if !g:ack_use_cword_for_empty_search
echo "No regular expression found."
return
endif
endif
" If no pattern is provided, search for the word under the cursor
let l:grepargs = empty(a:args) ? expand("<cword>") : a:args . join(a:000, ' ')
"Bypass search if cursor is on blank string
if l:grepargs == ""
echo "No regular expression found."
return
endif
" NOTE: we escape special chars, but not everything using shellescape to
" allow for passing arguments etc
let l:escaped_args = escape(l:grepargs, '|#%')
@ -224,4 +242,5 @@ function! s:Warn(msg) "{{{
echohl WarningMsg | echomsg 'Ack: ' . a:msg | echohl None
endf "}}}
let g:autoloaded_ack = 1
" vim:set et sw=2 ts=2 tw=78 fdm=marker

View file

@ -4,6 +4,10 @@
Author: Antoine Imbert <antoine.imbert+ackvim@gmail.com> *ack-author*
License: Same terms as Vim itself (see |license|)
This plugin is only available if 'compatible' is not set.
{Vi does not have any of this}
==============================================================================
INTRODUCTION *ack*
@ -16,7 +20,7 @@ shows the results in a split window.
Search recursively in {directory} (which defaults to the current
directory) for the {pattern}. Behaves just like the |:grep| command, but
will open the |Quickfix| window for you. If [!] is not given the first
occurence is jumped to.
occurrence is jumped to.
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
@ -90,7 +94,6 @@ Example:
>
let g:ackprg = "ag --vimgrep"
<
*g:ack_default_options*
g:ack_default_options
Default: " -s -H --nocolor --nogroup --column"
@ -107,18 +110,17 @@ Example:
let g:ack_default_options =
\ " -s -H --nocolor --nogroup --column --smart-case --follow"
<
*g:ack_apply_qmappings*
g:ack_apply_qmappings
Default: 1
This option enable mappings on quickview window.
This option enables mappings on the |quickfix| window.
*g:ack_apply_lmappings*
g:ack_apply_lmappings
Default: 1
This option enable mappings on Location list window.
This option enables mappings on |location-list| windows.
*g:ack_mappings*
g:ack_mappings
@ -139,7 +141,6 @@ Example, if you want to open the result in the middle of the screen:
>
let g:ack_mappings = { "o": "<CR>zz" }
<
*g:ack_qhandler*
g:ack_qhandler
Default: "botright copen"
@ -150,7 +151,6 @@ If you want to open a quickview window with 30 lines you can do:
>
let g:ack_qhandler = "botright copen 30"
<
*g:ack_lhandler*
g:ack_lhandler
Default: "botright lopen"
@ -161,9 +161,7 @@ If you want to open a Location list window with 30 lines you can do:
>
let g:ack_lhandler = "botright lopen 30"
<
*g:ackhighlight*
g:ackhighlight
Default: 0
@ -173,7 +171,6 @@ Example:
>
let g:ackhighlight = 1
<
*g:ack_autoclose*
g:ack_autoclose
Default: 0
@ -185,9 +182,7 @@ Example:
>
let g:ack_autoclose = 1
<
*g:ack_autofold_results*
g:ack_autofold_results
Default: 0
@ -200,9 +195,7 @@ Example:
>
let g:ack_autofold_results = 1
<
*g:ackpreview*
g:ackpreview
Default: 0
@ -212,9 +205,7 @@ Example:
>
let g:ackpreview = 1
<
*g:ack_use_dispatch*
g:ack_use_dispatch
Default: 0
@ -229,28 +220,96 @@ Example:
>
let g:ack_use_dispatch = 1
<
*g:ack_use_cword_for_empty_search*
g:ack_use_cword_for_empty_search
Default: 1
Use this option to enable blank searches to run against the word under the
cursor. When this option is not set, blank searches will only output an error
message.
Example:
>
let g:ack_use_cword_for_empty_search = 0
<
==============================================================================
MAPPINGS *ack-mappings*
The following keyboard shortcuts are available in the quickfix window:
The following keyboard shortcuts are available in the |quickfix| and
|location-list| windows:
o open file (same as enter).
? display a quick summary of these mappings.
O open file and close quickfix window.
o open file (same as Enter).
O open file and close the quickfix window.
go preview file (open but maintain focus on ack.vim results).
t open in a new tab.
T open in new tab silently.
T open in new tab without moving to it.
h open in horizontal split.
H open in horizontal split silently.
H open in horizontal split, keeping focus on the results.
v open in vertical split.
gv open in vertical split silently.
gv open in vertical split, keeping focus on the results.
q close the quickfix window.
To adjust these, see |g:ack_mappings|.
==============================================================================
Ignoring files *ack-ignore*
If you're using this plugin with ag, The Silver Searcher, bear in mind that:
- It ignores file patterns from your .gitignore and .hgignore.
- If there are other files in your source repository you don't wish to
search, you can add their patterns to an .agignore file.
==============================================================================
ISSUES AND FAQ *ack-issues-and-faq*
I don't want to jump to the first result automatically.~
Use `:Ack!`, with bang. If you want this behavior most of the time, you
might like an abbreviation or mapping in your personal config, something
like these:
>
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
<
Most of the `:[L]Ack*` commands support this. Note that this behavior
follows the convention of Vim's built-in |:grep| and |:make| commands.
I use NERDTree and opening ack.vim results in a vertical split displacing it.~
You are probably using NERDTree with its default alignment at the left
side of the window. Set these custom mappings in your vimrc to work around
this:
>
let g:ack_mappings = {
\ 'v': '<C-W><CR><C-W>L<C-W>p<C-W>J<C-W>p',
\ 'gv': '<C-W><CR><C-W>L<C-W>p<C-W>J' }
<
This solution will be improved in the future.
Results show a mix of relative and absolute paths, making them hard to read.~
This is a quirk of Vim that can happen with plain |:vimgrep| too. You can
try this in your vimrc to work around it:
>
autocmd BufAdd * exe "cd" fnameescape(getcwd())
<
but for some users this may be disruptive to their Vim workflow. For more
details, see:
http://vi.stackexchange.com/a/4816/7174
https://github.com/mileszs/ack.vim/issues/143
vim:set et sw=4 ts=4 tw=78:

View file

@ -1,14 +1,15 @@
==== ack.vim quick help ===============
*?:* Show/quit this help
*t:* Open in a new tab
*T:* Open in a new tab silently
*o:* Open
*O:* Open and close result window
*go:* Preview
*h:* Horizontal open
*H:* Horizontal open silently
*v:* Vertical open
*gv:* Vertical open silently
*?:* a quick summary of these keys, repeat to close
*o:* to open (same as Enter)
*O:* to open and close the quickfix window
*go:* to preview file, open but maintain focus on ack.vim results
*t:* to open in new tab
*T:* to open in new tab without moving to it
*h:* to open in horizontal split
*H:* to open in horizontal split, keeping focus on the results
*v:* to open in vertical split
*gv:* to open in vertical split, keeping focus on the results
*q:* to close the quickfix window
========================================

View file

@ -1,17 +1,17 @@
if exists('g:loaded_ack')
if exists('g:loaded_ack') || &cp
finish
endif
if !exists("g:ack_default_options")
let g:ack_default_options = " -s -H --nocolor --nogroup --column"
let g:ack_default_options = " -s -H --nopager --nocolor --nogroup --column"
endif
" Location of the ack utility
if !exists("g:ackprg")
if executable('ack')
let g:ackprg = "ack"
elseif executable('ack-grep')
if executable('ack-grep')
let g:ackprg = "ack-grep"
elseif executable('ack')
let g:ackprg = "ack"
else
finish
endif
@ -63,6 +63,10 @@ if !exists("g:ack_autofold_results")
let g:ack_autofold_results = 0
endif
if !exists("g:ack_use_cword_for_empty_search")
let g:ack_use_cword_for_empty_search = 1
endif
command! -bang -nargs=* -complete=file Ack call ack#Ack('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep<bang>', <q-args>)

View file

@ -1,5 +1,7 @@
# ag.vim #
## Deprecated: See [this comment](https://github.com/rking/ag.vim/issues/124#issuecomment-227038003) for more info. Maybe try [ack.vim](https://github.com/mileszs/ack.vim#can-i-use-ag-the-silver-searcher-with-this) as an alternative. ##
This plugin is a front for ag, A.K.A.
[the_silver_searcher](https://github.com/ggreer/the_silver_searcher). Ag can
be used as a replacement for 153% of the uses of `ack`. This plugin will allow
@ -21,13 +23,13 @@ Vim has various ways of installing plugins, the standard way is in [the document
cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && echo "set runtimepath^=~/.vim/bundle/ag" >> ~/.vimrc
```
Then open vim and rum `:helptags ~/.vim/bundle/ag/doc`.
Then open vim and run `:helptags ~/.vim/bundle/ag/doc`.
### Configuration ###
You can specify a custom ag name and path in your .vimrc like so:
let g:agprg="<custom-ag-path-goes-here> --vimgrep"
let g:ag_prg="<custom-ag-path-goes-here> --vimgrep"
You can configure ag.vim to always start searching from your project root
instead of the cwd
@ -67,6 +69,9 @@ In the quickfix window, you can use:
gv to open in vertical split silently
q to close the quickfix window
### Related Plugin ###
[vim-ag-anything](https://github.com/Chun-Yang/vim-ag-anything) adds an 'ga' action to search any text object.
### Acknowledgements ###
This Vim plugin is derived (and by derived, I mean copied, almost entirely)

View file

@ -1,17 +1,26 @@
" NOTE: You must, of course, install ag / the_silver_searcher
" FIXME: Delete deprecated options below on or after 15-7 (6 months from when they were changed) {{{
" FIXME: Delete deprecated options below on or after 2016-4 (6 months from when the deprecation warning was added) {{{
if exists("g:agprg")
let g:ag_prg = g:agprg
echohl WarningMsg
call input('g:agprg is deprecated and will be removed. Please use g:ag_prg')
echohl None
endif
if exists("g:aghighlight")
let g:ag_highlight = g:aghighlight
echohl WarningMsg
call input('g:aghighlight is deprecated and will be removed. Please use g:ag_highlight')
echohl None
endif
if exists("g:agformat")
let g:ag_format = g:agformat
echohl WarningMsg
call input('g:agformat is deprecated and will be removed. Please use g:ag_format')
echohl None
endif
" }}} FIXME: Delete the deprecated options above on or after 15-7 (6 months from when they were changed)
@ -79,6 +88,11 @@ function! ag#Ag(cmd, args)
let l:grepargs = a:args . join(a:000, ' ')
end
if empty(l:grepargs)
echo "Usage: ':Ag {pattern}' (or just :Ag to search for the word under the cursor). See ':help :Ag' for more information."
return
endif
" Format, used to manage column jump
if a:cmd =~# '-g$'
let s:ag_format_backup=g:ag_format
@ -169,8 +183,12 @@ function! ag#Ag(cmd, args)
echom "ag.vim keys: q=quit <cr>/e/t/h/v=enter/edit/tab/split/vsplit go/T/H/gv=preview versions of same"
endif
endif
else
else " Close the split window automatically:
cclose
lclose
echohl WarningMsg
echom 'No matches for "'.a:args.'"'
echohl None
endif
endfunction

View file

@ -2,5 +2,6 @@
*.zip
note.txt
tags
tags-cn
.hg*
tmp/*

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,173 @@
" =============================================================================
" File: autoload/ctrlp/autoignore.vim
" Description: Auto-ignore Extension
" Author: Ludovic Chabant <github.com/ludovicchabant>
" =============================================================================
" Global Settings {{{
if exists('g:ctrlp_autoignore_loaded') && g:ctrlp_autoignore_loaded
\ && !g:ctrlp_autoignore_debug
finish
endif
let g:ctrlp_autoignore_loaded = 1
if !exists('g:ctrlp_autoignore_debug')
let g:ctrlp_autoignore_debug = 0
endif
if !exists('g:ctrlp_autoignore_trace')
let g:ctrlp_autoignore_trace = 0
endif
" }}}
" Initialization {{{
if !exists('g:ctrlp_custom_ignore')
let g:ctrlp_custom_ignore = {}
endif
let g:ctrlp_custom_ignore['func'] = 'ctrlp#autoignore#ignore'
let g:ctrlp_custom_ignore['func-init'] = 'ctrlp#autoignore#ignore_init'
let g:ctrlp_custom_ignore['func-close'] = 'ctrlp#autoignore#ignore_close'
if !exists('g:ctrlp_root_markers')
let g:ctrlp_root_markers = []
endif
call add(g:ctrlp_root_markers, '.ctrlpignore')
" }}}
" Internals {{{
function! s:trace(message) abort
if g:ctrlp_autoignore_trace
echom "ctrlp_autoignore: " . a:message
endif
endfunction
let s:proj_cache = {}
let s:active_cwd = ''
let s:active_cwd_len = 0
let s:active_patterns = []
let s:changed_wildignore = 0
let s:prev_wildignore = ''
function! s:load_project_patterns(root_dir) abort
let l:ign_path = a:root_dir . '/.ctrlpignore'
if !filereadable(l:ign_path)
call s:trace("No pattern file at: " . l:ign_path)
return []
endif
let l:cursyntax = 'regexp'
let l:knownsyntaxes = ['regexp', 'wildignore']
let l:patterns = []
let l:lines = readfile(l:ign_path)
for line in l:lines
" Comment line?
if match(line, '\v^\s*$') >= 0 || match(line, '\v^\s*#') >= 0
continue
endif
" Syntax change?
let l:matches = matchlist(line, '\v^syntax:\s?(\w+)\s*$')
if len(l:matches) > 0
let l:cursyntax = l:matches[1]
if index(l:knownsyntaxes, l:cursyntax) < 0
echoerr "ctrlp_autoignore: Unknown syntax '".l:cursyntax."' in: ".l:ign_path
endif
continue
endif
" Patterns!
let l:matches = matchlist(line, '\v^((dir|file|link)\:)?(.*)')
let l:mtype = l:matches[2]
let l:mpat = l:matches[3]
call add(l:patterns, {'syn': l:cursyntax, 'type': l:mtype, 'pat': l:mpat})
endfor
call s:trace("Loaded " . len(l:patterns) . " patterns from: " . l:ign_path)
return l:patterns
endfunction
function! s:get_project_patterns(root_dir) abort
let l:ign_path = a:root_dir . '/.ctrlpignore'
let l:ign_mtime = getftime(l:ign_path)
let l:patterns = get(s:proj_cache, a:root_dir)
if type(l:patterns) == type({})
" Check that these patterns are still valid.
if l:ign_mtime < 0
" File got deleted! :(
let l:patterns['pats'] = []
return l:patterns['pats']
elseif l:ign_mtime <= l:patterns['mtime']
" File hasn't changed! :)
return l:patterns['pats']
endif
endif
call s:trace("Loading patterns for project: " . a:root_dir)
let l:loaded = s:load_project_patterns(a:root_dir)
let s:proj_cache[a:root_dir] = {
\'mtime': localtime(),
\'pats': l:loaded}
return l:loaded
endfunction
" The custom ignore function that CtrlP will be using in addition to
" normal pattern-based matching.
function! ctrlp#autoignore#ignore(item, type) abort
let l:cnv_item = tr(strpart(a:item, s:active_cwd_len), "\\", "/")
for pat in s:active_patterns
if pat['syn'] != 'regexp'
continue
endif
if pat['type'] == '' || pat['type'] == a:type
if match(l:cnv_item, pat['pat']) >= 0
call s:trace("Ignoring ".l:cnv_item." because of ".pat['pat'])
return 1
endif
endif
endfor
return 0
endfunction
function! ctrlp#autoignore#ignore_init() abort
let l:root = getcwd()
let s:active_cwd = l:root
" len+1 is for including the next separator after the root.
let s:active_cwd_len = len(l:root) + 1
let s:active_patterns = s:get_project_patterns(l:root)
call s:trace("Got ".len(s:active_patterns)." patterns for ".l:root)
let s:changed_wildignore = 0
let s:prev_wildignore = &wildignore
for pat in s:active_patterns
if pat['syn'] == 'wildignore'
execute 'set wildignore+='.pat['pat']
let s:changed_wildignore = 1
endif
endfor
if s:changed_wildignore
call s:trace("Set wildignore to ".&wildignore)
endif
endfunction
function! ctrlp#autoignore#ignore_close() abort
if s:changed_wildignore
execute 'set wildignore='.s:prev_wildignore
let s:prev_wildignore = ''
call s:trace("Set wildignore back to ".&wildignore)
endif
endfunction
" List patterns for a given project's root.
function! ctrlp#autoignore#get_patterns(root_dir) abort
let l:patterns = s:get_project_patterns(a:root_dir)
for pat in l:patterns
let l:prefix = pat['type'] == '' ? '(all)' : pat['type']
echom l:prefix . ':' . pat['pat']
endfor
endfunction
" }}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View file

@ -112,13 +112,20 @@ fu! ctrlp#bookmarkdir#accept(mode, str)
en
endf
fu! ctrlp#bookmarkdir#add(dir, ...)
let str = 'Directory to bookmark: '
let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir')
if cwd == '' | retu | en
let cwd = fnamemodify(cwd, ':p')
let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
if name == '' | retu | en
fu! ctrlp#bookmarkdir#add(bang, dir, ...)
let ctrlp_tilde_homedir = get(g:, 'ctrlp_tilde_homedir', 0)
let cwd = fnamemodify(getcwd(), ctrlp_tilde_homedir ? ':p:~' : ':p')
let dir = fnamemodify(a:dir, ctrlp_tilde_homedir ? ':p:~' : ':p')
if a:bang == '!'
let cwd = dir != '' ? dir : cwd
let name = a:0 && a:1 != '' ? a:1 : cwd
el
let str = 'Directory to bookmark: '
let cwd = dir != '' ? dir : s:getinput(str, cwd, 'dir')
if cwd == '' | retu | en
let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
if name == '' | retu | en
en
let name = tr(name, ' ', ' ')
cal s:savebookmark(name, cwd)
cal s:msg(name, cwd)

View file

@ -43,6 +43,7 @@ let s:bins = [
\ ]
let s:types = {
\ 'ant' : '%sant%sant%spt',
\ 'asm' : '%sasm%sasm%sdlmt',
\ 'aspperl': '%sasp%sasp%sfsv',
\ 'aspvbs' : '%sasp%sasp%sfsv',
@ -52,16 +53,20 @@ let s:types = {
\ 'cpp' : '%sc++%sc++%snvdtcgsuf',
\ 'cs' : '%sc#%sc#%sdtncEgsipm',
\ 'cobol' : '%scobol%scobol%sdfgpPs',
\ 'delphi' : '%spascal%spascal%sfp',
\ 'dosbatch': '%sdosbatch%sdosbatch%slv',
\ 'eiffel' : '%seiffel%seiffel%scf',
\ 'erlang' : '%serlang%serlang%sdrmf',
\ 'expect' : '%stcl%stcl%scfp',
\ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
\ 'go' : '%sgo%sgo%sfctv',
\ 'html' : '%shtml%shtml%saf',
\ 'java' : '%sjava%sjava%spcifm',
\ 'javascript': '%sjavascript%sjavascript%sf',
\ 'lisp' : '%slisp%slisp%sf',
\ 'lua' : '%slua%slua%sf',
\ 'make' : '%smake%smake%sm',
\ 'matlab' : '%smatlab%smatlab%sf',
\ 'ocaml' : '%socaml%socaml%scmMvtfCre',
\ 'pascal' : '%spascal%spascal%sfp',
\ 'perl' : '%sperl%sperl%sclps',
@ -69,16 +74,20 @@ let s:types = {
\ 'python' : '%spython%spython%scmf',
\ 'rexx' : '%srexx%srexx%ss',
\ 'ruby' : '%sruby%sruby%scfFm',
\ 'rust' : '%srust%srust%sfTgsmctid',
\ 'scheme' : '%sscheme%sscheme%ssf',
\ 'sh' : '%ssh%ssh%sf',
\ 'csh' : '%ssh%ssh%sf',
\ 'zsh' : '%ssh%ssh%sf',
\ 'scala' : '%sscala%sscala%sctTmlp',
\ 'slang' : '%sslang%sslang%snf',
\ 'sml' : '%ssml%ssml%secsrtvf',
\ 'sql' : '%ssql%ssql%scFPrstTvfp',
\ 'tex' : '%stex%stex%sipcsubPGl',
\ 'tcl' : '%stcl%stcl%scfmp',
\ 'vera' : '%svera%svera%scdefgmpPtTvx',
\ 'verilog': '%sverilog%sverilog%smcPertwpvf',
\ 'vhdl' : '%svhdl%svhdl%sPctTrefp',
\ 'vim' : '%svim%svim%savf',
\ 'yacc' : '%syacc%syacc%sl',
\ }
@ -130,7 +139,7 @@ fu! s:exectags(cmd)
endf
fu! s:exectagsonfile(fname, ftype)
let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype]
let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs --extra= ', a:ftype]
if type(s:types[ft]) == 1
let ags .= s:types[ft]
let bin = s:bin
@ -151,7 +160,11 @@ fu! s:esctagscmd(bin, args, ...)
let [ssl, &ssl] = [&ssl, 0]
en
let fname = a:0 ? shellescape(a:1) : ''
let cmd = shellescape(a:bin).' '.a:args.' '.fname
if (has('win32') || has('win64'))
let cmd = a:bin.' '.a:args.' '.fname
else
let cmd = shellescape(a:bin).' '.a:args.' '.fname
endif
if &sh =~ 'cmd\.exe'
let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
en

View file

@ -6,6 +6,7 @@
" Static variables {{{1
let [s:mrbs, s:mrufs] = [[], []]
let s:mruf_map_string = '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val'
fu! ctrlp#mrufiles#opts()
let [pref, opts] = ['g:ctrlp_mruf_', {
@ -15,6 +16,7 @@ fu! ctrlp#mrufiles#opts()
\ 'case_sensitive': ['s:cseno', 1],
\ 'relative': ['s:re', 0],
\ 'save_on_update': ['s:soup', 1],
\ 'map_string': ['g:ctrlp_mruf_map_string', s:mruf_map_string],
\ }]
for [ke, va] in items(opts)
let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
@ -51,7 +53,7 @@ fu! s:reformat(mrufs, ...)
let cwd = tr(cwd, '\', '/')
cal map(a:mrufs, 'tr(v:val, "\\", "/")')
en
retu map(a:mrufs, '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val')
retu map(a:mrufs, g:ctrlp_mruf_map_string)
endf
fu! s:record(bufnr)
@ -66,10 +68,12 @@ fu! s:record(bufnr)
endf
fu! s:addtomrufs(fname)
let fn = fnamemodify(a:fname, ':p')
let fn = fnamemodify(a:fname, get(g:, 'ctrlp_tilde_homedir', 0) ? ':p:~' : ':p')
let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
let abs_fn = fnamemodify(fn,':p')
if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
\ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu
\ || !empty(getbufvar('^' . abs_fn . '$', '&bt')) || !filereadable(abs_fn)
retu
en
let idx = index(s:mrufs, fn, 0, !{s:cseno})
if idx
@ -143,7 +147,7 @@ fu! ctrlp#mrufiles#init()
let s:locked = 0
aug CtrlPMRUF
au!
au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('<abuf>', 1))
au BufWinEnter,BufWinLeave,BufWritePost * cal s:record(expand('<abuf>', 1))
au QuickFixCmdPre *vimgrep* let s:locked = 1
au QuickFixCmdPost *vimgrep* let s:locked = 0
au VimLeavePre * cal s:savetofile(s:mergelists())

View file

@ -21,7 +21,7 @@ cal add(g:ctrlp_ext_vars, {
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:findcount(str)
fu! s:findcount(str, tgaddr)
let [tg, ofname] = split(a:str, '\t\+\ze[^\t]\+$')
let tgs = taglist('^'.tg.'$')
if len(tgs) < 2
@ -48,7 +48,13 @@ fu! s:findcount(str)
for tgi in ntgs
let cnt += 1
if tgi["filename"] == ofname
let [fnd, pos] = [0, cnt]
if a:tgaddr != ""
if a:tgaddr == tgi["cmd"]
let [fnd, pos] = [0, cnt]
en
else
let [fnd, pos] = [0, cnt]
en
en
endfo
retu [1, fnd, pos, len(ctgs)]
@ -92,8 +98,9 @@ endf
fu! ctrlp#tag#accept(mode, str)
cal ctrlp#exit()
let tgaddr = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\t\zs[^\t]\{-1,}\ze\%(;"\)\?\t')
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str, tgaddr)]
let cmds = {
\ 't': ['tab sp', 'tab stj'],
\ 'h': ['sp', 'stj'],
@ -121,6 +128,7 @@ fu! ctrlp#tag#accept(mode, str)
en
cal feedkeys(":".cmd." ".tg."\r".ext, 'nt')
en
cal feedkeys('zvzz', 'nt')
cal ctrlp#setlcdir()
endf

File diff suppressed because it is too large Load diff

View file

@ -63,18 +63,27 @@ Overview:~
|ctrlp_default_input|.........Seed the prompt with an initial string.
|ctrlp_abbrev|................Input abbreviations.
|ctrlp_key_loop|..............Use input looping for multi-byte input.
|ctrlp_use_migemo|............Use Migemo patterns for Japanese filenames.
|ctrlp_prompt_mappings|.......Change the mappings inside the prompt.
|ctrlp_line_prefix|...........Prefix for each line in ctrlp window.
|ctrlp_open_single_match|.....Automatically accept when only one candidate.
|ctrlp_brief_prompt|..........Exit CtrlP on empty prompt by <bs>.
|ctrlp_match_current_file|....Include current file in match entries.
|ctrlp_types|.................Names of builtin types.
MRU mode:
|ctrlp_mruf_max|..............Max MRU entries to remember.
|ctrlp_mruf_exclude|..........Files that shouldn't be remembered.
|ctrlp_mruf_include|..........Files to be remembered.
|ctrlp_mruf_relative|.........Show only MRU files in the working directory.
|ctrlp_tilde_homedir|....Save MRU file paths in home dir as ~/.
|ctrlp_mruf_default_order|....Disable sorting.
|ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not.
|ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added.
Buffer mode:
|ctrlp_bufname_mod|...........File name section modificator.
|ctrlp_bufpath_mod|...........File path section modificator.
BufferTag mode: (to enable, see |ctrlp-extensions|)
|g:ctrlp_buftag_ctags_bin|....The location of the ctags-compatible binary.
|g:ctrlp_buftag_systemenc|....The encoding used for the ctags command.
@ -118,7 +127,7 @@ Set this to 1 to set regexp search as the default: >
Can be toggled on/off by pressing <c-r> inside the prompt.
*'g:ctrlp_match_window'*
Change the postion, the listing order of results, the minimum and the maximum
Change the position, the listing order of results, the minimum and the maximum
heights of the match window: >
let g:ctrlp_match_window = ''
<
@ -181,13 +190,12 @@ variable: >
let g:ctrlp_working_path_mode = 'ra'
<
c - the directory of the current file.
a - like "c", but only applies when the current working directory outside of
CtrlP isn't a direct ancestor of the directory of the current file.
r - the nearest ancestor that contains one of these directories or files:
a - the directory of the current file, unless it is a subdirectory of the cwd
r - the nearest ancestor of the current file that contains one of these
directories or files:
.git .hg .svn .bzr _darcs
w - begin finding a root from the current working directory outside of CtrlP
instead of from the directory of the current file (default). Only applies
when "r" is also present.
w - modifier to "r": start search from the cwd instead of the current file's
directory
0 or <empty> - disable this feature.
Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as
@ -261,6 +269,9 @@ Examples: >
let g:ctrlp_custom_ignore = {
\ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@<!$'
\ }
let g:ctrlp_custom_ignore = {
\ 'func': 'some#custom#match_function'
\ }
<
Note #1: by default, |wildignore| and |g:ctrlp_custom_ignore| only apply when
|globpath()| is used to scan for files, thus these options do not apply when a
@ -269,6 +280,12 @@ command defined with |g:ctrlp_user_command| is being used.
Note #2: when changing the option's variable type, remember to |:unlet| it
first or restart Vim to avoid the "E706: Variable type mismatch" error.
Note #3: when using the "func" ignore type, you must provide the full name of
a function that can be called from CtrlP. An |autoload| function name is
recommended here. The function must take 2 parameters, the item to match and
its type. The type will be "dir", "file", or "link". The function must return
1 if the item should be ignored, 0 otherwise.
*'g:ctrlp_max_files'*
The maximum number of files to scan, set to 0 for no limit: >
let g:ctrlp_max_files = 10000
@ -327,7 +344,7 @@ Some examples: >
" Single VCS, listing command lists untracked files (slower):
let g:ctrlp_user_command =
\ ['.git', 'cd %s && git ls-files . -co --exclude-standard']
\ ['.git', 'cd %s && git ls-files -co --exclude-standard']
let g:ctrlp_user_command =
\ ['.hg', 'hg --cwd %s status -numac -I . $(hg root)'] " MacOSX/Linux
@ -434,6 +451,23 @@ Instead of 1 or 0, if the value of the option is a string, it'll be used as-is
as the default input: >
let g:ctrlp_default_input = 'anystring'
<
This option works well together with |g:ctrlp_open_single_match|
*'g:ctrlp_match_current_file'*
Includes the current file in the match entries: >
let g:ctrlp_match_current_file = 1
By default, the current file is excluded from the list.
Note: does not apply when |g:ctrlp_match_func| is used.
*'g:ctrlp_types'*
Set this to list of names to customize core types: >
let g:ctrlp_types = ['mru', 'fil']
By default, the types are: >
let g:ctrlp_types = ['fil', 'buf', 'mru'].
*'g:ctrlp_abbrev'*
Define input abbreviations that can be expanded (either internally or visibly)
@ -497,12 +531,6 @@ Note #2: you can toggle this feature inside the prompt with a custom mapping: >
let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': ['<F3>'] }
<
*'g:ctrlp_use_migemo'*
Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
works in regexp mode. To split the pattern, separate words with space: >
let g:ctrlp_use_migemo = 0
<
*'g:ctrlp_prompt_mappings'*
Use this to customize the mappings inside CtrlP's prompt to your liking. You
only need to keep the lines that you've changed the values (inside []): >
@ -549,6 +577,34 @@ default <c-h> mapping: >
let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['<left>', '<c-^>'] }
<
*'g:ctrlp_line_prefix'*
This prefix will be prepended to each line in ctrlp's item listing.
default: >
let g:ctrlp_line_prefix = '> '
<
*'g:ctrlp_open_single_match'*
List of CtrlP modes for which CtrlP should accept an entry directly, if only
one candidate exists.
Example: >
let g:ctrlp_open_single_match = ['buffer tags', 'buffer']
<
This is currently only really useful together with |g:ctrlp_default_input|
set before launching, and cleared afterwards, with a function such as
following: >
fu! <SID>tagsUnderCursor()
try
let default_input_save = get(g:, 'ctrlp_default_input', '')
let g:ctrlp_default_input = expand('<cword>')
CtrlPBufTagAll
finally
if exists('default_input_save')
let g:ctrlp_default_input = default_input_save
endif
endtry
endfu
>
<
----------------------------------------
MRU mode options:~
@ -574,6 +630,14 @@ Example: >
let g:ctrlp_mruf_include = '\.py$\|\.rb$'
<
*'g:ctrlp_tilde_homedir'*
Set this to 1 to save every MRU file path $HOME/$filepath in the $HOME dir
as ~/$filepath instead of $HOME/$filepath : >
let g:ctrlp_tilde_homedir = 0
<
Note: This applies also to all dir paths stored by :CtrlPBookmarkDirAdd!
<
*'g:ctrlp_mruf_relative'*
Set this to 1 to show only MRU files in the current working directory: >
let g:ctrlp_mruf_relative = 0
@ -581,7 +645,6 @@ Set this to 1 to show only MRU files in the current working directory: >
Note: you can use a custom mapping to toggle this option inside the prompt: >
let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': ['<F2>'] }
<
*'g:ctrlp_mruf_default_order'*
Set this to 1 to disable sorting when searching in MRU mode: >
let g:ctrlp_mruf_default_order = 0
@ -598,7 +661,14 @@ Set this to 0 to disable saving of the MRU list to hard drive whenever a new
entry is added, saving will then only occur when exiting Vim: >
let g:ctrlp_mruf_save_on_update = 1
<
*'g:ctrlp_bufname_mod'*
Modify file name section according to modificator string. See |filename-modifiers|. >
let g:ctrlp_bufname_mod = ':t'
<
*'g:ctrlp_bufpath_mod'*
Modify file path section according to modificator string. See |filename-modifiers|. >
let g:ctrlp_bufpath_mod = ':~:.:h'
<
----------------------------------------
Advanced options:~
@ -772,6 +842,15 @@ Example: >
" }
endfunction
<
*'g:ctrlp_brief_prompt'*
When this is set to 1, the <bs> on empty prompt exit CtrlP.
*ctrlp-default-value*
Otherwize, you can use below to change default value.
Example: >
let g:ctrlp_path_nolim = 1
This is possible to change no-limit mode for match type "path".
===============================================================================
COMMANDS *ctrlp-commands*
@ -953,8 +1032,12 @@ Function keys:~
- Remove deleted files from the MRU list.
<F7>
- Wipe the MRU list.
- Delete MRU entries marked by <c-z>.
MRU mode:
- Wipe the list.
- Delete entries marked by <c-z>.
Buffer mode:
- Delete entry under the cursor or delete multiple entries marked by <c-z>.
Pasting:~
@ -1027,7 +1110,7 @@ d) Submit two dots '..' to go upward the directory tree by 1 level. To go up
e) Similarly, submit '/' or '\' to find and go to the project's root.
If the project is large, using a VCS listing command to look for files
might help speeding up the intial scan (see |g:ctrlp_user_command| for more
might help speeding up the initial scan (see |g:ctrlp_user_command| for more
details).
Note: d) and e) only work in file, directory and mixed modes.
@ -1138,8 +1221,27 @@ Available extensions:~
* BookmarkDir mode:~
- Name: 'bookmarkdir'
- Commands: ":CtrlPBookmarkDir",
":CtrlPBookmarkDirAdd [directory]".
":CtrlPBookmarkDirAdd [directory] [TITLE]".
":CtrlPBookmarkDirAdd! [directory] [TITLE]".
- Search for a bookmarked directory and change the working directory to it.
- Add either the dir [directory], if supplied, or otherwise ask for it,
under the title given by either [TITLE], if supplied, or otherwise ask for
it, to the CtrlPBookmarkDir list.
- Add either the dir [directory], if supplied, or otherwise the current
work dir ( [CWD] ) under the title given by either [TITLE], if supplied,
or otherwise [CWD] to the CtrlPBookmarkDir list.
The last command can be used to add all recently used work dirs to the
CtrlPBookmarkDir list by an autocommand like
>
augroup CtrlPDirMRU
autocmd!
autocmd FileType * if &modifiable | execute 'silent CtrlPBookmarkDirAdd! %:p:h' | endif
augroup END
<
- Mappings:
+ <cr> change the local working directory for CtrlP, keep it open and
switch to find file mode.
@ -1149,6 +1251,80 @@ Available extensions:~
- Wipe bookmark list.
- Delete entries marked by <c-z>.
*ctrlp-autoignore-extension*
* Autoignore mode:~
- Name: 'autoignore'
- This extension doesn't add new commands. It adds support for per-project
ignore patterns (as per |ctrlp_custom_ignore|) via a `.ctrlpignore` file
at the root of the project. It's basically like a `.gitignore` or
`.hgignore` for CtrlP.
Note: auto-ignore won't work when |g:ctrlp_user_command| is used.
Note: `.ctrlpignore` will be added to the root markers (see
|g:ctrlp_root_markers|).
- Ignore file syntax:
Empty lines, and lines starting with `#` (comments) are ignored.
Other lines are treated like regular expression patterns. See *string-match*
for how patterns are used. Anything that matches any of the patterns will be
ignored from CtrlP's search results.
Example:
\.tmp$
^generated/
local\.cfg
Note: patterns should use forward slashes, even on Windows.
You can also switch to a glob-like syntax like this:
syntax:wildignore
*.tar.gz
*.tmp
This will temporarily add each pattern to |'wildignore'| for the
duration of the file scan, and remove them at the end.
You can switch back to the default regular-expression-based patterns by
writing:
syntax:regexp
You can also specify a match on only a given type of item:
dir:build
file:foo\.txt
This will only ignore directories with "build" in them, and files with
"foo.txt" in them. Not files with "build" in them or vice-versa.
Note: to ignore a root directory "build", and not _any_ directory with
"build" in it, you can root the regex: ^build$
- FAQ:
Q: Why can't CtrlP support `.gitignore` or `.hgignore` natively?
A: Those files look at first like they may contain all the patterns
you'd want to exclude from CtrlP already. However, more often than not,
there are some differences. Those files list patterns that should not be
included in source-control. This includes things you want to ignore, but
also things you may not want to: local settings, external packages and
dependencies, etc. The author felt the trouble of supporting various
syntaxes was too much compared to just copy/pasting a few lines. Feel
free to contribute a patch if you disagree :)
Q: I enabled |ctrlp-autoignore-extension|, or edited `.ctrlpignore`, but
none of the new patterns are working. What did I do wrong?
A: Probably nothing! CtrlP can cache search results for faster response
times. You can hit <F5> to force it to refresh. This will use the newer
ignore patterns if the `.ctrlpignore` file has changed, too.
----------------------------------------
Buffer Tag mode options:~
@ -1189,6 +1365,17 @@ Highlighting:~
CtrlPPrtText : the prompt's text (|hl-Normal|)
CtrlPPrtCursor : the prompt's cursor when moving over the text (Constant)
* Buffer explorer mode:
CtrlPBufferNr : buffer number
CtrlPBufferInd : '+', '-', '=' and '#' indicators (see |:buffers|)
CtrlPBufferHid : hidden buffer
CtrlPBufferHidMod : hidden and modified buffer
CtrlPBufferVis : visible buffer
CtrlPBufferVisMod : visible and modified buffer
CtrlPBufferCur : current buffer
CtrlPBufferCurMod : current and modified buffer
CtrlPBufferPath : buffer path
* In extensions:
CtrlPTabExtra : the part of each line that's not matched against (Comment)
CtrlPBufName : the buffer name an entry belongs to (|hl-Directory|)
@ -1259,11 +1446,12 @@ MISCELLANEOUS CONFIGS *ctrlp-miscellaneous-configs*
===============================================================================
CREDITS *ctrlp-credits*
Developed by Kien Nguyen <github.com/kien>. Distributed under Vim's |license|.
Originally developed by Kien Nguyen <github.com/kien>. Now maintained by the
members of the ctrlpvim Github organisation
(https://github.com/orgs/ctrlpvim/people). Distributed under Vim's |license|.
Project's homepage: http://kien.github.com/ctrlp.vim
Git repository: https://github.com/kien/ctrlp.vim
Mercurial repository: https://bitbucket.org/kien/ctrlp.vim
Project's homepage: http://ctrlpvim.github.com/ctrlp.vim
Git repository: https://github.com/ctrlpvim/ctrlp.vim
-------------------------------------------------------------------------------
Thanks to everyone that has submitted ideas, bug reports or helped debugging on
@ -1290,10 +1478,14 @@ Special thanks:~
* Jo De Boeck <github.com/grimpy>
* Rudi Grinberg <github.com/rgrinberg>
* Timothy Mellor <github.com/mellort>
* Sergey Vlasov <github.com/noscript>
===============================================================================
CHANGELOG *ctrlp-changelog*
+ New buffer explorer mode with highlighting (|+conceal| recommended)
+ New options: |g:ctrlp_bufname_mod|,
|g:ctrlp_bufpath_mod|
+ Combine *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* and
*g:ctrlp_max_height* into |g:ctrlp_match_window|.
+ New option: |g:ctrlp_match_window|.

View file

@ -10,17 +10,23 @@ if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp
en
let g:loaded_ctrlp = 1
let s:types = ['fil', 'buf', 'mru']
if !exists('g:ctrlp_types')
let g:ctrlp_types = s:types
el
call filter(g:ctrlp_types, "index(['fil', 'buf', 'mru'], v:val)!=-1")
en
let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs,
\ g:ctrlp_allmixes, g:ctrlp_buftags, g:ctrlp_ext_vars, g:ctrlp_builtins]
\ = [[], [], [], [], {}, {}, [], 2]
\ = [[], [], [], [], {}, {}, [], len(g:ctrlp_types)-1]
if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': <q-args> })
com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': <q-args> })
com! -n=? -com=dir CtrlP cal ctrlp#init('fil', { 'dir': <q-args> })
com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init('mru', { 'dir': <q-args> })
com! -bar CtrlPBuffer cal ctrlp#init(1)
com! -bar CtrlPBuffer cal ctrlp#init('buf')
com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': <q-args> })
com! -bar CtrlPClearCache cal ctrlp#clr()
@ -29,12 +35,14 @@ com! -bar CtrlPClearAllCaches cal ctrlp#clra()
com! -bar ClearCtrlPCache cal ctrlp#clr()
com! -bar ClearAllCtrlPCaches cal ctrlp#clra()
com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' })
com! -bar CtrlPCurWD cal ctrlp#init('fil', { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init('fil', { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init('fil', { 'mode': 'r' })
if g:ctrlp_map != '' && !hasmapto(':<c-u>'.g:ctrlp_cmd.'<cr>', 'n')
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
exe 'nn <silent> <plug>(ctrlp) :<c-u>'.g:ctrlp_cmd.'<cr>'
if g:ctrlp_map != '' && !hasmapto('<plug>(ctrlp)')
exe 'map' g:ctrlp_map '<plug>(ctrlp)'
en
cal ctrlp#mrufiles#init()
@ -53,16 +61,16 @@ com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
com! -n=? -com=buffer CtrlPLine
\ cal ctrlp#init(ctrlp#line#cmd(1, <q-args>))
\ cal ctrlp#init(ctrlp#line#cmd('buf', <q-args>))
com! -n=? -com=buffer CtrlPChange
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
\ cal ctrlp#init(ctrlp#changes#cmd('fil', <q-args>))
com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id())
com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id())
com! -n=? -com=dir CtrlPBookmarkDirAdd
\ cal ctrlp#call('ctrlp#bookmarkdir#add', <q-args>)
com! -n=? -com=dir -bang CtrlPBookmarkDirAdd
\ cal ctrlp#call('ctrlp#bookmarkdir#add', '<bang>', <q-args>)
" vim:ts=2:sw=2:sts=2

View file

@ -32,8 +32,8 @@ Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands.
Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help.
* Submit two or more dots `..` to go up the directory tree by one or multiple levels.
* End the input string with a colon `:` followed by a command to execute it on the opening file(s):
Use `:25` to jump to line 25.
* End the input string with a colon `:` followed by a command to execute it on the opening file(s):
Use `:25` to jump to line 25.
Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files.
## Basic Options
@ -44,20 +44,27 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi
let g:ctrlp_cmd = 'CtrlP'
```
* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable:
* When invoked without an explicit starting directory, CtrlP will set its local working directory according to this variable:
```vim
let g:ctrlp_working_path_mode = 'ra'
```
`'c'` - the directory of the current file.
`'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
`'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.
`'a'` - the directory of the current file, unless it is a subdirectory of the cwd
`'r'` - the nearest ancestor of the current file that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
`'w'` - modifier to "r": start search from the cwd instead of the current file's directory
`0` or `''` (empty string) - disable this feature.
Define additional root markers with the `g:ctrlp_root_markers` option.
If none of the default markers (`.git` `.hg` `.svn` `.bzr` `_darcs`) are present in a project, you can define additional ones with `g:ctrlp_root_markers`:
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`:
```vim
let g:ctrlp_root_markers = ['pom.xml', '.p4ignore']
```
If more than one mode is specified, they will be tried in order until a directory is located.
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`. If a custom listing command is being used, exclusions are ignored:
```vim
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
@ -78,11 +85,17 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
```
* Ignore files in `.gitignore`
```vim
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
```
Check `:help ctrlp-options` for other options.
## Installation
Use your favorite method or check the homepage for a [quick installation guide][3].
[1]: http://i.imgur.com/yIynr.png
[2]: https://github.com/kien/ctrlp.vim/tree/extensions
[3]: http://kien.github.com/ctrlp.vim#installation
[1]: http://i.imgur.com/aOcwHwt.png
[2]: https://github.com/ctrlpvim/ctrlp.vim/tree/extensions
[3]: http://ctrlpvim.github.com/ctrlp.vim#installation

View file

@ -33,8 +33,8 @@ function! s:get_color(group, attr)
endfunction
function! s:set_color(group, attr, color)
let gui = has('gui_running')
execute printf("hi %s %s%s=%s", a:group, gui ? 'gui' : 'cterm', a:attr, a:color)
let gui = a:color =~ '^#'
execute printf('hi %s %s%s=%s', a:group, gui ? 'gui' : 'cterm', a:attr, a:color)
endfunction
function! s:blank(repel)
@ -106,7 +106,7 @@ function! s:resize_pads()
endfunction
function! s:tranquilize()
let bg = s:get_color('Normal', 'bg')
let bg = s:get_color('Normal', 'bg#')
for grp in ['NonText', 'FoldColumn', 'ColorColumn', 'VertSplit',
\ 'StatusLine', 'StatusLineNC', 'SignColumn']
" -1 on Vim / '' on GVim
@ -161,6 +161,8 @@ function! s:maps_resize()
return mapped
endfunction
nnoremap <silent> <plug>(goyo-resize) :<c-u>call <sid>resize_pads()<cr>
function! s:goyo_on(dim)
let dim = s:parse_arg(a:dim)
if empty(dim)
@ -207,13 +209,13 @@ function! s:goyo_on(dim)
endif
" vim-airline
let t:goyo_disabled_airline = exists("#airline")
let t:goyo_disabled_airline = exists('#airline')
if t:goyo_disabled_airline
AirlineToggle
endif
" vim-powerline
let t:goyo_disabled_powerline = exists("#PowerlineMain")
let t:goyo_disabled_powerline = exists('#PowerlineMain')
if t:goyo_disabled_powerline
augroup PowerlineMain
autocmd!
@ -222,7 +224,7 @@ function! s:goyo_on(dim)
endif
" lightline.vim
let t:goyo_disabled_lightline = exists('#LightLine')
let t:goyo_disabled_lightline = exists('#lightline')
if t:goyo_disabled_lightline
silent! call lightline#disable()
endif
@ -263,13 +265,18 @@ function! s:goyo_on(dim)
autocmd ColorScheme * call s:tranquilize()
autocmd BufWinEnter * call s:hide_linenr() | call s:hide_statusline()
autocmd WinEnter,WinLeave * call s:hide_statusline()
if has('nvim')
autocmd TermClose * call feedkeys("\<plug>(goyo-resize)")
endif
augroup END
call s:hide_statusline()
if exists('g:goyo_callbacks[0]')
call g:goyo_callbacks[0]()
endif
silent! doautocmd User GoyoEnter
if exists('#User#GoyoEnter')
doautocmd User GoyoEnter
endif
endfunction
function! s:goyo_off()
@ -328,7 +335,7 @@ function! s:goyo_off()
let &winheight = wh
for [k, v] in items(goyo_revert)
execute printf("let &%s = %s", k, string(v))
execute printf('let &%s = %s', k, string(v))
endfor
execute 'colo '. get(g:, 'colors_name', 'default')
@ -342,12 +349,15 @@ function! s:goyo_off()
endif
endif
if goyo_disabled_airline && !exists("#airline")
if goyo_disabled_airline && !exists('#airline')
AirlineToggle
" For some reason, Airline requires two refreshes to avoid display
" artifacts
silent! AirlineRefresh
silent! AirlineRefresh
endif
if goyo_disabled_powerline && !exists("#PowerlineMain")
if goyo_disabled_powerline && !exists('#PowerlineMain')
doautocmd PowerlineStartup VimEnter
silent! PowerlineReloadColorscheme
endif
@ -363,7 +373,9 @@ function! s:goyo_off()
if exists('g:goyo_callbacks[1]')
call g:goyo_callbacks[1]()
endif
silent! doautocmd User GoyoLeave
if exists('#User#GoyoLeave')
doautocmd User GoyoLeave
endif
endfunction
function! s:relsz(expr, limit)
@ -414,6 +426,10 @@ function! goyo#execute(bang, dim)
if exists('#goyo') == 0
call s:goyo_on(a:dim)
elseif !empty(a:dim)
if winnr('$') < 5
call s:goyo_off()
return goyo#execute(a:bang, a:dim)
endif
let dim = s:parse_arg(a:dim)
if !empty(dim)
let t:goyo_dim = dim

View file

View file

@ -0,0 +1,22 @@
language: generic
sudo: false
install:
- git clone --depth=1 https://github.com/thinca/vim-themis /tmp/themis
- git clone https://github.com/vim/vim $HOME/vim
- (if ! test -d $HOME/vim-7.4/bin; then cd $HOME/vim && git checkout . && git checkout v7.4 && ./configure --prefix=$HOME/vim-7.4 && make && make install; fi)
- (if ! test -d $HOME/vim-7.3/bin; then cd $HOME/vim && git checkout . && git checkout v7.3 && ./configure --prefix=$HOME/vim-7.3 && make && make install; fi)
- (if ! test -d $HOME/vim-7.2.051/bin; then cd $HOME/vim && git checkout . && git checkout v7.2.051 && ./configure --prefix=$HOME/vim-7.2.051 && make && make install; fi)
cache:
directories:
- $HOME/vim-7.4
- $HOME/vim-7.3
- $HOME/vim-7.2.051
script:
- /tmp/themis/bin/themis --reporter spec
- PATH=$HOME/vim-7.4/bin/:$PATH /tmp/themis/bin/themis --reporter spec
- PATH=$HOME/vim-7.3/bin/:$PATH /tmp/themis/bin/themis --reporter spec
- PATH=$HOME/vim-7.2.051/bin/:$PATH /tmp/themis/bin/themis --reporter spec

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2013-2016 itchyny
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,788 @@
# lightline.vim
A light and configurable statusline/tabline for Vim
https://github.com/itchyny/lightline.vim
### powerline theme (default)
![lightline.vim - powerline](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/powerline/0.png)
### wombat (with the patched font)
![lightline.vim - wombat](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/wombat/0.png)
### jellybeans (with the patched font)
![lightline.vim - jellybeans](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/jellybeans/0.png)
### solarized theme (dark)
![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark/0.png)
### solarized theme (light)
![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light/0.png)
### PaperColor theme (light)
![lightline.vim - PaperColor](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor/0.png)
### seoul256 theme
![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256/0.png)
### landscape theme (with the patched font)
![lightline.vim - landscape](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape/0.png)
With branch name, read-only mark and modified mark.
![lightline.vim - landscape - fugitive](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape/5.png)
landscape is my colorscheme, which is a high-contrast cui-supported colorscheme, available at https://github.com/itchyny/landscape.vim
## Why yet another clone of powerline?
+ [vim-powerline](https://github.com/Lokaltog/vim-powerline) is a nice plugin, but deprecated.
+ [powerline](https://github.com/Lokaltog/powerline) is a nice plugin, but difficult to configure.
+ [vim-airline](https://github.com/bling/vim-airline) is a nice plugin, but it uses too much functions of other plugins, which should be done by users in `.vimrc`.
## Spirit of this plugin
+ Minimalism. The core script is very small.
+ Configurability. You can create your own component and easily add to the statusline/tabline.
+ Orthogonality. Any plugin should not change the settings of another plugin. Such plugin-crossing settings should be written by users in `.vimrc`.
## Author
itchyny (https://github.com/itchyny)
## License
This software is released under the MIT License, see LICENSE.
## Installation
### Manually
1. Put all files under $VIM.
### Pathogen
1. Install with the following command.
git clone https://github.com/itchyny/lightline.vim ~/.vim/bundle/lightline.vim
### Vundle (https://github.com/gmarik/Vundle.vim)
1. Add the following configuration to your `.vimrc`.
Plugin 'itchyny/lightline.vim'
2. Install with `:PluginInstall`.
### NeoBundle (https://github.com/Shougo/neobundle.vim)
1. Add the following configuration to your `.vimrc`.
NeoBundle 'itchyny/lightline.vim'
2. Install with `:NeoBundleInstall`.
### vim-plug (https://github.com/junegunn/vim-plug)
1. Add the following configuration to your `.vimrc`.
Plug 'itchyny/lightline.vim'
2. Install with `:PlugInstall`.
## Configuration tutorial
By default, the statusline looks like:
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/1.png)
If you use the wombat colorscheme, add the following settings to your `.vimrc` (or \_vimrc on Windows):
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ }
```
to get:
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/2.png)
If your statusline looks like
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/21.png)
and the cool statuslines appear only on `:vsp`, add
```vim
set laststatus=2
```
to your `.vimrc`.
If you have problem like
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/20.png)
then add
```sh
export TERM=xterm-256color
```
to your `.*shrc` and add
```vim
if !has('gui_running')
set t_Co=256
endif
```
to your `.vimrc`.
If the colors of the statusline do not change from the default colors, move the settings of `g:lightline` before setting the colorscheme.
If you are reloading your `.vimrc` via `autocmd` and get this problem
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/20.png)
when saving it you need to add the nested flag to your `autocmd` like so
```vim
augroup reload_vimrc
autocmd!
autocmd bufwritepost $MYVIMRC nested source $MYVIMRC
augroup END
```
Colors appear correctly? Now let's see how to change the appearance.
You may think that the default read-only mark is not so cool:
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/3.png)
Then edit the read-only component.
The lightline components are stored in `g:lightline.component`.
So you add the settings of `g:lightline.component.readonly` in your `.vimrc`. (the following settings are effective with the patched font for vim-powerline):
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"⭤":""}',
\ }
\ }
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/4.png)
How nice!
But the boundaries are quadrilateral. You may miss the powerline.
You have installed a cool font for powerlines, so you can use it.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"⭤":""}',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/5.png)
Hurrah! Cool!
If your statusline looks like:
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/16.png)
the patched font is not installed.
There are two kinds of patched fonts:
+ The patched fonts for [vim-powerline](https://github.com/Lokaltog/vim-powerline): see https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher
+ The patched fonts for [powerline](https://github.com/Lokaltog/powerline): see https://github.com/Lokaltog/powerline-fonts
Create or download a font and install it.
And add the `guifont` setting to your `.vimrc` (see `:help 'guifont'` for more detail).
If you are using the vim in a terminal, the font cannot be controlled in `.vimrc`.
Open the setting of the terminal and select the patched font.
This tutorial is based on the former, the font for vim-powerline (Inconsolata for Powerline).
If you have installed the patched font for powerline, use the following settings instead.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"":""}',
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/19.png)
If you have installed the font for powerline and your statusline looks like
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/18.png)
remove
```vim
set ambiwidth=double
```
from your `.vimrc`. If you want to keep this setting, use the patched font for vim-powerline.
+ https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher
If you will not install a patched font, use ascii characters like:
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"x":""}',
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/17.png)
If the triangles do not appear (but you get some spaces or weird characters like &lt;bf&gt; or ¿), firstly try adding
```vim
set encoding=utf-8
scriptencoding utf-8
```
to the head of your `.vimrc`.
Still you have weird characters, use the unicode numbers. For powerline font
users:
```vim
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
```
For vim-powerline font users:
```vim
\ 'separator': { 'left': "\u2b80", 'right': "\u2b82" },
\ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" }
```
Almost all of things go well with the patched font but if the triangle looks weird:
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/22.png)
If you are using iTerm2, change the following settings of iTerm2:
+ set `Profiles>Colors>Minimum contrast` to the Lowest.
+ set `Profiles>Window>Transparency` to the Opaquest.
For other terminals, this weird-triangle problem will be resolved by disabling transparency or contrast adjustment.
If you want to get rid of the extraneous default vim mode information that is now provided by lightline:
![lightline.vim - showmode](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/showmode.png)
```vim
set noshowmode
```
Now, let us get back to the tutorial (with the patched font for vim-powerline).
You look into a help file to find the marks annoying.
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/6.png)
Help files are read-only and no-modifiable? We know that!
OK, so you again edit the components.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/7.png)
Huh? Weird!
The components do not collapse even if they have no information!
In order to avoid this situation, you set expressions to `g:lightline.component_visible_condition`, which should become 1 only when the corresponding components have information.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/8.png)
Okay. It works nice.
How does lightline decide the components to show in the statusline?
It's very simple.
The variables to select components are `g:lightline.active.left` and `g:lightline.active.right`.
For example, you add the `g:lightline.active.left` in `.vimrc`.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
```
If the plugin arranges all the components (in a situation you `set paste` and the file `.vimrc` is read-only, try to modify):
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/9.png)
The mode component, the paste component, read-only component, filename component and modified component in a row.
Normally, the paste component does not show up.
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/10.png)
If the file is not read-only (more common cases), the read-only component does not show up.
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/11.png)
Again look into `g:lightline.active.left`.
```vim
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified' ] ] ...
```
And the screen shot of all the components.
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/9.png)
The mode and paste component are displayed in the same group.
The read-only, filename and modified component are in the second group.
It corresponds to the structure of `g:lightline.active.left`.
You can configure the components in the statusline by the following four variables:
+ `g:lightline.active.left`
+ `g:lightline.active.right`
+ `g:lightline.inactive.left`
+ `g:lightline.inactive.right`
Of course, your settings in `.vimrc` have priority over the default settings in lightline.
GitHub branch is important for us.
And it is a default component in [powerline](https://github.com/Lokaltog/powerline) and [vim-powerline](https://github.com/Lokaltog/vim-powerline).
However, lightline does not provide the branch feature by default.
In order to show the branch in the statusline, you firstly install the [vim-fugitive](https://github.com/tpope/vim-fugitive) plugin.
Then edit the `g:lightline` in your `.vimrc`.
+ Add your fugitive component to `g:lightline.component`.
+ Add the condition when the fugitive component has information to `g:lightline.component_visible_condition`.
+ Add the component by inserting `'fugitive'` to `g:lightline.active.left`.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/12.png)
Okay, the branch component is added!
Now, you might get tired of setting both `'component'` and `'component_visible_condition'`.
Or if you want to do something more complicated?
In fact, the components can be created using functions.
Add your function names for components to `g:lightline.component_function`.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! LightLineReadonly()
if &filetype == "help"
return ""
elseif &readonly
return "⭤"
else
return ""
endif
endfunction
function! LightLineFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/13.png)
Fine and readable!
Finally, you come up with concatenating the three components: the read-only mark, the filename and the modified mark.
Now you may know what to do.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified',
\ 'filename': 'LightLineFilename'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! LightLineReadonly()
if &filetype == "help"
return ""
elseif &readonly
return "⭤"
else
return ""
endif
endfunction
function! LightLineFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/14.png)
Oops! We forgot the cool mark for the branch component! (work with the patched font for vim-powerline)
```vim
function! LightLineFugitive()
if exists("*fugitive#head")
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
endif
return ''
endfunction
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/15.png)
How cool!!!
Of course, you can name your component as you wish.
```vim
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'my_component' ] ] },
\ 'component_function': {
\ 'my_component': 'LightLineComponent', ...
```
This is the end of the tutorial. For more information, see `:help lightline`. Good luck with your nice statuslines.
### Cool characters for the patched fonts
Symbol | Default | powerline | vim-powerline
------------------ | ------- | ------------- | -------------
separator.left | '' | '' (\ue0b0) | '⮀' (\u2b80)
separator.right | '' | '' (\ue0b2) | '⮂' (\u2b82)
subseparator.left | '\|' | '' (\ue0b1) | '⮁' (\u2b81)
subseparator.right | '\|' | '' (\ue0b3) | '⮃' (\u2b83)
branch symbol | -- | '' (\ue0a0) | '⭠' (\u2b60)
readonly symbol | -- | '' (\ue0a2) | '⭤' (\u2b64)
linecolumn symbol | -- | '' (\ue0a1) | '⭡' (\u2b81)
### My settings
I show my settings. I use the patched font for vim-powerline.
```vim
let g:lightline = {
\ 'colorscheme': 'landscape',
\ 'mode_map': { 'c': 'NORMAL' },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'modified': 'LightLineModified',
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
function! LightLineFugitive()
if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head")
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
endif
return ''
endfunction
function! LightLineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
return winwidth(0) > 60 ? lightline#mode() : ''
endfunction
```
When the current window width is narrow, the mode component and the file information component collapse.
For example, the [gundo](https://github.com/sjl/gundo.vim) buffer is narrow.
Before:
![lightline.vim - gundo](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/gundo0.png)
After:
![lightline.vim - gundo](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/gundo1.png)
Nice looking, isn't it?
### For power users
For users who uses following plugins.
- [CtrlP](https://github.com/kien/ctrlp.vim)
- [Tagbar](https://github.com/majutsushi/tagbar)
- [Gundo](http://github.com/sjl/gundo.vim)
- [NERDtree](http://github.com/scrooloose/nerdtree)
- [Syntastic](https://github.com/scrooloose/syntastic)
- [unite.vim](https://github.com/Shougo/unite.vim)
- [vimfiler.vim](https://github.com/Shougo/vimfiler.vim)
- [vimshell.vim](https://github.com/Shougo/vimshell.vim)
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark'] ],
\ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ 'component_expand': {
\ 'syntastic': 'SyntasticStatuslineFlag',
\ },
\ 'component_type': {
\ 'syntastic': 'error',
\ },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
function! LightLineModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
let fname = expand('%:t')
return fname == 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
\ fname =~ '__Gundo\|NERD_tree' ? '' :
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
function! LightLineFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '' " edit here for cool mark
let branch = fugitive#head()
return branch !=# '' ? mark.branch : ''
endif
catch
endtry
return ''
endfunction
function! LightLineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname == 'ControlP' ? 'CtrlP' :
\ fname == '__Gundo__' ? 'Gundo' :
\ fname == '__Gundo_Preview__' ? 'Gundo Preview' :
\ fname =~ 'NERD_tree' ? 'NERDTree' :
\ &ft == 'unite' ? 'Unite' :
\ &ft == 'vimfiler' ? 'VimFiler' :
\ &ft == 'vimshell' ? 'VimShell' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
function! CtrlPMark()
if expand('%:t') =~ 'ControlP' && has_key(g:lightline, 'ctrlp_item')
call lightline#link('iR'[g:lightline.ctrlp_regex])
return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item
\ , g:lightline.ctrlp_next], 0)
else
return ''
endif
endfunction
let g:ctrlp_status_func = {
\ 'main': 'CtrlPStatusFunc_1',
\ 'prog': 'CtrlPStatusFunc_2',
\ }
function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked)
let g:lightline.ctrlp_regex = a:regex
let g:lightline.ctrlp_prev = a:prev
let g:lightline.ctrlp_item = a:item
let g:lightline.ctrlp_next = a:next
return lightline#statusline(0)
endfunction
function! CtrlPStatusFunc_2(str)
return lightline#statusline(0)
endfunction
let g:tagbar_status_func = 'TagbarStatusFunc'
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction
augroup AutoSyntastic
autocmd!
autocmd BufWritePost *.c,*.cpp call s:syntastic()
augroup END
function! s:syntastic()
SyntasticCheck
call lightline#update()
endfunction
let g:unite_force_overwrite_statusline = 0
let g:vimfiler_force_overwrite_statusline = 0
let g:vimshell_force_overwrite_statusline = 0
```
### Note for developers of other plugins
Appearance consistency matters.
The statusline is an important space for Vim users.
Overwriting the statusline forcibly in your plugin is not a good idea.
It is not hospitality, but just an annoying feature.
If your plugin has such a feature, add an option to be modest.
A good design is the following.
Firstly, give the users a clue to judge which buffer is the one your plugin creates.
The filename is a manner and the filetype is another.
Then, export a function which is useful to be shown in the statusline.
Lastly, for advanced users, set important information in buffer variables.
So that the users can obtain the condition of the plugin easily.

View file

@ -0,0 +1,485 @@
" =============================================================================
" Filename: autoload/lightline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2016/06/12 22:40:00.
" =============================================================================
let s:save_cpo = &cpo
set cpo&vim
let s:_ = 1
function! lightline#update() abort
if s:_
call lightline#init()
call lightline#colorscheme()
endif
if !s:lightline.enable.statusline
return
endif
let w = winnr()
let s = winnr('$') == 1 ? [lightline#statusline(0)] : [lightline#statusline(0), lightline#statusline(1)]
for n in range(1, winnr('$'))
call setwinvar(n, '&statusline', s[n!=w])
call setwinvar(n, 'lightline', n!=w)
endfor
endfunction
function! lightline#update_once() abort
if !exists('w:lightline') || w:lightline
call lightline#update()
endif
endfunction
function! lightline#update_disable() abort
if !s:lightline.enable.statusline
return
endif
call setwinvar(0, '&statusline', '')
endfunction
function! lightline#enable() abort
call lightline#colorscheme()
call lightline#update()
if s:lightline.enable.tabline
set tabline=%!lightline#tabline()
endif
augroup lightline
autocmd!
autocmd WinEnter,BufWinEnter,FileType,ColorScheme,SessionLoadPost * call lightline#update()
autocmd ColorScheme,SessionLoadPost * call lightline#highlight()
autocmd CursorMoved,BufUnload * call lightline#update_once()
augroup END
augroup lightline-disable
autocmd!
augroup END
augroup! lightline-disable
endfunction
function! lightline#disable() abort
let [&statusline, &tabline] = [get(s:, '_statusline', ''), get(s:, '_tabline', '')]
for t in range(1, tabpagenr('$'))
for n in range(1, tabpagewinnr(t, '$'))
call settabwinvar(t, n, '&statusline', '')
endfor
endfor
augroup lightline
autocmd!
augroup END
augroup! lightline
augroup lightline-disable
autocmd!
autocmd WinEnter * call lightline#update_disable()
augroup END
endfunction
function! lightline#toggle() abort
if exists('#lightline')
call lightline#disable()
else
call lightline#enable()
endif
endfunction
let s:_lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly', 'filename', 'modified' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'inactive': {
\ 'left': [ [ 'filename' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ] ]
\ },
\ 'tabline': {
\ 'left': [ [ 'tabs' ] ],
\ 'right': [ [ 'close' ] ]
\ },
\ 'tab': {
\ 'active': [ 'tabnum', 'filename', 'modified' ],
\ 'inactive': [ 'tabnum', 'filename', 'modified' ]
\ },
\ 'component': {
\ 'mode': '%{lightline#mode()}',
\ 'absolutepath': '%F', 'relativepath': '%f', 'filename': '%t', 'modified': '%M', 'bufnum': '%n',
\ 'paste': '%{&paste?"PASTE":""}', 'readonly': '%R', 'charvalue': '%b', 'charvaluehex': '%B',
\ 'spell': '%{&spell?&spelllang:""}', 'fileencoding': '%{&fenc!=#""?&fenc:&enc}', 'fileformat': '%{&ff}',
\ 'filetype': '%{&ft!=#""?&ft:"no ft"}', 'percent': '%3p%%', 'percentwin': '%P',
\ 'lineinfo': '%3l:%-2v', 'line': '%l', 'column': '%c', 'close': '%999X X '
\ },
\ 'component_visible_condition': {
\ 'modified': '&modified||!&modifiable', 'readonly': '&readonly', 'paste': '&paste', 'spell': '&spell'
\ },
\ 'component_function': {},
\ 'component_expand': {
\ 'tabs': 'lightline#tabs'
\ },
\ 'component_type': {
\ 'tabs': 'tabsel', 'close': 'raw'
\ },
\ 'tab_component': {},
\ 'tab_component_function': {
\ 'filename': 'lightline#tab#filename', 'modified': 'lightline#tab#modified',
\ 'readonly': 'lightline#tab#readonly', 'tabnum': 'lightline#tab#tabnum'
\ },
\ 'colorscheme': 'default',
\ 'mode_map': {
\ 'n': 'NORMAL', 'i': 'INSERT', 'R': 'REPLACE', 'v': 'VISUAL', 'V': 'V-LINE', "\<C-v>": 'V-BLOCK',
\ 'c': 'COMMAND', 's': 'SELECT', 'S': 'S-LINE', "\<C-s>": 'S-BLOCK', 't': 'TERMINAL'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '|', 'right': '|' },
\ 'tabline_separator': {},
\ 'tabline_subseparator': {},
\ 'enable': { 'statusline': 1, 'tabline': 1 },
\ '_mode_': {
\ 'n': 'normal', 'i': 'insert', 'R': 'replace', 'v': 'visual', 'V': 'visual', "\<C-v>": 'visual',
\ 'c': 'command', 's': 'select', 'S': 'select', "\<C-s>": 'select', 't': 'terminal'
\ },
\ 'mode_fallback': { 'replace': 'insert', 'terminal': 'insert', 'select': 'visual' },
\ 'palette': {},
\ 'winwidth': winwidth(0),
\ }
function! lightline#init() abort
let s:lightline = deepcopy(get(g:, 'lightline', {}))
for [key, value] in items(s:_lightline)
if type(value) == 4
if !has_key(s:lightline, key)
let s:lightline[key] = {}
endif
call extend(s:lightline[key], value, 'keep')
elseif !has_key(s:lightline, key)
let s:lightline[key] = value
endif
unlet value
endfor
call extend(s:lightline.tabline_separator, s:lightline.separator, 'keep')
call extend(s:lightline.tabline_subseparator, s:lightline.subseparator, 'keep')
let s:lightline.tabline_configured = 0
for components in deepcopy(s:lightline.tabline.left + s:lightline.tabline.right)
if len(filter(components, 'v:val !=# "tabs" && v:val !=# "close"')) > 0
let s:lightline.tabline_configured = 1
break
endif
endfor
if !exists('s:_statusline')
let s:_statusline = &statusline
endif
if !exists('s:_tabline')
let s:_tabline = &tabline
endif
if s:lightline.enable.tabline
set tabline=%!lightline#tabline()
else
let &tabline = get(s:, '_tabline', '')
endif
for f in values(s:lightline.component_function)
silent! call call(f, [])
endfor
for f in values(s:lightline.tab_component_function)
silent! call call(f, [1])
endfor
let s:mode = ''
endfunction
function! lightline#colorscheme() abort
try
let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette
catch
call lightline#error('Could not load colorscheme ' . s:lightline.colorscheme . '.')
let s:lightline.colorscheme = 'default'
let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette
finally
let s:highlight = {}
call lightline#highlight('normal')
call lightline#link()
let s:_ = 0
if has('win32') && !has('gui_running') && &t_Co < 256
for u in values(s:lightline.palette)
for v in values(u)
for _ in v
let [_[2], _[3]] = [lightline#colortable#gui2cui(_[0], _[2]), lightline#colortable#gui2cui(_[1], _[3])]
endfor
endfor
endfor
endif
endtry
endfunction
function! lightline#palette() abort
return s:lightline.palette
endfunction
function! lightline#mode() abort
return get(s:lightline.mode_map, mode(), '')
endfunction
let s:mode = ''
function! lightline#link(...) abort
let mode = get(s:lightline._mode_, a:0 ? a:1 : mode(), 'normal')
if s:mode == mode
return ''
endif
let s:mode = mode
if !has_key(s:highlight, mode)
call lightline#highlight(mode)
endif
let types = map(s:uniq(sort(filter(values(s:lightline.component_type), 'v:val !=# "raw"'))), '[v:val, 1]')
for [p, l] in [['Left', len(s:lightline.active.left)], ['Right', len(s:lightline.active.right)]]
for [i, t] in map(range(0, l), '[v:val, 0]') + types
if i != l
exec printf('hi link LightLine%s_active_%s LightLine%s_%s_%s', p, i, p, mode, i)
endif
for [j, s] in map(range(0, l), '[v:val, 0]') + types
if i + 1 == j || t || s && i != l
exec printf('hi link LightLine%s_active_%s_%s LightLine%s_%s_%s_%s', p, i, j, p, mode, i, j)
endif
endfor
endfor
endfor
exec printf('hi link LightLineMiddle_active LightLineMiddle_%s', mode)
return ''
endfunction
function! s:term(p) abort
return get(a:p, 4) !=# '' ? 'term='.a:p[4].' cterm='.a:p[4].' gui='.a:p[4] : ''
endfunction
if exists('*uniq')
let s:uniq = function('uniq')
else
function! s:uniq(xs) abort
let i = len(a:xs) - 1
while i > 0
if a:xs[i] ==# a:xs[i - 1]
call remove(a:xs, i)
endif
let i -= 1
endwhile
return a:xs
endfunction
endif
function! lightline#highlight(...) abort
let [c, f] = [s:lightline.palette, s:lightline.mode_fallback]
let [s:lightline.llen, s:lightline.rlen] = [len(c.normal.left), len(c.normal.right)]
let [s:lightline.tab_llen, s:lightline.tab_rlen] = [len(has_key(get(c, 'tabline', {}), 'left') ? c.tabline.left : c.normal.left), len(has_key(get(c, 'tabline', {}), 'right') ? c.tabline.right : c.normal.right)]
let types = map(s:uniq(sort(filter(values(s:lightline.component_type), 'v:val !=# "raw"'))), '[v:val, 1]')
let modes = a:0 ? [a:1] : extend(['normal', 'insert', 'replace', 'visual', 'inactive', 'command', 'select', 'tabline'], has('nvim') ? ['terminal'] : [])
for mode in modes
let s:highlight[mode] = 1
let d = has_key(c, mode) ? mode : has_key(f, mode) && has_key(c, f[mode]) ? f[mode] : 'normal'
let left = d ==# 'tabline' ? s:lightline.tabline.left : d ==# 'inactive' ? s:lightline.inactive.left : s:lightline.active.left
let right = d ==# 'tabline' ? s:lightline.tabline.right : d ==# 'inactive' ? s:lightline.inactive.right : s:lightline.active.right
let ls = has_key(get(c, d, {}), 'left') ? c[d].left : has_key(f, d) && has_key(get(c, f[d], {}), 'left') ? c[f[d]].left : c.normal.left
let ms = has_key(get(c, d, {}), 'middle') ? c[d].middle[0] : has_key(f, d) && has_key(get(c, f[d], {}), 'middle') ? c[f[d]].middle[0] : c.normal.middle[0]
let rs = has_key(get(c, d, {}), 'right') ? c[d].right : has_key(f, d) && has_key(get(c, f[d], {}), 'right') ? c[f[d]].right : c.normal.right
for [p, l, zs] in [['Left', len(left), ls], ['Right', len(right), rs]]
for [i, t] in map(range(0, l), '[v:val, 0]') + types
if i < l || i < 1
let r = t ? (has_key(get(c, d, []), i) ? c[d][i][0] : has_key(get(c, 'tabline', {}), i) ? c.tabline[i][0] : get(c.normal, i, zs)[0]) : get(zs, i, ms)
exec printf('hi LightLine%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', p, mode, i, r[0], r[1], r[2], r[3], s:term(r))
endif
for [j, s] in map(range(0, l), '[v:val, 0]') + types
if i + 1 == j || t || s && i != l
let q = s ? (has_key(get(c, d, []), j) ? c[d][j][0] : has_key(get(c, 'tabline', {}), j) ? c.tabline[j][0] : get(c.normal, j, zs)[0]) : (j != l ? get(zs, j, ms) :ms)
exec printf('hi LightLine%s_%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s', p, mode, i, j, r[1], q[1], r[3], q[3])
endif
endfor
endfor
endfor
exec printf('hi LightLineMiddle_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', mode, ms[0], ms[1], ms[2], ms[3], s:term(ms))
endfor
endfunction
function! s:subseparator(components, subseparator, expanded) abort
let [a, c, f, v] = [ a:components, s:lightline.component, s:lightline.component_function, s:lightline.component_visible_condition ]
let xs = map(range(len(a:components)), 'a:expanded[v:val] ? "1" :
\ has_key(f, a[v:val]) ? (exists("*".f[a[v:val]]) ? "" : "exists(\"*".f[a[v:val]]."\")&&").f[a[v:val]]."()!=#\"\"" :
\ has_key(v, a[v:val]) ? "(" . v[a[v:val]] . ")" : has_key(c, a[v:val]) ? "1" : "0"')
return '%{' . (xs[0] ==# '1' ? '' : xs[0] . '&&(') . join(xs[1:], '||') . (xs[0] ==# '1' ? '' : ')') . '?"' . a:subseparator . '":""}'
endfunction
function! lightline#concatenate(xs, right) abort
let separator = a:right ? s:lightline.subseparator.right : s:lightline.subseparator.left
return join(filter(copy(a:xs), 'v:val !=# ""'), ' ' . separator . ' ')
endfunction
function! lightline#statusline(inactive) abort
if a:inactive && !has_key(s:highlight, 'inactive')
call lightline#highlight('inactive')
endif
return s:line(0, a:inactive)
endfunction
function! s:normalize(result) abort
if type(a:result) == 3
return map(a:result, 'type(v:val) == 1 ? v:val : string(v:val)')
elseif type(a:result) == 1
return [a:result]
else
return [string(a:result)]
endif
endfunction
function! s:evaluate_expand(component) abort
try
let result = call(a:component, [])
if type(result) == 1 && result ==# ''
return []
endif
catch
return []
endtry
return map(type(result) == 3 ? (result + [[], [], []])[:2] : [[], [result], []], 'filter(s:normalize(v:val), "v:val !=# ''''")')
endfunction
function! s:convert(name, index) abort
if has_key(s:lightline.component_expand, a:name)
let type = get(s:lightline.component_type, a:name, a:index)
return filter(s:map(s:evaluate_expand(s:lightline.component_expand[a:name]), '[v:val, 1, v:key == 1 ? "' . type . '" : "' . a:index . '"]'), 'v:val[0] != []')
else
return [[[a:name], 0, a:index]]
endif
endfunction
function! s:flatten_twice(xss) abort
let ys = []
for xs in a:xss
for x in xs
let ys += x
endfor
endfor
return ys
endfunction
if v:version > 702 || v:version == 702 && has('patch295')
let s:map = function('map')
else
function! s:map(xs, f) abort
let ys = []
for i in range(len(a:xs))
call extend(ys, map(a:xs[(i):(i)], substitute(a:f, 'v:key', i, 'g')))
endfor
return ys
endfunction
endif
function! s:expand(components) abort
let components = []
let expanded = []
let indices = []
let previndex = -1
let xs = s:flatten_twice(s:map(deepcopy(a:components), 'map(v:val, "s:convert(v:val, ''" . v:key . "'')")'))
for [component, expand, index] in xs
if previndex != index
call add(indices, index)
call add(components, [])
call add(expanded, [])
endif
call extend(components[-1], component)
call extend(expanded[-1], repeat([expand], len(component)))
let previndex = index
endfor
call add(indices, string(len(a:components)))
return [components, expanded, indices]
endfunction
function! s:line(tabline, inactive) abort
let _ = a:tabline ? '' : '%{lightline#link()}'
if s:lightline.palette == {}
call lightline#colorscheme()
endif
let [l, r] = a:tabline ? [s:lightline.tab_llen, s:lightline.tab_rlen] : [s:lightline.llen, s:lightline.rlen]
let [p, s] = a:tabline ? [s:lightline.tabline_separator, s:lightline.tabline_subseparator] : [s:lightline.separator, s:lightline.subseparator]
let [c, f, t] = [s:lightline.component, s:lightline.component_function, s:lightline.component_type]
let mode = a:tabline ? 'tabline' : a:inactive ? 'inactive' : 'active'
let l_ = has_key(s:lightline, mode) ? s:lightline[mode].left : s:lightline.active.left
let [lt, lc, ll] = s:expand(copy(l_))
let r_ = has_key(s:lightline, mode) ? s:lightline[mode].right : s:lightline.active.right
let [rt, rc, rl] = s:expand(copy(r_))
for i in range(len(lt))
let _ .= '%#LightLineLeft_' . mode . '_' . ll[i] . '#'
for j in range(len(lt[i]))
let x = lc[i][j] ? lt[i][j] : has_key(f, lt[i][j]) ? (exists('*' . f[lt[i][j]]) ? '%{' . f[lt[i][j]] . '()}' : '%{exists("*' . f[lt[i][j]] . '")?' . f[lt[i][j]] . '():""}') : get(c, lt[i][j], '')
let _ .= has_key(t, lt[i][j]) && t[lt[i][j]] ==# 'raw' || x ==# '' ? x : '%( ' . x . ' %)'
if j < len(lt[i]) - 1 && s.left !=# ''
let _ .= s:subseparator(lt[i][(j):], s.left, lc[i][(j):])
endif
endfor
let _ .= '%#LightLineLeft_' . mode . '_' . ll[i] . '_' . ll[i + 1] . '#'
let _ .= i < l + len(lt) - len(l_) && ll[i] < l || ll[i] != ll[i + 1] ? p.left : len(lt[i]) ? s.left : ''
endfor
let _ .= '%#LightLineMiddle_' . mode . '#%='
for i in reverse(range(len(rt)))
let _ .= '%#LightLineRight_' . mode . '_' . rl[i] . '_' . rl[i + 1] . '#'
let _ .= i < r + len(rt) - len(r_) && rl[i] < r || rl[i] != rl[i + 1] ? p.right : len(rt[i]) ? s.right : ''
let _ .= '%#LightLineRight_' . mode . '_' . rl[i] . '#'
for j in range(len(rt[i]))
let x = rc[i][j] ? rt[i][j] : has_key(f, rt[i][j]) ? (exists('*' . f[rt[i][j]]) ? '%{' . f[rt[i][j]] . '()}' : '%{exists("*' . f[rt[i][j]] . '")?' . f[rt[i][j]] . '():""}') : get(c, rt[i][j], '')
let _ .= has_key(t, rt[i][j]) && t[rt[i][j]] ==# 'raw' || x ==# '' ? x : '%( ' . x . ' %)'
if j < len(rt[i]) - 1 && s.right !=# ''
let _ .= s:subseparator(rt[i][(j):], s.right, rc[i][(j):])
endif
endfor
endfor
return _
endfunction
let s:tabnr = -1
let s:tabcnt = -1
let s:tabline = ''
function! lightline#tabline() abort
if !has_key(s:highlight, 'tabline')
call lightline#highlight('tabline')
endif
if s:lightline.tabline_configured || s:tabnr != tabpagenr() || s:tabcnt != tabpagenr('$')
let s:tabnr = tabpagenr()
let s:tabcnt = tabpagenr('$')
let s:tabline = s:line(1, 0)
endif
return s:tabline
endfunction
function! lightline#tabs() abort
let [x, y, z] = [[], [], []]
let nr = tabpagenr()
let cnt = tabpagenr('$')
for i in range(1, cnt)
call add(i < nr ? x : i == nr ? y : z, '%'. i . 'T%{lightline#onetab(' . i . ',' . (i == nr) . ')}' . (i == cnt ? '%T' : ''))
endfor
let abbr = '...'
let n = min([max([s:lightline.winwidth / 40, 2]), 8])
if len(x) > n && len(z) > n
let x = extend(add(x[:n/2-1], abbr), x[-(n+1)/2:])
let z = extend(add(z[:(n+1)/2-1], abbr), z[-n/2:])
elseif len(x) + len(z) > 2 * n
if len(x) > n
let x = extend(add(x[:(2*n-len(z))/2-1], abbr), x[-(2*n-len(z)+1)/2:])
elseif len(z) > n
let z = extend(add(z[:(2*n-len(x)+1)/2-1], abbr), z[-(2*n-len(x))/2:])
endif
endif
return [x, y, z]
endfunction
function! lightline#onetab(n, active) abort
let _ = []
for name in a:active ? s:lightline.tab.active : s:lightline.tab.inactive
if has_key(s:lightline.tab_component_function, name)
call add(_, call(s:lightline.tab_component_function[name], [a:n]))
else
call add(_, get(s:lightline.tab_component, name, ''))
endif
endfor
return join(filter(_, 'v:val !=# ""'), ' ')
endfunction
function! lightline#error(msg) abort
echohl ErrorMsg
echomsg 'lightline.vim: '.a:msg
echohl None
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,228 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme.vim
" Author: itchyny
" License: MIT License
" Last Change: 2015/03/18 08:37:17.
" =============================================================================
let s:save_cpo = &cpo
set cpo&vim
let s:cuicolor = {
\ '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,
\
\ 'yellow' : 136,
\ 'orange' : 166,
\ 'red' : 160,
\ 'magenta' : 125,
\ 'violet' : 61,
\ 'blue' : 33,
\ 'cyan' : 37,
\ 'green' : 64,
\ }
let s:guicolor = {
\ 'black' : '#000000',
\ 'white' : '#ffffff',
\
\ 'darkestgreen' : '#005f00',
\ 'darkgreen' : '#008700',
\ 'mediumgreen' : '#5faf00',
\ 'brightgreen' : '#afdf00',
\
\ 'darkestcyan' : '#005f5f',
\ 'mediumcyan' : '#87dfff',
\
\ 'darkestblue' : '#005f87',
\ 'darkblue' : '#0087af',
\
\ 'darkestred' : '#5f0000',
\ 'darkred' : '#870000',
\ 'mediumred' : '#af0000',
\ 'brightred' : '#df0000',
\ 'brightestred' : '#ff0000',
\
\ 'darkestpurple' : '#5f00af',
\ 'mediumpurple' : '#875fdf',
\ 'brightpurple' : '#dfdfff',
\
\ 'brightorange' : '#ff8700',
\ 'brightestorange': '#ffaf00',
\
\ 'gray0' : '#121212',
\ 'gray1' : '#262626',
\ 'gray2' : '#303030',
\ 'gray3' : '#4e4e4e',
\ 'gray4' : '#585858',
\ 'gray5' : '#606060',
\ 'gray6' : '#808080',
\ 'gray7' : '#8a8a8a',
\ 'gray8' : '#9e9e9e',
\ 'gray9' : '#bcbcbc',
\ 'gray10' : '#d0d0d0',
\
\ 'yellow' : '#b58900',
\ 'orange' : '#cb4b16',
\ 'red' : '#dc322f',
\ 'magenta' : '#d33682',
\ 'violet' : '#6c71c4',
\ 'blue' : '#268bd2',
\ 'cyan' : '#2aa198',
\ 'green' : '#859900',
\ }
function! s:convert(rgb) abort
let rgb = map(matchlist(a:rgb, '#\(..\)\(..\)\(..\)')[1:3], '0 + ("0x".v:val)')
if len(rgb) == 0
return 0
endif
if rgb[0] == 0xc0 && rgb[1] == 0xc0 && rgb[2] == 0xc0
return 7
elseif rgb[0] == 0x80 && rgb[1] == 0x80 && rgb[2] == 0x80
return 8
elseif (rgb[0] == 0x80 || rgb[0] == 0x00) && (rgb[1] == 0x80 || rgb[1] == 0x00) && (rgb[2] == 0x80 || rgb[2] == 0x00)
return (rgb[0] / 0x80) + (rgb[1] / 0x80) * 2 + (rgb[1] / 0x80) * 4
elseif abs(rgb[0]-rgb[1]) < 3 && abs(rgb[1]-rgb[2]) < 3 && abs(rgb[2]-rgb[0]) < 3
return s:black((rgb[0] + rgb[1] + rgb[2]) / 3)
else
return 16 + ((s:nr(rgb[0]) * 6) + s:nr(rgb[1])) * 6 + s:nr(rgb[2])
endif
endfunction
function! s:black(x) abort
if a:x < 0x04
return 16
elseif a:x > 0xf4
return 231
elseif index([0x00, 0x5f, 0x87, 0xaf, 0xdf, 0xff], a:x) >= 0
let l = a:x / 0x30
return ((l * 6) + l) * 6 + l + 16
else
return 232 + (a:x < 8 ? 0 : a:x < 0x60 ? (a:x-8)/10 : a:x < 0x76 ? (a:x-0x60)/6+9 : (a:x-8)/10)
endif
endfunction
function! s:nr(x) abort
return a:x < 0x2f ? 0 : a:x < 0x73 ? 1 : a:x < 0x9b ? 2 : a:x < 0xc7 ? 3 : a:x < 0xef ? 4 : 5
endfunction
function! s:rgb(r, g, b) abort
return printf('#%02x%02x%02x', a:r, a:g, a:b)
endfunction
function! s:upconvert(nr) abort
let x = a:nr * 1
if x < 7
let [b, rg] = [x / 4, x % 4]
let [g, r] = [rg / 2, rg % 2]
return s:rgb(r * 0x80, g * 0x80, b * 0x80)
elseif x == 7
return s:rgb(0xc0, 0xc0, 0xc0)
elseif x == 8
return s:rgb(0x80, 0x80, 0x80)
elseif x < 16
let y = x - 8
let [b, rg] = [y / 4, y % 4]
let [g, r] = [rg / 2, rg % 2]
return s:rgb(r * 0xff, g * 0xff, b * 0xff)
elseif x < 232
let y = x - 16
let [rg, b] = [y / 6, y % 6]
let [r, g] = [rg / 6, rg % 6]
let l = [0x00, 0x5f, 0x87, 0xaf, 0xdf, 0xff]
return s:rgb(l[r], l[g], l[b])
elseif x < 241
let k = (x - 232) * 10 + 8
return s:rgb(k, k, k)
elseif x < 243
let k = (x - 241) * 6 + 0x60
return s:rgb(k, k, k)
else
let k = (x - 232) * 10 + 8
return s:rgb(k, k, k)
endif
endfunction
function! lightline#colorscheme#fill(p) abort
for k in values(a:p)
for l in values(k)
for m in l
if len(m) < 4
if type(m[0]) == 1 && type(m[1]) == 1
if m[0] =~# '^\d\+$' && m[1] =~# '^\d\+$'
call insert(m, s:upconvert(m[1]), 0)
call insert(m, s:upconvert(m[1]), 0)
else
call insert(m, get(s:cuicolor, m[0], s:convert(m[0])), 2)
call insert(m, get(s:cuicolor, m[1], s:convert(m[1])), 3)
let m[0] = get(s:guicolor, m[0], m[0])
let m[1] = get(s:guicolor, m[1], m[1])
endif
elseif type(m[0]) == 0 && type(m[1]) == 0
call insert(m, s:upconvert(m[1]), 0)
call insert(m, s:upconvert(m[1]), 0)
endif
endif
endfor
endfor
endfor
return a:p
endfunction
function! lightline#colorscheme#flatten(p) abort
for k in values(a:p)
for l in values(k)
for m in range(len(l))
let attr = ''
if len(l[m]) == 3 && type(l[m][2]) == 1
let attr = l[m][2]
endif
let l[m] = [l[m][0][0], l[m][1][0], l[m][0][1], l[m][1][1]]
if !empty(attr)
call add(l[m], attr)
endif
endfor
endfor
endfor
return a:p
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,46 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/16color.vim
" Author: itchyny
" License: MIT License
" Last Change: 2014/01/02 10:04:03.
" =============================================================================
let s:base03 = [ '#808080', 8 ]
let s:base02 = [ '#000000', 0 ]
let s:base01 = [ '#00ff00', 10 ]
let s:base00 = [ '#ffff00', 11 ]
let s:base0 = [ '#0000ff', 12 ]
let s:base1 = [ '#00ffff', 14 ]
let s:base2 = [ '#c0c0c0', 7 ]
let s:base3 = [ '#ffffff', 15 ]
let s:yellow = [ '#808000', 3 ]
let s:orange = [ '#ff0000', 9 ]
let s:red = [ '#800000', 1 ]
let s:magenta = [ '#800080', 5 ]
let s:violet = [ '#ff00ff', 13 ]
let s:blue = [ '#000080', 4 ]
let s:cyan = [ '#008080', 6 ]
let s:green = [ '#008000', 2 ]
if &background ==# 'light'
let [s:base03, s:base3] = [s:base3, s:base03]
let [s:base02, s:base2] = [s:base2, s:base02]
let [s:base01, s:base1] = [s:base1, s:base01]
let [s:base00, s:base0] = [s:base0, s:base00]
endif
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base3, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base01 ], [ s:base00, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ]
let s:p.insert.left = [ [ s:base3, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base3, s:red ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base3, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.left = [ [ s:base2, s:base01 ] ]
let s:p.tabline.tabsel = [ [ s:base2, s:base02 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base2 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:base2, s:red ] ]
let s:p.normal.warning = [ [ s:base02, s:yellow ] ]
let g:lightline#colorscheme#16color#palette = lightline#colorscheme#flatten(s:p)

View file

@ -0,0 +1,12 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/PaperColor.vim
" Author: TKNGUE
" License: MIT License
" Last Change: 2015/07/28 07:35:00.
" =============================================================================
if &background ==# 'light'
let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_light#palette
else
let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_dark#palette
endif

View file

@ -0,0 +1,60 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/PaperColor_dark.vim
" Author: TKNGUE
" License: MIT License
" Last Change: 2015-07-27 06:01
" =============================================================================
let s:red = '#df0000'
let s:green = '#008700'
let s:blue = '#00afaf'
let s:pink = '#afdf00'
let s:olive = '#dfaf5f'
let s:navy = '#df875f'
let s:orange = '#d75f00'
let s:purple = '#8959a8'
let s:aqua = '#3e999f'
" Basics:
let s:foreground = '#d0d0d0'
let s:background = '#444444'
let s:window = '#efefef'
let s:status = '#c6c6c6'
let s:error = '#5f0000'
" Tabline:
let s:tabline_bg = '#3a3a3a'
let s:tabline_active_fg = '#1c1c1c'
let s:tabline_active_bg = '#00afaf'
let s:tabline_inactive_fg = '#c6c6c6'
let s:tabline_inactive_bg = '#585858'
" Statusline:
let s:statusline_active_fg = '#1c1c1c'
let s:statusline_active_bg = '#5f8787'
let s:statusline_inactive_fg = '#c6c6c6'
let s:statusline_inactive_bg = '#444444'
" Visual:
let s:visual_fg = '#000000'
let s:visual_bg = '#8787af'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.normal.right = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]]
let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ]
let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ]
let s:p.inactive.middle = [ [ s:foreground, s:background ], ]
let s:p.insert.left = [ [ s:background, s:blue], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.replace.left = [ [ s:background, s:pink ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.visual.left = [ [ s:visual_fg, s:visual_bg ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]]
let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ]
let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:background, s:error ] ]
let g:lightline#colorscheme#PaperColor_dark#palette = lightline#colorscheme#fill(s:p)

View file

@ -0,0 +1,55 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/PaperColor_light.vim
" Author: TKNGUE
" License: MIT License
" Last Change: 2015/07/28 07:46:40.
" =============================================================================
let s:red = '#df0000'
let s:green = '#008700'
let s:blue = '#4271ae'
let s:pink = '#d7005f'
let s:olive = '#718c00'
let s:navy = '#005f87'
let s:orange = '#d75f00'
let s:purple = '#8959a8'
let s:aqua = '#3e999f'
" Basics:
let s:foreground = '#4d4d4c'
let s:background = '#F5F5F5'
let s:window = '#efefef'
let s:status = s:aqua
let s:error = '#ffafdf'
" Tabline:
let s:tabline_bg = s:navy
let s:tabline_active_fg = s:foreground
let s:tabline_active_bg = s:window
let s:tabline_inactive_fg = s:background
let s:tabline_inactive_bg = s:aqua
" Statusline:
let s:statusline_active_fg = s:window
let s:statusline_active_bg = s:navy
let s:statusline_inactive_fg = s:foreground
let s:statusline_inactive_bg = '#dadada'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.normal.right = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]]
let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ]
let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ]
let s:p.inactive.middle = [ [ s:foreground, s:background ], ]
let s:p.insert.left = [ [ s:blue, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.replace.left = [ [ s:background, s:pink ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.visual.left = [ [ s:background, s:orange ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]]
let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ]
let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:background, s:error ] ]
let s:p.normal.warning = [ [ s:background, s:olive ] ]
let g:lightline#colorscheme#PaperColor_light#palette = lightline#colorscheme#fill(s:p)

View file

@ -0,0 +1,41 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/Tomorrow.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/09/07 12:22:37.
" =============================================================================
let s:base03 = '#fafafa'
let s:base023 = '#dfdfdf'
let s:base02 = '#c8c8c8'
let s:base01 = '#b4b4b4'
let s:base00 = '#808080'
let s:base0 = '#666666'
let s:base1 = '#555555'
let s:base2 = '#4f4f4f'
let s:base3 = '#4d4d4c'
let s:red = '#c82829'
let s:orange = '#f5871f'
let s:yellow = '#eab700'
let s:green = '#718c00'
let s:cyan = '#3e999f'
let s:blue = '#4271ae'
let s:magenta = '#8959a8'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base00, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base03 ] ]
let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base02, s:orange ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.left = [ [ s:base2, s:base01 ] ]
let s:p.tabline.tabsel = [ [ s:base2, s:base023 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base00 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:red, s:base01 ] ]
let s:p.normal.warning = [ [ s:yellow, s:base0 ] ]
let g:lightline#colorscheme#Tomorrow#palette = lightline#colorscheme#fill(s:p)

View file

@ -0,0 +1,41 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/Tomorrow_Night.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/09/07 12:23:38.
" =============================================================================
let s:base3 = '#c5c8c6'
let s:base2 = '#bababa'
let s:base1 = '#a0a0a0'
let s:base0 = '#909090'
let s:base00 = '#666666'
let s:base01 = '#555555'
let s:base02 = '#434343'
let s:base023 = '#303030'
let s:base03 = '#1d1f21'
let s:red = '#cc6666'
let s:orange = '#de935f'
let s:yellow = '#f0c674'
let s:green = '#b5bd68'
let s:cyan = '#8abeb7'
let s:blue = '#81a2be'
let s:magenta = '#b294bb'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base00, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base03 ] ]
let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base02, s:orange ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.left = [ [ s:base2, s:base01 ] ]
let s:p.tabline.tabsel = [ [ s:base2, s:base023 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base0 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:red, s:base023 ] ]
let s:p.normal.warning = [ [ s:yellow, s:base02 ] ]
let g:lightline#colorscheme#Tomorrow_Night#palette = lightline#colorscheme#fill(s:p)

View file

@ -0,0 +1,43 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/09/07 14:13:21.
" =============================================================================
let s:base3 = '#ffffff'
let s:base23 = '#ffffff'
let s:base2 = '#ffffff'
let s:base1 = '#ffffff'
let s:base0 = '#ffffff'
let s:base00 = '#6060df'
let s:base01 = '#6060af'
let s:base02 = '#606087'
let s:base023 = '#202087'
let s:base03 = '#002451'
let s:red = '#ff9da4'
let s:orange = '#ffc58f'
let s:yellow = '#ffeead'
let s:green = '#d1f1a9'
let s:cyan = '#99ffff'
let s:blue = '#bbdaff'
let s:magenta = '#ebbbff'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base023, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.left = [ [ s:base02, s:base0 ], [ s:base00, s:base03 ] ]
let s:p.insert.left = [ [ s:base023, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base023, s:orange ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base023, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.left = [ [ s:base2, s:base01 ] ]
let s:p.tabline.tabsel = [ [ s:base2, s:base03 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base1 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:base023, s:red ] ]
let s:p.normal.warning = [ [ s:base023, s:yellow ] ]
let g:lightline#colorscheme#Tomorrow_Night_Blue#palette = lightline#colorscheme#fill(s:p)

View file

@ -0,0 +1,42 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/09/07 14:13:26.
" =============================================================================
let s:base3 = '#eaeaea'
let s:base23 = '#d0d0d0'
let s:base2 = '#c6c6c6'
let s:base1 = '#b2b2b2'
let s:base0 = '#949494'
let s:base00 = '#767676'
let s:base01 = '#606060'
let s:base02 = '#4e4e4e'
let s:base023 = '#262626'
let s:base03 = '#12124c'
let s:red = '#d54e53'
let s:orange = '#e78c45'
let s:yellow = '#e7c547'
let s:green = '#b9ca4a'
let s:cyan = '#70c0b1'
let s:blue = '#7aa6da'
let s:magenta = '#c397d8'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base023, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.left = [ [ s:base02, s:base0 ], [ s:base00, s:base03 ] ]
let s:p.insert.left = [ [ s:base023, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base023, s:orange ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base023, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.left = [ [ s:base2, s:base01 ] ]
let s:p.tabline.tabsel = [ [ s:base2, s:base023 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base1 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:red, s:base023 ] ]
let s:p.normal.warning = [ [ s:yellow, s:base02 ] ]
let g:lightline#colorscheme#Tomorrow_Night_Bright#palette = lightline#colorscheme#fill(s:p)

View file

@ -0,0 +1,42 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/09/07 14:14:14.
" =============================================================================
let s:base3 = '#cccccc'
let s:base23 = '#bbbbbb'
let s:base2 = '#aaaaaa'
let s:base1 = '#999999'
let s:base0 = '#777777'
let s:base00 = '#666666'
let s:base01 = '#555555'
let s:base02 = '#444444'
let s:base023 = '#333333'
let s:base03 = '#2d2d2d'
let s:red = '#f2777a'
let s:orange = '#f99157'
let s:yellow = '#ffcc66'
let s:green = '#99cc99'
let s:cyan = '#009999'
let s:blue = '#99cccc'
let s:magenta = '#cc99cc'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base023, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.left = [ [ s:base02, s:base0 ], [ s:base00, s:base03 ] ]
let s:p.insert.left = [ [ s:base023, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base023, s:orange ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base023, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.left = [ [ s:base2, s:base01 ] ]
let s:p.tabline.tabsel = [ [ s:base2, s:base03 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base1 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:base023, s:red ] ]
let s:p.normal.warning = [ [ s:base023, s:yellow ] ]
let g:lightline#colorscheme#Tomorrow_Night_Eighties#palette = lightline#colorscheme#fill(s:p)

View file

@ -0,0 +1,8 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/default.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/08/22 06:05:52.
" =============================================================================
let g:lightline#colorscheme#default#palette = g:lightline#colorscheme#powerline#palette

View file

@ -0,0 +1,40 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/jellybeans.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/09/07 12:21:04.
" =============================================================================
let s:base03 = [ '#151513', 233 ]
let s:base02 = [ '#30302c ', 236 ]
let s:base01 = [ '#4e4e43', 239 ]
let s:base00 = [ '#666656', 242 ]
let s:base0 = [ '#808070', 244 ]
let s:base1 = [ '#949484', 246 ]
let s:base2 = [ '#a8a897', 248 ]
let s:base3 = [ '#e8e8d3', 253 ]
let s:yellow = [ '#ffb964', 215 ]
let s:orange = [ '#fad07a', 222 ]
let s:red = [ '#cf6a4c', 167 ]
let s:magenta = [ '#f0a0c0', 217 ]
let s:blue = [ '#8197bf', 103 ]
let s:cyan = [ '#8fbfdc', 110 ]
let s:green = [ '#99ad6a', 107 ]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base0, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ]
let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base02, s:red ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base0, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base00, s:base02 ] ]
let s:p.tabline.left = [ [ s:base3, s:base00 ] ]
let s:p.tabline.tabsel = [ [ s:base3, s:base02 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base1 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:red, s:base02 ] ]
let s:p.normal.warning = [ [ s:yellow, s:base01 ] ]
let g:lightline#colorscheme#jellybeans#palette = lightline#colorscheme#flatten(s:p)

View file

@ -0,0 +1,25 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/landscape.vim
" Author: itchyny
" License: MIT License
" Last Change: 2015/11/26 21:49:44.
" =============================================================================
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ ['#0000ff', '#ffffff', 21, 231, 'bold' ], [ '#ffffff', '#0000ff', 231, 21 ] ]
let s:p.normal.right = [ [ '#303030', '#d0d0d0', 236, 252 ], [ '#303030', '#8a8a8a', 236, 245 ], [ '#bcbcbc', '#585858', 250, 240 ] ]
let s:p.inactive.right = [ [ '#121212', '#606060', 233, 241 ], [ '#121212', '#3a3a3a', 233, 237 ], [ '#121212', '#262626', 233, 235 ] ]
let s:p.inactive.left = s:p.inactive.right[1:]
let s:p.insert.left = [ ['#005f00', '#ffffff', 22, 231, 'bold' ], [ '#ffffff', '#005f00', 231, 22 ] ]
let s:p.replace.left = [ [ '#af0000', '#ffffff', 124, 231, 'bold' ], [ '#ffffff', '#af0000', 231, 124 ] ]
let s:p.visual.left = [ [ '#5f00ff', '#ffffff', 57, 231, 'bold' ], [ '#ffffff', '#5f00ff', 231, 57 ] ]
let s:p.normal.middle = [ [ '#8a8a8a', '#303030', 245, 236 ] ]
let s:p.inactive.middle = [ [ '#303030', '#121212', 236, 233 ] ]
let s:p.tabline.left = [ [ '#d0d0d0', '#666666', 252, 242 ] ]
let s:p.tabline.tabsel = [ [ '#dadada', '#121212', 253, 233 ] ]
let s:p.tabline.middle = [ [ '#8a8a8a', '#3a3a3a', 245, 237 ] ]
let s:p.tabline.right = [ [ '#d0d0d0', '#666666', 252, 242 ] ]
let s:p.normal.error = [ [ '#d0d0d0', '#ff0000', 252, 196 ] ]
let s:p.normal.warning = [ [ '#262626', '#ffff00', 235, 226 ] ]
let g:lightline#colorscheme#landscape#palette = s:p

View file

@ -0,0 +1,28 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/powerline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/09/07 15:54:41.
" =============================================================================
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ ['darkestgreen', 'brightgreen', 'bold'], ['white', 'gray4'] ]
let s:p.normal.right = [ ['gray5', 'gray10'], ['gray9', 'gray4'], ['gray8', 'gray2'] ]
let s:p.inactive.right = [ ['gray1', 'gray5'], ['gray4', 'gray1'], ['gray4', 'gray0'] ]
let s:p.inactive.left = s:p.inactive.right[1:]
let s:p.insert.left = [ ['darkestcyan', 'white', 'bold'], ['white', 'darkblue'] ]
let s:p.insert.right = [ [ 'darkestcyan', 'mediumcyan' ], [ 'mediumcyan', 'darkblue' ], [ 'mediumcyan', 'darkestblue' ] ]
let s:p.replace.left = [ ['white', 'brightred', 'bold'], ['white', 'gray4'] ]
let s:p.visual.left = [ ['darkred', 'brightorange', 'bold'], ['white', 'gray4'] ]
let s:p.normal.middle = [ [ 'gray7', 'gray2' ] ]
let s:p.insert.middle = [ [ 'mediumcyan', 'darkestblue' ] ]
let s:p.replace.middle = s:p.normal.middle
let s:p.replace.right = s:p.normal.right
let s:p.tabline.left = [ [ 'gray9', 'gray4' ] ]
let s:p.tabline.tabsel = [ [ 'gray9', 'gray1' ] ]
let s:p.tabline.middle = [ [ 'gray2', 'gray8' ] ]
let s:p.tabline.right = [ [ 'gray9', 'gray3' ] ]
let s:p.normal.error = [ [ 'gray9', 'brightestred' ] ]
let s:p.normal.warning = [ [ 'gray1', 'yellow' ] ]
let g:lightline#colorscheme#powerline#palette = lightline#colorscheme#fill(s:p)

View file

@ -0,0 +1,42 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/seoul256.vim
" Author: atweiden
" License: MIT License
" Last Change: 2015/11/02 08:23:27.
" =============================================================================
let s:base03 = [ '#151513', 233 ]
let s:base02 = [ '#30302c ', 236 ]
let s:base01 = [ '#4e4e43', 239 ]
let s:base00 = [ '#666656', 242 ]
let s:base0 = [ '#808070', 244 ]
let s:base1 = [ '#949484', 246 ]
let s:base2 = [ '#a8a897', 248 ]
let s:base3 = [ '#e8e8d3', 253 ]
let s:yellow = [ '#d8af5f', 3 ]
let s:orange = [ '#d7875f', 216 ]
let s:red = [ '#d68787', 131 ]
let s:magenta = [ '#df5f87', 168 ]
let s:peach = [ '#d7afaf', 181 ]
let s:blue = [ '#87afaf', 109 ]
let s:cyan = [ '#87d7d7', 23 ]
let s:green = [ '#87af87', 108 ]
let s:white = [ '#d0d0d0', 252 ]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base0, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ]
let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base02, s:peach ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base0, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base00, s:base02 ] ]
let s:p.tabline.left = [ [ s:base3, s:base00 ] ]
let s:p.tabline.tabsel = [ [ s:base3, s:base02 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base1 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:red, s:base02 ] ]
let s:p.normal.warning = [ [ s:yellow, s:base01 ] ]
let g:lightline#colorscheme#seoul256#palette = lightline#colorscheme#flatten(s:p)

View file

@ -0,0 +1,80 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/solarized.vim
" Author: itchyny
" License: MIT License
" Last Change: 2016/08/08 10:31:00.
" =============================================================================
let s:cuicolors = {
\ 'base03': [ '8', '234', 'DarkGray' ],
\ 'base02': [ '0', '235', 'Black' ],
\ 'base01': [ '10', '239', 'LightGreen' ],
\ 'base00': [ '11', '240', 'LightYellow' ],
\ 'base0': [ '12', '244', 'LightBlue' ],
\ 'base1': [ '14', '245', 'LightCyan' ],
\ 'base2': [ '7', '187', 'LightGray' ],
\ 'base3': [ '15', '230', 'White' ],
\ 'yellow': [ '3', '136', 'DarkYellow' ],
\ 'orange': [ '9', '166', 'LightRed' ],
\ 'red': [ '1', '124', 'DarkRed' ],
\ 'magenta': [ '5', '125', 'DarkMagenta' ],
\ 'violet': [ '13', '61', 'LightMagenta' ],
\ 'blue': [ '4', '33', 'DarkBlue' ],
\ 'cyan': [ '6', '37', 'DarkCyan' ],
\ 'green': [ '2', '64', 'DarkGreen' ],
\ }
" The following condition only applies for the console and is the same
" condition vim-colors-solarized uses to determine which set of colors
" to use.
let s:solarized_termcolors = get(g:, 'solarized_termcolors', 256)
if s:solarized_termcolors != 256 && &t_Co >= 16
let s:cuiindex = 0
elseif s:solarized_termcolors == 256
let s:cuiindex = 1
else
let s:cuiindex = 2
endif
let s:base03 = [ '#002b36', s:cuicolors.base03[s:cuiindex] ]
let s:base02 = [ '#073642', s:cuicolors.base02[s:cuiindex] ]
let s:base01 = [ '#586e75', s:cuicolors.base01[s:cuiindex] ]
let s:base00 = [ '#657b83', s:cuicolors.base00[s:cuiindex] ]
let s:base0 = [ '#839496', s:cuicolors.base0[s:cuiindex] ]
let s:base1 = [ '#93a1a1', s:cuicolors.base1[s:cuiindex] ]
let s:base2 = [ '#eee8d5', s:cuicolors.base2[s:cuiindex] ]
let s:base3 = [ '#fdf6e3', s:cuicolors.base3[s:cuiindex] ]
let s:yellow = [ '#b58900', s:cuicolors.yellow[s:cuiindex] ]
let s:orange = [ '#cb4b16', s:cuicolors.orange[s:cuiindex] ]
let s:red = [ '#dc322f', s:cuicolors.red[s:cuiindex] ]
let s:magenta = [ '#d33682', s:cuicolors.magenta[s:cuiindex] ]
let s:violet = [ '#6c71c4', s:cuicolors.violet[s:cuiindex] ]
let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ]
let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ]
let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ]
if &background ==# 'light'
let [ s:base03, s:base3 ] = [ s:base3, s:base03 ]
let [ s:base02, s:base2 ] = [ s:base2, s:base02 ]
let [ s:base01, s:base1 ] = [ s:base1, s:base01 ]
let [ s:base00, s:base0 ] = [ s:base0, s:base00 ]
endif
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base03, s:blue ], [ s:base03, s:base00 ] ]
let s:p.normal.right = [ [ s:base03, s:base1 ], [ s:base03, s:base00 ] ]
let s:p.inactive.right = [ [ s:base03, s:base00 ], [ s:base0, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base0, s:base02 ] ]
let s:p.insert.left = [ [ s:base03, s:green ], [ s:base03, s:base00 ] ]
let s:p.replace.left = [ [ s:base03, s:red ], [ s:base03, s:base00 ] ]
let s:p.visual.left = [ [ s:base03, s:magenta ], [ s:base03, s:base00 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base01, s:base02 ] ]
let s:p.tabline.left = [ [ s:base03, s:base00 ] ]
let s:p.tabline.tabsel = [ [ s:base03, s:base1 ] ]
let s:p.tabline.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:base03, s:red ] ]
let s:p.normal.warning = [ [ s:base03, s:yellow ] ]
let g:lightline#colorscheme#solarized#palette = lightline#colorscheme#flatten(s:p)

View file

@ -0,0 +1,40 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/wombat.vim
" Author: itchyny
" License: MIT License
" Last Change: 2015/11/30 08:37:43.
" =============================================================================
let s:base03 = [ '#242424', 235 ]
let s:base023 = [ '#353535 ', 236 ]
let s:base02 = [ '#444444 ', 238 ]
let s:base01 = [ '#585858', 240 ]
let s:base00 = [ '#666666', 242 ]
let s:base0 = [ '#808080', 244 ]
let s:base1 = [ '#969696', 247 ]
let s:base2 = [ '#a8a8a8', 248 ]
let s:base3 = [ '#d0d0d0', 252 ]
let s:yellow = [ '#cae682', 180 ]
let s:orange = [ '#e5786d', 173 ]
let s:red = [ '#e5786d', 203 ]
let s:magenta = [ '#f2c68a', 216 ]
let s:blue = [ '#8ac6f2', 117 ]
let s:cyan = s:blue
let s:green = [ '#95e454', 119 ]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.right = [ [ s:base023, s:base01 ], [ s:base00, s:base02 ] ]
let s:p.inactive.left = [ [ s:base1, s:base02 ], [ s:base00, s:base023 ] ]
let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base2, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base1, s:base023 ] ]
let s:p.tabline.left = [ [ s:base3, s:base00 ] ]
let s:p.tabline.tabsel = [ [ s:base3, s:base03 ] ]
let s:p.tabline.middle = [ [ s:base2, s:base02 ] ]
let s:p.tabline.right = [ [ s:base2, s:base00 ] ]
let s:p.normal.error = [ [ s:base03, s:red ] ]
let s:p.normal.warning = [ [ s:base023, s:yellow ] ]
let g:lightline#colorscheme#wombat#palette = lightline#colorscheme#flatten(s:p)

View file

@ -0,0 +1,42 @@
" =============================================================================
" Filename: autoload/lightline/colortable.vim
" Author: itchyny
" License: MIT License
" Last Change: 2015/03/29 06:21:39.
" =============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! s:load() abort
let rgbfile = $VIMRUNTIME . '/rgb.txt'
let table = {}
if filereadable(rgbfile)
for _ in map(filter(readfile(rgbfile), 'v:val !~# "^!"'), 'matchlist(v:val, "^\\s*\\(\\d\\+\\)\\s\\+\\(\\d\\+\\)\\s\\+\\(\\d\\+\\)\\s\\+\\(.*\\)")[1:4]')
let table[tolower(_[3])] = _[0:2]
endfor
endif
return table
endfunction
let s:table = s:load()
function! lightline#colortable#name_to_rgb(name) abort
let name = tolower(a:name)
return has_key(s:table, name) ? s:table[name] : []
endfunction
function! lightline#colortable#gui2cui(rgb, fallback) abort
let rgb = map(matchlist(a:rgb, '#\(..\)\(..\)\(..\)')[1:3], '0 + ("0x".v:val)')
if len(rgb) == 0
let rgb = lightline#colortable#name_to_rgb(a:rgb)
if len(rgb) == 0
return a:fallback % 128
endif
endif
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
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,33 @@
" =============================================================================
" Filename: autoload/lightline/tab.vim
" Author: itchyny
" License: MIT License
" Last Change: 2016/05/07 22:31:02.
" =============================================================================
let s:save_cpo = &cpo
set cpo&vim
function! lightline#tab#filename(n) abort
let buflist = tabpagebuflist(a:n)
let winnr = tabpagewinnr(a:n)
let _ = expand('#'.buflist[winnr - 1].':t')
return _ !=# '' ? _ : '[No Name]'
endfunction
function! lightline#tab#modified(n) abort
let winnr = tabpagewinnr(a:n)
return gettabwinvar(a:n, winnr, '&modified') ? '+' : gettabwinvar(a:n, winnr, '&modifiable') ? '' : '-'
endfunction
function! lightline#tab#readonly(n) abort
let winnr = tabpagewinnr(a:n)
return gettabwinvar(a:n, winnr, '&readonly') ? 'RO' : ''
endfunction
function! lightline#tab#tabnum(n) abort
return a:n
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,24 @@
" =============================================================================
" Filename: plugin/lightline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2016/03/14 03:31:58.
" =============================================================================
if exists('g:loaded_lightline') || v:version < 700
finish
endif
let g:loaded_lightline = 1
let s:save_cpo = &cpo
set cpo&vim
augroup lightline
autocmd!
autocmd WinEnter,BufWinEnter,FileType,ColorScheme,SessionLoadPost * call lightline#update()
autocmd ColorScheme,SessionLoadPost * call lightline#highlight()
autocmd CursorMoved,BufUnload * call lightline#update_once()
augroup END
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,20 @@
let s:sids = {}
function! s:sid(path) abort
if has_key(s:sids, a:path)
return s:sids[a:path]
endif
redir => scriptnames
silent! scriptnames
redir END
for line in split(scriptnames, '\n')
if line =~# a:path
let sid = matchstr(line, '\v^\s*\zs\d+\ze')
let s:sids[a:path] = sid
return sid
endif
endfor
endfunction
function! SID(name) abort
return function(printf("\<SNR>%d_%s", s:sid('autoload/lightline.vim'), a:name))
endfunction

View file

@ -0,0 +1,90 @@
let s:suite = themis#suite('concatenate')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
let g:lightline = { 'subseparator': { 'left': '>', 'right': '<' } }
call lightline#init()
endfunction
function! s:suite.nil()
call s:assert.equals(lightline#concatenate([], 0), '')
call s:assert.equals(lightline#concatenate([], 1), '')
endfunction
function! s:suite.one()
call s:assert.equals(lightline#concatenate(['foo'], 0), 'foo')
call s:assert.equals(lightline#concatenate(['foo'], 1), 'foo')
endfunction
function! s:suite.two()
call s:assert.equals(lightline#concatenate(['foo', 'bar'], 0), 'foo > bar')
call s:assert.equals(lightline#concatenate(['foo', 'bar'], 1), 'foo < bar')
endfunction
function! s:suite.three()
call s:assert.equals(lightline#concatenate(['foo', 'bar', 'baz'], 0), 'foo > bar > baz')
call s:assert.equals(lightline#concatenate(['foo', 'bar', 'baz'], 1), 'foo < bar < baz')
endfunction
function! s:suite.one_empty()
call s:assert.equals(lightline#concatenate([''], 0), '')
call s:assert.equals(lightline#concatenate([''], 1), '')
endfunction
function! s:suite.two_empty_left()
call s:assert.equals(lightline#concatenate(['', 'bar'], 0), 'bar')
call s:assert.equals(lightline#concatenate(['', 'bar'], 1), 'bar')
endfunction
function! s:suite.two_empty_right()
call s:assert.equals(lightline#concatenate(['foo', ''], 0), 'foo')
call s:assert.equals(lightline#concatenate(['foo', ''], 1), 'foo')
endfunction
function! s:suite.two_empty_both()
call s:assert.equals(lightline#concatenate(['', ''], 0), '')
call s:assert.equals(lightline#concatenate(['', ''], 1), '')
endfunction
function! s:suite.three_empty_left()
call s:assert.equals(lightline#concatenate(['', 'bar', 'baz'], 0), 'bar > baz')
call s:assert.equals(lightline#concatenate(['', 'bar', 'baz'], 1), 'bar < baz')
endfunction
function! s:suite.three_empty_middle()
call s:assert.equals(lightline#concatenate(['foo', '', 'baz'], 0), 'foo > baz')
call s:assert.equals(lightline#concatenate(['foo', '', 'baz'], 1), 'foo < baz')
endfunction
function! s:suite.three_empty_right()
call s:assert.equals(lightline#concatenate(['foo', 'bar', ''], 0), 'foo > bar')
call s:assert.equals(lightline#concatenate(['foo', 'bar', ''], 1), 'foo < bar')
endfunction
function! s:suite.three_empty_middle_right()
call s:assert.equals(lightline#concatenate(['foo', '', ''], 0), 'foo')
call s:assert.equals(lightline#concatenate(['foo', '', ''], 1), 'foo')
endfunction
function! s:suite.three_empty_left_right()
call s:assert.equals(lightline#concatenate(['', 'bar', ''], 0), 'bar')
call s:assert.equals(lightline#concatenate(['', 'bar', ''], 1), 'bar')
endfunction
function! s:suite.three_empty_left_middle()
call s:assert.equals(lightline#concatenate(['', '', 'baz'], 0), 'baz')
call s:assert.equals(lightline#concatenate(['', '', 'baz'], 1), 'baz')
endfunction
function! s:suite.three_empty_all()
call s:assert.equals(lightline#concatenate(['', '', ''], 0), '')
call s:assert.equals(lightline#concatenate(['', '', ''], 1), '')
endfunction
function! s:suite.keep_original()
let xs = ['', 'bar', '']
call s:assert.equals(lightline#concatenate(xs, 0), 'bar')
call s:assert.equals(xs, ['', 'bar', ''])
call s:assert.equals(lightline#concatenate(xs, 1), 'bar')
call s:assert.equals(xs, ['', 'bar', ''])
endfunction

View file

@ -0,0 +1,15 @@
let s:suite = themis#suite('error')
let s:assert = themis#helper('assert')
function! s:message() abort
redir => messages
silent! messages
redir END
return split(messages, '\n')[-1]
endfunction
function! s:suite.error()
let message = 'An error occurred.'
call lightline#error(message)
call s:assert.equals(s:message(), 'lightline.vim: ' . message)
endfunction

View file

@ -0,0 +1,612 @@
let s:suite = themis#suite('expand')
let s:assert = themis#helper('assert')
function! s:expand(...)
return call(SID('expand'), a:000)
endfunction
function! s:suite.expand()
let g:lightline = {}
call lightline#init()
call s:assert.equals(s:expand([]),
\ [[], [], ['0']])
endfunction
function! s:suite.default()
let g:lightline = {}
call lightline#init()
call s:assert.equals(s:expand([['mode', 'paste'], ['readonly', 'filename', 'modified']]),
\ [[['mode', 'paste'], ['readonly', 'filename', 'modified']], [[0, 0], [0, 0, 0]], ['0', '1', '2']])
endfunction
function! s:suite.custom()
function! Custom()
return [ ['left'], ['middle'], ['right'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type()
function! Custom()
return [ ['left'], ['middle'], ['right'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left'], ['middle'], ['right'], ['modified']], [[0, 0], [1], [1], [1], [0]], ['0', '1', 'custom', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left'], ['middle'], ['right', 'modified']], [[0, 0, 1], [1], [1, 0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.multiple()
function! Custom()
return [ ['x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['x0', 'x1', 'x2', 'y0', 'y1', 'y2', 'z0', 'z1', 'z2'], ['modified']], [[0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'x0', 'x1', 'x2', 'y0', 'y1', 'y2', 'z0', 'z1', 'z2', 'modified']], [[0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.multiple_type()
function! Custom()
return [ ['x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2'], ['modified']], [[0, 0], [1, 1, 1], [1, 1, 1], [1, 1, 1], [0]], ['0', '1', 'custom', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2', 'modified']], [[0, 0, 1, 1, 1], [1, 1, 1], [1, 1, 1, 0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.flatten()
function! Custom()
return [ 'left', 'middle', 'right' ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_flatten()
function! Custom()
return [ 'left', 'middle', 'right' ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left'], ['middle'], ['right'], ['modified']], [[0, 0], [1], [1], [1], [0]], ['0', '1', 'custom', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left'], ['middle'], ['right', 'modified']], [[0, 0, 1], [1], [1, 0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_string()
function! Custom()
return 'custom'
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'custom', 'modified']], [[0, 0, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_string()
function! Custom()
return 'custom'
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_void_string()
function! Custom()
return ''
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_void_string()
function! Custom()
return ''
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_number()
function! Custom()
return 24
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['24'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', '24', 'modified']], [[0, 0, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_number()
function! Custom()
return 24
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['24'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename'], ['24'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_void_string_array()
function! Custom()
return ['', '', '']
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_void_string_array()
function! Custom()
return ['', '', '']
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_void_string_array_2()
function! Custom()
return [[''], [''], ['']]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_void_string_array_2()
function! Custom()
return [[''], [''], ['']]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_void_string_array_3()
function! Custom()
return ['', 'custom', '']
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'custom', 'modified']], [[0, 0, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_void_string_array_3()
function! Custom()
return ['', 'custom', '']
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_void_string_array_4()
function! Custom()
return [[''], ['custom'], ['']]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'custom', 'modified']], [[0, 0, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_void_string_array_4()
function! Custom()
return [[''], ['custom'], ['']]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_left_nil()
function! Custom()
return [ [], ['y0', 'y1'], ['z0', 'z1'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom'], ['modified']]),
\ [[['filename'], ['y0', 'y1', 'z0', 'z1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'modified']]),
\ [[['filename', 'y0', 'y1', 'z0', 'z1', 'modified']], [[0, 1, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_left_nil()
function! Custom()
return [ [], ['y0', 'y1'], ['z0', 'z1'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom'], ['modified']]),
\ [[['filename'], ['y0', 'y1'], ['z0', 'z1'], ['modified']], [[0], [1, 1], [1, 1], [0]], ['0', 'custom', '1', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'modified']]),
\ [[['filename'], ['y0', 'y1'], ['z0', 'z1', 'modified']], [[0], [1, 1], [1, 1, 0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_right_nil()
function! Custom()
return [ ['x0', 'x1'], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom'], ['modified']]),
\ [[['filename'], ['x0', 'x1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'modified']]),
\ [[['filename', 'x0', 'x1', 'y0', 'y1', 'modified']], [[0, 1, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_right_nil()
function! Custom()
return [ ['x0', 'x1'], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom'], ['modified']]),
\ [[['filename'], ['x0', 'x1'], ['y0', 'y1'], ['modified']], [[0], [1, 1], [1, 1], [0]], ['0', '1', 'custom', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'modified']]),
\ [[['filename', 'x0', 'x1'], ['y0', 'y1'], ['modified']], [[0, 1, 1], [1, 1], [0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_one()
function! Custom()
return [ 'left' ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left', 'modified']], [[0, 0, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_one()
function! Custom()
return [ 'left' ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left', 'modified']], [[0, 0, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_two()
function! Custom()
return [ 'left', 'middle']
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left', 'middle'], ['modified']], [[0, 0], [1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left', 'middle', 'modified']], [[0, 0, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_two()
function! Custom()
return [ 'left', 'middle' ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left'], ['middle'], ['modified']], [[0, 0], [1], [1], [0]], ['0', '1', 'custom', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left'], ['middle'], ['modified']], [[0, 0, 1], [1], [0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_mixed()
function! Custom()
return ['left', { 'custom': 24 }, [function('tr')]]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left', '{''custom'': 24}', 'function(''tr'')'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left', '{''custom'': 24}', 'function(''tr'')', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_mixed()
function! Custom()
return ['left', { 'custom': 24 }, [function('tr')]]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left'], ['{''custom'': 24}'], ['function(''tr'')'], ['modified']], [[0, 0], [1], [1], [1], [0]], ['0', '1', 'custom', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left'], ['{''custom'': 24}'], ['function(''tr'')', 'modified']], [[0, 0, 1], [1], [1, 0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_mixed_2()
function! Custom()
return [['left', ''], ['', { 'custom': 24 }, ''], [[function('tr')], '']]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left', '{''custom'': 24}', '[function(''tr'')]'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left', '{''custom'': 24}', '[function(''tr'')]', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_mixed_2()
function! Custom()
return [['left', ''], ['', { 'custom': 24 }, ''], [[function('tr')], '']]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left'], ['{''custom'': 24}'], ['[function(''tr'')]'], ['modified']], [[0, 0], [1], [1], [1], [0]], ['0', '1', 'custom', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left'], ['{''custom'': 24}'], ['[function(''tr'')]', 'modified']], [[0, 0, 1], [1], [1, 0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_error()
function! Custom()
throw 'error'
return 'custom'
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.custom_type_error()
function! Custom()
throw 'error'
return 'custom'
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.notfound()
let g:lightline = { 'component_expand': { 'custom': 'NotFound' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
endfunction
function! s:suite.custom_type_notfound()
let g:lightline = { 'component_expand': { 'custom': 'NotFound' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['modified']], [[0, 0], [0]], ['0', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']])
endfunction
function! s:suite.duplicated_left_nil()
function! Custom()
return [ [], ['y0', 'y1'], ['z0', 'z1'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]),
\ [[['filename'], ['y0', 'y1', 'z0', 'z1', 'y0', 'y1', 'z0', 'z1'], ['modified']], [[0], [1, 1, 1, 1, 1, 1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]),
\ [[['filename', 'y0', 'y1', 'z0', 'z1', 'y0', 'y1', 'z0', 'z1', 'modified']], [[0, 1, 1, 1, 1, 1, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_type_left_nil()
function! Custom()
return [ [], ['y0', 'y1'], ['z0', 'z1'] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]),
\ [[['filename'], ['y0', 'y1'], ['z0', 'z1'], ['y0', 'y1'], ['z0', 'z1'], ['modified']], [[0], [1, 1], [1, 1], [1, 1], [1, 1], [0]], ['0', 'custom', '1', 'custom', '1', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]),
\ [[['filename'], ['y0', 'y1'], ['z0', 'z1'], ['y0', 'y1'], ['z0', 'z1', 'modified']], [[0], [1, 1], [1, 1], [1, 1], [1, 1, 0]], ['0', 'custom', '0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_right_nil()
function! Custom()
return [ ['x0', 'x1'], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]),
\ [[['filename'], ['x0', 'x1', 'y0', 'y1', 'x0', 'x1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1, 1, 1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]),
\ [[['filename', 'x0', 'x1', 'y0', 'y1', 'x0', 'x1', 'y0', 'y1', 'modified']], [[0, 1, 1, 1, 1, 1, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_type_right_nil()
function! Custom()
return [ ['x0', 'x1'], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]),
\ [[['filename'], ['x0', 'x1'], ['y0', 'y1'], ['x0', 'x1'], ['y0', 'y1'], ['modified']], [[0], [1, 1], [1, 1], [1, 1], [1, 1], [0]], ['0', '1', 'custom', '1', 'custom', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]),
\ [[['filename', 'x0', 'x1'], ['y0', 'y1'], ['x0', 'x1'], ['y0', 'y1'], ['modified']], [[0, 1, 1], [1, 1], [1, 1], [1, 1], [0]], ['0', 'custom', '0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_both_nil()
function! Custom()
return [ [], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]),
\ [[['filename'], ['y0', 'y1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]),
\ [[['filename', 'y0', 'y1', 'y0', 'y1', 'modified']], [[0, 1, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_type_both_nil()
function! Custom()
return [ [], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]),
\ [[['filename'], ['y0', 'y1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', 'custom', '2', '3']])
call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]),
\ [[['filename'], ['y0', 'y1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', 'custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_both_nil_left_most()
function! Custom()
return [ [], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['custom', 'custom'], ['modified']]),
\ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], ['0', '1', '2']])
call s:assert.equals(s:expand([['custom', 'custom', 'modified']]),
\ [[['y0', 'y1', 'y0', 'y1', 'modified']], [[1, 1, 1, 1, 0]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_type_both_nil_left_most()
function! Custom()
return [ [], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['custom', 'custom'], ['modified']]),
\ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], ['custom', '1', '2']])
call s:assert.equals(s:expand([['custom', 'custom', 'modified']]),
\ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], ['custom', '0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_both_nil_right_most()
function! Custom()
return [ [], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom', 'custom']]),
\ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', '1', '2']])
call s:assert.equals(s:expand([['filename', 'custom', 'custom']]),
\ [[['filename', 'y0', 'y1', 'y0', 'y1']], [[0, 1, 1, 1, 1]], ['0', '1']])
delfunction Custom
endfunction
function! s:suite.duplicated_type_both_nil_right_most()
function! Custom()
return [ [], ['y0', 'y1'], [] ]
endfunction
let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(s:expand([['filename'], ['custom', 'custom']]),
\ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', 'custom', '2']])
call s:assert.equals(s:expand([['filename', 'custom', 'custom']]),
\ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', 'custom', '1']])
delfunction Custom
endfunction

View file

@ -0,0 +1,171 @@
let s:suite = themis#suite('highlight')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
hi clear
endfunction
function! s:hi(name)
redir => hi
silent! exec 'hi' a:name
redir END
return substitute(join(split(hi, "\n"), ''), ' \+', ' ', 'g')
endfunction
function! s:pattern(xs, ...) abort
let ys = a:0 ? a:xs[1:] : a:xs
let zs = get(a:000, 0, a:xs)
return 'ctermfg=' . ys[2] . ' ctermbg=' . zs[3] . '.*guifg=' . ys[0] . ' guibg=' . zs[1]
endfunction
function! s:suite.highlight()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightLineLeft_normal_1'), s:pattern(palette.normal.left[1]))
call s:assert.match(s:hi('LightLineLeft_normal_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_normal_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_normal_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_normal_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.insert()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('insert')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_insert_0'), s:pattern(palette.insert.left[0]))
call s:assert.match(s:hi('LightLineLeft_insert_1'), s:pattern(palette.insert.left[1]))
call s:assert.match(s:hi('LightLineLeft_insert_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_insert_0'), s:pattern(palette.insert.right[0]))
call s:assert.match(s:hi('LightLineRight_insert_1'), s:pattern(palette.insert.right[1]))
call s:assert.match(s:hi('LightLineRight_insert_2'), s:pattern(palette.insert.right[2]))
call s:assert.match(s:hi('LightLineRight_insert_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_insert'), s:pattern(palette.insert.middle[0]))
endfunction
function! s:suite.visual()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('visual')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_visual_0'), s:pattern(palette.visual.left[0]))
call s:assert.match(s:hi('LightLineLeft_visual_1'), s:pattern(palette.visual.left[1]))
call s:assert.match(s:hi('LightLineLeft_visual_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_visual_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_visual_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_visual_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_visual_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.replace()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('replace')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_replace_0'), s:pattern(palette.replace.left[0]))
call s:assert.match(s:hi('LightLineLeft_replace_1'), s:pattern(palette.replace.left[1]))
call s:assert.match(s:hi('LightLineLeft_replace_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_replace_0'), s:pattern(palette.replace.right[0]))
call s:assert.match(s:hi('LightLineRight_replace_1'), s:pattern(palette.replace.right[1]))
call s:assert.match(s:hi('LightLineRight_replace_2'), s:pattern(palette.replace.right[2]))
call s:assert.match(s:hi('LightLineRight_replace_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_replace'), s:pattern(palette.replace.middle[0]))
endfunction
function! s:suite.left_right()
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ]
\ },
\ }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightLineLeft_normal_1'), s:pattern(palette.normal.left[1]))
call s:assert.match(s:hi('LightLineLeft_normal_2'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineLeft_normal_3'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineLeft_normal_4'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_normal_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_normal_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_normal_3'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineRight_normal_4'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineRight_normal_5'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.no_components()
let g:lightline = {
\ 'active': {
\ 'left': [],
\ 'right': []
\ },
\ 'inactive': {
\ 'left': [],
\ 'right': []
\ },
\ }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightLineLeft_normal_1'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_normal_1'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.subseparator()
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ]
\ },
\ }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
for i in range(4)
for j in range(5)
if i + 1 == j
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', i, j)), s:pattern(get(palette.normal.left, i, palette.normal.middle[0]), get(palette.normal.left, j, palette.normal.middle[0])))
else
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', i, j)), 'E411: highlight group not found\|cleared')
endif
endfor
endfor
endfunction
function! s:suite.component_type()
let g:lightline = { 'component_type': { 'error': 'error', 'warning': 'warning' } }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
for type in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s', type)), s:pattern(palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_0_%s', type)), s:pattern(palette.normal.left[0], palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_1_%s', type)), s:pattern(palette.normal.left[1], palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_2_%s', type)), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_0', type)), s:pattern(palette.normal[type][0], palette.normal.left[0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_1', type)), s:pattern(palette.normal[type][0], palette.normal.left[1]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_2', type)), s:pattern(palette.normal[type][0], palette.normal.middle[0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_3', type)), 'E411: highlight group not found\|cleared')
endfor
for type1 in ['error', 'warning']
for type2 in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', type1, type2)), s:pattern(palette.normal[type1][0], palette.normal[type2][0]))
endfor
endfor
endfunction

View file

@ -0,0 +1,131 @@
let s:suite = themis#suite('link')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
hi clear
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
endfunction
function! s:hi(name)
redir => hi
silent! exec 'hi' a:name
redir END
return substitute(join(split(hi, "\n"), ''), ' \+', ' ', 'g')
endfunction
function! s:suite.link()
call lightline#link()
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_normal_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_normal_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_normal_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_normal_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_normal_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_normal')
endfunction
function! s:suite.insert()
call lightline#link('i')
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_insert_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_insert_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_insert_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_insert_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_insert_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_insert')
endfunction
function! s:suite.visual()
call lightline#link('v')
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_visual_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_visual_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_visual_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_visual_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_visual_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_visual')
endfunction
function! s:suite.replace()
call lightline#link('R')
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_replace_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_replace_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_replace_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_replace_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_replace_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_replace')
endfunction
function! s:suite.left_right()
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ]
\ },
\ }
call lightline#init()
call lightline#colorscheme()
call lightline#link()
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_normal_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_normal_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'LightLineLeft_normal_2')
call s:assert.match(s:hi('LightLineLeft_active_3'), 'LightLineLeft_normal_3')
call s:assert.match(s:hi('LightLineLeft_active_4'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_normal_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_normal_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_normal_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'LightLineRight_normal_3')
call s:assert.match(s:hi('LightLineRight_active_4'), 'LightLineRight_normal_4')
call s:assert.match(s:hi('LightLineRight_active_5'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_normal')
endfunction
function! s:suite.subseparator()
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ]
\ },
\ }
call lightline#init()
call lightline#colorscheme()
call lightline#link()
for i in range(4)
for j in range(5)
if i + 1 == j
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', i, j)), printf('LightLineLeft_normal_%s_%s', i, j))
else
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', i, j)), 'E411: highlight group not found')
endif
endfor
endfor
endfunction
function! s:suite.component_type()
let g:lightline = { 'component_type': { 'error': 'error', 'warning': 'warning' } }
call lightline#init()
call lightline#colorscheme()
call lightline#link()
for type in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_active_%s', type)), printf('LightLineLeft_normal_%s', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_0_%s', type)), printf('LightLineLeft_normal_0_%s', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_1_%s', type)), printf('LightLineLeft_normal_1_%s', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_2_%s', type)), 'E411: highlight group not found')
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_0', type)), printf('LightLineLeft_normal_%s_0', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_1', type)), printf('LightLineLeft_normal_%s_1', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_2', type)), printf('LightLineLeft_normal_%s_2', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_3', type)), 'E411: highlight group not found')
endfor
for type1 in ['error', 'warning']
for type2 in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', type1, type2)), printf('LightLineLeft_normal_%s_%s', type1, type2))
endfor
endfor
endfunction

View file

@ -0,0 +1,14 @@
let s:suite = themis#suite('mode')
let s:assert = themis#helper('assert')
function! s:suite.mode()
let g:lightline = {}
call lightline#init()
call s:assert.equals(lightline#mode(), 'NORMAL')
endfunction
function! s:suite.mode_map()
let g:lightline = { 'mode_map': { 'n': 'N' } }
call lightline#init()
call s:assert.equals(lightline#mode(), 'N')
endfunction

View file

@ -0,0 +1,98 @@
let s:suite = themis#suite('onetab')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
let g:lightline = {}
call lightline#init()
tabnew
tabonly
endfunction
function! s:suite.onetab()
call s:assert.equals(lightline#onetab(1, 1), '1 [No Name]')
endfunction
function! s:suite.tabnew()
tabnew
call s:assert.equals(lightline#onetab(1, 0), '1 [No Name]')
call s:assert.equals(lightline#onetab(2, 1), '2 [No Name]')
endfunction
function! s:suite.tabnew_tabnew()
tabnew
tabnew
call s:assert.equals(lightline#onetab(1, 0), '1 [No Name]')
call s:assert.equals(lightline#onetab(2, 0), '2 [No Name]')
call s:assert.equals(lightline#onetab(3, 1), '3 [No Name]')
endfunction
function! s:suite.modified()
call append(0, '')
call s:assert.equals(lightline#onetab(1, 1), '1 [No Name] +')
undo
endfunction
function! s:suite.filename()
edit test
call s:assert.equals(lightline#onetab(1, 1), '1 test')
tabnew
bunload test
endfunction
function! s:suite.filename_modified()
edit test
call append(0, '')
call s:assert.equals(lightline#onetab(1, 1), '1 test +')
tabnew
bunload! test
endfunction
function! s:suite.active_inactive()
let g:lightline = { 'tab': { 'active': [ 'tabnum', 'filename' ], 'inactive': [ 'filename' ] } }
call lightline#init()
edit test
call append(0, '')
call s:assert.equals(lightline#onetab(1, 1), '1 test')
call s:assert.equals(lightline#onetab(1, 0), 'test')
tabnew
bunload! test
endfunction
function! s:suite.tab_component()
let g:lightline = { 'tab': { 'active': [ 'custom' ] }, 'tab_component': { 'custom': 'custom' } }
call lightline#init()
call s:assert.equals(lightline#onetab(1, 1), 'custom')
call s:assert.equals(lightline#onetab(2, 1), 'custom')
endfunction
function! s:suite.tab_component_function()
function! Custom(n)
return 'custom: ' . a:n
endfunction
let g:lightline = { 'tab': { 'active': [ 'custom' ] }, 'tab_component_function': { 'custom': 'Custom' } }
call lightline#init()
call s:assert.equals(lightline#onetab(1, 1), 'custom: 1')
call s:assert.equals(lightline#onetab(2, 1), 'custom: 2')
delfunction Custom
endfunction
function! s:suite.tab_component_empty_middle()
let g:lightline = { 'tab': { 'active': [ 'tabnum', 'custom', 'filename' ], 'inactive': [ 'tabnum', 'custom', 'custom', 'filename' ] }, 'tab_component': { 'custom': '' } }
call lightline#init()
call s:assert.equals(lightline#onetab(1, 1), '1 [No Name]')
call s:assert.equals(lightline#onetab(2, 1), '2 [No Name]')
endfunction
function! s:suite.tab_component_empty_left()
let g:lightline = { 'tab': { 'active': [ 'custom', 'filename' ], 'inactive': [ 'custom', 'custom', 'filename' ] }, 'tab_component': { 'custom': '' } }
call lightline#init()
call s:assert.equals(lightline#onetab(1, 1), '[No Name]')
call s:assert.equals(lightline#onetab(2, 1), '[No Name]')
endfunction
function! s:suite.tab_component_empty_middle()
let g:lightline = { 'tab': { 'active': [ 'tabnum', 'custom' ], 'inactive': [ 'tabnum', 'custom', 'custom' ] }, 'tab_component': { 'custom': '' } }
call lightline#init()
call s:assert.equals(lightline#onetab(1, 1), '1')
call s:assert.equals(lightline#onetab(2, 1), '2')
endfunction

View file

@ -0,0 +1,302 @@
let s:suite = themis#suite('subseparator')
let s:assert = themis#helper('assert')
function! s:subseparator(...)
return eval(substitute(call(SID('subseparator'), a:000), '^%{\|}$', '', 'g'))
endfunction
function! s:suite.subseparator_component()
let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
endfunction
function! s:suite.subseparator_component_visible_condition_1()
let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1', 'custom2': '1', 'custom3': '1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
endfunction
function! s:suite.subseparator_component_visible_condition_2()
let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '0', 'custom2': '1', 'custom3': '1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_visible_condition_3()
let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
endfunction
function! s:suite.subseparator_component_visible_condition_4()
let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '0' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_visible_condition_5()
let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '0', 'custom2': '0', 'custom3': '0' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_visible_condition_6()
let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1||0', 'custom2': '0', 'custom3': '0' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_visible_condition_7()
let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1||1', 'custom2': '0', 'custom3': '0' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_function()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_function_1()
function! Custom1()
return 'custom1'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
delfunction Custom1
endfunction
function! s:suite.subseparator_component_function_2()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
delfunction Custom1
delfunction Custom2
endfunction
function! s:suite.subseparator_component_function_3()
function! Custom1()
return 'custom1'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
delfunction Custom1
delfunction Custom3
endfunction
function! s:suite.subseparator_component_function_4()
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_function_5()
function! Custom1()
return ''
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_function_6()
function! Custom1()
return ''
endfunction
function! Custom2()
return ''
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_function_7()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return ''
endfunction
function! Custom3()
return ''
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_expand()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_expand': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [1, 1, 1]), '|')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_expand()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_expand': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [1, 1, 1]), '|')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_expand_1()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_expand': { 'custom1': 'Custom1' }, 'component_function': { 'custom2': 'Custom2', 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [1, 0, 0]), '|')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_expand_2()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_expand': { 'custom1': 'Custom1', 'custom2': 'Custom2' }, 'component_function': { 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [1, 1, 0]), '|')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_expand_3()
function! Custom1()
return ''
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2' }, 'component_expand': { 'custom3': 'Custom3' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 1]), '')
delfunction Custom1
delfunction Custom2
delfunction Custom3
endfunction
function! s:suite.subseparator_component_not_found()
function! Custom1()
return 'custom1'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
delfunction Custom1
endfunction
function! s:suite.subseparator_component_not_found_1()
function! Custom2()
return 'custom2'
endfunction
let g:lightline = { 'component_function': { 'custom2': 'Custom2' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
delfunction Custom2
endfunction
function! s:suite.subseparator_component_not_found_2()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
delfunction Custom1
delfunction Custom2
endfunction

View file

@ -0,0 +1,67 @@
let s:suite = themis#suite('tabline')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
let g:lightline = {}
call lightline#init()
tabnew
tabonly
endfunction
function! s:suite.tabline()
call s:assert.equals(&tabline, '%!lightline#tabline()')
endfunction
function! s:suite.enabled()
let g:lightline = { 'enable': { 'tabline': 1 } }
call lightline#init()
call s:assert.equals(&tabline, '%!lightline#tabline()')
endfunction
function! s:suite.disabled()
let g:lightline = { 'enable': { 'tabline': 0 } }
call lightline#init()
call s:assert.equals(&tabline, '')
endfunction
function! s:suite.tabnew()
let tabline = lightline#tabline()
tabnew
call s:assert.not_equals(lightline#tabline(), tabline)
endfunction
function! s:suite.tabnew_first()
let tabline = lightline#tabline()
0tabnew
call s:assert.not_equals(lightline#tabline(), tabline)
endfunction
function! s:suite.tabnext()
tabnew
let tabline = lightline#tabline()
tabnext
call s:assert.not_equals(lightline#tabline(), tabline)
endfunction
function! s:suite.tabonly()
tabnew
tabfirst
let tabline = lightline#tabline()
tabonly
call s:assert.not_equals(lightline#tabline(), tabline)
endfunction
function! s:suite.tabclose()
tabnew
let tabline = lightline#tabline()
tabclose
call s:assert.not_equals(lightline#tabline(), tabline)
endfunction
function! s:suite.tabclose_last()
tabnew
tabfirst
let tabline = lightline#tabline()
$tabclose
call s:assert.not_equals(lightline#tabline(), tabline)
endfunction

View file

@ -0,0 +1,99 @@
let s:suite = themis#suite('tabs')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
let g:lightline = { 'winwidth': 180 }
call lightline#init()
tabnew
tabonly
endfunction
function! s:tab(number, ...) abort
let active = get(a:000, 0, 0)
let last = get(a:000, 1, 0)
return '%' . a:number . 'T%{lightline#onetab(' . a:number . ',' . active . ')}' . (last ? '%T' : '')
endfunction
function! s:suite.tabs()
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1, 1)], []])
endfunction
function! s:suite.tabnew()
tabnew
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1, 1)], []])
endfunction
function! s:suite.tabnew_tabnew()
tabnew
tabnew
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2)], [s:tab(3, 1, 1)], []])
endfunction
function! s:suite.tabnew_tabfirst()
tabnew
tabfirst
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2, 0, 1)]])
endfunction
function! s:suite.tabnew_tabnew_tabfirst()
tabnew
tabnew
tabfirst
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2), s:tab(3, 0, 1)]])
endfunction
function! s:suite.tabnew_tabnew_tabprevious()
tabnew
tabnew
tabprevious
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1)], [s:tab(3, 0, 1)]])
endfunction
function! s:suite.tabnew_20()
for i in range(19)
tabnew
endfor
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), s:tab(4), '...', s:tab(16), s:tab(17), s:tab(18), s:tab(19)], [s:tab(20, 1, 1)], []])
endfunction
function! s:suite.tabnew_20_tabfirst()
for i in range(19)
tabnew
endfor
tabfirst
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2), s:tab(3), s:tab(4), s:tab(5), '...', s:tab(17), s:tab(18), s:tab(19), s:tab(20, 0, 1)]])
endfunction
function! s:suite.tabnew_20_tabfirst_tabnext()
for i in range(19)
tabnew
endfor
tabfirst
tabnext
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1)], [s:tab(3), s:tab(4), s:tab(5), s:tab(6), '...', s:tab(18), s:tab(19), s:tab(20, 0, 1)]])
endfunction
function! s:suite.tabnew_20_tabnext_10()
for i in range(19)
tabnew
endfor
tabnext 10
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), '...', s:tab(8), s:tab(9)], [s:tab(10, 1)], [s:tab(11), s:tab(12), '...', s:tab(19), s:tab(20, 0, 1)]])
endfunction
function! s:suite.tabnew_20_tabprevious()
for i in range(19)
tabnew
endfor
tabprevious
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), '...', s:tab(15), s:tab(16), s:tab(17), s:tab(18)], [s:tab(19, 1)], [s:tab(20, 0, 1)]])
endfunction
function! s:suite.tabnew_20_tabprevious_tabprevious()
for i in range(19)
tabnew
endfor
tabprevious
tabprevious
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), '...', s:tab(15), s:tab(16), s:tab(17)], [s:tab(18, 1)], [s:tab(19), s:tab(20, 0, 1)]])
endfunction

View file

@ -0,0 +1,37 @@
let s:suite = themis#suite('toggle')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
let g:lightline = {}
call lightline#init()
tabnew
tabonly
endfunction
function! s:suite.default()
call s:assert.equals(exists('#lightline'), 1)
call s:assert.equals(exists('#lightline-disable'), 0)
call s:assert.not_equals(&tabline, '')
endfunction
function! s:suite.disable_enable()
call lightline#disable()
call s:assert.equals(exists('#lightline'), 0)
call s:assert.equals(exists('#lightline-disable'), 1)
call s:assert.equals(&tabline, '')
call lightline#enable()
call s:assert.equals(exists('#lightline'), 1)
call s:assert.equals(exists('#lightline-disable'), 0)
call s:assert.not_equals(&tabline, '')
endfunction
function! s:suite.toggle()
call lightline#toggle()
call s:assert.equals(exists('#lightline'), 0)
call s:assert.equals(exists('#lightline-disable'), 1)
call s:assert.equals(&tabline, '')
call lightline#toggle()
call s:assert.equals(exists('#lightline'), 1)
call s:assert.equals(exists('#lightline-disable'), 0)
call s:assert.not_equals(&tabline, '')
endfunction

View file

@ -0,0 +1,46 @@
let s:suite = themis#suite('uniq')
let s:assert = themis#helper('assert')
function! s:uniq(...)
try
return call(SID('uniq'), a:000)
catch
return call(function('uniq'), a:000)
endtry
endfunction
function! s:suite.nil()
call s:assert.equals(s:uniq([]), [])
endfunction
function! s:suite.one()
call s:assert.equals(s:uniq(['foo']), ['foo'])
endfunction
function! s:suite.two()
call s:assert.equals(s:uniq(['foo', 'bar']), ['foo', 'bar'])
endfunction
function! s:suite.three()
call s:assert.equals(s:uniq(['foo', 'bar', 'baz']), ['foo', 'bar', 'baz'])
endfunction
function! s:suite.two_duplicated()
call s:assert.equals(s:uniq(['foo', 'foo']), ['foo'])
endfunction
function! s:suite.three_duplicated()
call s:assert.equals(s:uniq(['foo', 'bar', 'foo']), ['foo', 'bar', 'foo'])
endfunction
function! s:suite.many1()
call s:assert.equals(s:uniq(['foo', 'foo', 'bar', 'baz', 'baz', 'qux', 'foo']), ['foo', 'bar', 'baz', 'qux', 'foo'])
endfunction
function! s:suite.many2()
call s:assert.equals(s:uniq(['foo', 'foo', 'foo', 'foo', 'bar', 'bar', 'bar']), ['foo', 'bar'])
endfunction
function! s:suite.many3()
call s:assert.equals(s:uniq(['foo', 'foo', 'bar', 'bar', 'bar', 'foo', 'foo', 'foo']), ['foo', 'bar', 'foo'])
endfunction

View file

@ -0,0 +1,153 @@
Next
- Rename "primary" and "secondary" trees to "tab" and "window" trees.
- Move a bunch of buffer level variables into the NERDTree and UI classes.
- Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing)
- Remove the old style UI - Remove 'NERDTreeDirArrows' option.
- On windows default to + and ~ for expand/collapse directory symbols.
- Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends.
5.0.0
- Refactor the code significantly:
* Break the classes out into their own files.
* Make the majority of the code OO - previously large parts were
effectively a tangle of "global" methods.
- Add an API to assign flags to nodes. This allows VCS plugins like
https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to
Xuyuanp for helping design/test/build said API.
- add 'scope' argument to the key map API see :help NERDTreeAddKeyMap()
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
- add support for custom path filters. See :help NERDTreeAddPathFilter()
- add path listener API. See :help NERDTreePathListenerAPI.
- expand the fs menu functionality to list file properties (PhilRunninger,
apbarrero, JESii)
- make bookmarks work with `~` home shortcuts (hiberabyss)
- show OSX specific fsmenu options in regular vim on mac (evindor)
- make dir arrow icons configurable (PickRelated)
- optimise node sorting performance when opening large dirs (vtsang)
- make the root note render prettier by truncating it at a path slash (gcmt)
- remove NERDChristmasTree option - its always christmas now
- add "cascade" open and closing for dirs containing only another single
dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm)
Many other fixes, doc updates and contributions from:
actionshrimp
SchDen
egalpin
cperl82 - many small fixes
toiffel
WoLpH
handcraftedbits
devmanhinton
xiaodili
zhangoose
gastropoda
mixvin
alvan
lucascaton
kelaban
shanesmith
staeff
pendulm
stephenprater
franksort
agrussellknives
AndrewRadev
Twinside
4.2.0
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars
instead of the old +~| chars to define the tree structure (sickill)
- shift the syntax highlighting out into its own syntax file (gnap)
- add some mac specific options to the filesystem menu - for macvim
only (andersonfreitas)
- Add NERDTreeMinimalUI option to remove some non functional parts of the
nerdtree ui (camthompson)
- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the
new behaviour (benjamingeiger)
- if no name is given to :Bookmark, make it default to the name of the
target file/dir (minyoung)
- use 'file' completion when doing copying, create, and move
operations (EvanDotPro)
- lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly
Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
4.1.0
features:
- NERDTreeFind to reveal the node for the current buffer in the tree,
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
Doug McInnes) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
Ritter and Rémi Prévost.
- truncate the root node if wider than the tree window. Thanks to Victor
Gonzalez.
bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
jfilip1024, and Chris Chambers
4.0.0
- add a new programmable menu system (see :help NERDTreeMenu).
- add new APIs to add menus/menu-items to the menu system as well as
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
- fix a bug where the script ignored directories whose name ended in a dot,
thanks to Aggelos Orfanakos for the patch.
- fix a bug when using the x mapping on the tree root, thanks to Bryan
Venteicher for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer
wasnt being stored on closing the window, thanks to Richard Hart.
- fix a bug where NERDTreeMirror would mirror the wrong tree
3.1.1
- fix a bug where a non-listed no-name buffer was getting created every
time the tree windows was created, thanks to Derek Wyatt and owen1
- make <CR> behave the same as the 'o' mapping
- some helptag fixes in the doc, thanks strull
- fix a bug when using :set nohidden and opening a file where the previous
buf was modified. Thanks iElectric
- other minor fixes
3.1.0
New features:
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
NERDTree-gs
- make the statusline for the nerd tree window default to something
hopefully more useful. See :help 'NERDTreeStatusline'
Bugfixes:
- make the hijack netrw functionality work when vim is started with "vim
<some dir>" (thanks to Alf Mikula for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
- add -bar to all the nerd tree :commands so they can chain with other
:commands (thanks to tpope)
- fix bugs when ignorecase was set (thanks to nach)
- fix a bug with the relative path code (thanks to nach)
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
3.0.1
Bugfixes:
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
was not set
- fix a bug where :NERDTree <path> would fail if <path> was relative and
didnt start with a ./ or ../ Thanks to James Kanze.
- make the q mapping work with secondary (:e <dir> style) trees,
thanks to jamessan
- fix a bunch of small bugs with secondary trees
More insane refactoring.
3.0.0
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
- allow sharing of trees across tabs, see :help :NERDTreeMirror
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
- change the '<tab>' mapping to 'i'
- change the 'H' mapping to 'I'
- lots of refactoring

View file

@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View file

@ -55,7 +55,7 @@ The following features and functionality are provided by the NERD tree:
Installation
------------
[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install nerdtree.
####[pathogen.vim](https://github.com/tpope/vim-pathogen)
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdtree.git
@ -63,6 +63,12 @@ Installation
Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`.
####[apt-vim](https://github.com/egalpin/apt-vim)
apt-vim install -y https://github.com/scrooloose/nerdtree.git
Faq
---
@ -70,6 +76,7 @@ Faq
Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin).
---
> Can I have the nerdtree on every tab automatically?
@ -79,29 +86,44 @@ http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers
If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs)
---
> How can I open a NERDTree automatically when vim starts up?
Stick this in your vimrc: `autocmd vimenter * NERDTree`
---
> How can I open a NERDTree automatically when vim starts up if no files were specified?
Stick this in your vimrc
Stick this in your vimrc:
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
Note: Now start vim with plain `vim`, not `vim .`
---
> How can I map a specific key or shortcut to open NERDTree?
Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
map <C-n> :NERDTreeToggle<CR>
---
> How can I close vim if the only window left open is a NERDTree?
Stick this in your vimrc:
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
---
> Can I have different highlighting for different file extensions?
See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696
---
> How can I change default arrows?
Use these variables in your vimrc. Note that below are default arrow symbols
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'

View file

@ -4,17 +4,17 @@ endif
let g:loaded_nerdtree_autoload = 1
function! nerdtree#version()
return '4.2.0'
return '5.0.0'
endfunction
" SECTION: General Functions {{{1
"============================================================
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
"inits a secondary nerd tree in the current buffer if appropriate
"inits a window tree in the current buffer if appropriate
function! nerdtree#checkForBrowse(dir)
if a:dir != '' && isdirectory(a:dir)
call g:NERDTreeCreator.CreateSecondary(a:dir)
call g:NERDTreeCreator.CreateWindowTree(a:dir)
endif
endfunction
@ -94,7 +94,7 @@ endfunction
" FUNCTION: nerdtree#postSourceActions() {{{2
function! nerdtree#postSourceActions()
call g:NERDTreeBookmark.CacheBookmarks(0)
call g:NERDTreeBookmark.CacheBookmarks(1)
call nerdtree#ui_glue#createDefaultBindings()
"load all nerdtree plugins

View file

@ -105,7 +105,7 @@ endfunction
"FUNCTION: s:activateBookmark() {{{1
"handle the user activating a bookmark
function! s:activateBookmark(bm)
call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {})
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {})
endfunction
" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1
@ -140,9 +140,7 @@ endfunction
" FUNCTION: s:chRoot(node) {{{1
" changes the current root to the selected one
function! s:chRoot(node)
call a:node.makeRoot()
call b:NERDTree.render()
call b:NERDTreeRoot.putCursorHere(0, 0)
call b:NERDTree.changeRoot(a:node)
endfunction
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
@ -157,7 +155,7 @@ function! nerdtree#ui_glue#chRootCwd()
if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str()
return
endif
call s:chRoot(g:NERDTreeDirNode.New(cwd))
call s:chRoot(g:NERDTreeDirNode.New(cwd, b:NERDTree))
endfunction
" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1
@ -173,6 +171,7 @@ function! nerdtree#ui_glue#clearBookmarks(bookmarks)
call bookmark.delete()
endfor
endif
call b:NERDTree.root.refresh()
call b:NERDTree.render()
endfunction
@ -188,17 +187,17 @@ endfunction
" closes the parent dir of the current node
function! s:closeCurrentDir(node)
let parent = a:node.parent
while g:NERDTreeCascadeOpenSingleChildDir && !parent.isRoot()
let childNodes = parent.getVisibleChildren()
if len(childNodes) == 1 && childNodes[0].path.isDirectory
let parent = parent.parent
else
break
endif
endwhile
if parent ==# {} || parent.isRoot()
call nerdtree#echo("cannot close tree root")
else
while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot()
if parent.parent.getVisibleChildCount() == 1
call parent.close()
let parent = parent.parent
else
break
endif
endwhile
call parent.close()
call b:NERDTree.render()
call parent.putCursorHere(0, 0)
@ -208,8 +207,8 @@ endfunction
" FUNCTION: s:closeTreeWindow() {{{1
" close the tree window
function! s:closeTreeWindow()
if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
exec "buffer " . b:NERDTreePreviousBuf
if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1
exec "buffer " . b:NERDTree.previousBuf()
else
if winnr("$") > 1
call g:NERDTree.Close()
@ -227,6 +226,7 @@ function! s:deleteBookmark(bm)
if nr2char(getchar()) ==# 'y'
try
call a:bm.delete()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
redraw
catch /^NERDTree/
@ -241,7 +241,7 @@ endfunction
" FUNCTION: s:displayHelp() {{{1
" toggles the help display
function! s:displayHelp()
let b:treeShowHelp = b:treeShowHelp ? 0 : 1
call b:NERDTree.ui.toggleHelp()
call b:NERDTree.render()
call b:NERDTree.ui.centerView()
endfunction
@ -269,27 +269,29 @@ function! s:findAndRevealPath()
endtry
if p.isUnder(cwd)
call g:NERDTreeCreator.CreatePrimary(cwd.str())
call g:NERDTreeCreator.CreateTabTree(cwd.str())
else
call g:NERDTreeCreator.CreatePrimary(p.getParent().str())
call g:NERDTreeCreator.CreateTabTree(p.getParent().str())
endif
else
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.TogglePrimary('')
call g:NERDTreeCreator.ToggleTabTree('')
else
call g:NERDTree.CursorToTreeWin()
endif
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden)
call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree))
else
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.TogglePrimary("")
call g:NERDTreeCreator.ToggleTabTree("")
endif
endif
endif
call g:NERDTree.CursorToTreeWin()
call b:NERDTreeRoot.reveal(p)
let node = b:NERDTree.root.reveal(p)
call b:NERDTree.render()
call node.putCursorHere(1,0)
if p.isUnixHiddenFile()
let g:NERDTreeShowHidden = showhidden
@ -312,7 +314,7 @@ function! s:handleLeftClick()
endfor
if currentNode.path.isDirectory
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~▾▸] \?$'
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \?$'
call currentNode.activate()
return
endif
@ -409,7 +411,7 @@ endfunction
" FUNCTION: s:jumpToRoot() {{{1
" moves the cursor to the root node
function! s:jumpToRoot()
call b:NERDTreeRoot.putCursorHere(1, 0)
call b:NERDTree.root.putCursorHere(1, 0)
call b:NERDTree.ui.centerView()
endfunction
@ -442,13 +444,13 @@ endfunction
" put the cursor on the given bookmark and, if its a file, open it
function! nerdtree#ui_glue#openBookmark(name)
try
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0)
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
call targetNode.putCursorHere(0, 1)
redraw!
catch /^NERDTree.BookmarkedNodeNotFoundError/
call nerdtree#echo("note - target node is not cached")
let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name)
let targetNode = g:NERDTreeFileNode.New(bookmark.path)
let targetNode = g:NERDTreeFileNode.New(bookmark.path, b:NERDTree)
endtry
if targetNode.path.isDirectory
call targetNode.openExplorer()
@ -510,7 +512,7 @@ endfunction
" put the cursor on the node associate with the given name
function! nerdtree#ui_glue#revealBookmark(name)
try
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0)
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
call targetNode.putCursorHere(0, 1)
catch /^NERDTree.BookmarkNotFoundError/
call nerdtree#echo("Bookmark isnt cached under the current root")
@ -522,7 +524,7 @@ endfunction
" will be reloaded.
function! s:refreshRoot()
call nerdtree#echo("Refreshing the root node. This could take a while...")
call b:NERDTreeRoot.refresh()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
redraw
call nerdtree#echo("Refreshing the root node. This could take a while... DONE")
@ -545,10 +547,10 @@ endfunction
" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1
function! nerdtree#ui_glue#setupCommands()
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
@ -602,28 +604,28 @@ endfunction
"keepState: 1 if the current root should be left open when the tree is
"re-rendered
function! nerdtree#ui_glue#upDir(keepState)
let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
let cwd = b:NERDTree.root.path.str({'format': 'UI'})
if cwd ==# "/" || cwd =~# '^[^/]..$'
call nerdtree#echo("already at top dir")
else
if !a:keepState
call b:NERDTreeRoot.close()
call b:NERDTree.root.close()
endif
let oldRoot = b:NERDTreeRoot
let oldRoot = b:NERDTree.root
if empty(b:NERDTreeRoot.parent)
let path = b:NERDTreeRoot.path.getParent()
let newRoot = g:NERDTreeDirNode.New(path)
if empty(b:NERDTree.root.parent)
let path = b:NERDTree.root.path.getParent()
let newRoot = g:NERDTreeDirNode.New(path, b:NERDTree)
call newRoot.open()
call newRoot.transplantChild(b:NERDTreeRoot)
let b:NERDTreeRoot = newRoot
call newRoot.transplantChild(b:NERDTree.root)
let b:NERDTree.root = newRoot
else
let b:NERDTreeRoot = b:NERDTreeRoot.parent
let b:NERDTree.root = b:NERDTree.root.parent
endif
if g:NERDTreeChDirMode ==# 2
call b:NERDTreeRoot.path.changeToDir()
call b:NERDTree.root.path.changeToDir()
endif
call b:NERDTree.render()

View file

@ -37,9 +37,7 @@ CONTENTS *NERDTree-contents*
4.3.Menu API..........................|NERDTreeAddPathFilter()|
4.4.Path Listener API.................|NERDTreePathListenerAPI|
5.About...................................|NERDTreeAbout|
6.Changelog...............................|NERDTreeChangelog|
7.Credits.................................|NERDTreeCredits|
8.License.................................|NERDTreeLicense|
6.License.................................|NERDTreeLicense|
==============================================================================
1. Intro *NERDTree*
@ -673,9 +671,6 @@ NERD tree. These options should be set in your vimrc.
|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
'Press ? for help' text.
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
+ ~ chars when displaying directories.
|'NERDTreeCascadeOpenSingleChildDir'|
Cascade open while selected directory has only
one child that also is a directory.
@ -684,6 +679,9 @@ NERD tree. These options should be set in your vimrc.
a buffer when a file is being deleted or renamed
via a context menu command.
|'NERDTreeCreatePrefix'| Specify a prefix to be used when creating the
NERDTree window.
------------------------------------------------------------------------------
3.2. Customisation details *NERDTreeOptionDetails*
@ -778,13 +776,13 @@ Default: 1.
If set to 1, doing a >
:edit <some directory>
<
will open up a "secondary" NERD tree instead of a netrw in the target window.
will open up a window level NERD tree instead of a netrw in the target window.
Secondary NERD trees behaves slightly different from a regular trees in the
Window level trees behaves slightly different from a regular trees in the
following respects:
1. 'o' will open the selected file in the same window as the tree,
replacing it.
2. you can have as many secondary tree as you want in the same tab.
2. you can have one tree per window - instead of per tab.
------------------------------------------------------------------------------
*'NERDTreeIgnore'*
@ -947,7 +945,7 @@ Other examples: >
------------------------------------------------------------------------------
*'NERDTreeStatusline'*
Values: Any valid statusline setting.
Default: %{b:NERDTreeRoot.path.strForOS(0)}
Default: %{b:NERDTree.root.path.strForOS(0)}
Tells the script what to use as the |'statusline'| setting for NERD tree
windows.
@ -988,19 +986,6 @@ of the following lines to set this option: >
let NERDTreeMinimalUI=1
<
------------------------------------------------------------------------------
*'NERDTreeDirArrows'*
Values: 0 or 1
Default: 0.
This option is used to change the default look of directory nodes displayed in
the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to
1 it shows right and down arrows. Use one of the follow lines to set this
option: >
let NERDTreeDirArrows=0
let NERDTreeDirArrows=1
<
------------------------------------------------------------------------------
*'NERDTreeCascadeOpenSingleChildDir'*
Values: 0 or 1
@ -1028,6 +1013,17 @@ option: >
let NERDTreeAutoDeleteBuffer=0
let NERDTreeAutoDeleteBuffer=1
<
------------------------------------------------------------------------------
*'NERDTreeCreatePrefix'*
Values: Any valid command prefix.
Default: "silent".
Internally, NERDTree uses the |:edit| command to create a buffer in which to
display its tree view. You can augment this behavior by specifying a prefix
string such as "keepalt" or similar. For example, to have NERDTree create its
tree window using `silent keepalt keepjumps edit`:
let NERDTreeCreatePrefix='silent keepalt keepjumps'
<
==============================================================================
4. The NERD tree API *NERDTreeAPI*
@ -1205,7 +1201,7 @@ Use this API if you want to run a callback for events on Path objects. E.G >
"This function will be called whenever a Path object is created.
"a:event is an object that contains a bunch of relevant info -
"including the path in question. See lib/event.vim for details.
"including the path in question. See lib/nerdtree/event.vim for details.
endfunction
<
Current events supported:
@ -1235,187 +1231,8 @@ The latest stable versions can be found at
The latest dev versions are on github
http://github.com/scrooloose/nerdtree
==============================================================================
6. Changelog *NERDTreeChangelog*
Next
- add 'scope' argument to the key map API
- add NERDTreeCustomIgnoreFilter hook - needs doc
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
- add support for custom path filters. See :help NERDTreeAddPathFilter()
- add path listener API. See :help NERDTreePathListenerAPI.
4.2.0
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars
instead of the old +~| chars to define the tree structure (sickill)
- shift the syntax highlighting out into its own syntax file (gnap)
- add some mac specific options to the filesystem menu - for macvim
only (andersonfreitas)
- Add NERDTreeMinimalUI option to remove some non functional parts of the
nerdtree ui (camthompson)
- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the
new behaviour (benjamingeiger)
- if no name is given to :Bookmark, make it default to the name of the
target file/dir (minyoung)
- use 'file' completion when doing copying, create, and move
operations (EvanDotPro)
- lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly
Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
4.1.0
features:
- NERDTreeFind to reveal the node for the current buffer in the tree,
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
Doug McInnes) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
Ritter and Rémi Prévost.
- truncate the root node if wider than the tree window. Thanks to Victor
Gonzalez.
bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
jfilip1024, and Chris Chambers
4.0.0
- add a new programmable menu system (see :help NERDTreeMenu).
- add new APIs to add menus/menu-items to the menu system as well as
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
- fix a bug where the script ignored directories whose name ended in a dot,
thanks to Aggelos Orfanakos for the patch.
- fix a bug when using the x mapping on the tree root, thanks to Bryan
Venteicher for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer
wasnt being stored on closing the window, thanks to Richard Hart.
- fix a bug where NERDTreeMirror would mirror the wrong tree
3.1.1
- fix a bug where a non-listed no-name buffer was getting created every
time the tree windows was created, thanks to Derek Wyatt and owen1
- make <CR> behave the same as the 'o' mapping
- some helptag fixes in the doc, thanks strull
- fix a bug when using :set nohidden and opening a file where the previous
buf was modified. Thanks iElectric
- other minor fixes
3.1.0
New features:
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
NERDTree-gs
- make the statusline for the nerd tree window default to something
hopefully more useful. See :help 'NERDTreeStatusline'
Bugfixes:
- make the hijack netrw functionality work when vim is started with "vim
<some dir>" (thanks to Alf Mikula for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
- add -bar to all the nerd tree :commands so they can chain with other
:commands (thanks to tpope)
- fix bugs when ignorecase was set (thanks to nach)
- fix a bug with the relative path code (thanks to nach)
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
3.0.1
Bugfixes:
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
was not set
- fix a bug where :NERDTree <path> would fail if <path> was relative and
didnt start with a ./ or ../ Thanks to James Kanze.
- make the q mapping work with secondary (:e <dir> style) trees,
thanks to jamessan
- fix a bunch of small bugs with secondary trees
More insane refactoring.
3.0.0
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
- allow sharing of trees across tabs, see :help :NERDTreeMirror
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
- change the '<tab>' mapping to 'i'
- change the 'H' mapping to 'I'
- lots of refactoring
==============================================================================
7. Credits *NERDTreeCredits*
Thanks to the following people for testing, bug reports, ideas etc. Without
you I probably would have got bored of the hacking the NERD tree and
just downloaded pr0n instead.
Tim Carey-Smith (halorgium)
Vigil
Nick Brettell
Thomas Scott Urban
Terrance Cohen
Yegappan Lakshmanan
Jason Mills
Michael Geddes (frogonwheels)
Yu Jun
Michael Madsen
AOYAMA Shotaro
Zhang Weiwu
Niels Aan de Brugh
Olivier Yiptong
Zhang Shuhan
Cory Echols
Piotr Czachur
Yuan Jiang
Matan Nassau
Maxim Kim
Charlton Wang
Matt Wozniski (godlygeek)
knekk
Sean Chou
Ryan Penn
Simon Peter Nicholls
Michael Foobar
Tomasz Chomiuk
Denis Pokataev
Tim Pope (tpope)
James Kanze
James Vega (jamessan)
Frederic Chanal (nach)
Alf Mikula
Lucas S. Buchala
Curtis Harvey
Guillaume Duranceau
Richard Hart (hates)
Doug McInnes
Stefan Ritter
Rémi Prévost
Victor Gonzalez
Stephan Baumeister
Ricky
jfilip1024
Chris Chambers
Vitaly Bogdanov
Patrick O'Loughlin (paddyoloughlin)
Cam Thompson (camthompson)
Marcin Kulik (sickill)
Steve DeWald (sdewald)
Ivan Necas (iNecas)
George Ang (gnap)
Evan Coury (EvanDotPro)
Andrew Radev (AndrewRadev)
Matt Gauger (mathias)
Scott Stevenson (scottstvnsn)
Anderson Freitas (andersonfreitas)
Kamil K. Lemański (kml)
Yehuda Katz (wycats)
Min-Young Wu (minyoung)
Benjamin Geiger (benjamingeiger)
==============================================================================
8. License *NERDTreeLicense*
6. License *NERDTreeLicense*
The NERD tree is released under the wtfpl.
See http://sam.zoy.org/wtfpl/COPYING.

View file

@ -3,9 +3,9 @@
let s:Bookmark = {}
let g:NERDTreeBookmark = s:Bookmark
" FUNCTION: Bookmark.activate() {{{1
function! s:Bookmark.activate(...)
call self.open(a:0 ? a:1 : {})
" FUNCTION: Bookmark.activate(nerdtree) {{{1
function! s:Bookmark.activate(nerdtree, ...)
call self.open(a:nerdtree, a:0 ? a:1 : {})
endfunction
" FUNCTION: Bookmark.AddBookmark(name, path) {{{1
@ -87,6 +87,7 @@ function! s:Bookmark.CacheBookmarks(silent)
let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
let path = fnamemodify(path, ':p')
try
let bookmark = s:Bookmark.New(name, g:NERDTreePath.New(path))
@ -127,26 +128,18 @@ endfunction
" Delete this bookmark. If the node for this bookmark is under the current
" root, then recache bookmarks for its Path object
function! s:Bookmark.delete()
let node = {}
try
let node = self.getNode(1)
catch /^NERDTree.BookmarkedNodeNotFoundError/
endtry
call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self))
if !empty(node)
call node.path.cacheDisplayString()
endif
call s:Bookmark.Write()
endfunction
" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{1
" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1
" Gets the treenode for this bookmark
"
" Args:
" searchFromAbsoluteRoot: specifies whether we should search from the current
" tree root, or the highest cached node
function! s:Bookmark.getNode(searchFromAbsoluteRoot)
let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot
function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot)
let searchRoot = a:searchFromAbsoluteRoot ? a:nerdtree.root.AbsoluteTreeRoot() : a:nerdtree.root
let targetNode = searchRoot.findNode(self.path)
if empty(targetNode)
throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name
@ -154,12 +147,12 @@ function! s:Bookmark.getNode(searchFromAbsoluteRoot)
return targetNode
endfunction
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{1
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1
" Class method that finds the bookmark with the given name and returns the
" treenode for it.
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot)
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree)
let bookmark = s:Bookmark.BookmarkFor(a:name)
return bookmark.getNode(a:searchFromAbsoluteRoot)
return bookmark.getNode(nerdtree, a:searchFromAbsoluteRoot)
endfunction
" FUNCTION: Bookmark.GetSelected() {{{1
@ -209,8 +202,11 @@ function! s:Bookmark.New(name, path)
return newBookmark
endfunction
" FUNCTION: Bookmark.open([options]) {{{1
" FUNCTION: Bookmark.open(nerdtree, [options]) {{{1
"Args:
"
"nerdtree: the tree to load open the bookmark in
"
"A dictionary containing the following keys (all optional):
" 'where': Specifies whether the node should be opened in new split/tab or in
" the previous window. Can be either 'v' (vertical split), 'h'
@ -219,11 +215,11 @@ endfunction
" 'keepopen': dont close the tree window
" 'stay': open the file, but keep the cursor in the tree win
"
function! s:Bookmark.open(...)
function! s:Bookmark.open(nerdtree, ...)
let opts = a:0 ? a:1 : {}
if self.path.isDirectory && !has_key(opts, 'where')
call self.toRoot()
call self.toRoot(a:nerdtree)
else
let opener = g:NERDTreeOpener.New(self.path, opts)
call opener.open(self)
@ -265,26 +261,24 @@ function! s:Bookmark.str()
return '>' . self.name . ' ' . pathStr
endfunction
" FUNCTION: Bookmark.toRoot() {{{1
" FUNCTION: Bookmark.toRoot(nerdtree) {{{1
" Make the node for this bookmark the new tree root
function! s:Bookmark.toRoot()
function! s:Bookmark.toRoot(nerdtree)
if self.validate()
try
let targetNode = self.getNode(1)
let targetNode = self.getNode(a:nerdtree, 1)
catch /^NERDTree.BookmarkedNodeNotFoundError/
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path)
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree)
endtry
call targetNode.makeRoot()
call b:NERDTree.render()
call targetNode.putCursorHere(0, 0)
call a:nerdtree.changeRoot(targetNode)
endif
endfunction
" FUNCTION: Bookmark.ToRoot(name) {{{1
" FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1
" Make the node for this bookmark the new tree root
function! s:Bookmark.ToRoot(name)
function! s:Bookmark.ToRoot(name, nerdtree)
let bookmark = s:Bookmark.BookmarkFor(a:name)
call bookmark.toRoot()
call bookmark.toRoot(a:nerdtree)
endfunction
" FUNCTION: Bookmark.validate() {{{1
@ -293,7 +287,6 @@ function! s:Bookmark.validate()
return 1
else
call s:Bookmark.CacheBookmarks(1)
call b:NERDTree.render()
call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.")
return 0
endif
@ -304,7 +297,7 @@ endfunction
function! s:Bookmark.Write()
let bookmarkStrings = []
for i in s:Bookmark.Bookmarks()
call add(bookmarkStrings, i.name . ' ' . i.path.str())
call add(bookmarkStrings, i.name . ' ' . fnamemodify(i.path.str(), ':~'))
endfor
"add a blank line before the invalid ones

View file

@ -1,5 +1,5 @@
"CLASS: Creator
"Creates primary/secondary/mirror nerdtree windows. Sets up all the window and
"Creates tab/window/mirror nerdtree windows. Sets up all the window and
"buffer options and key mappings etc.
"============================================================
let s:Creator = {}
@ -16,7 +16,7 @@ function! s:Creator._bindMappings()
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>', b:NERDTree)
command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call b:NERDTree.render()
command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) <bar> call b:NERDTree.render()
command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write()
@ -32,22 +32,26 @@ function! s:Creator.BufNamePrefix()
return 'NERD_tree_'
endfunction
"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1
function! s:Creator.CreatePrimary(name)
"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
function! s:Creator.CreateTabTree(name)
let creator = s:Creator.New()
call creator.createPrimary(a:name)
call creator.createTabTree(a:name)
endfunction
"FUNCTION: s:Creator.createPrimary(a:name) {{{1
"FUNCTION: s:Creator.createTabTree(a:name) {{{1
"name: the name of a bookmark or a directory
function! s:Creator.createPrimary(name)
function! s:Creator.createTabTree(name)
let path = self._pathForString(a:name)
"abort if exception was thrown (bookmark/dir doesn't exist)
if empty(path)
return
endif
if path == {}
return
endif
"if instructed to, then change the vim CWD to the dir the NERDTree is
"inited in
if g:NERDTreeChDirMode != 0
@ -58,32 +62,26 @@ function! s:Creator.createPrimary(name)
if g:NERDTree.IsOpen()
call g:NERDTree.Close()
endif
unlet t:NERDTreeBufName
call self._removeTreeBufForTab()
endif
call self._createTreeWin()
call self._createNERDTree(path)
let b:NERDTreeType = "primary"
let b:treeShowHelp = 0
let b:NERDTreeIgnoreEnabled = 1
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
call self._createNERDTree(path, "tab")
call b:NERDTree.render()
call b:NERDTreeRoot.putCursorHere(0, 0)
call b:NERDTree.root.putCursorHere(0, 0)
call self._broadcastInitEvent()
endfunction
"FUNCTION: s:Creator.CreateSecondary(dir) {{{1
function! s:Creator.CreateSecondary(dir)
"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
function! s:Creator.CreateWindowTree(dir)
let creator = s:Creator.New()
call creator.createSecondary(a:dir)
call creator.createWindowTree(a:dir)
endfunction
"FUNCTION: s:Creator.createSecondary(dir) {{{1
function! s:Creator.createSecondary(dir)
"FUNCTION: s:Creator.createWindowTree(dir) {{{1
function! s:Creator.createWindowTree(dir)
try
let path = g:NERDTreePath.New(a:dir)
catch /^NERDTree.InvalidArgumentsError/
@ -96,14 +94,13 @@ function! s:Creator.createSecondary(dir)
let previousBuf = expand("#")
"we need a unique name for each secondary tree buffer to ensure they are
"we need a unique name for each window tree buffer to ensure they are
"all independent
exec "silent edit " . self._nextBufferName()
exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName()
let b:NERDTreePreviousBuf = bufnr(previousBuf)
call self._createNERDTree(path)
call self._createNERDTree(path, "window")
let b:NERDTree._previousBuf = bufnr(previousBuf)
call self._setCommonBufOptions()
let b:NERDTreeType = "secondary"
call b:NERDTree.render()
@ -111,8 +108,8 @@ function! s:Creator.createSecondary(dir)
endfunction
" FUNCTION: s:Creator._createNERDTree(path) {{{1
function! s:Creator._createNERDTree(path)
let b:NERDTree = g:NERDTree.New(a:path)
function! s:Creator._createNERDTree(path, type)
let b:NERDTree = g:NERDTree.New(a:path, a:type)
"TODO: This is kept for compatability only since many things use
"b:NERDTreeRoot instead of the new NERDTree.root
"Remove this one day
@ -145,7 +142,7 @@ function! s:Creator.createMirror()
let i = 0
while i < len(treeBufNames)
let bufName = treeBufNames[i]
let treeRoot = getbufvar(bufName, "NERDTreeRoot")
let treeRoot = getbufvar(bufName, "NERDTree").root
let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName
let i = i + 1
endwhile
@ -201,6 +198,15 @@ function! s:Creator._createTreeWin()
call self._setCommonBufOptions()
endfunction
"FUNCTION: s:Creator._isBufHidden(nr) {{{1
function! s:Creator._isBufHidden(nr)
redir => bufs
silent ls!
redir END
return bufs =~ a:nr . '..h'
endfunction
"FUNCTION: s:Creator.New() {{{1
function! s:Creator.New()
let newCreator = copy(self)
@ -245,7 +251,7 @@ function! s:Creator._pathForString(str)
let path = g:NERDTreePath.New(dir)
catch /^NERDTree.InvalidArgumentsError/
call nerdtree#echo("No bookmark or directory found for: " . a:str)
return
return {}
endtry
endif
if !path.isDirectory
@ -255,6 +261,23 @@ function! s:Creator._pathForString(str)
return path
endfunction
" Function: s:Creator._removeTreeBufForTab() {{{1
function! s:Creator._removeTreeBufForTab()
let buf = bufnr(t:NERDTreeBufName)
"if &hidden is not set then it will already be gone
if buf != -1
"nerdtree buf may be mirrored/displayed elsewhere
if self._isBufHidden(buf)
exec "bwipeout " . buf
endif
endif
unlet t:NERDTreeBufName
endfunction
"FUNCTION: s:Creator._setCommonBufOptions() {{{1
function! s:Creator._setCommonBufOptions()
"throwaway buffer options
@ -283,12 +306,6 @@ function! s:Creator._setCommonBufOptions()
endif
call self._setupStatusline()
let b:treeShowHelp = 0
let b:NERDTreeIgnoreEnabled = 1
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
call self._bindMappings()
setlocal filetype=nerdtree
endfunction
@ -318,20 +335,20 @@ function! s:Creator._tabpagevar(tabnr, var)
return v
endfunction
"FUNCTION: s:Creator.TogglePrimary(dir) {{{1
function! s:Creator.TogglePrimary(dir)
"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1
function! s:Creator.ToggleTabTree(dir)
let creator = s:Creator.New()
call creator.togglePrimary(a:dir)
call creator.toggleTabTree(a:dir)
endfunction
"FUNCTION: s:Creator.togglePrimary(dir) {{{1
"FUNCTION: s:Creator.toggleTabTree(dir) {{{1
"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
"closed it is restored or initialized (if it doesnt exist)
"
"Args:
"dir: the full path for the root node (is only used if the NERD tree is being
"initialized.
function! s:Creator.togglePrimary(dir)
function! s:Creator.toggleTabTree(dir)
if g:NERDTree.ExistsForTab()
if !g:NERDTree.IsOpen()
call self._createTreeWin()
@ -343,7 +360,7 @@ function! s:Creator.togglePrimary(dir)
call g:NERDTree.Close()
endif
else
call self.createPrimary(a:dir)
call self.createTabTree(a:dir)
endif
endfunction

View file

@ -8,8 +8,30 @@ function! s:NERDTree.AddPathFilter(callback)
call add(s:NERDTree.PathFilters(), a:callback)
endfunction
"FUNCTION: s:NERDTree.changeRoot(node) {{{1
function! s:NERDTree.changeRoot(node)
if a:node.path.isDirectory
let self.root = a:node
else
call a:node.cacheParent()
let self.root = a:node.parent
endif
call self.root.open()
"change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode ==# 2
exec "cd " . self.root.path.str({'format': 'Edit'})
endif
call self.render()
call self.root.putCursorHere(0, 0)
silent doautocmd User NERDTreeNewRoot
endfunction
"FUNCTION: s:NERDTree.Close() {{{1
"Closes the primary NERD tree window for this tab
"Closes the tab tree window for this tab
function! s:NERDTree.Close()
if !s:NERDTree.IsOpen()
return
@ -43,7 +65,7 @@ endfunction
"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1
"Places the cursor at the top of the bookmarks table
function! s:NERDTree.CursorToBookmarkTable()
if !b:NERDTreeShowBookmarks
if !b:NERDTree.ui.getShowBookmarks()
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
endif
@ -73,13 +95,18 @@ endfunction
" Function: s:NERDTree.ExistsForBuffer() {{{1
" Returns 1 if a nerd tree root exists in the current buffer
function! s:NERDTree.ExistsForBuf()
return exists("b:NERDTreeRoot")
return exists("b:NERDTree")
endfunction
" Function: s:NERDTree.ExistsForTab() {{{1
" Returns 1 if a nerd tree root exists in the current tab
function! s:NERDTree.ExistsForTab()
return exists("t:NERDTreeBufName")
if !exists("t:NERDTreeBufName")
return
end
"check b:NERDTree is still there and hasn't been e.g. :bdeleted
return !empty(getbufvar(bufnr(t:NERDTreeBufName), 'NERDTree'))
endfunction
function! s:NERDTree.ForCurrentBuf()
@ -90,14 +117,29 @@ function! s:NERDTree.ForCurrentBuf()
endif
endfunction
"FUNCTION: s:NERDTree.ForCurrentTab() {{{1
function! s:NERDTree.ForCurrentTab()
if !s:NERDTree.ExistsForTab()
return
endif
let bufnr = bufnr(t:NERDTreeBufName)
return getbufvar(bufnr, "NERDTree")
endfunction
"FUNCTION: s:NERDTree.getRoot() {{{1
function! s:NERDTree.getRoot()
return self.root
endfunction
"FUNCTION: s:NERDTree.GetWinNum() {{{1
"gets the nerd tree window number for this tab
function! s:NERDTree.GetWinNum()
if exists("t:NERDTreeBufName")
return bufwinnr(t:NERDTreeBufName)
else
return -1
endif
return -1
endfunction
"FUNCTION: s:NERDTree.IsOpen() {{{1
@ -105,6 +147,16 @@ function! s:NERDTree.IsOpen()
return s:NERDTree.GetWinNum() != -1
endfunction
"FUNCTION: s:NERDTree.isTabTree() {{{1
function! s:NERDTree.isTabTree()
return self._type == "tab"
endfunction
"FUNCTION: s:NERDTree.isWinTree() {{{1
function! s:NERDTree.isWinTree()
return self._type == "window"
endfunction
"FUNCTION: s:NERDTree.MustBeOpen() {{{1
function! s:NERDTree.MustBeOpen()
if !s:NERDTree.IsOpen()
@ -113,11 +165,11 @@ function! s:NERDTree.MustBeOpen()
endfunction
"FUNCTION: s:NERDTree.New() {{{1
function! s:NERDTree.New(path)
function! s:NERDTree.New(path, type)
let newObj = copy(self)
let newObj.ui = g:NERDTreeUI.New(newObj)
let newObj.root = g:NERDTreeDirNode.New(a:path)
let newObj.root = g:NERDTreeDirNode.New(a:path, newObj)
let newObj._type = a:type
return newObj
endfunction
@ -129,6 +181,10 @@ function! s:NERDTree.PathFilters()
return s:NERDTree._PathFilters
endfunction
"FUNCTION: s:NERDTree.previousBuf() {{{1
function! s:NERDTree.previousBuf()
return self._previousBuf
endfunction
"FUNCTION: s:NERDTree.render() {{{1
"A convenience function - since this is called often

View file

@ -11,8 +11,8 @@ function! s:Notifier.AddListener(event, funcname)
call add(listeners, a:funcname)
endfunction
function! s:Notifier.NotifyListeners(event, path, params)
let event = g:NERDTreeEvent.New(b:NERDTree, a:path, a:event, a:params)
function! s:Notifier.NotifyListeners(event, path, nerdtree, params)
let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params)
for listener in s:Notifier.GetListenersForEvent(a:event)
call {listener}(event)

View file

@ -64,7 +64,7 @@ endfunction
"FUNCTION: Opener._gotoTargetWin() {{{1
function! s:Opener._gotoTargetWin()
if b:NERDTreeType ==# "secondary"
if b:NERDTree.isWinTree()
if self._where == 'v'
vsplit
elseif self._where == 'h'
@ -149,7 +149,7 @@ function! s:Opener.New(path, opts)
let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen')
let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : ''
let newObj._treetype = b:NERDTreeType
let newObj._nerdtree = b:NERDTree
call newObj._saveCursorPos()
return newObj
@ -247,34 +247,25 @@ function! s:Opener._openFile()
endif
call self._gotoTargetWin()
if self._treetype ==# "secondary"
call self._path.edit()
else
call self._path.edit()
if self._stay
call self._restoreCursorPos()
endif
call self._path.edit()
if self._stay
call self._restoreCursorPos()
endif
endfunction
"FUNCTION: Opener._openDirectory(node) {{{1
function! s:Opener._openDirectory(node)
if self._treetype ==# "secondary"
if self._nerdtree.isWinTree()
call self._gotoTargetWin()
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
call g:NERDTreeCreator.CreateWindow(a:node.path.str())
else
call self._gotoTargetWin()
if empty(self._where)
call a:node.makeRoot()
call b:NERDTree.render()
call a:node.putCursorHere(0, 0)
call b:NERDTree.changeRoot(a:node)
elseif self._where == 't'
call g:NERDTreeCreator.CreatePrimary(a:node.path.str())
call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
else
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
call g:NERDTreeCreator.CreateWindowTree(a:node.path.str())
endif
endif

View file

@ -40,9 +40,7 @@ endfunction
"FUNCTION: Path.cacheDisplayString() {{{1
function! s:Path.cacheDisplayString() abort
let self.cachedDisplayString = self.flagSet.renderToString()
let self.cachedDisplayString .= self.getLastPathComponent(1)
let self.cachedDisplayString = self.getLastPathComponent(1)
if self.isExecutable
let self.cachedDisplayString = self.cachedDisplayString . '*'
@ -63,7 +61,7 @@ function! s:Path.cacheDisplayString() abort
endif
if self.isReadOnly
let self.cachedDisplayString .= ' [RO]'
let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']'
endif
endfunction
@ -406,11 +404,11 @@ function! s:Path.isUnixHiddenPath()
endif
endfunction
"FUNCTION: Path.ignore() {{{1
"FUNCTION: Path.ignore(nerdtree) {{{1
"returns true if this path should be ignored
function! s:Path.ignore()
function! s:Path.ignore(nerdtree)
"filter out the user specified paths to ignore
if b:NERDTreeIgnoreEnabled
if a:nerdtree.ui.isIgnoreFilterEnabled()
for i in g:NERDTreeIgnore
if self._ignorePatternMatches(i)
return 1
@ -418,18 +416,18 @@ function! s:Path.ignore()
endfor
for callback in g:NERDTree.PathFilters()
if {callback}({'path': self, 'nerdtree': b:NERDTree})
if {callback}({'path': self, 'nerdtree': a:nerdtree})
return 1
endif
endfor
endif
"dont show hidden files unless instructed to
if b:NERDTreeShowHidden ==# 0 && self.isUnixHiddenFile()
if !a:nerdtree.ui.getShowHidden() && self.isUnixHiddenFile()
return 1
endif
if b:NERDTreeShowFiles ==# 0 && self.isDirectory ==# 0
if a:nerdtree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0
return 1
endif
@ -455,10 +453,22 @@ function! s:Path._ignorePatternMatches(pattern)
return self.getLastPathComponent(0) =~# pat
endfunction
"FUNCTION: Path.isUnder(path) {{{1
"return 1 if this path is somewhere under the given path in the filesystem.
"FUNCTION: Path.isAncestor(path) {{{1
"return 1 if this path is somewhere above the given path in the filesystem.
"
"a:path should be a dir
function! s:Path.isAncestor(path)
if !self.isDirectory
return 0
endif
let this = self.str()
let that = a:path.str()
return stridx(that, this) == 0
endfunction
"FUNCTION: Path.isUnder(path) {{{1
"return 1 if this path is somewhere under the given path in the filesystem.
function! s:Path.isUnder(path)
if a:path.isDirectory == 0
return 0
@ -572,16 +582,16 @@ function! s:Path.readInfoFromDisk(fullpath)
endif
endfunction
"FUNCTION: Path.refresh() {{{1
function! s:Path.refresh()
"FUNCTION: Path.refresh(nerdtree) {{{1
function! s:Path.refresh(nerdtree)
call self.readInfoFromDisk(self.str())
call g:NERDTreePathNotifier.NotifyListeners('refresh', self, {})
call g:NERDTreePathNotifier.NotifyListeners('refresh', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction
"FUNCTION: Path.refreshFlags() {{{1
function! s:Path.refreshFlags()
call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, {})
"FUNCTION: Path.refreshFlags(nerdtree) {{{1
function! s:Path.refreshFlags(nerdtree)
call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction

View file

@ -9,7 +9,7 @@ let g:NERDTreeDirNode = s:TreeDirNode
"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1
"class method that returns the highest cached ancestor of the current root
function! s:TreeDirNode.AbsoluteTreeRoot()
let currentNode = b:NERDTreeRoot
let currentNode = b:NERDTree.root
while currentNode.parent != {}
let currentNode = currentNode.parent
endwhile
@ -21,7 +21,7 @@ unlet s:TreeDirNode.activate
function! s:TreeDirNode.activate(...)
let opts = a:0 ? a:1 : {}
call self.toggleOpen(opts)
call b:NERDTree.render()
call self.getNerdtree().render()
call self.putCursorHere(0, 0)
endfunction
@ -68,11 +68,27 @@ endfunction
"Returns:
"the newly created node
function! s:TreeDirNode.createChild(path, inOrder)
let newTreeNode = g:NERDTreeFileNode.New(a:path)
let newTreeNode = g:NERDTreeFileNode.New(a:path, self.getNerdtree())
call self.addChild(newTreeNode, a:inOrder)
return newTreeNode
endfunction
"FUNCTION: TreeDirNode.displayString() {{{1
unlet s:TreeDirNode.displayString
function! s:TreeDirNode.displayString()
let cascade = self.getCascade()
let rv = ""
for node in cascade
let rv = rv . node.path.displayString()
endfor
let sym = cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable
let flags = cascade[-1].path.flagSet.renderToString()
return sym . ' ' . flags . rv
endfunction
"FUNCTION: TreeDirNode.findNode(path) {{{1
"Will find one of the children (recursively) that has the given path
"
@ -98,6 +114,33 @@ function! s:TreeDirNode.findNode(path)
return {}
endfunction
"FUNCTION: TreeDirNode.getCascade() {{{1
"Return an array of dir nodes (starting from self) that can be cascade opened.
function! s:TreeDirNode.getCascade()
let rv = [self]
let node = self
while 1
let vc = node.getVisibleChildren()
if len(vc) != 1
break
endif
let visChild = vc[0]
"TODO: optimize
if !visChild.path.isDirectory
break
endif
call add(rv, visChild)
let node = visChild
endwhile
return rv
endfunction
"FUNCTION: TreeDirNode.getChildCount() {{{1
"Returns the number of children this node has
function! s:TreeDirNode.getChildCount()
@ -171,6 +214,12 @@ function! s:TreeDirNode.getChildIndex(path)
return -1
endfunction
"FUNCTION: TreeDirNode.getDirChildren() {{{1
"Get all children that are directories
function! s:TreeDirNode.getDirChildren()
return filter(self.children, 'v:val.path.isDirectory == 1')
endfunction
"FUNCTION: TreeDirNode.GetSelected() {{{1
"Returns the current node if it is a dir node, or else returns the current
"nodes parent
@ -199,7 +248,7 @@ endfunction
function! s:TreeDirNode.getVisibleChildren()
let toReturn = []
for i in self.children
if i.path.ignore() ==# 0
if i.path.ignore(self.getNerdtree()) ==# 0
call add(toReturn, i)
endif
endfor
@ -212,6 +261,13 @@ function! s:TreeDirNode.hasVisibleChildren()
return self.getVisibleChildCount() != 0
endfunction
"FUNCTION: TreeDirNode.isCascadable() {{{1
"true if this dir has only one visible child - which is also a dir
function! s:TreeDirNode.isCascadable()
let c = self.getVisibleChildren()
return len(c) == 1 && c[0].path.isDirectory
endfunction
"FUNCTION: TreeDirNode._initChildren() {{{1
"Removes all childen from this node and re-reads them
"
@ -244,19 +300,15 @@ function! s:TreeDirNode._initChildren(silent)
for i in files
"filter out the .. and . directories
"Note: we must match .. AND ../ cos sometimes the globpath returns
"Note: we must match .. AND ../ since sometimes the globpath returns
"../ for path with strange chars (eg $)
" if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
"
" Regular expression is too expensive. Use simply string comparison
" instead
if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." &&
if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." &&
\ i[len(i)-2:1] != "." && i[len(i)-1] != "."
"put the next file in a new node and attach it
try
let path = g:NERDTreePath.New(i)
call self.createChild(path, 0)
call g:NERDTreePathNotifier.NotifyListeners('init', path, {})
call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {})
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
let invalidFilesFound += 1
endtry
@ -275,13 +327,13 @@ function! s:TreeDirNode._initChildren(silent)
return self.getChildCount()
endfunction
"FUNCTION: TreeDirNode.New(path) {{{1
"FUNCTION: TreeDirNode.New(path, nerdtree) {{{1
"Returns a new TreeNode object with the given path and parent
"
"Args:
"path: a path object representing the full filesystem path to the file/dir that the node represents
unlet s:TreeDirNode.New
function! s:TreeDirNode.New(path)
"path: dir that the node represents
"nerdtree: the tree the node belongs to
function! s:TreeDirNode.New(path, nerdtree)
if a:path.isDirectory != 1
throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object."
endif
@ -293,6 +345,7 @@ function! s:TreeDirNode.New(path)
let newTreeNode.children = []
let newTreeNode.parent = {}
let newTreeNode._nerdtree = a:nerdtree
return newTreeNode
endfunction
@ -356,7 +409,7 @@ endfunction
"FUNCTION: TreeDirNode._openInNewTab() {{{1
function! s:TreeDirNode._openInNewTab()
tabnew
call g:NERDTreeCreator.CreatePrimary(self.path.str())
call g:NERDTreeCreator.CreateTabTree(self.path.str())
endfunction
"FUNCTION: TreeDirNode.openRecursively() {{{1
@ -377,7 +430,7 @@ endfunction
"Args:
"forceOpen: 1 if this node should be opened regardless of file filters
function! s:TreeDirNode._openRecursively2(forceOpen)
if self.path.ignore() ==# 0 || a:forceOpen
if self.path.ignore(self.getNerdtree()) ==# 0 || a:forceOpen
let self.isOpen = 1
if self.children ==# []
call self._initChildren(1)
@ -394,7 +447,7 @@ endfunction
"FUNCTION: TreeDirNode.refresh() {{{1
unlet s:TreeDirNode.refresh
function! s:TreeDirNode.refresh()
call self.path.refresh()
call self.path.refresh(self.getNerdtree())
"if this node was ever opened, refresh its children
if self.isOpen || !empty(self.children)
@ -425,7 +478,7 @@ function! s:TreeDirNode.refresh()
"the node doesnt exist so create it
else
let newNode = g:NERDTreeFileNode.New(path)
let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree())
let newNode.parent = self
call add(newChildNodes, newNode)
endif
@ -450,7 +503,7 @@ endfunction
"FUNCTION: TreeDirNode.refreshFlags() {{{1
unlet s:TreeDirNode.refreshFlags
function! s:TreeDirNode.refreshFlags()
call self.path.refreshFlags()
call self.path.refreshFlags(self.getNerdtree())
for i in self.children
call i.refreshFlags()
endfor
@ -458,13 +511,16 @@ endfunction
"FUNCTION: TreeDirNode.refreshDirFlags() {{{1
function! s:TreeDirNode.refreshDirFlags()
call self.path.refreshFlags()
call self.path.refreshFlags(self.getNerdtree())
endfunction
"FUNCTION: TreeDirNode.reveal(path) {{{1
"reveal the given path, i.e. cache and open all treenodes needed to display it
"in the UI
function! s:TreeDirNode.reveal(path)
"Returns the revealed node
function! s:TreeDirNode.reveal(path, ...)
let opts = a:0 ? a:1 : {}
if !a:path.isUnder(self.path)
throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str()
endif
@ -473,9 +529,10 @@ function! s:TreeDirNode.reveal(path)
if self.path.equals(a:path.getParent())
let n = self.findNode(a:path)
call b:NERDTree.render()
call n.putCursorHere(1,0)
return
if has_key(opts, "open")
call n.open()
endif
return n
endif
let p = a:path
@ -484,7 +541,7 @@ function! s:TreeDirNode.reveal(path)
endwhile
let n = self.findNode(p)
call n.reveal(a:path)
return n.reveal(a:path, opts)
endfunction
"FUNCTION: TreeDirNode.removeChild(treenode) {{{1

View file

@ -19,7 +19,7 @@ function! s:TreeFileNode.bookmark(name)
"it so we can update its display string
let oldMarkedNode = {}
try
let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1)
let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1, self.getNerdtree())
catch /^NERDTree.BookmarkNotFoundError/
catch /^NERDTree.BookmarkedNodeNotFoundError/
endtry
@ -41,7 +41,7 @@ function! s:TreeFileNode.cacheParent()
if parentPath.equals(self.path)
throw "NERDTree.CannotCacheParentError: already at root"
endif
let self.parent = s:TreeFileNode.New(parentPath)
let self.parent = s:TreeFileNode.New(parentPath, self.getNerdtree())
endif
endfunction
@ -59,7 +59,7 @@ endfunction
function! s:TreeFileNode.copy(dest)
call self.path.copy(a:dest)
let newPath = g:NERDTreePath.New(a:dest)
let parent = b:NERDTreeRoot.findNode(newPath.getParent())
let parent = self.getNerdtree().root.findNode(newPath.getParent())
if !empty(parent)
call parent.refresh()
return parent.findNode(newPath)
@ -83,7 +83,7 @@ endfunction
"Return:
"a string that can be used in the view to represent this node
function! s:TreeFileNode.displayString()
return self.path.displayString()
return self.path.flagSet.renderToString() . self.path.displayString()
endfunction
"FUNCTION: TreeFileNode.equals(treenode) {{{1
@ -165,7 +165,7 @@ function! s:TreeFileNode.findSibling(direction)
"if the next node is not an ignored node (i.e. wont show up in the
"view) then return it
if self.parent.children[siblingIndx].path.ignore() ==# 0
if self.parent.children[siblingIndx].path.ignore(self.getNerdtree()) ==# 0
return self.parent.children[siblingIndx]
endif
@ -178,11 +178,16 @@ function! s:TreeFileNode.findSibling(direction)
return {}
endfunction
"FUNCTION: TreeFileNode.getNerdtree(){{{1
function! s:TreeFileNode.getNerdtree()
return self._nerdtree
endfunction
"FUNCTION: TreeFileNode.GetRootForTab(){{{1
"get the root node for this tab
function! s:TreeFileNode.GetRootForTab()
if g:NERDTree.ExistsForTab()
return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
return getbufvar(t:NERDTreeBufName, 'NERDTree').root
end
return {}
endfunction
@ -195,7 +200,7 @@ function! s:TreeFileNode.GetSelected()
if path ==# {}
return {}
endif
return b:NERDTreeRoot.findNode(path)
return b:NERDTree.root.findNode(path)
catch /^NERDTree/
return {}
endtry
@ -205,51 +210,32 @@ endfunction
"returns 1 if this node should be visible according to the tree filters and
"hidden file filters (and their on/off status)
function! s:TreeFileNode.isVisible()
return !self.path.ignore()
return !self.path.ignore(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.isRoot() {{{1
"returns 1 if this node is b:NERDTreeRoot
function! s:TreeFileNode.isRoot()
if !g:NERDTree.ExistsForBuf()
throw "NERDTree.NoTreeError: No tree exists for the current buffer"
endif
return self.equals(b:NERDTreeRoot)
return self.equals(self.getNerdtree().root)
endfunction
"FUNCTION: TreeFileNode.makeRoot() {{{1
"Make this node the root of the tree
function! s:TreeFileNode.makeRoot()
if self.path.isDirectory
let b:NERDTreeRoot = self
else
call self.cacheParent()
let b:NERDTreeRoot = self.parent
endif
call b:NERDTreeRoot.open()
"change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode ==# 2
exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'})
endif
silent doautocmd User NERDTreeNewRoot
endfunction
"FUNCTION: TreeFileNode.New(path) {{{1
"FUNCTION: TreeFileNode.New(path, nerdtree) {{{1
"Returns a new TreeNode object with the given path and parent
"
"Args:
"path: a path object representing the full filesystem path to the file/dir that the node represents
function! s:TreeFileNode.New(path)
"path: file/dir that the node represents
"nerdtree: the tree the node belongs to
function! s:TreeFileNode.New(path, nerdtree)
if a:path.isDirectory
return g:NERDTreeDirNode.New(a:path)
return g:NERDTreeDirNode.New(a:path, a:nerdtree)
else
let newTreeNode = copy(self)
let newTreeNode.path = a:path
let newTreeNode.parent = {}
let newTreeNode._nerdtree = a:nerdtree
return newTreeNode
endif
endfunction
@ -289,7 +275,7 @@ endfunction
"recurseUpward: try to put the cursor on the parent if the this node isnt
"visible
function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
let ln = b:NERDTree.ui.getLineNum(self)
let ln = self.getNerdtree().ui.getLineNum(self)
if ln != -1
if a:isJump
mark '
@ -298,11 +284,11 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
else
if a:recurseUpward
let node = self
while node != {} && b:NERDTree.ui.getLineNum(node) ==# -1
while node != {} && self.getNerdtree().ui.getLineNum(node) ==# -1
let node = node.parent
call node.open()
endwhile
call b:NERDTree.render()
call self._nerdtree.render()
call node.putCursorHere(a:isJump, 0)
endif
endif
@ -310,12 +296,12 @@ endfunction
"FUNCTION: TreeFileNode.refresh() {{{1
function! s:TreeFileNode.refresh()
call self.path.refresh()
call self.path.refresh(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.refreshFlags() {{{1
function! s:TreeFileNode.refreshFlags()
call self.path.refreshFlags()
call self.path.refreshFlags(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.rename() {{{1
@ -326,7 +312,7 @@ function! s:TreeFileNode.rename(newName)
call self.parent.removeChild(self)
let parentPath = self.path.getParent()
let newParent = b:NERDTreeRoot.findNode(parentPath)
let newParent = self.getNerdtree().root.findNode(parentPath)
if newParent != {}
call newParent.createChild(self.path, 1)
@ -337,70 +323,24 @@ endfunction
"FUNCTION: TreeFileNode.renderToString {{{1
"returns a string representation for this tree to be rendered in the view
function! s:TreeFileNode.renderToString()
return self._renderToString(0, 0, [], self.getChildCount() ==# 1)
return self._renderToString(0, 0)
endfunction
"Args:
"depth: the current depth in the tree for this call
"drawText: 1 if we should actually draw the line for this node (if 0 then the
"child nodes are rendered only)
"vertMap: a binary array that indicates whether a vertical bar should be draw
"for each depth in the tree
"isLastChild:true if this curNode is the last child of its parent
function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
function! s:TreeFileNode._renderToString(depth, drawText)
let output = ""
if a:drawText ==# 1
let treeParts = ''
let treeParts = repeat(' ', a:depth - 1)
"get all the leading spaces and vertical tree parts for this line
if a:depth > 1
for j in a:vertMap[0:-2]
if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
else
if j ==# 1
let treeParts = treeParts . '| '
else
let treeParts = treeParts . ' '
endif
endif
endfor
if !self.path.isDirectory
let treeParts = treeParts . ' '
endif
"get the last vertical tree part for this line which will be different
"if this node is the last child of its parent
if !g:NERDTreeDirArrows
if a:isLastChild
let treeParts = treeParts . '`'
else
let treeParts = treeParts . '|'
endif
endif
"smack the appropriate dir/file symbol on the line before the file/dir
"name itself
if self.path.isDirectory
if self.isOpen
if g:NERDTreeDirArrows
let treeParts = treeParts . '▾ '
else
let treeParts = treeParts . '~'
endif
else
if g:NERDTreeDirArrows
let treeParts = treeParts . '▸ '
else
let treeParts = treeParts . '+'
endif
endif
else
if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
else
let treeParts = treeParts . '-'
endif
endif
let line = treeParts . self.displayString()
let output = output . line . "\n"
@ -410,18 +350,15 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
if self.path.isDirectory ==# 1 && self.isOpen ==# 1
let childNodesToDraw = self.getVisibleChildren()
if len(childNodesToDraw) > 0
"draw all the nodes children except the last
let lastIndx = len(childNodesToDraw)-1
if lastIndx > 0
for i in childNodesToDraw[0:lastIndx-1]
let output = output . i._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 1), 0)
endfor
endif
if self.isCascadable() && a:depth > 0
"draw the last child, indicating that it IS the last
let output = output . childNodesToDraw[lastIndx]._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 0), 1)
let output = output . childNodesToDraw[0]._renderToString(a:depth, 0)
elseif len(childNodesToDraw) > 0
for i in childNodesToDraw
let output = output . i._renderToString(a:depth + 1, 1)
endfor
endif
endif

View file

@ -21,18 +21,18 @@ endfunction
"prints out the quick help
function! s:UI._dumpHelp()
let old_h = @h
if b:treeShowHelp ==# 1
if self.getShowHelp()
let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n"
let @h=@h."\" ============================\n"
let @h=@h."\" File node mappings~\n"
let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
let @h=@h."\" <CR>,\n"
if b:NERDTreeType ==# "primary"
if self.nerdtree.isTabTree()
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
else
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n"
endif
if b:NERDTreeType ==# "primary"
if self.nerdtree.isTabTree()
let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n"
endif
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
@ -87,10 +87,10 @@ function! s:UI._dumpHelp()
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Tree filtering mappings~\n"
let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n"
"add quickhelp entries for each custom key map
let @h=@h."\"\n\" ----------------------------\n"
@ -116,7 +116,7 @@ function! s:UI._dumpHelp()
let @h=@h."\" :ClearBookmarks [<names>]\n"
let @h=@h."\" :ClearAllBookmarks\n"
silent! put h
elseif g:NERDTreeMinimalUI == 0
elseif !self.isMinimal()
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
silent! put h
endif
@ -129,6 +129,12 @@ endfunction
function! s:UI.New(nerdtree)
let newObj = copy(self)
let newObj.nerdtree = a:nerdtree
let newObj._showHelp = 0
let newObj._ignoreEnabled = 1
let newObj._showFiles = g:NERDTreeShowFiles
let newObj._showHidden = g:NERDTreeShowHidden
let newObj._showBookmarks = g:NERDTreeShowBookmarks
return newObj
endfunction
@ -149,18 +155,11 @@ function! s:UI.getPath(ln)
"check to see if we have the root node
if a:ln == rootLine
return b:NERDTreeRoot.path
endif
if !g:NERDTreeDirArrows
" in case called from outside the tree
if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
return {}
endif
return self.nerdtree.root.path
endif
if line ==# s:UI.UpDirLine()
return b:NERDTreeRoot.path.getParent()
return self.nerdtree.root.path.getParent()
endif
let indent = self._indentLevelFor(line)
@ -183,7 +182,7 @@ function! s:UI.getPath(ln)
"have we reached the top of the tree?
if lnum == rootLine
let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir
break
endif
if curLineStripped =~# '/$'
@ -196,7 +195,7 @@ function! s:UI.getPath(ln)
endif
endif
endwhile
let curFile = b:NERDTreeRoot.path.drive . dir . curFile
let curFile = self.nerdtree.root.path.drive . dir . curFile
let toReturn = g:NERDTreePath.New(curFile)
return toReturn
endfunction
@ -206,19 +205,19 @@ endfunction
function! s:UI.getLineNum(file_node)
"if the node is the root then return the root line no.
if a:file_node.isRoot()
return b:NERDTree.ui.getRootLineNum()
return self.getRootLineNum()
endif
let totalLines = line("$")
"the path components we have matched so far
let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')]
let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')]
"the index of the component we are searching for
let curPathComponent = 1
let fullpath = a:file_node.path.str({'format': 'UI'})
let lnum = b:NERDTree.ui.getRootLineNum()
let lnum = self.getRootLineNum()
while lnum > 0
let lnum = lnum + 1
"have we reached the bottom of the tree?
@ -259,15 +258,33 @@ function! s:UI.getRootLineNum()
return rootLine
endfunction
"FUNCTION: s:UI.getShowBookmarks() {{{1
function! s:UI.getShowBookmarks()
return self._showBookmarks
endfunction
"FUNCTION: s:UI.getShowFiles() {{{1
function! s:UI.getShowFiles()
return self._showFiles
endfunction
"FUNCTION: s:UI.getShowHelp() {{{1
function! s:UI.getShowHelp()
return self._showHelp
endfunction
"FUNCTION: s:UI.getShowHidden() {{{1
function! s:UI.getShowHidden()
return self._showHidden
endfunction
"FUNCTION: s:UI._indentLevelFor(line) {{{1
function! s:UI._indentLevelFor(line)
let level = match(a:line, '[^ \-+~▸▾`|]') / s:UI.IndentWid()
" check if line includes arrows
if match(a:line, '[▸▾]') > -1
" decrement level as arrow uses 3 ascii chars
let level = level - 1
endif
return level
"have to do this work around because match() returns bytes, not chars
let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']')
let leadChars = strchars(a:line[0:numLeadBytes-1])
return leadChars / s:UI.IndentWid()
endfunction
"FUNCTION: s:UI.IndentWid() {{{1
@ -275,19 +292,25 @@ function! s:UI.IndentWid()
return 2
endfunction
"FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1
function! s:UI.isIgnoreFilterEnabled()
return self._ignoreEnabled == 1
endfunction
"FUNCTION: s:UI.isMinimal() {{{1
function! s:UI.isMinimal()
return g:NERDTreeMinimalUI
endfunction
"FUNCTION: s:UI.MarkupReg() {{{1
function! s:UI.MarkupReg()
if g:NERDTreeDirArrows
return '^\([▾▸] \| \+[▾▸] \| \+\)'
endif
return '^[ `|]*[\-+~]'
return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)'
endfunction
"FUNCTION: s:UI._renderBookmarks {{{1
function! s:UI._renderBookmarks()
if g:NERDTreeMinimalUI == 0
if !self.isMinimal()
call setline(line(".")+1, ">----------Bookmarks----------")
call cursor(line(".")+1, col("."))
endif
@ -334,6 +357,11 @@ function! s:UI.saveScreenState()
call nerdtree#exec(win . "wincmd w")
endfunction
"FUNCTION: s:UI.setShowHidden(val) {{{1
function! s:UI.setShowHidden(val)
let self._showHidden = a:val
endfunction
"FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1
"returns the given line with all the tree parts stripped off
"
@ -347,7 +375,7 @@ function! s:UI._stripMarkup(line, removeLeadingSpaces)
let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","")
"strip off any read only flag
let line = substitute (line, ' \[RO\]', "","")
let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","")
"strip off any bookmark flags
let line = substitute (line, ' {[^}]*}', "","")
@ -390,29 +418,29 @@ function! s:UI.render()
call self._dumpHelp()
"delete the blank line before the help and add one after it
if g:NERDTreeMinimalUI == 0
if !self.isMinimal()
call setline(line(".")+1, "")
call cursor(line(".")+1, col("."))
endif
if b:NERDTreeShowBookmarks
if self.getShowBookmarks()
call self._renderBookmarks()
endif
"add the 'up a dir' line
if !g:NERDTreeMinimalUI
if !self.isMinimal()
call setline(line(".")+1, s:UI.UpDirLine())
call cursor(line(".")+1, col("."))
endif
"draw the header line
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
call setline(line(".")+1, header)
call cursor(line(".")+1, col("."))
"draw the tree
let old_o = @o
let @o = b:NERDTreeRoot.renderToString()
let @o = self.nerdtree.root.renderToString()
silent put o
let @o = old_o
@ -443,47 +471,52 @@ function! s:UI.renderViewSavingPosition()
let currentNode = currentNode.parent
endwhile
call b:NERDTree.render()
call self.render()
if currentNode != {}
call currentNode.putCursorHere(0, 0)
endif
endfunction
"FUNCTION: s:UI.toggleHelp() {{{1
function! s:UI.toggleHelp()
let self._showHelp = !self._showHelp
endfunction
" FUNCTION: s:UI.toggleIgnoreFilter() {{{1
" toggles the use of the NERDTreeIgnore option
function! s:UI.toggleIgnoreFilter()
let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled
call b:NERDTree.ui.renderViewSavingPosition()
call b:NERDTree.ui.centerView()
let self._ignoreEnabled = !self._ignoreEnabled
call self.renderViewSavingPosition()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
" toggles the display of bookmarks
function! s:UI.toggleShowBookmarks()
let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks
if b:NERDTreeShowBookmarks
call b:NERDTree.render()
let self._showBookmarks = !self._showBookmarks
if self.getShowBookmarks()
call self.nerdtree.render()
call g:NERDTree.CursorToBookmarkTable()
else
call b:NERDTree.ui.renderViewSavingPosition()
call self.renderViewSavingPosition()
endif
call b:NERDTree.ui.centerView()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowFiles() {{{1
" toggles the display of hidden files
function! s:UI.toggleShowFiles()
let b:NERDTreeShowFiles = !b:NERDTreeShowFiles
call b:NERDTree.ui.renderViewSavingPosition()
call b:NERDTree.ui.centerView()
let self._showFiles = !self._showFiles
call self.renderViewSavingPosition()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowHidden() {{{1
" toggles the display of hidden files
function! s:UI.toggleShowHidden()
let b:NERDTreeShowHidden = !b:NERDTreeShowHidden
call b:NERDTree.ui.renderViewSavingPosition()
let self._showHidden = !self._showHidden
call self.renderViewSavingPosition()
call self.centerView()
endfunction

View file

@ -2,7 +2,6 @@
" File: exec_menuitem.vim
" Description: plugin for NERD Tree that provides an execute file menu item
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Last Change: 22 July, 2009
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You

View file

@ -2,7 +2,6 @@
" File: fs_menu.vim
" Description: plugin for the NERD Tree that provides a file system menu
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Last Change: 17 July, 2009
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
@ -24,7 +23,7 @@ call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callbac
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
if has("gui_mac") || has("gui_macvim")
if has("gui_mac") || has("gui_macvim") || has("mac")
call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
@ -34,18 +33,11 @@ if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
"FUNCTION: s:echo(msg){{{1
function! s:echo(msg)
redraw
echomsg "NERDTree: " . a:msg
endfunction
"FUNCTION: s:echoWarning(msg){{{1
function! s:echoWarning(msg)
echohl warningmsg
call s:echo(a:msg)
echohl normal
endfunction
if has("unix") || has("osx")
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})
else
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'})
endif
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
"prints out the given msg and, if the user responds by pushing 'y' then the
@ -107,17 +99,17 @@ function! NERDTreeAddNode()
\ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
if newNodeName ==# ''
call s:echo("Node Creation Aborted.")
call nerdtree#echo("Node Creation Aborted.")
return
endif
try
let newPath = g:NERDTreePath.Create(newNodeName)
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
let parentNode = b:NERDTree.root.findNode(newPath.getParent())
let newTreeNode = g:NERDTreeFileNode.New(newPath)
let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree)
if empty(parentNode)
call b:NERDTreeRoot.refresh()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
elseif parentNode.isOpen || !empty(parentNode.children)
call parentNode.addChild(newTreeNode, 1)
@ -125,7 +117,7 @@ function! NERDTreeAddNode()
call newTreeNode.putCursorHere(1, 0)
endif
catch /^NERDTree/
call s:echoWarning("Node Not Created.")
call nerdtree#echoWarning("Node Not Created.")
endtry
endfunction
@ -138,7 +130,7 @@ function! NERDTreeMoveNode()
\ "", curNode.path.str(), "file")
if newNodePath ==# ''
call s:echo("Node Renaming Aborted.")
call nerdtree#echo("Node Renaming Aborted.")
return
endif
@ -159,7 +151,7 @@ function! NERDTreeMoveNode()
redraw
catch /^NERDTree/
call s:echoWarning("Node Not Renamed.")
call nerdtree#echoWarning("Node Not Renamed.")
endtry
endfunction
@ -199,10 +191,33 @@ function! NERDTreeDeleteNode()
redraw
catch /^NERDTree/
call s:echoWarning("Could not remove node")
call nerdtree#echoWarning("Could not remove node")
endtry
else
call s:echo("delete aborted")
call nerdtree#echo("delete aborted")
endif
endfunction
" FUNCTION: NERDTreeListNode() {{{1
function! NERDTreeListNode()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let metadata = split(system('ls -ld ' . shellescape(treenode.path.str())), '\n')
call nerdtree#echo(metadata[0])
else
call nerdtree#echo("No information avaialable")
endif
endfunction
" FUNCTION: NERDTreeListNodeWin32() {{{1
function! NERDTreeListNodeWin32()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n')
call nerdtree#echo(metadata[0])
else
call nerdtree#echo("No information avaialable")
endif
endfunction
@ -221,7 +236,7 @@ function! NERDTreeCopyNode()
let confirmed = 1
if currentNode.path.copyingWillOverwrite(newNodePath)
call s:echo("Warning: copying may overwrite files! Continue? (yN)")
call nerdtree#echo("Warning: copying may overwrite files! Continue? (yN)")
let choice = nr2char(getchar())
let confirmed = choice ==# 'y'
endif
@ -230,22 +245,23 @@ function! NERDTreeCopyNode()
try
let newNode = currentNode.copy(newNodePath)
if empty(newNode)
call b:NERDTreeRoot.refresh()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
else
call NERDTreeRender()
call newNode.putCursorHere(0, 0)
endif
catch /^NERDTree/
call s:echoWarning("Could not copy node")
call nerdtree#echoWarning("Could not copy node")
endtry
endif
else
call s:echo("Copy aborted.")
call nerdtree#echo("Copy aborted.")
endif
redraw
endfunction
" FUNCTION: NERDTreeQuickLook() {{{1
function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
@ -253,18 +269,19 @@ function! NERDTreeQuickLook()
endif
endfunction
" FUNCTION: NERDTreeRevealInFinder() {{{1
function! NERDTreeRevealInFinder()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let x = system("open -R '" . treenode.path.str() . "'")
call system("open -R '" . treenode.path.str() . "'")
endif
endfunction
" FUNCTION: NERDTreeExecuteFile() {{{1
function! NERDTreeExecuteFile()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let x = system("open '" . treenode.path.str() . "'")
call system("open '" . treenode.path.str() . "'")
endif
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

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