diff --git a/.gitignore b/.gitignore index 66d01465..56dee29f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..785dc102 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 4d78188f..489ec5f9 100644 --- a/README.md +++ b/README.md @@ -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 `` * [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 ``, because `` 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 ``, because `` 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 `` * [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 (`o`): map o :BufExplorer -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 (`f`): map f :MRU -Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin: +Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin (`j` or `f`): let g:ctrlp_map = '' -Open [PeepOpen](https://peepcode.com/products/peepopen) plugin: - - map j :PeepOpen - Managing the [NERD Tree](https://github.com/scrooloose/nerdtree) plugin: map nn :NERDTreeToggle map nb :NERDTreeFromBookmark map nf :NERDTreeFind -[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. (`z`) map z :Goyo ### Normal mode mappings -Fast saving of a buffer: +Fast saving of a buffer (`w`): nmap w :w! - -Treat long lines as break lines (useful when moving around in them): - - map j gj - map k gk Map `` to `/` (search) and `+` to `?` (backwards search): @@ -172,14 +163,14 @@ Disable highlight when `` is pressed: map :noh -Smart way to move between windows: +Smart way to move between windows (`j` etc.): map j map k map h map l -Closing of current buffer(s): +Closing of current buffer(s) (`bd` and (`ba`)): " Close current buffer map bd :Bclose @@ -316,14 +307,8 @@ Vimscript mappings: map n :cn map p :cp -## 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) diff --git a/sources_forked/peaksea/colors/peaksea.vim b/sources_forked/peaksea/colors/peaksea.vim index 78481e0f..06924bc1 100644 --- a/sources_forked/peaksea/colors/peaksea.vim +++ b/sources_forked/peaksea/colors/peaksea.vim @@ -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 diff --git a/sources_forked/yankring/doc/yankring.txt b/sources_forked/yankring/doc/yankring.txt deleted file mode 100755 index d4c246d3..00000000 --- a/sources_forked/yankring/doc/yankring.txt +++ /dev/null @@ -1,1412 +0,0 @@ -*yankring.txt* For Vim version 7.0. - -Author: David Fishburn August 29, 2009 -Version: 10.0 - -For instructions on installing this file, type - :help add-local-help |add-local-help| inside Vim. - - -============================================================================== -1. Contents *yankring* *yankring-contents* - - 1. Contents...............................: |yankring-contents| - 2. Description............................: |yankring-description| - 3. Configuration..........................: |yankring-configure| - 3.1 Global Variables...................: |yankring-globals| - 3.2 Default Keys.......................: |yankring-mappings| - 3.3 Customizing Maps...................: |yankring-custom-maps| - 4. Using the YankRing Window..............: |yankring-window| - 5. Commands...............................: |yankring-commands| - 5.1 YRToggle..........................: |YRToggle| - 5.2 YRClear...........................: |YRClear| - 5.3 YRShow............................: |YRShow| - 5.5 YRGetElem.........................: |YRGetElem| - 5.6 YRGetMultiple.....................: |YRGetMultiple| - 5.7 YRPush............................: |YRPush| - 5.8 YRPop.............................: |YRPop| - 5.9 YRYankCount.......................: |YRYankCount| - 5.10 YRYankRange.......................: |YRYankRange| - 5.11 YRDeleteRange.....................: |YRDeleteRange| - 5.12 YRPaste...........................: |YRPaste| - 5.13 YRReplace.........................: |YRReplace| - 5.14 YRMapsCreate......................: |YRMapsCreate| - 5.15 YRMapsDelete......................: |YRMapsDelete| - 5.16 YRSearch..........................: |YRSearch| - 5.17 YRRunAfterMaps....................: |yankring-custom-maps| - 6. Tutorial...............................: |yankring-tutorial| - 6.1 YRShow............................: |YRShow-example| - 6.2 YRReplace.........................: |YRReplace-example| - 6.3 YRPush............................: |YRPush-example| - 6.4 YRClear...........................: |YRClear-example| - 6.8 YRPop.............................: |YRPop-example| - 6.9 Visual modes......................: |yankring-visual-example| - 6.10 Using ranges......................: |YRYankRange-example| - 6.11 :global...........................: |global-example| - 6.12 YRSearch..........................: |YRSearch-example| - 7. History................................: |yankring-history| - -============================================================================== -2. Description *yankring-description* - -Vim already maintains a list of numbered registers containing the last 9 -deletes. These previous deletes can be referenced using [register]p, so -"1p will paste the last delete, "2p the 2nd last delete. For more -information see |quote_number|. - -Vim does not provide any mechanism to reference previously yanked text. -In Emacs this feature is called the "kill ring". - -The YankRing plugin allows the user to configure the number of yanked -and deleted text. After text has been pasted, it can be replaced with -a previous value from the yankring. - -As of version 3.0, the yankring's content will persist (by default) -between starting and stopping Vim. - -The plugin can be toggled on and off, and supports: - Ranges - Registers - Counts - All visual modes - All motions - All text-objects - -If you have any suggestions for the improvement of this plugin, see the -yankring.vim file for my email address. Suggestions / bug reports are -always welcome. - -For details on the changes between versions see |yankring-history|. - -============================================================================== -3. Configuration *yankring-configure* - -The YankRing allows the user to choose which keys are to be assigned to -the various commands. By default, the YankRing chose keys identical -with Vim's standard behaviour/keys. - -3.1 Global Variables *yankring-globals* - -You can customize the YankRing by setting various global variables in -your |.vimrc|. -> - yankring_max_history -< Default: 100 - Controls how many elements to save in the yankring. > - let g:yankring_max_history = 100 - yankring_min_element_length -< Default: 1 - If the yanked element has a length less than this value - if will not be added to the YankRing. This can be useful if - you want to bypass single letter deletes by adding the - following to your .vimrc: > - let g:yankring_min_element_length = 2 - yankring_max_element_length -< Default: 1048576 (1M) - Will truncate a new entry to the specified maximum. If - g:yankring_max_element_length is set to 0, there is no limit. > - let g:yankring_max_element_length = 4194304 " 4M - yankring_max_display -< Default: 500 - When the YankRing window is opened, each element is displayed on a - separate line. Since each yank could be very large, the display of - the element is limited to the above default. > - let g:yankring_max_display = 70 - yankring_enabled -< Default: 1 - If you do not want to YankRing enabled by default, set this - variable in your |vimrc|. > - let g:yankring_enabled = 0 " Disables the yankring - yankring_persist -< Default: 1 - If you have enabled the storing of global variables in the |viminfo| - file, the YankRing will be default persist the contents of the ring - between starting and stopping Vim. To disable this feature: > - let g:yankring_persist = 0 - yankring_share_between_instances -< Default: 1 - By default, any instance of Vim will share the same yankring - history file. But if want each instance to have their own history - you can set this option to 0. Setting g:yankring_persist = 0 and - g:yankring_share_between_instances = 0 will ensure no 2 instances - of Vim share the same YankRing history AND the history is not - remembered the next time Vim is started. > - let g:yankring_share_between_instances = 0 - yankring_dot_repeat_yank -< Default: Based on the Vim cpoption setting - By default Vim will not repeat (using '.') yanking of text. This can - be controlled via the |'cpoptions'| setting. The YankRing now respects - the cpoptions setting, if 'y' is included and you press '.', the - previous yank command is repeated and added to the yankring. - You can also add this behaviour by setting this in your |vimrc|: > - let g:yankring_dot_repeat_yank = 1 - yankring_ignore_duplicate -< Default: 1 - Duplicates will not be added to the YankRing by default. If a - duplicate is found, that element will be moved to the top of the - yankring. This can be controlled by setting this in your |vimrc|: > - let g:yankring_ignore_duplicate = 0 - yankring_map_dot -< Default: 1 - If the '.' (repeat) command should be mapped by the yankring. Since - most of the normal commands yy,dd,dw,... are mapped by the yankring, - if g:yankring_map_dot is false the . operator will not repeat these - operations. The YankRing tracks several of the internal Vim registers - and decides whether an action was the result of the YankRing or an - action outside of it. If the previous action was a result of the - yankring, it will be executed again. If it was an action outside of - the yankring, it asks Vim to repeat the command. > - let g:yankring_map_dot = 1 - yankring_paste_using_g -< Default: 1 - By default [p] and [P] are mapped to interact with the yankring. This - option controls whether [gp] and [gP] are also mapped. Setting this - option to 0 will not create these maps. > - let g:yankring_paste_using_g = 1 - yankring_window_use_separate -< Default: 1 - This is a new feature as of the 2.0 release. The YankRing now uses a - separate split buffer to display the yankring. There are many buffer - specific maps that allow you to operate over the various elements from - within the yankring. Setting this option to 0, uses the 1.0 - interface. > - let g:yankring_window_use_separate = 0 - yankring_window_auto_close -< Default: 1 - By default once you choose an option in the YankRing buffer, the - action is performed and the buffer window is closed, returning you to - the original buffer. This option can be toggled from within the - YankRing buffer by pressing [a]. The YankRing buffer status line - visually indicates where auto close is enabled or disabled. There are - many times where you need to paste (or delete) many items from the - yankring. Pressing [a], disables auto close, allows you to paste many - items, and finally you can press [a] to re-enable auto close, followed - by [q] to quit the buffer window. > - let g:yankring_window_auto_close = 1 - yankring_window_use_horiz -< Default: 1 - When the YankRing window is opened, it uses a horizontal split at the - bottom of the Vim window. It can optionally use a vertical split by - setting this option to 0. > - let g:yankring_window_use_horiz = 0 " Use vertical split - yankring_window_height -< Default: 1 - If using a horizontal split, this option controls how high to make - the window. > - let g:yankring_window_height = 8 - yankring_window_width -< Default: 1 - If using a vertical split, this option controls how wide to make the - window. > - let g:yankring_window_width = 30 - yankring_window_use_bottom -< Default: 1 - If using a horizontal split, this option control whether the window is - opened at the top or bottom of the Vim window. Setting this option to - 0 forces the window to open at the top of the Vim window. > - let g:yankring_window_use_bottom = 1 - yankring_window_use_right -< Default: 1 - If using a vertical split, this option control whether the window is - opened on the left or right side of the Vim window. To force the - window to open on the left side, set this option to 0. > - let g:yankring_window_use_right = 1 - yankring_window_increment -< Default: 1 - If using a vertical split the default width of the vertical window may - be too narrow to view enough of the elements. Pressing [] will - increase the size of the window by this number of columns. Pressing - [] again will toggle it back to the original size. > - let g:yankring_window_increment = 50 - yankring_manage_numbered_reg -< Default: 0 - Vim already maintains a list of numbered registers containing the last - yanked item and the previous 9 deletes. These items can be referenced - using [register]p, so "0p will paste the last yank, "1p will paste the - last delete, "2p the 2nd last delete. For more information see - |quote_number|. - If you wish the YankRing to maintain these numbered registers so - the top 10 elements in the YankRing are in the numbered reqisters 0-9 - you can put the following in your |vimrc| > - let g:yankring_manage_numbered_reg = 1 - yankring_ignore_operator -< Default: 'g~ gu gU ! = gq g? > < zf g@' - There are a number of Vim operations which do not change any - registers, and therefore should not be captured by the yankring. - This list is used to ignore the appropriate operators. - You can put the following in your |vimrc| > - let g:yankring_ignore_operator = 'g~ gu gU ! = gq g? > < zf g@' - yankring_history_dir -< Default: $HOME - The YankRing stores the text in a file. This global variable - allows you to customize where the file(s) will be stored. - You can put the following in your |vimrc| > - let g:yankring_history_dir = '$VIM' - yankring_history_file -< Default: 'yankring_history' - The history filename prefix can be controlled by setting this - variable. - You can put the following in your |vimrc| > - let g:yankring_history_file = 'my_yankring_history_file' - yankring_clipboard_monitor -< Default: 1 - When flipping between applications I find I often copy text - and attempt to use it inside of Vim. This is typically easy - by simply using "+p, but there are times when I will repeatedly - want to use the same text later on. By default, the YankRing - will detect when Vim regains focus and check if the clipboard - has changed since it last checked. If so, it will add the contents - of the clipboard to the YankRing. To disable this feature - you can put the following in your |vimrc| > - let g:yankring_clipboard_monitor = 0 - yankring_paste_check_default_buffer -< Default: 1 - If the default register has changed without the YankRing registering - the change the YankRing will paste the top item from the history - rather than what is currently in the default register. - This option allows you to control the behaviour. Plugins can - intentionally change the default buffer which the YankRing has - no way to noticing. To disable this feature you can put the following - in your |vimrc| > - let g:yankring_paste_check_default_buffer = 0 - -< -3.2 Default Keys *yankring-mappings* - -You can choose to override the default keys by creating these global -variables in your |vimrc|. -> - yankring_n_keys -< n - normal mode - Default Vim 7.2: - 'Y D x X' - Default Vim 7.1 and below: - 'x yy dd yw dw ye de yE dE yiw diw yaw daw y$ d$ Y D yG dG ygg dgg' - - With the introduction of some new features in Vim 7.2 it is no longer - necessary to list all cmds which the YankRing will act upon. - The yankring_n_keys only lists actions which an omap cannot be used. - Using the yankring_separator, the above list is parsed and - individual mappings are created. For each of the above normal - commands the YankRing will include the text those commands - acted upon. There are many ways to accomplish the same result - in Vim, if you do not see a common key stroke you regularly use - simply add the following to your |vimrc| with the additional - keys you wished mapped. > - let g:yankring_n_keys = 'Y D x X' - yankring_o_keys -< o - omap mode - Default: - Standard motions: 'b B w W e E d y $ G ;' - Vim text objects: ' iw iW aw aW as is ap ip a] a[ i] i[' - 'a) a( ab i) i( ib a> a< i> i< at it ' - 'a} a{ aB i} i{ iB a" a'' a` i" i'' i`' - - As of Vim 7.2 omaps are used to capture changes to the registers - in Vim. All of the standard motion commands are captured. - New to YankRing 5.0 all default Vim text objects are also - captured. - Using the yankring_separator, the above list is parsed and - individual mappings are created. For each of the above normal - commands the YankRing will include the text those commands - acted upon. There are many ways to accomplish the same result - in Vim, if you do not see a common key stroke you regularly use - simply add the following to your |vimrc| with the additional - keys you wished mapped. > - let g:yankring_o_keys = 'b B w W e E d y $ G ; iw iW aw aW' - yankring_zap_keys -< Default: 'f F t T / ?' - omaps are enough for most operations except for f and t. - These motions prompt the user for a character or string which - they should act upon. These must be treated as a special case - in YankRing. > - let g:yankring_zap_keys = 'f t' - yankring_ignore_operator -< Default: 'g~ gu gU ! = gq g? > < zf g@' - There are certain motions which do not update any registers - in Vim. If the registers are not changed, there is nothing - the YankRing can capture. This list instructs the YankRing - to ignore any action for these keys. > - let g:yankring_ignore_operator = 'g~ gu gU' - yankring_v_key -< v - visual mode - Default: y - Yanks visually select text. > - yankring_del_v_key -< n - normal mode - Default: d - The visually select text is included in the YankRing and deleted. > - yankring_paste_n_bkey -< n - normal mode - b - before - Default: P - The default Vim paste key will retrieve from the yankring. This - will paste the text BEFORE the current position. - There is a special check to see if the text in the default paste - register is the same as what is in the current position of the - yankring. If it is not, we assume the user used some other - mechanism to yank text (ie yt). If this is the case - we paste the text in the default paste buffer. Using the - text can be replaced with the current entry from the yankring. - Since there are many ways to do things in Vim, this provides - the best integration. > - yankring_paste_n_akey -< n - normal mode - a - after - Default: p - The default Vim paste key will retrieve from the yankring. This - will paste the text AFTER the current position. - There is a special check to see if the text in the default paste - register is the same as what is in the current position of the - yankring. If it is not, we assume the user used some other - mechanism to yank text (ie yt). If this is the case - we paste the text in the default paste buffer. Using the - text can be replaced with the current entry from the yankring. - Since there are many ways to do things in Vim, this provides - the best integration. > - yankring_paste_v_key -< n - normal mode - Default: p - This will replace the visually select text with the contents - from the yankring. See yankring_paste_n_akey for additional - details. > - yankring_replace_n_pkey -< n - normal mode - Default: - If you do not want to open the YankRing window to choose your - selection, then you can paste (as usual) then use a YankRing - mapping to cycle through items in the YankRing. This is especially - useful if you know you recently used the text you are looking for. - If you wish to cycle through the yankring, replacing the previously - pasted text with the previous yanked text you can repeatedly press - (or whatever keystroke you choose to map it to). This map - moves backwards through the yankring, so you will retrieve your - most recent yank. - - I prefer not to use since I like using that key to cycle - through all the matches in the QuickFix window. You can add - something similar to this in your |.vimrc| to get similar - functionality. - - On Windows use the ALT-< character to move through the YankRing. - To determine what character # these are go into insert mode - in a new buffer. Press CTRL-V then ALT and the < key. - Leave insert mode, move the cursor onto the character - and press ga. This will display the decimal, hex and octal - representation of the character. In this case it is 172. > - if has('win32') - let g:yankring_replace_n_pkey = '' - let g:yankring_replace_n_nkey = '' - " Instead map these keys to moving through items in the quickfix window. - nnoremap :cp - nnoremap :cn - endif -< Other users have also stated that this will work: > - let g:yankring_replace_n_pkey = '' - let g:yankring_replace_n_nkey = '' - yankring_replace_n_nkey -< n - normal mode - Default: - If you do not want to open the YankRing window to choose your - selection, then you can paste (as usual) then use a YankRing - mapping to cycle through items in the YankRing. This is especially - useful if you know you recently used the text you are looking for. - If you wish to cycle through the yankring, replacing the previously - pasted text with the next yanked text you can repeatedly press - (or whatever keystroke you choose to map it to). This map - moves forwards through the YankRing, so you will retrieve your - most recent yank. - - I prefer not to use since I like using that key to cycle - through all the matches in the QuickFix window. You can add - something similar to this in your |.vimrc| to get similar - functionality. - - On Windows use the ALT-> character to move through the YankRing. - To determine what character # these are go into insert mode - in a new buffer. Press CTRL-V then ALT and the > key. - Leave insert mode, move the cursor onto the character - and press ga. This will display the decimal, hex and octal - representation of the character. In this case it is 174. > - if has('win32') - let g:yankring_replace_n_pkey = '' - let g:yankring_replace_n_nkey = '' - " Instead map these keys to moving through items in the quickfix window. - nnoremap :cp - nnoremap :cn - endif -< Other users have also stated that this will work: > - let g:yankring_replace_n_pkey = '' - let g:yankring_replace_n_nkey = '' - -3.3 Customizing Maps *yankring-custom-maps* - -The YankRing plugin uses the yankring_n_keys global variable to create -a number of defaults maps. The maps are of the form: > - nnoremap Y :YRYankCount 'Y' -< -When capital Y is pressed, the YankRing will execute 'Y' and capture the -output from Vim. But there are cases where you do not want the default -behaviour of Vim, since you have customized some of these maps. - -In this case, I usually map Y to be |y$|, which makes it consistent with -the |D| and |C| operators. The way yankring_n_keys works does not allow -me to customize this behaviour. Since many people may like to customize -the behaviour of these maps the YankRing will check to see if a -function called YRRunAfterMaps() exists. If it does, it will call -this function after it has created the maps. So in my case, I created -the following function in my |vimrc|: > - function! YRRunAfterMaps() - nnoremap Y :YRYankCount 'y$' - endfunction -< -You can do anything you need in this function. > - nnoremap Y :YRYankCount 'y$' -< -This line remaps Y (which the user presses) to the YRYankCount command. The -YRYankCount tells Vim to execute y$ instead. - - -============================================================================== -4. Using the YankRing Window: *yankring-window* - -This is a new feature as of the 2.0 release. The YankRing uses a -separate split buffer to display the yankring. There are many buffer -specific maps that allow you to operate over the various elements from -within the yankring. - -To display the YankRing buffer you can issue the :YRShow command. For -convience you can map a key, , to this command: > - :nnoremap :YRShow - -Status line~ -The first line in the YankRing window is the status line. > - AutoClose=1;ClipboardMonitor=1;Cmds:p,P,d,r,s,a,c,u,q,,;Help=? -< -Help=?, pressing [?] will toggle the display of available commands the -yankring window supports. Pressing [?] again will remove the additional -items. - -AutoClose=1 indicates the window will close when an action is performed -against elements within the yankring. If you wish to perform multiple -yankring operations press [a] to toggle the auto close feature off. Use the -commands below and when finished you can press [a] to toggle auto close on and -press [q] to close the window. The Cmds displayed are simply reminders of -the available keys. - -ClipboardMonitor=1 indicates the YankRing will monitor the clipboard (+) -during Focus change events. If the clipboard has changed since the YankRing -last checked, the contents are added to the YankRing. Pressing [c] allows -you to quickly toggle this setting since it may not be useful at times. - -YankRing window key list~ -The following table lists the description of the keys that can be used -in the YankRing window. - - Key Description~ - p Puts text after the cursor. In visual mode, all elements - selected will be pasted. - P Puts text before the cursor. In visual mode, all elements - selected will be pasted. - gp Just like "p", but leave the cursor just after the new text. - gP Just like "P", but leave the cursor just after the new text. - Just like "p". - Just like "p". - <2-LeftMouse> Just like "p". Normal mode only. - d Removes the element from the yankring. In visual mode all - elements selected will be removed. - r Just like "p", but in visual mode if many lines are selected - it will paste these in reverse order. - s Prompts you for a regex to search the YankRing and display - only matching items. - a Toggles the g:yankring_window_auto_close setting. - u Updates the YankRing window. - q Closes the YankRing window. - Toggles the width of the vertical window by the - g:yankring_window_increment setting. - ? Toggles the display of the help. - - - - -============================================================================== -5. Commands: *yankring-commands* - -The predefined mappings call some specific commands with special parameters. -If you are going to create additional maps, it is important you mirror -the same parameters. Most of these commands have been made obsolete by -the YankRing window, since it incorporates the functionality below, but -through maps against a buffer, instead of commands. This makes it much easier -to use. - - -5.1 YRToggle *YRToggle* - Allows you to enable and disable the YankRing quickly. This - command will remove the default maps and recreate them. - - Examples: > - :YRToggle " Toggles it - :YRToggle 1 " Enables it - :YRToggle 0 " Disables it -< - -5.2 YRClear *YRClear* - Clears all elements from the yankring. - See also |YRClear-example|. - - -5.3 YRShow *YRShow* - Similar to |:register|, will display all the entries in the yankring. - The element at the top will be the next element pasted from the - yankring. - - Examples: > - :YRShow " Shows all entries in the yankring - - --- YankRing --- - Elem Content - 1 five^@ - 2 four^@ - 3 three^@ - 4 two^@ - 5 one^@ -< - -5.5 YRGetElem *YRGetElem* - This command has two modes. If no parameters are provided, it - becomes interactive. It uses YRShow to display the list and - allows you to choose which element to paste. If a parameter - is supplied it will paste that element from the yankring. If the - number specified is outside of the YankRing an error is returned. - You may want to create a separate mapping for this call. > - nnoremap yr :YRGetElem -< See also |YRSearch|. - - Examples: - Assume there are 10 elements in the YankRing and element 6 is - at the top of the ring. > - :YRGetElem " Interactive mode, you choose from a list - :YRGetElem 4 " Will paste element 5. - :YRGetElem 12 " Will paste element 6. - :YRGetElem 99 " Error, invalid choice is reported - :YRGetElem 0 " Error, invalid choice is reported - - -5.6 YRGetMultiple *YRGetMultiple* - Will paste many elements from the YankRing in one command. - If the number specified is 1 or less, it is assumed you want - just the current element pasted. If the number specified is - greater than or equal to the number of elements in the yankring, - it is assumed you want all elements pasted. If a ! is included - as part of the command, paste the items in reverse order. - See the |yankring-tutorial| for more examples. - - Examples: - Assume there are 10 elements in the YankRing. > - :YRGetMultiple 4 " Will paste elements 1,2,3,4 - :YRGetMultiple! 4 " Will paste elements 4,3,2,1 - :YRGetMultiple " Will paste element 1 - :YRGetMultiple 12 " Will paste elements 1,2,...,10 - :YRGetMultiple 99 " Will paste elements 1,2,...,10 - :YRGetMultiple 0 " Will paste element 1 - - -5.7 YRPush *YRPush* - Allows the user to "push" additional entries into the yankring. - If you yanked text via a key mapping which does not use the - YankRing (or there is text on the clipboard) you can use this - command to add the text to the yankring. - - Examples: > - :YRPush " Push the " register's contents - :YRPush '*' " Push the "* register's contents (clipboard) - :YRPush '+' " Push the "+ register's contents (clipboard) - :YRPush 'a' " Push the "a register's contents -< See also |YRPush-example|. - - -5.8 YRPop *YRPop* - Allows you to pop any elements from the yankring. If no parameters - are provided, the 1st element is removed from the yankring. The - command optionally takes a second parameter to specify how many - elements to pop. The default value is 1. - - Examples: > - :YRPop " Removes the highest numbered element from the - yankring - :YRPop 3 " Removes the 3rd element from the yankring - :YRPop 3,5 " Removes 5 elements from the YankRing beginning - at element 3 -< See also |YRPop-example|. - - -5.9 YRYankCount *YRYankCount* - This command has the most mappings created for it. If you are - in normal mode and you are not specifying a range, this command - will add the text to the yankring. - - The goal of this command is to allow the YankRing to be integrated - as seamlessly as possible with Vim. So it supports counts and - registers. If you create a mapping to it, you must pass as a - parameter the action you want Vim to perform. You could do the - following: > - nnoremap \test :YRYankCount 'dd' -< This map is executed when you hit the '\test' keystrokes, but - it will actually delete the current line and add it to the - yankring. - - The following are the default mappings: > - nnoremap yy :YRYankCount 'yy' - nnoremap dd :YRYankCount 'dd' - nnoremap yw :YRYankCount 'yw' - nnoremap dw :YRYankCount 'dw' - nnoremap ye :YRYankCount 'ye' - nnoremap de :YRYankCount 'de' - nnoremap yiw :YRYankCount 'yiw' - nnoremap diw :YRYankCount 'diw' - nnoremap Y :YRYankCount 'Y' - nnoremap D :YRYankCount 'D' - nnoremap y$ :YRYankCount 'y$' - nnoremap d$ :YRYankCount 'd$' - nnoremap yG :YRYankCount 'yG' - nnoremap dG :YRYankCount 'dG' -< - Examples: - yy - Adds the current line to the yankring. - dd - Adds the current line to the YankRing and deletes it. - 5yw - Adds 5 words to the yankring. - "ade - Deletes the word, and puts it into both the yankring - and the "a register. - 10"zyy - Places 10 lines into both the YankRing and the "z - register. - See also |yankring-tutorial|. - - -5.10 YRYankRange *YRYankRange* - This command by default is only called in visual mode. All - visual modes (|characterwise-visual|, |linewise-visual|, - |blockwise-visual|) are supported. Any visually selected text - is added to the yankring. You can also call this command - directly using a range. - - Examples: - Visual mode - ----------- - Press v (to enter visual mode), highlight want you want, - press y (to yank the selected area). - Repeat using V and Control-V. - - Normal mode - ----------- > - :5,20YRYankRange " Will yank lines 5-20 into the yankring - :5,20YRDeleteRange " Will delete lines 5-20 and add them to - the yankring -< See also |YRYankRange-example|. - - -5.11 YRDeleteRange *YRDeleteRange* - This command is identical to YRYankRange, except the range is - also deleted. - - -5.12 YRPaste *YRPaste* - This command will paste elements from the yankring. By default it has - been mapped to p and P to match Vim's native key strokes. The text - pasted is exactly what was yanked, including newline characters and - blockwise-visual mode behaviours. It supports counts and registers. - - Examples: - p " Paste the current element from the YankRing after the cursor - P " Paste the current element from the YankRing before the cursor - 5p " Paste the current element from the YankRing after the cursor - 5 times - "ap " Ignore the YankRing and paste the contents of register "a - 5"ap " Ignore the YankRing and paste the contents of register "a - 5 times - See also |yankring-tutorial|. - - -5.13 YRReplace *YRReplace* - The purpose of the YankRing is to gain access to previously yanked - (or deleted) elements. This command will replace the previously - paste with a different entry from the yankring. - By default, I choose (P for previous) to replace the last paste - while moving backwards through the yankring. (N for next) - replaces the last paste while moving forward through the yankring. - - Examples: - See the |yankring-tutorial| for examples. - - -5.14 YRMapsCreate *YRMapsCreate* - This public function is responsible for creating the maps which - enable the yankring. This function is called by the YRToggle - command. - - -5.15 YRMapsDelete *YRMapsDelete* - This public function removes the YankRing maps and disables - the yankring. This function is called by the YRToggle command. - - -5.16 YRSearch *YRSearch* - This command is similar to |YRGetElem|. The command takes - one parameter which is a regular expression. Similar to - YRGetElem, it will display all items in the YankRing that match - the regular expression. It is also interactive, and will - prompt you to enter which match you wish pasted. - See also |YRSearch-example|. - - -============================================================================== -6. Tutorial *yankring-tutorial* - -To understand how to use the yankring, the following example will -demonstrate the various features. Assume you have created the following -mapping: > - nnoremap :YRShow -< - Assume we have this buffer: > - one - two - three - four - five -< *YRShow-example* - Now yank (yy) each line separately starting at line 1. - Display the contents of the YankRing by executing the command - YRShow, or pressing . The contents of the YankRing is - displayed in a new buffer. The size, location and type of buffer - is configurable via various options. See section 3 for more details. > - :YRShow or F11 - --- YankRing --- - Elem Content - 1 five^@ - 2 four^@ - 3 three^@ - 4 two^@ - 5 one^@ -< Since we yanked the text starting at line 1 and finishing at - line 5, the most current YankRing element is the last one, the - contents of line 5. "five^@" is displayed, the "^@" is a - newline character (since we issued a "yy"). - - *yankring-window-example* - At this point, you have two options. You can choose which element - from the YankRing you wish to paste and press or 'p' or 'P' - and a variety of other options, see |yankring-window|. After pressing - the key, the YankRing window will close (default behaviour). Pressing - '?' will display additional help for the commands that are active within - the YankRing window. Pressing '?' will toggle the help. - - You do not need to interact with the YankRing using the YankRing window. - Using the window makes many tasks must easier, but for speed using some - of the other maps can be preferrable if you know what you have yanked / - deleted recently. It was designed to work with Vim in the usual manner. - You can press, 'p', to paste the last item in yanked or deleted. - - Close the YankRing window by pressing 'q' or F11 (which toggles it). - - *YRReplace-example* - Now, go to the end of the file and press 'p'. The resulting - buffer appears as: > - one - two - three - four - five - five -< - Assume you did not want 'five", but a different entry from within the - yankring. moves backwards through the yankring, it will replace - the previous pasted text with a different item from the yankring. This - allows you to quickly iterate through different elements. is the - default mapping, this can be user defined. See the following options for - more details: > - yankring_replace_n_nkey, yankring_replace_n_pkey -< - After pressing the buffer results in: > - one - two - three - four - five - four -< Now press 2. This would be the same as pressing - two times in a row. This results in: > - one - two - three - four - five - two -< Now press to move forwards through the yankring, - this results in: > - one - two - three - four - five - three -< Display the contents of the yankring. > - :YRShow - --- YankRing --- - Elem Content - 1 five^@ - 2 four^@ - 3 three^@ - 4 two^@ - 5 one^@ -< - Now lets yank some text with a key stroke that has not been - mapped to the yankring. Place your cursor at the start of - line 4. Press 'ytr', yank-to-(to the character r), which yanks - the 'fou' letters (no newline character). Now press p. Here is - the result: > - one - two - three - ffouour - five - three -< This is good, even though the keys 'ytr' has not been mapped - to YRYankCount, the YankRing still pasted the most recently - yanked text. Since the text did not have a newline character - the 'fou' was inserted after the 'f'. - - Now replace that previous paste with the current element from - the YankRing by pressing . This is the result: > - one - two - three - four - one - five - three -< The #1 entry in the YankRing is still the line "five@". When - choosing the next entry, it wraps around to the last entry in - the yankring, element #5. The 'fou' was replaced with 'one^@'. - Since it had a newline character in it (when it was yanked) the - newline is included when it is pasted. - - *YRPush-example* - Assume you need to paste text from the system clipboard, and this - is text you will need routinely. We can simulate this by running - this command (see |quote+|): > - :let @+ = "From the clipboard\n" - :echo @+ - -< With the cursor at the start of the line with the word 'five', press 'p'. - We still have pasted the 'fou' which is in the default paste buffer. > - one - two - three - four - two - ffouive - three -< We have the option of getting the text from the clipboard directly - with the following. > - First undo the previous change - u - Next - "+p -< The line changes since we bypassed the yankring, and specified - which register to get the text from: > - four - five - From the clipboard - three -< replaces this with the #1 entry in the yankring: > - four - five - five - three -< Now add the contents of the clipboard to the yankring: > - :YRPush '+' -< Move the cursor to the last row 'three' and press 'p'. The result is: > - four - five - one - three - From the clipboard -< YRPush '+' adds the value of the register '+' to the yankring, but it - also adds its contents to the default Vim paste buffer. So pressing - 'p' pasted this text. Adding a new value to the YankRing we have - repositioned it which you can see with: > - :YRShow or F11 - --- YankRing --- - Elem Content - 1 From the clipboard^@ - 2 five^@ - 3 four^@ - 4 three^@ - 5 two^@ - 6 one^@ -< *YRClear-example* - Now we will clear the yankring, and begin over again. Delete all lines - from the buffer and replace them with the original rows: > - one - two - three - four - five -< Now run this command to clear the YankRing to start over: > - :YRClear -< - Issue a 'yy' on each of the 5 lines. If you run the YRShow command you - should see the following: > - :YRShow or F11 - --- YankRing --- - Elem Content - 1 five^@ - 2 four^@ - 3 three^@ - 4 two^@ - 5 one^@ -< *any-item-example* - If you need to quickly browse the YankRing to determine which element you - wish to paste you can simply press 'p' or or on any element - displayed in the YankRing window. Press '?' for more detailed description - of the commands available. - - Using the YankRing window can be much faster if you do not want to cycle - through the YankRing using and to find the element. - - *multiple-items-example* - There are times when you need to move through a buffer capturing many - different lines (or snippets of code) and eventually want to switch - buffers and paste these elements. With some advance planning you can do - this without the YankRing by issuing commands of the form: > - "ayy - "Ayy -< When specifying the register using UPPERCASE, Vim appends the yanked text - to register "a, instead of replacing it. Many times you forget the - advance planning (or didn't even know about this great feature) you can - use the YankRing window to do this easily. If this is the current - yankring: > - :YRShow or F11 - --- YankRing --- - Elem Content - 1 five^@ - 2 four^@ - 3 three^@ - 4 two^@ - 5 one^@ -< The YankRing works in |visual-mode|. To demonstrate move the cursor in - the buffer to the line with 'two'. Press 'F11' to display the yankring - window. Move the cursor to element 2, press 'V' to enable - |linewise-visual| mode and then press 'j' twice. This should have - visually highlighted elements 2,3,4. Press 'p' to paste all the - highlighted elements: > - one - two - four - three - two - three - four - five -< You can see here it has pasted four, three, two after the second line of - the buffer. Now press 'u' to undo our last change. Leave the cursor - on the second line 'two'. Press 'F11' to show the YankRing again. - Visually select the same lines, but this time press 'r' instead of 'p'. - 'r' is for reverse, so it will paste the following: > - one - two - two - three - four - three - four - five -< - *YRGetMultiple-example* - The same behaviour listed above (by visually selecting items in the - YankRing window) can be achieved using the YRGetMultiple command. - Assume there are 10 elements in the YankRing. > - :YRGetMultiple 4 " Will paste elements 1,2,3,4 - :YRGetMultiple! 4 " Will paste elements 4,3,2,1 - :YRGetMultiple " Will paste element 1 - :YRGetMultiple 12 " Will paste elements 1,2,...,10 - :YRGetMultiple 99 " Will paste elements 1,2,...,10 - :YRGetMultiple 0 " Will paste element 1 -< - *YRSearch-example* - The default size of the YankRing is 100 elements. It can be - tedious searching through the YankRing to find the element you - need. YRSearch is similar to YRShow except it will limit the - items displayed to only those items matching the regex provided. > - :YRShow - --- YankRing --- - Elem Content - 1 Three Mississippi - 2 Two Mississippi - 3 One Mississippi - 4 @", '\\/.*$^~[]' ) - :YRSearch Mississippi - --- YankRing --- - Elem Content - 1 Three Mississippi - 2 Two Mississippi - 3 One Mississippi -< Consider some items which require escaping the search string: > - :YRSearch @", '\\ - --- YankRing --- - Elem Content - 1 @", '\\/.*$^~[]' ) -< Forward slashes and various other symbols require escapes, in this - case the slash was not escaped enough: > - :YRSearch @", '\\/ - --- YankRing --- - Elem Content -< There are enough escapes this time: > - :YRSearch @", '\\\\/ - --- YankRing --- - Elem Content - 1 @", '\\/.*$^~[]' ) -< Period, star, dollar and so on require one slash: > - :YRSearch @", '\\\\/\.\*\$\^\~\[\] - --- YankRing --- - Elem Content - 1 @", '\\/.*$^~[]' ) - -< *YRPop-example* - You can remove any element from the YankRing by pressing pressing 'd' from - within the YankRing window. Visual mode is also supported to remove more - than one element at a time. > - :YRShow - --- YankRing --- - Elem Content - 1 four^@ - 2 three^@ - 3 two^@ - 4 one^@ -< Visually select elements 2,3. Press 'd', the result is: > - :YRShow - --- YankRing --- - Elem Content - 1 four^@ - 2 one^@ - -< *yankring-visual-example* - There are 3 visual modes and all are supported. Any visually selected - text is added to the yankring. You can try the various modes. Move - the cursor to inside the buffer (not the YankRing window). - - |characterwise-visual| - Go to line 1, press 'v' and move using the cursor keys until you have - highlighted some text. Then press y to yank the visually selected - area. Pressing p with paste the yanked region. - - |linewise-visual| - Go to line 2, press 'V' and move using the cursor keys until you have - highlighted some text. Notice the entire line is selected (including - the carriage returns). Then press y to yank the visually selected - area. Pressing p with paste the yanked region. - - |blockwise-visual| - Go to line 3 column 4, press CTRL-V and move to the right using the - cursor keys until you have highlighted some text. Then press y to - yank the visually selected area. Pressing p with paste the yanked - region. Notice the pasted text retained its blockwise visual - characteristics. - - *YRYankRange-example* - YRYankRange is called during visual modes, but it is also possible to - use this via the command line. > - :1,4YRYankRange - :3,$YRDeleteRange - :YRShow -< - *global-example* - Using Vim's |:global| command can be very useful at times. The example - adds all rows (in a buffer) to the YankRing if they have a certain - phrase: > - :g/addme/YRYankCount 'yy' -< This is the breakdown for the above command: > - :g - for each line in the buffer - /addme - check if the string "addme" is in the line - /YRYankCount 'yy' - Ask the YankRing to execute the 'yy' command - - -============================================================================== -7. History *yankring-history* - - 10.0: January 31, 2010 - NF: Change the buffer name to [YankRing] to resemble other - non-user buffers. - NF: Added g:yankring_min_element_length which can prevent - items from being added to the YankRing if they are too small. - For example, single character deletes (Vedran M). - BF: When shifting focus back to Vim, the YankRing may incorrectly - report: "YR:Failed to change to the yankring buffer, - please contact author". - BF: When entering Vim for the first time and hitting "p" - nothing was pasted (Mark Huiskes). - BF: When entering Vim for the first time and the - yankring_clipboard_monitor = 1, the clipboard entry - was not automatically added to the yankring. - BF: When overriding the default and setting - g:yankring_window_use_bottom = 0, the YankRing would - report the error (Sergey Khorev): - E21: Cannot make changes, 'modifiable' is off - - 9.0: August 29, 2009: - BF: You cannot execute a macro with ":normal @a". It is still - not possible, but you can execute it with ":normal! @a" - (A S Budden). - BF: When g:yankring_persist = 0 the YankRing could go into - an infinite loop (A S Budden). - BF: When replaying a macro which used any of the zap - keys (f,F,t,T,/,?) you were prompted again for the - string to match on (Ovidiu C). - BF: When checking the clipboard for changes - (g:yankring_clipboard_monitor == 1) only add the item - if it is not already in the ring. Previously, the item - was moved to the top of the YankRing each time you flipped - focus. - - 8.0: December 21, 2008: - NF: Changed the implementation of YRGetSearch() (David Liang). - BF: Under some unknown circumstances, the yankring can fail - to change to the correct buffer. Put in code to double - check and abort. - BF: Yanking and pasting a line which ends in a backslash - resulted in the backslash being replaced by "@@@". - BF: When repeating a command (".") which used any of the zap - keys (f,F,t,T,/,?) you were prompted again for the - string to match on (Vasilii Pascal). - - 7.0: November 14, 2008: - NF: Added support for the / and ? motions so that y/search is - supported (Vasilii Pascal). - NF: When the YankRing window is displayed (or updated) an additional - check is made against the default register. If it has changed - since the YankRing recorded it, the value will be added to the - history. - NF: Added support for more motions h, j, k, l, H, M, L, ^, 0, -, +, _. - And a pile of g motions g_, g^, gm, g$, gk, gj, gg, ge, gE. - NF: The YankRing window will display a message it is operating - in a limited mode if not using Vim 7.2 or the correct patch - level. - BF: Correction to some internal code which could lead to an - endless loop (John Beckett). - BF: Opening and closing the YankRing window with "set report=0" - reported "1 line less" messages (Bill McCarthy). - BF: Changed the default value of g:yankring_paste_check_default_buffer - to check if the default paste buffer has changed when pressing - 'p'. For example, if a plugin has changed the default registers - it will be pasted rather than the top item from the YankRing. - BF: YRMapsDelete did not remove all the maps created by the YankRing. - BF: Under particular circumstances, yanking text with embedded @ - characters were not properly stored and retrieved from the - YankRing (Andrew Long). - BF: Changed to use xmaps instead of vmaps so that the maps only work - in visual mode and not select mode (David Liang). - - 6.1: October 31, 2008: - BF: If the g:yankring_history_dir contains spaces (default on - Windows) an error was reported. A simple work around was to - let g:yankring_history_dir = 'c:\Vim' or no spaces (Matt). - - 6.0: October 25, 2008: - NF: The YankRing now maintains the history in a file. This means - if you are running multiple instances of Vim, they all see - the same yankring. - NF: The location and name of the file is configurable by the user. - NF: The g:yankring_separator is no longer used and has been removed. - NF: The g:yankring_max_element_length can be used to limit the size - of an element in the yankring. - NF: The g:yankring_share_between_instances can be used to indicate - whether each instance of Vim running on a machine should share - the history file or whether each should have their own - individual history file. - NF: The g:yankring_clipboard_monitor can be used to indicate - whether changes to the system clipboard should be added to the - YankRing (default is on). - NF: The YankRing window can toggle the clipboard monitor by pressing - 'c'. See the help in the window by pressing ?. - NF: Added some highlighting to the YankRing window (Marty Grenfell). - - 5.0: September 21, 2008: - NF: The YankRing can recognize certain Vim commands which do not - change the contents of a buffer and not attempt to capture it. - NF: The global variables which allow you to customize the behaviour - are now space separated instead of comma separated. This - provides greater flexibility but will require you to modify - your vimrc (if you have customized it). (Andy Wokula) - BF: If using from within insert mode, the YankRing inserted - characters into the buffer instead of capturing the changes, - this was fixed by Andy Wokula (Agathoklis Hatzimanikas). - BF: The YankRing did not properly account for all the different - forms of counts "5yy" worked but "y5y" did not (Edwin Shao). - - 4.1: August 9, 2008: - NF: The YankRing now allows you to override which operators should - be ignored (yankring_ignore_operator). By default this is - set for the standard Vim operators which do not modify any - registers (Examples: = and gu) (Andy Wokula). - NF: The YankRing did not map v_x (Matt Tolton). - BF: The expression register (quote=) was not accounted for correctly - (Agathoklis Hatzimanikas). - BF: Using the v:operator variable must be escaped when used in - a regular expression. - - 4.0: June 24, 2008: - NF: The YankRing by default now captures all |text-objects| and - all motions (|motion.txt|) which Vim supports. Version 3.0 only - supported a subset of the basic motion commands. - NF: Prior to this version only predefined maps triggered the - capture of data into the yankring. These maps only supported - yanks and deletes. The YankRing now also supports - operator-pending mode, which allows a greater range of operations - to be automatically captured and added to the yankring. - Operating pending mode functionality requires Vim 7.2 or Vim 7.1 - with patch #205. If using Vim 7.1 you can determine this with: - echo has("patch205") - NF: Prior to this version only yanks and deletes were registered - in the yankring. Changes are now also captured into the - yankring. - NF: The YankRing will also capture the system cliboard when focus is - returned to the vim window. This is useful if you copy text - between applications. - NF: The YankRing window always opened bottom horizontal. Now it - can be opened top or bottom and horizontal or vertically. - This can be controlled via variables in your .vimrc. - BF: The YankRing has an option to persist between instances - of Vim by storing the values in global variables within - the viminfo. This has led to some unusual ordering of - items in the ring from conflicts between instances. - This option has been turn off by default. - BF: Their was an issue with yanking using y$. - - 3.1: September 10, 2007: - NF: YRClear will now unlet all global variables it uses to store - the data if the persist storage is specified (the default). - Large values in the viminfo file could possibly affect other - applications. - - 3.0: September 7, 2007: - NF: Converted the YankRing to use the new Vim7's List object which - means it is no longer compatible with Vim6. - NF: By default the YankRing will now maintain the yankring's items - persistently by default. It does this via the |viminfo| file. - This means the contents of the YankRing rely on the internal - variables of only 1 Vim instance. - BF: YRToggle was not unmapping 'gp' and 'gP'. - BF: YRSearch prompted the user for a regex even if one was provided - on the command line. - BF: If g:yankring_manage_numbered_reg is enabled, the "." operator - did not correctly repeat the previous action (Pedro DeRose). - - 2.2: November 1, 2005: - NF: Added 'x' to the list of yankring_n_keys. This is very useful - in visual mode since it can delete a lot of characters. - - 2.2: October 19, 2005: - BF: If you pressed '?' to toggle the display of the help in the - YankRing window, the window would close. This also applied to - 'a', which allowed you to toggle the autoclose feature. - - 2.1: October 11, 2005: - NF: Added the ability for the YankRing to override Vim's numbered - registers. Instead of the numbered registers holding the last - yanked value, and the 9 previous deletes, they will now reflect - the top 10 items in the yankring. This allows you to reference - them directly with "5p. - - 2.0: August 20, 2005: - NF: Much improved usability, the YankRing now has a "GUI" to service - the yankring. If YRShow or YRSearch is used, a split buffer is - opened which displays all the elements in the yankring. There - are a number of maps that allow you to interact with the - contents. The window can be positioned vertically or - horizontally as well as being sized all through options - specified in your vimrc. - NF: YRPop can now delete any items from the yankring, rather - that just from the top. - NF: YRSetTop has been removed, it is no longer required as the - internal representation of the YankRing has changed. - BF: If g:yankring_ignore_duplicate is set (which is the default) - you could get some unpredicable results when moving - backwards and forwards ( and ) through the - previous values. - - 1.7: June 10, 2005: - BF: The expression register support added in version 1.6 used - getreg('='), which has the side effect of executing the - expression register. Depending on what was in the register - this could have unusual results. Changed to use histget(). - - 1.6: April 20, 2005: - NF: YRSearch is similar to YRGetElem. Given a regular expression - it will interactively display all the elements in the yankring - that match the regular expression. You can enter the number - of the element to paste it. If you have many elements within - the yankring, this can help you identify them more easily. - NF: Updated the default history size from 30 to 100, which is - partially the reason for the YRSearch command. - NF: By default it supports "gp" and "gP", in addition to "p" and "P". - NF: Added support for the expression register (:h quote=). Here - is an example of how it is used: - "="X"P - - 1.5: March 30, 2005: - NF: The YankRing now respects the cpoptions setting, if 'y' is - included and you press '.', the previous yank command is executed - and added to the yankring. You can also add this behaviour by - setting this in your |vimrc|: > - let g:yankring_dot_repeat_yank = 1 -< NF: Duplicates will not be added to the YankRing by default. If - a duplicate is found, the element will be moved to the top - of the yankring. This can be controlled by setting this in - your |vimrc|: > - let g:yankring_ignore_duplicate = 0 (1 is default) -< BF: Regression from version 1.4, the '.' operator may incorrectly - insert garbage. - - 1.4: March 28, 2005: - NF: YRToggle has been updated. If you toggle the YankRing off - (disable) the maps it creates are removed. Calling YRToggle - again will recreate the maps. This truly disables the yankring, - where the previous version attempted to do this via code. - BF: Using the '.' operator was not correctly replaying operations - that did not move text in some way (g~t_) changed the case - of the text but a '.' did not replay it. - BF: When replacing previously pasted text the YankRing did not - respect what key was used to paste the text originally. - All replaced items were pasted using 'p', even if you had - originally pasted the text with 'P'. - - 1.3: March 16, 2005: - BF: The '.' operator did not handle the <<, >> shift operator. - Pressing '.' would result in the previous YankRing operation - instead of repeating the shift. - - 1.2: March 14, 2005: - NF: Added support for '.' operator to repeat the last change. - NF: Changed YRGetElem to show the contents of the yankring - and allow you to choose which element you want pasted. - It is only interactive if you do not provide a parameter. - NF: Added 'ygg,dgg' default maps by extending the yankring_n_keys - variable. - - 1.1: March 09, 2005: - NF: Added support for the black hole register |quote_|. - NF: Custom Maps allows the user to more finely tune the yankring - maps to perform whatever action they require. This function, - YRRunAfterMaps(), is run automatically after the YankRing - creates it's default mappings. See |yankring-custom-maps|. - NF: Added some more default maps by extending the yankring_n_keys - variable. It now contains: - yy,dd,yw,dw,ye,de,yE,dE,yiw,diw,yaw,daw,y$,d$,Y,D,yG,dG - NOTE: You can easily extend these default mappings by - creating this global variable in your |vimrc|, you do not - have to wait for the plugin to be updated. - NF: Added support for Dr. Chips GetLatestVimScripts plugin. - BF: The check for g:yankring_n_keys was incorrect, so it was not - possible to override the default maps. - - 1.0: March 08, 2005: - NF: Initial release. - -vim: ts=4 ft=help tw=78 diff --git a/sources_forked/yankring/plugin/yankring.vim b/sources_forked/yankring/plugin/yankring.vim deleted file mode 100755 index 769dcd6d..00000000 --- a/sources_forked/yankring/plugin/yankring.vim +++ /dev/null @@ -1,2461 +0,0 @@ -" yankring.vim - Yank / Delete Ring for Vim -" --------------------------------------------------------------- -" Version: 10.0 -" Authors: David Fishburn -" Last Modified: 2010 Jan 24 -" Script: http://www.vim.org/scripts/script.php?script_id=1234 -" Based On: Mocked up version by Yegappan Lakshmanan -" http://groups.yahoo.com/group/vim/post?act=reply&messageNum=34406 -" License: GPL (Gnu Public License) -" GetLatestVimScripts: 1234 1 :AutoInstall: yankring.vim - -if exists('loaded_yankring') || &cp - finish -endif - -if v:version < 700 - echomsg 'yankring: You need at least Vim 7.0' - finish -endif - -let loaded_yankring = 100 - -let s:yr_has_voperator = 0 -if v:version > 701 || ( v:version == 701 && has("patch205") ) - let s:yr_has_voperator = 1 -endif - -if !exists('g:yankring_history_dir') - let g:yankring_history_dir = expand('$HOME') -else - let g:yankring_history_dir = expand(g:yankring_history_dir) -endif - -if !exists('g:yankring_history_file') - let g:yankring_history_file = 'yankring_history' -endif - -" Allow the user to override the # of yanks/deletes recorded -if !exists('g:yankring_max_history') - let g:yankring_max_history = 100 -elseif g:yankring_max_history < 0 - let g:yankring_max_history = 100 -endif - -" Specify the minimum length of 1 entry -if !exists('g:yankring_min_element_length') - let g:yankring_min_element_length = 1 -endif - -" Specify the maximum length of 1 entry (1MB default) -if !exists('g:yankring_max_element_length') - let g:yankring_max_element_length = 1048576 -endif - -" Allow the user to specify if the plugin is enabled or not -if !exists('g:yankring_enabled') - let g:yankring_enabled = 1 -endif - -" Specify max display length for each element for YRShow -if !exists('g:yankring_max_display') - let g:yankring_max_display = 0 -endif - -" Check if yankring should persist between Vim instances -if !exists('g:yankring_persist') - let g:yankring_persist = 1 -endif - -" Check if yankring share 1 file between all instances of Vim -if !exists('g:yankring_share_between_instances') - let g:yankring_share_between_instances = 1 -endif - -" Specify whether the results of the ring should be displayed -" in a separate buffer window instead of the use of echo -if !exists('g:yankring_window_use_separate') - let g:yankring_window_use_separate = 1 -endif - -" Specifies whether the window is closed after an action -" is performed -if !exists('g:yankring_window_auto_close') - let g:yankring_window_auto_close = 1 -endif - -" When displaying the buffer, how many lines should it be -if !exists('g:yankring_window_height') - let g:yankring_window_height = 8 -endif - -" When displaying the buffer, how many lines should it be -if !exists('g:yankring_window_width') - let g:yankring_window_width = 30 -endif - -" When displaying the buffer, where it should be placed -if !exists('g:yankring_window_use_horiz') - let g:yankring_window_use_horiz = 1 -endif - -" When displaying the buffer, where it should be placed -if !exists('g:yankring_window_use_bottom') - let g:yankring_window_use_bottom = 1 -endif - -" When displaying the buffer, where it should be placed -if !exists('g:yankring_window_use_right') - let g:yankring_window_use_right = 1 -endif - -" If the user presses , toggle the width of the window -if !exists('g:yankring_window_increment') - let g:yankring_window_increment = 50 -endif - -" Controls whether the . operator will repeat yank operations -" The default is based on cpoptions: |cpo-y| -" y A yank command can be redone with ".". -if !exists('g:yankring_dot_repeat_yank') - let g:yankring_dot_repeat_yank = (&cpoptions=~'y'?1:0) -endif - -" Only adds unique items to the yankring. -" If the item already exists, that element is set as the -" top of the yankring. -if !exists('g:yankring_ignore_duplicate') - let g:yankring_ignore_duplicate = 1 -endif - -" Vim automatically manages the numbered registers: -" 0 - last yanked text -" 1-9 - last deleted items -" If this option is turned on, the yankring will manage the -" values in them. -if !exists('g:yankring_manage_numbered_reg') - let g:yankring_manage_numbered_reg = 0 -endif - -" Allow the user to specify what characters to use for the mappings. -if !exists('g:yankring_n_keys') - " 7.1.patch205 introduces the v:operator function which was essential - " to gain the omap support. - if s:yr_has_voperator == 1 - " Use omaps for the rest of the functionality - let g:yankring_n_keys = 'Y D x X' - else - let g:yankring_n_keys = 'x yy dd yw dw ye de yE dE yiw diw yaw daw y$ d$ Y D yG dG ygg dgg' - endif -endif - -" Allow the user to specify what operator pending motions to map -if !exists('g:yankring_o_keys') - " o-motions and text objects, without zap-to-char motions - let g:yankring_o_keys = 'b B w W e E d h j k l H M L y G ^ 0 $ , ;' - let g:yankring_o_keys .= ' g_ g^ gm g$ gk gj gg ge gE - + _ ' - let g:yankring_o_keys .= ' iw iW aw aW as is ap ip a] a[ i] i[ a) a( ab i) i( ib a> a< i> i< at it a} a{ aB i} i{ iB a" a'' a` i" i'' i`' -endif - -if !exists('g:yankring_zap_keys') - let g:yankring_zap_keys = 'f F t T / ? @' -endif - -" Allow the user to specify what operator pending motions to map -if !exists('g:yankring_ignore_operator') - let g:yankring_ignore_operator = 'g~ gu gU ! = gq g? > < zf g@' -endif -let g:yankring_ignore_operator = ' '.g:yankring_ignore_operator.' ' - -" Whether we should map the . operator -if !exists('g:yankring_map_dot') - let g:yankring_map_dot = 1 -endif - -" Whether we sould map the "g" paste operators -if !exists('g:yankring_paste_using_g') - let g:yankring_paste_using_g = 1 -endif - -if !exists('g:yankring_v_key') - let g:yankring_v_key = 'y' -endif - -if !exists('g:yankring_del_v_key') - let g:yankring_del_v_key = 'd x' -endif - -if !exists('g:yankring_paste_n_bkey') - let g:yankring_paste_n_bkey = 'P' -endif - -if !exists('g:yankring_paste_n_akey') - let g:yankring_paste_n_akey = 'p' -endif - -if !exists('g:yankring_paste_v_bkey') - let g:yankring_paste_v_bkey = 'P' -endif - -if !exists('g:yankring_paste_v_akey') - let g:yankring_paste_v_akey = 'p' -endif - -if !exists('g:yankring_paste_check_default_buffer') - let g:yankring_paste_check_default_buffer = 1 -endif - -if !exists('g:yankring_replace_n_pkey') - let g:yankring_replace_n_pkey = '' -endif - -if !exists('g:yankring_replace_n_nkey') - let g:yankring_replace_n_nkey = '' -endif - -if !exists('g:yankring_clipboard_monitor') - let g:yankring_clipboard_monitor = (has('clipboard')?1:0) -endif - -if !exists('g:yankring_default_menu_mode') - let g:yankring_default_menu_mode = 3 -endif - -" Script variables for the yankring buffer -let s:yr_buffer_name = '[YankRing]' -let s:yr_buffer_last_winnr = -1 -let s:yr_buffer_last = -1 -let s:yr_buffer_id = -1 -let s:yr_search = '' -let s:yr_remove_omap_dot = 0 -let s:yr_history_version = 'v2' -let s:yr_history_v1_nl = '@@@' -let s:yr_history_v1_nl_pat = '\%(\\\)\@ 0 - let new_state = ((a:1 == 1) ? 1 : 0) - endif - - " YRToggle accepts an integer value to specify the state - if new_state == g:yankring_enabled - return - elseif new_state == 1 - call s:YRMapsCreate() - else - call s:YRMapsDelete() - endif -endfunction - - -" Enables or disables the yankring -function! s:YRDisplayElem(disp_nbr, script_var) - if g:yankring_max_display == 0 - if g:yankring_window_use_separate == 1 - let max_display = 500 - else - let max_display = g:yankring_window_width + - \ g:yankring_window_increment - - \ 12 - endif - else - let max_display = g:yankring_max_display - endif - - let elem = matchstr(a:script_var, '^.*\ze,.*$') - if s:yr_history_version == 'v1' - " v1 - " let elem = substitute(elem, '\%(\\\)\@max_display)? - \ (strpart(elem,0,max_display). - \ '...'): - \ elem - \ ) - \ ) - - return "" -endfunction - - -" Enables or disables the yankring -function! s:YRShow(...) - " If no parameter was provided assume the user wants to - " toggle the display. - let toggle = 1 - if a:0 > 0 - let toggle = matchstr(a:1, '\d\+') - endif - - if toggle == 1 - if bufwinnr(s:yr_buffer_id) > -1 - " If the YankRing window is already open close it - exec bufwinnr(s:yr_buffer_id) . "wincmd w" - hide - - " Switch back to the window which the YankRing - " window was opened from - if bufwinnr(s:yr_buffer_last) != -1 - " If the buffer is visible, switch to it - exec s:yr_buffer_last_winnr . "wincmd w" - endif - - return - endif - endif - - " Reset the search string, since this is automatically called - " if the yankring window is open. A previous search must be - " cleared since we do not want to show new items. The user can - " always run the search again. - let s:yr_search = "" - - " It is possible for registers to be changed outside of the - " maps of the YankRing. Perform this quick check when we - " show the contents (or when it is refreshed). - if g:yankring_paste_check_default_buffer == 1 - let save_reg = 0 - let register = ((&clipboard=='unnamed')?'+':'"') - - if &clipboard == 'unnamed' && getreg('+') != s:yr_prev_clipboard - let save_reg = 1 - endif - if register == '"' && getreg('"') != s:yr_prev_reg_unnamed - let save_reg = 1 - endif - - if save_reg == 1 - " The user has performed a yank / delete operation - " outside of the yankring maps. Add this - " value to the yankring. - call YRRecord(register) - endif - endif - - " List is shown in order of replacement - " assuming using previous yanks - let output = "--- YankRing ---\n" - let output = output . "Elem Content\n" - - call s:YRHistoryRead() - let disp_item_nr = 1 - for elem in s:yr_history_list - let output = output . s:YRDisplayElem(disp_item_nr, elem) . "\n" - let disp_item_nr += 1 - endfor - - if g:yankring_window_use_separate == 1 - call s:YRWindowOpen(output) - else - echo output - endif -endfunction - - -" Used in omaps if a following character is required -" like with motions (f,t) -function! s:YRGetChar() - let msg = "YR:Enter character:" - echomsg msg - let c = getchar() - if c =~ '^\d\+$' - let c = nr2char(c) - echomsg msg.c - endif - return c -endfunction - - -" Used in omaps if a following string is required -" like with motions (/,?) -" function! s:YRGetSearch() -" " let msg = "YR:Enter string:" -" " echomsg msg -" let str = input("YR:Enter string:") -" " let str = '' -" " while 1==1 -" " let c = getchar() -" " if c =~ '^\d\+$' -" " let c = nr2char(c) -" " if c == "\" -" " return c -" " endif -" " if c == "\" -" " break -" " endif -" " let str = str.c -" " echomsg msg.str -" " else -" " break -" " endif -" " endwhile -" return str -" endfunction - - -" Paste a certain item from the yankring -" If no parameter is provided, this function becomes interactive. It will -" display the list (using YRShow) and allow the user to choose an element. -function! s:YRGetElem(...) - if s:yr_count == 0 - call s:YRWarningMsg('YR: yankring is empty') - return -1 - endif - - let default_buffer = ((&clipboard=='unnamed')?'+':'"') - - let direction = 'p' - if a:0 > 1 - " If the user indicated to paste above or below - " let direction = ((a:2 ==# 'P') ? 'P' : 'p') - if a:2 =~ '\(p\|gp\|P\|gP\)' - let direction = a:2 - endif - endif - - " Check to see if a specific value has been provided - let elem = 0 - if a:0 > 0 - " Ensure we get only the numeric value (trim it) - let elem = matchstr(a:1, '\d\+') - let elem = elem - 1 - else - " If no parameter was supplied display the yankring - " and prompt the user to enter the value they want pasted. - call s:YRShow(0) - - if g:yankring_window_use_separate == 1 - " The window buffer is used instead of command line - return - endif - - let elem = input("Enter # to paste:") - - " Ensure we get only the numeric value (trim it) - let elem = matchstr(elem, '\d\+') - - if elem == '' - " They most likely pressed enter without entering a value - return - endif - - let elem = elem - 1 - endif - - if elem < 0 || elem >= s:yr_count - call s:YRWarningMsg("YR: Invalid choice:".elem) - return -1 - endif - - let default_buffer = ((&clipboard=='unnamed')?'+':'"') - call setreg(default_buffer - \ , s:YRGetValElemNbr((elem), 'v') - \ , s:YRGetValElemNbr((elem), 't') - \ ) - exec "normal! ".direction - - " Set the previous action as a paste in case the user - " press . to repeat - call s:YRSetPrevOP('p', '', default_buffer, 'n') - -endfunction - - -" Starting the top of the ring it will paste x items from it -function! s:YRGetMultiple(reverse_order, ...) - if s:yr_count == 0 - call s:YRWarningMsg('YR: yankring is empty') - return - endif - - " If the user provided a range, exit after that many - " have been displayed - let max = 1 - if a:0 == 1 - " If no yank command has been supplied, assume it is - " a full line yank - let max = matchstr(a:1, '\d\+') - endif - if max > s:yr_count - " Default to all items if they specified a very high value - let max = s:yr_count - endif - - " Base the increment on the sort order of the results - let increment = ((a:reverse_order==0)?(1):(-1)) - if a:reverse_order == 0 - let increment = 1 - let elem = 0 - else - let increment = -1 - let elem = (max - 1) - endif - - if a:0 > 1 - let iter = 1 - while iter <= a:0 - let elem = (a:{iter} - 1) - call s:YRGetElem(elem) - let iter = iter + 1 - endwhile - else - while max > 0 - " Paste the first item, and move on to the next. - " digits the element # is - call s:YRGetElem(elem) - let elem = elem + increment - let max = max - 1 - endwhile - endif -endfunction - - -" Given a regular expression, check each element within -" the yankring, display only the matching items and prompt -" the user for which item to paste -function! s:YRSearch(...) - if s:yr_count == 0 - call s:YRWarningMsg('YR: yankring is empty') - return - endif - - let s:yr_search = "" - " If the user provided a range, exit after that many - " have been displayed - if a:0 == 0 || (a:0 == 1 && a:1 == "") - let s:yr_search = input('Enter [optional] regex:') - else - let s:yr_search = a:1 - endif - - if s:yr_search == "" - " Show the entire yankring - call s:YRShow(0) - return - endif - - " List is shown in order of replacement - " assuming using previous yanks - let output = "--- YankRing ---\n" - let output = output . "Elem Content\n" - let valid_choices = [] - - let search_result = filter(copy(s:yr_history_list), "v:val =~ '".s:yr_search."'") - - let disp_item_nr = 1 - - for elem in s:yr_history_list - if elem =~ s:yr_search - let output = output . s:YRDisplayElem(disp_item_nr, elem) . "\n" - call add(valid_choices, disp_item_nr.'') - endif - let disp_item_nr += 1 - endfor - - if len(valid_choices) == 0 - let output = output . "Search for [".s:yr_search."] did not match any items " - endif - - if g:yankring_window_use_separate == 1 - call s:YRWindowOpen(output) - else - if len(valid_choices) > 0 - echo output - let elem = input("Enter # to paste:") - - " Ensure we get only the numeric value (trim it) - let elem = matchstr(elem, '\d\+') - - if elem == '' - " They most likely pressed enter without entering a value - return - endif - - if index(valid_choices, elem) != -1 - exec 'YRGetElem ' . elem - else - " User did not choose one of the elements that were found - " Remove leading , - call s:YRWarningMsg( "YR: Item[" . elem . "] not found, only valid choices are[" . - \ join(valid_choices, ',') . - \ "]" - \ ) - return -1 - endif - - else - call s:YRWarningMsg( "YR: The pattern [" . - \ s:yr_search . - \ "] does not match any items in the yankring" - \ ) - endif - endif - -endfunction - - -" Resets the common script variables for managing the ring. -function! s:YRReset() - let s:yr_history_list = [] - " Update the history file - call s:YRHistorySave() -endfunction - - -" Clears the yankring by simply setting the # of items in it to 0. -" There is no need physically unlet each variable. -function! s:YRInit(...) - let s:yr_next_idx = 0 - let s:yr_last_paste_idx = 0 - let s:yr_count = 0 - let s:yr_history_last_upd = 0 - let s:yr_history_list = [] - let s:yr_paste_dir = 'p' - - " For the . op support - let s:yr_prev_op_code = '' - let s:yr_prev_op_mode = 'n' - let s:yr_prev_count = '' - let s:yr_prev_reg = '' - let s:yr_prev_reg_unnamed = '' - let s:yr_prev_reg_small = '' - let s:yr_prev_reg_insert = '' - let s:yr_prev_reg_expres = '' - let s:yr_prev_clipboard = '' - let s:yr_prev_vis_lstart = 0 - let s:yr_prev_vis_lend = 0 - let s:yr_prev_vis_cstart = 0 - let s:yr_prev_vis_cend = 0 - let s:yr_prev_changenr = 0 - let s:yr_prev_repeating = 0 - - " This is used to determine if the visual selection should be - " reset prior to issuing the YRReplace - let s:yr_prev_vis_mode = 0 - - if a:0 == 0 && g:yankring_persist == 0 - " The user wants the yankring reset each time Vim is started - call s:YRClear() - endif - - call s:YRHistoryRead() -endfunction - - -" Clears the yankring by simply setting the # of items in it to 0. -" There is no need physically unlet each variable. -function! s:YRClear() - call s:YRReset() - call s:YRInit('DoNotClear') - - " If the yankring window is open, refresh it - call s:YRWindowUpdate() -endfunction - - -" Determine which register the user wants to use -" For example the 'a' register: "ayy -function! s:YRRegister() - " v:register can be blank in some (unknown) cases - " so test for this condition and return the - " default register - let user_register = ((v:register=='')?('"'):(v:register)) - if &clipboard == 'unnamed' && user_register == '"' - let user_register = '+' - endif - return user_register -endfunction - - -" Allows you to push a new item on the yankring. Useful if something -" is in the clipboard and you want to add it to the yankring. -" Or if you yank something that is not mapped. -function! s:YRPush(...) - let user_register = s:YRRegister() - - if a:0 > 0 - " If no yank command has been supplied, assume it is - " a full line yank - let user_register = ((a:1 == '') ? user_register : a:1) - endif - - " If we are pushing something on to the yankring, add it to - " the default buffer as well so the next item pasted will - " be the item pushed - let default_buffer = ((&clipboard=='unnamed')?'+':'"') - call setreg(default_buffer, getreg(user_register), - \ getregtype(user_register)) - - call s:YRSetPrevOP('', '', '', 'n') - call YRRecord(user_register) -endfunction - - -" Allows you to pop off any element from the yankring. -" If no parameters are provided the first element is removed. -" If a vcount is provided, that many elements are removed -" from the top. -function! s:YRPop(...) - if s:yr_count == 0 - call s:YRWarningMsg('YR: yankring is empty') - return - endif - - let v_count = 1 - if a:0 > 1 - let v_count = a:2 - endif - - " If the user provided a parameter, remove that element - " from the yankring. - " If no parameter was provided assume the first element. - let elem_index = 0 - if a:0 > 0 - " Get the element # from the parameter - let elem_index = matchstr(a:1, '\d\+') - let elem_index = elem_index - 1 - endif - - " If the user entered a count, then remove that many - " elements from the ring. - while v_count > 0 - call s:YRMRUDel('s:yr_history_list', elem_index) - let v_count = v_count - 1 - endwhile - - " If the yankring window is open, refresh it - call s:YRWindowUpdate() -endfunction - - -" Adds this value to the yankring. -function! YRRecord(...) - - let register = '"' - if a:0 > 0 - " If no yank command has been supplied, assume it is - " a full line yank - let register = ((a:1 == '') ? register : a:1) - endif - - " v:register can be blank in some (unknown) cases - " if v:register == '' || v:register == '_' - if v:register == '_' - " Black hole register, ignore recording the operation - return "" - endif - - let register = ((&clipboard=='unnamed')?'+':register) - - " let s:yr_prev_changenr = changenr() - if register == '"' - " If the change has occurred via an omap, we must delay - " the capture of the default register until this event - " since register updates are not reflected until the - " omap function completes - let s:yr_prev_reg_unnamed = getreg('"') - let s:yr_prev_reg_small = getreg('-') - endif - - " Add item to list - " This will also account for duplicates. - call s:YRMRUAdd( 's:yr_history_list' - \ , getreg(register) - \ , getregtype(register) - \ ) - - if register =~ '[+*]' - let s:yr_prev_clipboard = @+ - endif - - " If the yankring window is open, refresh it - call s:YRWindowUpdate() - - " Manage the numbered registers - if g:yankring_manage_numbered_reg == 1 - call s:YRSetNumberedReg() - endif - - return "" -endfunction - - -" Adds this value to the yankring. -function! YRRecord3() - let register = '"' - - " v:register can be blank in some (unknown) cases - " if v:register == '' || v:register == '_' - if v:register == '_' - " Black hole register, ignore recording the operation - return "" - endif - - let register = ((&clipboard=='unnamed')?'+':register) - - if register == '"' - " If the change has occurred via an omap, we must delay - " the capture of the default register until this event - " since register updates are not reflected until the - " omap function completes - let s:yr_prev_reg_unnamed = getreg('"') - let s:yr_prev_reg_small = getreg('-') - endif - - if s:yr_remove_omap_dot == 1 - call s:YRMapsCreate('add_only_zap_keys') - endif - - " Add item to list - " This will also account for duplicates. - call s:YRMRUAdd( 's:yr_history_list' - \ , getreg(register) - \ , getregtype(register) - \ ) - - if register =~ '[+*]' - let s:yr_prev_clipboard = @+ - endif - - " If the yankring window is open, refresh it - call s:YRWindowUpdate() - - " Manage the numbered registers - if g:yankring_manage_numbered_reg == 1 - call s:YRSetNumberedReg() - endif - - return "" -endfunction - - -" Record the operation for the dot operator -function! s:YRSetPrevOP(op_code, count, reg, mode) - let s:yr_prev_op_code = a:op_code - let s:yr_prev_op_mode = a:mode - let s:yr_prev_count = a:count - let s:yr_prev_changenr = changenr() - let s:yr_prev_reg = a:reg - let s:yr_prev_reg_unnamed = getreg('"') - let s:yr_prev_reg_small = getreg('-') - let s:yr_prev_reg_insert = getreg('.') - let s:yr_prev_vis_lstart = line("'<") - let s:yr_prev_vis_lend = line("'>") - let s:yr_prev_vis_cstart = col("'<") - let s:yr_prev_vis_cend = col("'>") - let s:yr_prev_reg_expres = histget('=', -1) - - if a:mode == 'n' - " In normal mode, the change has already - " occurred, therefore we can mark the - " actual position of the change. - let s:yr_prev_chg_lstart = line("'[") - let s:yr_prev_chg_lend = line("']") - let s:yr_prev_chg_cstart = col("'[") - let s:yr_prev_chg_cend = col("']") - else - " If in operator pending mode, the change - " has not yet occurred. Therefore we cannot - " use the '[ and ]' markers. But we can - " store the current line position. - let s:yr_prev_chg_lstart = line(".") - let s:yr_prev_chg_lend = line(".") - let s:yr_prev_chg_cstart = col(".") - let s:yr_prev_chg_cend = col(".") - endif - - " If storing the last change position (using '[, ']) - " is not good enough, then another option is to: - " Use :redir on the :changes command - " and grab the last item. Store this value - " and compare it is YRDoRepeat. -endfunction - - -" Adds this value to the yankring. -function! s:YRDoRepeat() - let dorepeat = 0 - - if s:yr_has_voperator == 1 - " Let Vim handle the repeat, just capture the updates - " as usual. - return 0 - endif - - if s:yr_prev_op_code =~ '^c' - " You cannot repeat change operations, let Vim's - " standard mechanism handle these, or the user will - " be prompted again, instead of repeating the - " previous change. - return 0 - endif - - if g:yankring_manage_numbered_reg == 1 - " When resetting the numbered register we are - " must ignore the comparision of the " register. - if s:yr_prev_reg_small == getreg('-') && - \ s:yr_prev_reg_insert == getreg('.') && - \ s:yr_prev_reg_expres == histget('=', -1) && - \ s:yr_prev_vis_lstart == line("'<") && - \ s:yr_prev_vis_lend == line("'>") && - \ s:yr_prev_vis_cstart == col("'<") && - \ s:yr_prev_vis_cend == col("'>") && - \ s:yr_prev_chg_lstart == line("'[") && - \ s:yr_prev_chg_lend == line("']") && - \ s:yr_prev_chg_cstart == col("'[") && - \ s:yr_prev_chg_cend == col("']") - let dorepeat = 1 - endif - else - " Check the previously recorded value of the registers - " if they are the same, we need to reissue the previous - " yankring command. - " If any are different, the user performed a command - " command that did not involve the yankring, therefore - " we should just issue the standard "normal! ." to repeat it. - if s:yr_prev_reg_unnamed == getreg('"') && - \ s:yr_prev_reg_small == getreg('-') && - \ s:yr_prev_reg_insert == getreg('.') && - \ s:yr_prev_reg_expres == histget('=', -1) && - \ s:yr_prev_vis_lstart == line("'<") && - \ s:yr_prev_vis_lend == line("'>") && - \ s:yr_prev_vis_cstart == col("'<") && - \ s:yr_prev_vis_cend == col("'>") - let dorepeat = 1 - endif - if dorepeat == 1 && s:yr_prev_op_mode == 'n' - " Hmm, not sure why I was doing this now - " so I will remove it - " let dorepeat = 0 - " if s:yr_prev_chg_lstart == line("'[") && - " \ s:yr_prev_chg_lend == line("']") && - " \ s:yr_prev_chg_cstart == col("'[") && - " \ s:yr_prev_chg_cend == col("']") - " let dorepeat = 1 - " endif - elseif dorepeat == 1 && s:yr_prev_op_mode == 'o' - " Hmm, not sure why I was doing this now - " so I will remove it - " let dorepeat = 0 - " if s:yr_prev_chg_lstart == line("'[") && - " \ s:yr_prev_chg_lend == line("']") && - " \ s:yr_prev_chg_cstart == col("'[") && - " \ s:yr_prev_chg_cend == col("']") - " let dorepeat = 1 - " endif - endif - endif - - " " If another change has happened that was not part of the - " " yankring we cannot replay it (from the yankring). Use - " " the standard ".". - " " If the previous op was a change, do not use the yankring - " " to repeat it. - " " changenr() is buffer specific, so anytime you move to - " " a different buffer you will definitely perform a - " " standard "." - " " Any previous op that was a change, must be replaced using "." - " " since we do not want the user prompted to enter text again. - " if s:yr_prev_changenr == changenr() && s:yr_prev_op_code !~ '^c' - " let dorepeat = 1 - " endif - - " If we are going to repeat check to see if the - " previous command was a yank operation. If so determine - " if yank operations are allowed to be repeated. - if dorepeat == 1 && s:yr_prev_op_code =~ '^y' - " This value be default is set based on cpoptions. - if g:yankring_dot_repeat_yank == 0 - let dorepeat = 0 - endif - endif - return dorepeat -endfunction - - -" Manages the Vim's numbered registers -function! s:YRSetNumberedReg() - - let i = 1 - - while i <= 10 - if i > s:yr_count - break - endif - - call setreg( (i-1) - \ , s:YRGetValElemNbr((i-1),'v') - \ , s:YRGetValElemNbr((i-1),'t') - \ ) - let i += 1 - endwhile -endfunction - - -" This internal function will add and subtract values from a starting -" point and return the correct element number. It takes into account -" the circular nature of the yankring. -function! s:YRGetNextElem(start, iter) - - let needed_elem = a:start + a:iter - - " The yankring is a ring, so if an element is - " requested beyond the number of elements, we - " must wrap around the ring. - if needed_elem > s:yr_count - let needed_elem = needed_elem % s:yr_count - endif - - if needed_elem == 0 - " Can happen at the end or beginning of the ring - if a:iter == -1 - " Wrap to the bottom of the ring - let needed_elem = s:yr_count - else - " Wrap to the top of the ring - let needed_elem = 1 - endif - elseif needed_elem < 1 - " As we step backwards through the ring we could ask for a negative - " value, this will wrap it around to the end - let needed_elem = s:yr_count - endif - - return needed_elem - -endfunction - - -" Lets Vim natively perform the operation and then stores what -" was yanked (or deleted) into the yankring. -" Supports this for example - 5"ayy -" -" This is a legacy function now since the release of Vim 7.2 -" and the use of omaps with YankRing 5.0 and above. -" If Vim 7.1 has patch205, then the new omaps and the v:operator -" variable is used instead. -function! s:YRYankCount(...) range - - let user_register = s:YRRegister() - let v_count = v:count - - " Default yank command to the entire line - let op_code = 'yy' - if a:0 > 0 - " If no yank command has been supplied, assume it is - " a full line yank - let op_code = ((a:1 == '') ? op_code : a:1) - endif - - if op_code == '.' - if s:YRDoRepeat() == 1 - if s:yr_prev_op_code != '' - let op_code = s:yr_prev_op_code - let v_count = s:yr_prev_count - let user_register = s:yr_prev_reg - endif - else - " Set this flag so that YRRecord will - " ignore repeats - let s:yr_prev_repeating = 1 - exec "normal! ." - return - endif - else - let s:yr_prev_repeating = 0 - endif - - " Supports this for example - 5"ayy - " A delete operation will still place the items in the - " default registers as well as the named register - exec "normal! ". - \ ((v_count > 0)?(v_count):''). - \ (user_register=='"'?'':'"'.user_register). - \ op_code - - if user_register == '_' - " Black hole register, ignore recording the operation - return - endif - - call s:YRSetPrevOP(op_code, v_count, user_register, 'n') - - call YRRecord(user_register) -endfunction - - -" Handles ranges. There are visual ranges and command line ranges. -" Visual ranges are easy, since we pass through and let Vim deal -" with those directly. -" Command line ranges means we must yank the entire line, and not -" just a portion of it. -function! s:YRYankRange(do_delete_selection, ...) range - - let user_register = s:YRRegister() - let default_buffer = ((&clipboard=='unnamed')?'+':'"') - - " Default command mode to normal mode 'n' - let cmd_mode = 'n' - if a:0 > 0 - " Change to visual mode, if command executed via - " a visual map - let cmd_mode = ((a:1 == 'v') ? 'v' : 'n') - endif - - if cmd_mode == 'v' - " We are yanking either an entire line, or a range - exec "normal! gv". - \ (user_register==default_buffer?'':'"'.user_register). - \ 'y' - if a:do_delete_selection == 1 - exec "normal! gv". - \ (user_register==default_buffer?'':'"'.user_register). - \ 'd' - endif - else - " In normal mode, always yank the complete line, since this - " command is for a range. YRYankCount is used for parts - " of a single line - if a:do_delete_selection == 1 - exec a:firstline . ',' . a:lastline . 'delete '.user_register - else - exec a:firstline . ',' . a:lastline . 'yank ' . user_register - endif - endif - - if user_register == '_' - " Black hole register, ignore - return - endif - - call s:YRSetPrevOP('', '', user_register, 'n') - call YRRecord(user_register) -endfunction - - -" Paste from either the yankring or from a specified register -" Optionally a count can be provided, so paste the same value 10 times -function! s:YRPaste(replace_last_paste_selection, nextvalue, direction, ...) - " Disabling the yankring removes the default maps. - " But there are some maps the user can create on their own, and - " these would most likely call this function. So place an extra - " check and display a message. - if g:yankring_enabled == 0 - call s:YRWarningMsg( - \ 'YR: The yankring is currently disabled, use YRToggle.' - \ ) - return - endif - - - let user_register = s:YRRegister() - let default_buffer = ((&clipboard == 'unnamed')?'+':'"') - let v_count = v:count - - " Default command mode to normal mode 'n' - let cmd_mode = 'n' - if a:0 > 0 - " Change to visual mode, if command executed via - " a visual map - let cmd_mode = ((a:1 == 'v') ? 'v' : 'n') - endif - - " User has decided to bypass the yankring and specify a specific - " register - if user_register != default_buffer - if a:replace_last_paste_selection == 1 - call s:YRWarningMsg( 'YR: A register cannot be specified in replace mode' ) - return - else - " Check for the expression register, in this special case - " we must copy it's evaluation into the default buffer and paste - if user_register == '=' - " Save the default register since Vim will only - " allow the expression register to be pasted once - " and will revert back to the default buffer - let save_default_reg = @" - call setreg(default_buffer, eval(histget('=', -1)) ) - else - let user_register = '"'.user_register - endif - exec "normal! ". - \ ((cmd_mode=='n') ? "" : "gv"). - \ ((v_count > 0)?(v_count):''). - \ ((user_register=='=')?'':user_register). - \ a:direction - if user_register == '=' - let @" = save_default_reg - endif - " In this case, we have bypassed the yankring - " If the user hits next or previous we want the - " next item pasted to be the top of the yankring. - let s:yr_last_paste_idx = 0 - endif - let s:yr_paste_dir = a:direction - let s:yr_prev_vis_mode = ((cmd_mode=='n') ? 0 : 1) - return - endif - - " Try to second guess the user to make these mappings less intrusive. - " If the user hits paste, compare the contents of the paste register - " to the current entry in the yankring. If they are different, lets - " assume the user wants the contents of the paste register. - " So if they pressed [yt ] (yank to space) and hit paste, the yankring - " would not have the word in it, so assume they want the word pasted. - if a:replace_last_paste_selection != 1 - if s:yr_count > 0 || (default_buffer == '+' && len(@+) == 0) - " Only check the default buffer is the user wants us to. - " This was necessary prior to version 4.0 since we did not - " capture as many items as 4.0 and above does. (A. Budden) - if g:yankring_paste_check_default_buffer == 1 && - \ getreg(default_buffer) != s:yr_prev_reg_unnamed - " The user has performed a yank / delete operation - " outside of the yankring maps. First, add this - " value to the yankring. - call YRRecord(default_buffer) - " Now, use the most recently yanked text, rather than the - " value from the yankring. - exec "normal! ". - \ ((cmd_mode=='n') ? "" : "gv"). - \ ((v_count > 0)?(v_count):''). - \ a:direction - let s:yr_paste_dir = a:direction - let s:yr_prev_vis_mode = ((cmd_mode=='n') ? 0 : 1) - - " In this case, we have bypassed the yankring - " If the user hits next or previous we want the - " next item pasted to be the top of the yankring. - let s:yr_last_paste_idx = 0 - return - endif - else - exec "normal! ". - \ ((cmd_mode=='n') ? "" : "gv"). - \ ((v_count > 0)?(v_count):''). - \ a:direction - let s:yr_paste_dir = a:direction - let s:yr_prev_vis_mode = ((cmd_mode=='n') ? 0 : 1) - return - endif - endif - - if s:yr_count == 0 || (default_buffer == '+' && len(@+) == 0) - " Nothing to paste - return - endif - - if a:replace_last_paste_selection == 1 - " Replacing the previous put - let start = line("'[") - let end = line("']") - - if start != line('.') - call s:YRWarningMsg( 'YR: You must paste text first, before you can replace' ) - return - endif - - if start == 0 || end == 0 - return - endif - - " If a count was provided (ie 5), multiply the - " nextvalue accordingly and position the next paste index - let which_elem = a:nextvalue * ((v_count > 0)?(v_count):1) * -1 - let s:yr_last_paste_idx = s:YRGetNextElem( - \ s:yr_last_paste_idx, which_elem - \ ) - - let save_reg = getreg(default_buffer) - let save_reg_type = getregtype(default_buffer) - call setreg( default_buffer - \ , s:YRGetValElemNbr((s:yr_last_paste_idx-1),'v') - \ , s:YRGetValElemNbr((s:yr_last_paste_idx-1),'t') - \ ) - - " First undo the previous paste - exec "normal! u" - " Check if the visual selection should be reselected - " Next paste the correct item from the ring - " This is done as separate statements since it appeared that if - " there was nothing to undo, the paste never happened. - exec "normal! ". - \ ((s:yr_prev_vis_mode==0) ? "" : "gv"). - \ s:yr_paste_dir - call setreg(default_buffer, save_reg, save_reg_type) - call s:YRSetPrevOP('', '', '', 'n') - else - " User hit p or P - " Supports this for example - 5"ayy - " And restores the current register - let save_reg = getreg(default_buffer) - let save_reg_type = getregtype(default_buffer) - let s:yr_last_paste_idx = 1 - call setreg(default_buffer - \ , s:YRGetValElemNbr(0,'v') - \ , s:YRGetValElemNbr(0,'t') - \ ) - exec "normal! ". - \ ((cmd_mode=='n') ? "" : "gv"). - \ ( - \ ((v_count > 0)?(v_count):''). - \ a:direction - \ ) - call setreg(default_buffer, save_reg, save_reg_type) - call s:YRSetPrevOP( - \ a:direction - \ , v_count - \ , default_buffer - \ , 'n' - \ ) - let s:yr_paste_dir = a:direction - let s:yr_prev_vis_mode = ((cmd_mode=='n') ? 0 : 1) - endif - -endfunction - - -" Handle any omaps -function! YRMapsExpression(sid, motion, ...) - let cmds = a:motion - " echomsg "YRMapsE:".localtime() - " echomsg "YRMapsE 1:".cmds.":".v:operator.":".s:yr_maps_created_zap - - if (a:motion =~ '\.' && s:yr_remove_omap_dot == 1) || a:motion =~ '@' - " If we are repeating a series of commands we must - " unmap the _zap_ keys so that the user is not - " prompted when a command is replayed. - " These maps must be re-instated in YRRecord3() - " after the action of the replay is completed. - call s:YRMapsDelete('remove_only_zap_keys') - endif - - " Check if we are in operator-pending mode - if a:motion =~ '\('.substitute(g:yankring_zap_keys, ' ', '\\|', 'g').'\)' - if a:motion =~ '\(/\|?\)' - let zapto = (a:0==0 ? "" : input("YR:Enter string:")) - if zapto != "" - let zapto = zapto . "\" - else - let zapto = "\" - endif - else - let zapto = (a:0==0 ? "" : s:YRGetChar()) - endif - - if zapto == "\" - " Abort if the user hits Control C - call s:YRWarningMsg( "YR:Aborting command:".v:operator.a:motion ) - return "\" - endif - - let cmds = cmds . zapto - endif - - " There are a variety of commands which do not change the - " registers, so these operators should be ignored when - " determining which operations to record - " Simple example is '=' which simply formats the - " the selected text. - if ' \('.escape(join(split(g:yankring_ignore_operator), '\|'), '/.*~$^[]' ).'\) ' !~ escape(v:operator, '/.*~$^[]') - " Check if we are performing an action that will - " take us into insert mode - if '[cCsS]' !~ escape(v:operator, '/.*~$^[]') && a:motion !~ '@' - " if '[cCsS]' !~ escape(v:operator, '/.*~$^[]') - " If we have not entered insert mode, feed the call - " to record the current change when the function ends. - " This is necessary since omaps do not update registers - " until the function completes. - " The InsertLeave event will handle the motions - " that place us in insert mode and record the - " changes when insert mode ends. - let cmds .= a:sid. "yrrecord" - endif - endif - - " echomsg "YRMapsE 5:".a:motion.":'".cmds."':".s:yr_maps_created_zap - return cmds - -endfunction - - -" Handle any the @ -function! s:YRMapsMacro(bang, ...) range - " If we are repeating a series of commands we must - " unmap the _zap_ keys so that the user is not - " prompted when a command is replayed. - " These maps must be re-instated in YRRecord3() - " after the action of the replay is completed. - call s:YRMapsDelete('remove_only_zap_keys') - - " let zapto = (a:0==0 ? "" : s:YRGetChar()) - let zapto = s:YRGetChar() - - if zapto == "\" - " Abort if the user hits Control C - call s:YRWarningMsg( "YR:Aborting command:".v:operator.a:motion ) - return "" - endif - - let v_count = v:count - " If no count was specified it will have a value of 0 - " so set it to at least 1 - let v_count = ((v_count > 0)?(v_count):'') - - let range = '' - if a:firstline != a:lastline - let rannge = a:firstline.','.a:lastline - endif - - let cmd = range."normal! ".v_count.'@'.zapto - " DEBUG - " echomsg cmd - exec cmd - - call s:YRMapsCreate('add_only_zap_keys') -endfunction - - -" Create the default maps -function! s:YRMapsCreate(...) - " 7.1.patch205 introduces the v:operator function which was - " essential to gain the omap support. - if s:yr_has_voperator == 1 - let s:yr_remove_omap_dot = 1 - for key in split(g:yankring_zap_keys) - try - if key != '@' - exec 'omap ' key 'YRMapsExpression("", "'. key. '", 1)' - endif - catch - endtry - endfor - endif - - silent! nmap @ YRMapsExpression("", "@", "1") - - let s:yr_maps_created_zap = 1 - - if a:0 > 0 - " We have only removed the _zap_ keys temporarily - " so abandon further changes. - return - endif - - " 7.1.patch205 introduces the v:operator function which was essential - " to gain the omap support. - if s:yr_has_voperator == 1 - let s:yr_remove_omap_dot = 1 - " Set option to add and remove _zap_ keys when - " repeating commands - let o_maps = split(g:yankring_o_keys) - " Loop through and prompt the user for all buffer connection parameters. - for key in o_maps - exec 'omap ' key 'YRMapsExpression("", "'. escape(key,'\"'). '")' - endfor - endif - - " Iterate through a space separated list of mappings and create - " calls to the YRYankCount function - let n_maps = split(g:yankring_n_keys) - " Loop through and prompt the user for all buffer connection parameters. - for key in n_maps - " exec 'nnoremap '.key." :YRYankCount '".key."'" - " exec 'nnoremap '.key." :YRYankCount '".key."'" - " Andy Wokula's suggestion - exec 'nmap' key key."yrrecord" - endfor - - if g:yankring_map_dot == 1 - if s:yr_has_voperator == 1 - nmap . YRMapsExpression("", ".") - else - nnoremap . :YRYankCount '.' - endif - endif - - if g:yankring_v_key != '' - exec 'xnoremap '.g:yankring_v_key." :YRYankRange 'v'" - endif - if g:yankring_del_v_key != '' - for v_map in split(g:yankring_del_v_key) - if strlen(v_map) > 0 - try - exec 'xnoremap '.v_map." :YRDeleteRange 'v'" - catch - endtry - endif - endfor - endif - if g:yankring_paste_n_bkey != '' - exec 'nnoremap '.g:yankring_paste_n_bkey." :YRPaste 'P'" - if g:yankring_paste_using_g == 1 - exec 'nnoremap g'.g:yankring_paste_n_bkey." :YRPaste 'gP'" - endif - endif - if g:yankring_paste_n_akey != '' - exec 'nnoremap '.g:yankring_paste_n_akey." :YRPaste 'p'" - if g:yankring_paste_using_g == 1 - exec 'nnoremap g'.g:yankring_paste_n_akey." :YRPaste 'gp'" - endif - endif - if g:yankring_paste_v_bkey != '' - exec 'xnoremap '.g:yankring_paste_v_bkey." :YRPaste 'P', 'v'" - endif - if g:yankring_paste_v_akey != '' - exec 'xnoremap '.g:yankring_paste_v_akey." :YRPaste 'p', 'v'" - endif - if g:yankring_replace_n_pkey != '' - exec 'nnoremap '.g:yankring_replace_n_pkey." :YRReplace '-1', 'P'" - endif - if g:yankring_replace_n_nkey != '' - exec 'nnoremap '.g:yankring_replace_n_nkey." :YRReplace '1', 'p'" - endif - - let g:yankring_enabled = 1 - let s:yr_maps_created = 1 -endfunction - - -" Create the default maps -function! s:YRMapsDelete(...) - - let o_maps = split(g:yankring_zap_keys) - for key in o_maps - try - if key != '@' - silent! exec 'ounmap' key - endif - catch - endtry - endfor - - let s:yr_maps_created_zap = 0 - - if a:0 > 0 - " We have only removed the _zap_ keys temporarily - " so abandon further changes. - return - endif - - " Iterate through a space separated list of mappings and create - " calls to an appropriate YankRing function - let n_maps = split(g:yankring_n_keys) - " Loop through and prompt the user for all buffer connection parameters. - for key in n_maps - try - silent! exec 'nunmap' key - catch - endtry - endfor - - let o_maps = split(g:yankring_o_keys) - for key in o_maps - try - silent! exec 'ounmap' key - catch - endtry - endfor - - if g:yankring_map_dot == 1 - exec "nunmap ." - endif - if g:yankring_v_key != '' - exec 'vunmap '.g:yankring_v_key - endif - if g:yankring_del_v_key != '' - for v_map in split(g:yankring_del_v_key) - if strlen(v_map) > 0 - try - exec 'vunmap '.v_map - catch - endtry - endif - endfor - endif - if g:yankring_paste_n_bkey != '' - exec 'nunmap '.g:yankring_paste_n_bkey - if g:yankring_paste_using_g == 1 - exec 'nunmap g'.g:yankring_paste_n_bkey - endif - endif - if g:yankring_paste_n_akey != '' - exec 'nunmap '.g:yankring_paste_n_akey - if g:yankring_paste_using_g == 1 - exec 'nunmap g'.g:yankring_paste_n_akey - endif - endif - if g:yankring_paste_v_bkey != '' - exec 'vunmap '.g:yankring_paste_v_bkey - endif - if g:yankring_paste_v_akey != '' - exec 'vunmap '.g:yankring_paste_v_akey - endif - if g:yankring_replace_n_pkey != '' - exec 'nunmap '.g:yankring_replace_n_pkey - endif - if g:yankring_replace_n_nkey != '' - exec 'nunmap '.g:yankring_replace_n_nkey - endif - - let g:yankring_enabled = 0 - let s:yr_maps_created = 0 -endfunction - -function! s:YRGetValElemNbr( position, type ) - - let needed_elem = a:position - - " The List which contains the items in the yankring - " history is also ordered, most recent at the top - let elem = s:YRMRUGet('s:yr_history_list', needed_elem) - - if elem >= 0 - if a:type == 't' - return matchstr(elem, '^.*,\zs.*$') - else - let elem = matchstr(elem, '^.*\ze,.*$') - if s:yr_history_version == 'v1' - " Match three @@@ in a row as long as it is not - " preceeded by a @@@ - " v1 - let elem = substitute(elem, s:yr_history_v1_nl_pat, "\n", 'g') - let elem = substitute(elem, '\\@', '@', 'g') - else - let elem = substitute(elem, s:yr_history_v2_nl_pat, "\n", 'g') - endif - return elem - endif - else - return -1 - endif - - return "" -endfunction - -function! s:YRMRUReset( mru_list ) - - let {a:mru_list} = [] - - return 1 -endfunction - -function! s:YRMRUSize( mru_list ) - return len({a:mru_list}) -endfunction - -function! s:YRMRUElemFormat( element, element_type ) - let elem = a:element - if g:yankring_max_element_length != 0 - let elem = strpart(a:element, 0, g:yankring_max_element_length) - endif - if s:yr_history_version == 'v1' - let elem = escape(elem, '@') - let elem = substitute(elem, "\n", s:yr_history_v1_nl, 'g') - else - let elem = substitute(elem, "\n", s:yr_history_v2_nl, 'g') - endif - " Append the regtype to the end so we have it available - let elem = elem.",".a:element_type - - return elem -endfunction - -function! s:YRMRUHas( mru_list, find_str ) - " This function will find a string and return the element # - let find_idx = index({a:mru_list}, a:find_str) - - return find_idx -endfunction - -function! s:YRMRUGet( mru_list, position ) - " This function will return the value of the item at a:position - " Find the value of one element - let value = get({a:mru_list}, a:position, -2) - - return value -endfunction - -function! s:YRMRUAdd( mru_list, element, element_type ) - " Only add new items if they do not already exist in the MRU. - " If the item is found, move it to the start of the MRU. - let found = -1 - " let elem = a:element - " if g:yankring_max_element_length != 0 - " let elem = strpart(a:element, 0, g:yankring_max_element_length) - " endif - " if s:yr_history_version == 'v1' - " let elem = escape(elem, '@') - " let elem = substitute(elem, "\n", s:yr_history_v1_nl, 'g') - " else - " let elem = substitute(elem, "\n", s:yr_history_v2_nl, 'g') - " endif - " " Append the regtype to the end so we have it available - " let elem = elem.",".a:element_type - - if strlen(a:element) < g:yankring_min_element_length - return 1 - endif - - let elem = s:YRMRUElemFormat(a:element, a:element_type) - - " Refresh the List - call s:YRHistoryRead() - - let found = s:YRMRUHas(a:mru_list, elem) - - " Special case for efficiency, if it is first item in the - " List, do nothing - if found != 0 - if found != -1 - " Remove found item since we will add it to the top - call remove({a:mru_list}, found) - endif - call insert({a:mru_list}, elem, 0) - call s:YRHistorySave() - endif - - return 1 -endfunction - -function! s:YRMRUDel( mru_list, elem_nbr ) - - if a:elem_nbr >= 0 && a:elem_nbr < s:yr_count - call remove({a:mru_list}, a:elem_nbr) - call s:YRHistorySave() - endif - - return 1 -endfunction - -function! s:YRHistoryRead() - let refresh_needed = 1 - let yr_history_list = [] - let yr_filename = s:yr_history_file_{s:yr_history_version} - - if filereadable(yr_filename) - let last_upd = getftime(yr_filename) - - if s:yr_history_last_upd != 0 && last_upd <= s:yr_history_last_upd - let refresh_needed = 0 - endif - - if refresh_needed == 1 - let s:yr_history_list = readfile(yr_filename) - let s:yr_history_last_upd = last_upd - let s:yr_count = len(s:yr_history_list) - return - else - return - endif - else - if s:yr_history_version == 'v2' - " Check to see if an upgrade is required - " else, let the empty yr_history_list be returned. - if filereadable(s:yr_history_file_v1) - " Perform upgrade to v2 of the history file - call s:YRHistoryUpgrade('v1') - return - endif - endif - endif - - let s:yr_history_list = yr_history_list - call s:YRHistorySave() - -endfunction - -function! s:YRHistorySave() - if len(s:yr_history_list) > g:yankring_max_history - " Remove items which exceed the max # specified - call remove(s:yr_history_list, g:yankring_max_history) - endif - - let rc = writefile(s:yr_history_list, s:yr_history_file_{s:yr_history_version}) - - if rc == 0 - let s:yr_history_last_upd = getftime(s:yr_history_file_{s:yr_history_version}) - let s:yr_count = len(s:yr_history_list) - else - call s:YRErrorMsg( - \ 'YRHistorySave: Unable to save yankring history file: '. - \ s:yr_history_file_{s:yr_history_version} - \ ) - endif -endfunction - -function! s:YRHistoryUpgrade(version) - if a:version == 'v1' - if filereadable(s:yr_history_file_v1) - let v1_list = readfile(s:yr_history_file_v1) - let v2_list = [] - for elem in v1_list - " Restore from version 1 - let elem = substitute(elem, s:yr_history_v1_nl_pat, "\n", 'g') - let elem = substitute(elem, '\\@', '@', 'g') - " Encode to version 2 - let elem = substitute(elem, "\n", s:yr_history_v2_nl, 'g') - call add(v2_list, elem) - endfor - let s:yr_history_list = v2_list - call s:YRHistorySave() - call s:YRWarningMsg( - \ "YR:History file:". - \ s:yr_history_file_v1. - \ ' has been upgraded.' - \ ) - endif - endif -endfunction - -" YRWindowUpdate -" Checks if the yankring window is already open. -" If it is, it will refresh it. -function! s:YRWindowUpdate() - let orig_win_bufnr = bufwinnr('%') - - " Switch to the yankring buffer - " only if it is already visible - if bufwinnr(s:yr_buffer_id) != -1 - call s:YRShow(0) - " Switch back to the original buffer - exec orig_win_bufnr . "wincmd w" - endif -endfunction - -" YRWindowStatus -" Displays a brief command list and option settings. -" It also will toggle the Help text. -function! s:YRWindowStatus(show_help) - let full_help = 0 - let orig_win_bufnr = bufwinnr('%') - let yr_win_bufnr = bufwinnr(s:yr_buffer_id) - - if yr_win_bufnr == -1 - " Do not update the window status since the - " yankring is not currently displayed. - return "" - endif - " Switch to the yankring buffer - if orig_win_bufnr != yr_win_bufnr - " If the buffer is visible, switch to it - exec yr_win_bufnr . "wincmd w" - endif - - let msg = 'AutoClose='.g:yankring_window_auto_close. - \ ';ClipboardMonitor='.g:yankring_clipboard_monitor. - \ ';Cmds:,[g]p,[g]P,d,r,s,a,c,u,q,;Help=?'. - \ (s:yr_search==""?"":';SearchRegEx='.s:yr_search) - - if s:yr_has_voperator == 0 - let msg = msg . "\nYankRing has limited functionality without Vim 7.2 or higher" - endif - - " Toggle help by checking the first line of the buffer - if a:show_help == 1 && getline(1) !~ 'selection' - let full_help = 1 - let msg = - \ '" : [p]aste selection'."\n". - \ '" double-click : [p]aste selection'."\n". - \ '" [g]p : [g][p]aste selection'."\n". - \ '" [g]P : [g][P]aste selection'."\n". - \ '" r : [p]aste selection in reverse order'."\n". - \ '" s : [s]earch the yankring for text'."\n". - \ '" u : [u]pdate display'."\n". - \ '" a : toggle [a]utoclose setting'."\n". - \ '" c : toggle [c]lipboard monitor setting'."\n". - \ '" q : [q]uit / close the yankring window'."\n". - \ '" ? : Remove help text'."\n". - \ '" : toggles the width of the window'."\n". - \ '" Visual mode is supported for above commands'."\n". - \ msg - endif - - let saveMod = &modifiable - - " Go to the top of the buffer and remove any previous status - " Use the blackhole register so it does not affect the yankring - setlocal modifiable - exec 0 - silent! exec 'norm! "_d/^---'."\n" - call histdel("search", -1) - - silent! 0put =msg - - " Erase it's contents to the blackhole - silent! exec '%g/^\s*$/delete _' - call histdel("search", -1) - - call cursor(1,1) - if full_help == 0 - call search('^\d', 'W') - endif - - let &modifiable = saveMod - - if orig_win_bufnr != s:yr_buffer_id - exec orig_win_bufnr . "wincmd w" - endif -endfunction - -" YRWindowOpen -" Display the Most Recently Used file list in a temporary window. -function! s:YRWindowOpen(results) - - " Setup the cpoptions properly for the maps to work - let old_cpoptions = &cpoptions - set cpoptions&vim - setlocal cpoptions-=a,A - - " Save the current buffer number. The yankring will switch back to - " this buffer when an action is taken. - let s:yr_buffer_last = bufnr('%') - let s:yr_buffer_last_winnr = winnr() - - if bufwinnr(s:yr_buffer_id) == -1 - if g:yankring_window_use_horiz == 1 - if g:yankring_window_use_bottom == 1 - let location = 'botright' - else - let location = 'topleft' - " Creating the new window will offset all other - " window numbers. Account for that so we switch - " back to the correct window. - let s:yr_buffer_last_winnr = s:yr_buffer_last_winnr + 1 - endif - let win_size = g:yankring_window_height - else - " Open a horizontally split window. Increase the window size, if - " needed, to accomodate the new window - if g:yankring_window_width && - \ &columns < (80 + g:yankring_window_width) - " one extra column is needed to include the vertical split - let &columns = &columns + g:yankring_window_width + 1 - let s:yr_winsize_chgd = 1 - else - let s:yr_winsize_chgd = 0 - endif - - if g:yankring_window_use_right == 1 - " Open the window at the rightmost place - let location = 'botright vertical' - else - " Open the window at the leftmost place - let location = 'topleft vertical' - " Creating the new window will offset all other - " window numbers. Account for that so we switch - " back to the correct window. - let s:yr_buffer_last_winnr = s:yr_buffer_last_winnr + 1 - endif - let win_size = g:yankring_window_width - endif - - " Special consideration was involved with these sequence - " of commands. - " First, split the current buffer. - " Second, edit a new file. - " Third record the buffer number. - " If a different sequence is followed when the yankring - " buffer is closed, Vim's alternate buffer is the yanking - " instead of the original buffer before the yankring - " was shown. - let cmd_mod = '' - if v:version >= 700 - let cmd_mod = 'keepalt ' - endif - exec 'silent! ' . cmd_mod . location . ' ' . win_size . 'split ' - - " Using :e and hide prevents the alternate buffer - " from being changed. - exec ":e " . escape(s:yr_buffer_name, ' ') - " Save buffer id - let s:yr_buffer_id = bufnr('%') + 0 - else - " If the buffer is visible, switch to it - exec bufwinnr(s:yr_buffer_id) . "wincmd w" - endif - - " Perform a double check to ensure we have entered the correct - " buffer since we don't want to do the %d_ in the wrong buffer! - if (bufnr('%') + 0) != s:yr_buffer_id - call s:YRWarningMsg( - \ "YR:Failed to change to the yankring buffer, please contact author id:". - \ s:yr_buffer_id. - \ ' last:'.s:yr_buffer_last - \ ) - return -1 - endif - - " Mark the buffer as scratch - setlocal buftype=nofile - setlocal bufhidden=hide - setlocal noswapfile - setlocal nowrap - setlocal nonumber - setlocal nobuflisted - setlocal noreadonly - setlocal modifiable - - " set up syntax highlighting - syn match yankringTitle #^--- YankRing ---$#hs=s+4,he=e-4 - syn match yankringHeaders #^Elem Content$# - syn match yankringItemNumber #^\d\+# - - syn match yankringKey #^AutoClose.*#hs=e-6 - syn match yankringKey #^AutoClose.*\[g\]p#hs=e-3 contains=yankringKey - syn match yankringKey #^AutoClose.*\[p\]P#hs=e-3 contains=yankringKey - syn match yankringKey #^AutoClose.*,d,#hs=e-1,he=e-1 contains=yankringKey - syn match yankringKey #^AutoClose.*,r,#hs=e-1,he=e-1 contains=yankringKey - syn match yankringKey #^AutoClose.*,s,#hs=e-1,he=e-1 contains=yankringKey - syn match yankringKey #^AutoClose.*,a,#hs=e-1,he=e-1 contains=yankringKey - syn match yankringKey #^AutoClose.*,c,#hs=e-1,he=e-1 contains=yankringKey - syn match yankringKey #^AutoClose.*,u,#hs=e-1,he=e-1 contains=yankringKey - syn match yankringKey #^AutoClose.*,q,#hs=e-1,he=e-1 contains=yankringKey - syn match yankringKey #^AutoClose.*#hs=e-6 contains=yankringKey - syn match yankringKey #^AutoClose.*?$#hs=e contains=yankringKey - - syn match yankringKey #^".*:#hs=s+1,he=e-1 - syn match yankringHelp #^".*$# contains=yankringKey - - hi link yankringTitle directory - hi link yankringHeaders keyword - hi link yankringItemNumber constant - hi link yankringKey identifier - hi link yankringHelp string - - " Clear all existing maps for this buffer - " We should do this for all maps, but I am not sure how to do - " this for this buffer/window only without affecting all the - " other buffers. - mapclear - " Create a mapping to act upon the yankring - nnoremap <2-LeftMouse> :call YRWindowActionN('p' ,'n') - nnoremap :call YRWindowActionN('p' ,'n') - xnoremap :call YRWindowAction ('p' ,'v') - nnoremap p :call YRWindowActionN('p' ,'n') - xnoremap p :call YRWindowAction ('p' ,'v') - nnoremap P :call YRWindowActionN('P' ,'n') - xnoremap P :call YRWindowAction ('P' ,'v') - nnoremap gp :call YRWindowActionN('gp','n') - xnoremap gp :call YRWindowAction ('gp','v') - nnoremap gP :call YRWindowActionN('gP','n') - xnoremap gP :call YRWindowAction ('gP','v') - nnoremap d :call YRWindowActionN('d' ,'n') - xnoremap d :call YRWindowAction ('d' ,'v') - xnoremap r :call YRWindowAction ('r' ,'v') - nnoremap s :call YRWindowAction ('s' ,'n') - nnoremap a :call YRWindowAction ('a' ,'n') - nnoremap c :call YRWindowAction ('c' ,'n') - nnoremap ? :call YRWindowAction ('?' ,'n') - nnoremap u :call YRWindowAction ('u' ,'n') - nnoremap q :call YRWindowAction ('q' ,'n') - nnoremap \|:silent exec 'vertical resize '. - \ ( - \ g:yankring_window_use_horiz!=1 && winwidth('.') > g:yankring_window_width - \ ?(g:yankring_window_width) - \ :(winwidth('.') + g:yankring_window_increment) - \ ) - - " Erase it's contents to the blackhole - silent! exec '%delete _' - - " Display the status line / help - call s:YRWindowStatus(0) - exec 'normal! G' - - " Display the contents of the yankring - silent! put =a:results - - if getline('$') == '' - " Erase last blank line - silent! exec '$delete _' - endif - - " Move the cursor to the first line with an element - exec 0 - call search('^\d','W') - - setlocal nomodifiable - " - " Restore the previous cpoptions settings - let &cpoptions = old_cpoptions - -endfunction - -function! s:YRWindowActionN(op, cmd_mode) - let v_count = v:count - " If no count was specified it will have a value of 0 - " so set it to at least 1 - let v_count = ((v_count > 0)?(v_count):1) - - if v_count > 1 - if !exists("b:yankring_show_range_error") - let b:yankring_show_range_error = v_count - else - let b:yankring_show_range_error = b:yankring_show_range_error - 1 - endif - - if b:yankring_show_range_error == 1 - call s:YRWarningMsg("YR:Use visual mode if you need to specify a count") - unlet b:yankring_show_range_error - endif - return - endif - - call s:YRWindowAction(a:op, a:cmd_mode) - let v_count = v_count - 1 - - if g:yankring_window_auto_close == 1 && v_count == 0 && a:op != 'd' - " If autoclose is set close the window unless - " you are removing items from the YankRing - exec 'bdelete '.s:yr_buffer_id - return "" - endif - - return "" -endfunction - -function! s:YRWindowAction(op, cmd_mode) range - let default_buffer = ((&clipboard=='unnamed')?'+':'"') - let opcode = a:op - let lines = [] - let v_count = v:count - let cmd_mode = a:cmd_mode - let firstline = a:firstline - let lastline = a:lastline - - if a:lastline < a:firstline - let firstline = a:lastline - let lastline = a:firstline - endif - - if cmd_mode == 'n' - let v_count = 1 - " If a count was provided (5p), we want to repeat the paste - " 5 times, but this also alters the a:firstline and a:lastline - " ranges, which while in normal mode we do not want - let lastline = firstline - endif - " If no count was specified it will have a value of 0 - " so set it to at least 1 - let v_count = ((v_count > 0)?(v_count):1) - - if '[dr]' =~ opcode - " Reverse the order of the lines to act on - let begin = lastline - while begin >= firstline - call add(lines, getline(begin)) - let begin = begin - 1 - endwhile - else - " Process the selected items in order - let begin = firstline - while begin <= lastline - call add(lines, getline(begin)) - let begin = begin + 1 - endwhile - endif - - if opcode ==# 'q' - " Close the yankring window - if s:yr_winsize_chgd == 1 - " Adjust the Vim window width back to the width - " it was before we showed the yankring window - let &columns= &columns - (g:yankring_window_width) - endif - - " Hide the YankRing window - hide - - if bufwinnr(s:yr_buffer_last) != -1 - " If the buffer is visible, switch to it - exec s:yr_buffer_last_winnr . "wincmd w" - endif - - return - elseif opcode ==# 's' - " Switch back to the original buffer - exec s:yr_buffer_last_winnr . "wincmd w" - - call s:YRSearch() - return - elseif opcode ==# 'u' - " Switch back to the original buffer - exec s:yr_buffer_last_winnr . "wincmd w" - - call s:YRShow(0) - return - elseif opcode ==# 'a' - let l:curr_line = line(".") - " Toggle the auto close setting - let g:yankring_window_auto_close = - \ (g:yankring_window_auto_close == 1?0:1) - " Display the status line / help - call s:YRWindowStatus(0) - call cursor(l:curr_line,0) - return - elseif opcode ==# 'c' - let l:curr_line = line(".") - " Toggle the clipboard monitor setting - let g:yankring_clipboard_monitor = - \ (g:yankring_clipboard_monitor == 1?0:1) - " Display the status line / help - call s:YRWindowStatus(0) - call cursor(l:curr_line,0) - return - elseif opcode ==# '?' - " Display the status line / help - call s:YRWindowStatus(1) - return - endif - - " Switch back to the original buffer - exec s:yr_buffer_last_winnr . "wincmd w" - - " Intentional case insensitive comparision - if opcode =~? 'p' - let cmd = 'YRGetElem ' - let parms = ", '".opcode."' " - elseif opcode ==? 'r' - let opcode = 'p' - let cmd = 'YRGetElem ' - let parms = ", 'p' " - elseif opcode ==# 'd' - let cmd = 'YRPop ' - let parms = "" - endif - - " Only execute this code if we are operating on elements - " within the yankring - if '[auq?]' !~# opcode - while v_count > 0 - " let iter = 0 - " let index = 0 - for line in lines - let elem = matchstr(line, '^\d\+') - if elem > 0 - if elem > 0 && elem <= s:yr_count - " if iter > 0 && opcode =~# 'p' - if opcode =~# 'p' - " Move to the end of the last pasted item - " only if pasting after (not above) - " '] - endif - exec cmd . elem . parms - " let iter += 1 - endif - endif - endfor - let v_count = v_count - 1 - endwhile - - if opcode ==# 'd' - call s:YRShow(0) - return "" - endif - - if g:yankring_window_auto_close == 1 && cmd_mode == 'v' - exec 'bdelete '.s:yr_buffer_id - return "" - endif - - endif - - return "" - -endfunction - -function! s:YRWarningMsg(msg) - echohl WarningMsg - echomsg a:msg - echohl None -endfunction - -function! s:YRErrorMsg(msg) - echohl ErrorMsg - echomsg a:msg - echohl None -endfunction - -function! s:YRWinLeave() - " Track which window we are last in. We will use this information - " to determine where we need to paste any contents, or which - " buffer to return to. - - if s:yr_buffer_id < 0 - " The yankring window has never been activated - return - endif - - if winbufnr(winnr()) == s:yr_buffer_id - " Ignore leaving the yankring window - return - endif - - if bufwinnr(s:yr_buffer_id) != -1 - " YankRing window is visible, so save off the previous buffer ids - let s:yr_buffer_last_winnr = winnr() - let s:yr_buffer_last = winbufnr(s:yr_buffer_last_winnr) - " else - " let s:yr_buffer_last_winnr = -1 - " let s:yr_buffer_last = -1 - endif -endfunction - -function! s:YRFocusGained() - if g:yankring_clipboard_monitor == 1 - " If the clipboard has changed record it inside the yankring - " echomsg "YRFocusGained[".len(@+)."][".@+.']['.s:yr_prev_clipboard.']' - if len(@+) > 0 && @+ != s:yr_prev_clipboard - let elem = s:YRMRUElemFormat( - \ getreg('+') - \ , getregtype('+') - \ ) - let found = s:YRMRUHas('s:yr_history_list', elem) - - " Only add the item to the "top" of the ring if it is - " not in the ring already. - if found == -1 - call YRRecord("+") - " silent! call YRRecord("+") - endif - endif - - " If the yankring window is open, refresh it - call s:YRWindowUpdate() - endif -endfunction - -function! s:YRInsertLeave() - " The YankRing uses omaps to execute the prescribed motion - " and then appends to the motion a call to a YankRing - " function to record the contents of the changed register. - " - " We cannot append a function call to the end of a motion - " that results in Insert mode. For example, any command - " like 'cw' enters insert mode. Appending a function call - " after the w, simply writes out the call as if the user - " typed it. - " - " Using the InsertLeave event, allows us to capture the - " contents of any changed register after it completes. - - call YRRecord(s:YRRegister()) - - " When performing a change (not a yank or delete) - " it is not possible to call yrrecord at the end - " of the command (or it's contents will be inserted - " into the buffer instead of executed). - " So, when using ".", we have to remove the _zap_ - " keys and then re-add them back again after we - " record the updates. - if s:yr_remove_omap_dot == 1 - call s:YRMapsCreate('add_only_zap_keys') - endif - -endfunction - -" Deleting autocommands first is a good idea especially if we want to reload -" the script without restarting vim. -" Call YRFocusGained to check if the clipboard has been updated -augroup YankRing - autocmd! - autocmd VimEnter * :if has('clipboard') | call YRFocusGained() | endif - autocmd WinLeave * :call YRWinLeave() - autocmd FocusGained * :if has('clipboard') | call YRFocusGained() | endif - autocmd InsertLeave * :call YRInsertLeave() -augroup END - - -" copy register -inoremap ', '', 'g') - let res = '' - let max = 0 - let mx = '\(]\{-}>\)\|\(<\/td>\)\|\(]\{-}>\)\|\(<\/div>\)' - let m = split(buf, mx) - for str in m - let c = split(str, '<[^>]*?>') - let str = substitute(str, '<[^>]\{-}>', ' ', 'g') - let str = substitute(str, '>', '>', 'g') - let str = substitute(str, '<', '<', 'g') - let str = substitute(str, '"', '"', 'g') - let str = substitute(str, ''', "'", 'g') - let str = substitute(str, ' ', ' ', 'g') - let str = substitute(str, '¥', '\¥', 'g') - let str = substitute(str, '&', '\&', '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 diff --git a/sources_forked/zencoding/doc/zencoding.txt b/sources_forked/zencoding/doc/zencoding.txt deleted file mode 100755 index ee453283..00000000 --- a/sources_forked/zencoding/doc/zencoding.txt +++ /dev/null @@ -1,438 +0,0 @@ -*zencoding.txt* ZenCoding for Vim - - ------------------------------------------------------- - ZenCoding: vim plugins for HTML and CSS hi-speed coding - ------------------------------------------------------- - -Author: Yasuhiro Matsumoto -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| |n| - 6. Go to Previous Edit Point |zencoding-goto-previous-point| - 7. Update 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: -> -
- - -
-< -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* *,* - - Type abbreviation as 'div>p#foo$*3>a' and type |,|. -> -
-

- -

-

- -

-

- -

-
-< -2. Wrap with Abbreviation *zencoding-wrap-wtih-abbreviation* *v_,* - - Write as below. -> - test1 - test2 - test3 -< - Then do visual select(line wize) and type |,|. - If you request 'Tag:', then type 'ul>li*'. -> -
    -
  • test1
  • -
  • test2
  • -
  • test3
  • -
-< - If you type tag as 'blockquote', then you'll see as following. -> -
- test1 - test2 - test3 -
-< -3. Balance Tag Inward *zencoding-balance-tag-inward* *d* - - To select inward of ul tag, type |d| in insert mode. -> -
    - *
  • -
  • -
  • -
-< - If cursor is at '*', |d| select from begin of
    to end of
. - If cursor is at first of
  • , it select
  • . - -4. Balance Tag Outward *zencoding-balance-tag-outward* *D* - - To select outward of ul tag, insert mode, type D in insert mode. -> -
      - *
    • -
    • -
    • -
    -< - If cursor is at '*', |D| select from next letter of
      to previous - letter of
    . - If cursor is at first of
  • , it select
  • . - -5. Go to Next Edit Point *zencoding-goto-next-point* *n* - - To jump next point that need to edit, type |n| in insert mode. -> - *
    foo
    -
    -< - If cursor is at '*', |n| move a cursor into attribute value of div - specified id as 'foo'. And type again |n| move a cursor into inner of - div specified id as 'bar'. - -6. Go to Previous Edit Point *zencoding-goto-previous-point* *N* - - To jump previous point that need to edit, type |N| in insert mode. -> -
    foo
    -
    * -< - If cursor is at '*', |N| move a cursor into div specified id as 'bar'. - And type again |N| move a cursor into attribute value of 'foo'. - -7. Update Size *zencoding-update-image-size* *i* - - To expand or update size of image, type |i| on img tag -> - -< - Type 'i' on img tag -> - -< - If you change image, then type it again. it will be following. -> - -< -8. Merge Lines *zencoding-merge-lines* - - To join multi line text like following, type |J|. -> -
      -
    • -
    • -
    • -
    -< - If you select part of line include
  • and type |m|, it will be - following. -> -
      -
    • -
    -< -9. Remove Tag *zencoding-remove-tag* *k* - - To remove tag in the block, type |k|. -> - -< - Type |k| in insert mode, then -> -
    - -
    -< - And type |k| in there again, then div will be removed. - -10. Split/Join Tag *zencoding-split-join-tag* *j* - - To join block, type |j|. -> -
    - cursor is here -
    -< - Type |j| in insert mode. then, -> -
    -< - And type |j| in there again. -> -
    -
    -< -11. Toggle Comment *zencoding-toggle-comment* */* - - Move cursor to block -> -
    - hello world -
    -< - Type '/' in insert mode. -> - -< - Type '/' in there again. -> -
    - hello world -
    -< -12. Make anchor from URL *zencoding-make-anchor-url* *a* - - Move cursor to URL -> - http://www.google.com/ -< - Type |a| -> - Google -< -13. Make quoted text from URL *zencoding-quoted-text-url* *A* - - Move cursor to URL -> - http://github.com/ -< - Type |A| -> -
    - Secure source code hosting and collaborative development - GitHub
    -

    How does it work? Get up and running in seconds by forking a project, pushing an existing repository...

    - http://github.com/ -
    -< -14. Code Pretty *zencoding-code-pretty* *c* - - Select code block, for example select following code from "int main()". -> -

    Writing in C language

    - - int main() { - puts("hello world"); - } -< - Type |c| -> -

    Writing in C language

    - - int main() {
    -   puts("hello world");
    - }
    -< -============================================================================== -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 = '' -< - 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: diff --git a/sources_forked/zencoding/plugin/zencoding.vim b/sources_forked/zencoding/plugin/zencoding.vim deleted file mode 100755 index e627653d..00000000 --- a/sources_forked/zencoding/plugin/zencoding.vim +++ /dev/null @@ -1,215 +0,0 @@ -"============================================================================= -" File: zencoding.vim -" Author: Yasuhiro Matsumoto -" 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 "," (Ctrl+y and Comma) -" NOTE: Don't worry about key map. you can change it easily. -" +------------------------------------- -" | -" | -" | -" | -" | -" | -" | -" | _ -" | -" | -" +------------------------------------- -" Type following -" +------------------------------------- -" | div#foo$*2>div.bar -" +------------------------------------- -" And type "," -" +------------------------------------- -" |
    -" |
    _
    -" |
    -" |
    -" |
    -" |
    -" +------------------------------------- -" -" 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 = '' -endif - -function! s:install_plugin_i() - for item in [ - \ {'mode': 'i', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandAbbr', 'func': 'u:call zencoding#expandAbbr(0,"")a'}, - \ {'mode': 'i', 'var': 'user_zen_expandword_key', 'key': ';', 'plug': 'ZenCodingExpandWord', 'func': 'u:call zencoding#expandAbbr(1,"")a'}, - \ {'mode': 'i', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardInsert', 'func': ':call zencoding#balanceTag(1)'}, - \ {'mode': 'i', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardInsert', 'func': ':call zencoding#balanceTag(-1)'}, - \ {'mode': 'i', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)'}, - \ {'mode': 'i', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)'}, - \ {'mode': 'i', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()a'}, - \ {'mode': 'i', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()a'}, - \ {'mode': 'i', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagInsert', 'func': ':call zencoding#splitJoinTag()'}, - \ {'mode': 'i', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()a'}, - \ {'mode': 'i', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)a'}, - \ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)a'}, - \] - - if !hasmapto(''.item.plug, item.mode) - exe item.mode . 'noremap ' . 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 ' . key . ' ' . 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,"")'}, - \ {'mode': 'n', 'var': 'user_zen_expandword_key', 'key': ',', 'plug': 'ZenCodingExpandWord', 'func': ':call zencoding#expandAbbr(1,"")'}, - \ {'mode': 'n', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardNormal', 'func': ':call zencoding#balanceTag(1)'}, - \ {'mode': 'n', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardNormal', 'func': ':call zencoding#balanceTag(-1)'}, - \ {'mode': 'n', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)'}, - \ {'mode': 'n', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)'}, - \ {'mode': 'n', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()'}, - \ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()'}, - \ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagNormal', 'func': ':call zencoding#splitJoinTag()'}, - \ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()'}, - \ {'mode': 'n', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)'}, - \ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)'}, - \] - - if !hasmapto(''.item.plug, item.mode) - exe item.mode . 'noremap ' . 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 ' . key . ' ' . 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,"")'}, - \ {'mode': 'v', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardVisual', 'func': ':call zencoding#balanceTag(2)'}, - \ {'mode': 'v', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardVisual', 'func': ':call zencoding#balanceTag(-2)'}, - \ {'mode': 'v', 'var': 'user_zen_mergelines_key', 'key': 'm', 'plug': 'ZenCodingMergeLines', 'func': ':call zencoding#mergeLines()'}, - \ {'mode': 'v', 'var': 'user_zen_codepretty_key', 'key': 'c', 'plug': 'ZenCodingCodePretty', 'func': ':call zencoding#codePretty()'}, - \] - - if !hasmapto(''.item.plug, item.mode) - exe item.mode . 'noremap ' . 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 ' . key . ' ' . 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, ) - -let &cpo = s:save_cpo -unlet s:save_cpo - -" vim:set et: diff --git a/sources_forked/zencoding/unittest.vim b/sources_forked/zencoding/unittest.vim deleted file mode 100755 index c4fcc3d2..00000000 --- a/sources_forked/zencoding/unittest.vim +++ /dev/null @@ -1,794 +0,0 @@ -let s:sfile = expand('') - -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 = "\," - endif - silent! let query = substitute(query, '\$\$\$\$.*\$\$\$\$', '$$$$', '') - silent! call setline(1, split(query, "\n")) - let cmd = "normal gg0/\\$\\$\\$\\$\ri\\\\".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() -if s:sfile == expand('%:p') - ZenCodingUnitTest -endif - -finish -[ -{ - 'type': "html", - 'categories': [ - { - 'name': 'expand abbreviation', - 'tests': [ - { - 'query': "div", - 'result': "
    \n", - }, - { - 'query': "div#wrapper", - 'result': "
    \n", - }, - { - 'query': "div.box", - 'result': "
    \n", - }, - { - 'query': "a[title=TITLE]", - 'result': "\n", - }, - { - 'query': "div#wrapper.box", - 'result': "
    \n", - }, - { - 'query': "div#wrapper.box.current", - 'result': "
    \n", - }, - { - 'query': "div#wrapper.box.current[title=TITLE rel]", - 'result': "
    \n", - }, - { - 'query': "div#main+div#sub", - 'result': "
    \n
    \n", - }, - { - 'query': "div#main>div#sub", - 'result': "
    \n\t
    \n
    \n", - }, - { - 'query': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a", - 'result': "\n\n\n\t\n\t\n\n\n\t
    \n\t\t
    \n\t\t
      \n\t\t\t
    • \n\t\t\t
    • \n\t\t\t
    • \n\t\t\t
    • \n\t\t\t
    • \n\t\t
    \n\t
    \n\t\n\n", - }, - { - 'query': "ol>li*2", - 'result': "
      \n\t
    1. \n\t
    2. \n
    \n", - }, - { - 'query': "a", - 'result': "\n", - }, - { - 'query': "obj", - 'result': "\n", - }, - { - 'query': "cc:ie6>p+blockquote#sample$.so.many.classes*2", - 'result': "", - }, - { - 'query': "html:4t>div#wrapper>div#header+div#contents+div#footer", - 'result': "\n\n\n\t\n\t\n\n\n\t
    \n\t\t
    \n\t\t
    \n\t\t
    \n\t
    \n\t\n\n", - }, - { - 'query': "a[href=http://www.google.com/].foo#hoge", - 'result': "\n", - }, - { - 'query': "a[href=http://www.google.com/]{Google}", - 'result': "Google\n", - }, - { - 'query': "{ZenCoding}", - 'result': "ZenCoding", - }, - { - 'query': "a+b", - 'result': "\n\n", - }, - { - 'query': "a>b>i\n", - }, - { - 'query': "a>b>i^b", - 'result': "\n", - }, - { - 'query': "a>b>i<\n\n", - }, - { - 'query': "a>b>i^^b", - 'result': "\n\n", - }, - { - 'query': "blockquote>b>i<\n\n", - }, - { - 'query': "blockquote>b>i^^b", - 'result': "
    \n\n", - }, - { - 'query': "a[href=foo][class=bar]", - 'result': "\n", - }, - { - 'query': "a[a=b][b=c=d][e]{foo}*2", - 'result': "foo\nfoo\n", - }, - { - 'query': "a[a=b][b=c=d][e]*2{foo}", - 'result': "\n\nfoo", - }, - { - 'query': "a*2{foo}a", - 'result': "\n\nfoo\n", - }, - { - 'query': "a{foo}*2>b", - 'result': "foo\nfoo\n", - }, - { - 'query': "a*2{foo}>b", - 'result': "\n\nfoo", - }, - { - 'query': "table>tr>td.name#foo+td*3", - 'result': "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n
    \n", - }, - { - 'query': "div#header + div#footer", - 'result': "
    \n
    \n", - }, - { - 'query': "#header + div#footer", - 'result': "
    \n
    \n", - }, - { - 'query': "#header > ul > li < p{Footer}", - 'result': "
    \n\t
      \n\t\t
    • \n\t
    \n\t

    Footer

    \n
    \n", - }, - { - 'query': "#header > ul > li ^ p{Footer}", - 'result': "
    \n\t
      \n\t\t
    • \n\t
    \n\t

    Footer

    \n
    \n", - }, - { - 'query': "a#foo$$$*3", - 'result': "\n\n\n", - }, - { - 'query': "ul+", - 'result': "
      \n\t
    • \n
    \n", - }, - { - 'query': "table+", - 'result': "\n\t\n\t\t\n\t\n
    \n", - }, - { - 'query': "#header>li<#content", - 'result': "
    \n\t
  • \n
    \n
    \n", - }, - { - 'query': "#header>li^#content", - 'result': "
    \n\t
  • \n
    \n
    \n", - }, - { - 'query': "(#header>li)<#content", - 'result': "
    \n\t
  • \n
    \n
    \n", - }, - { - 'query': "(#header>li)^#content", - 'result': "
    \n\t
  • \n
    \n
    \n", - }, - { - 'query': "a>b>i<\n
    \n", - }, - { - 'query': "a>b>i^^div", - 'result': "\n
    \n", - }, - { - 'query': "(#header>h1)+#content+#footer", - 'result': "
    \n\t

    \n
    \n
    \n
    \n", - }, - { - 'query': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)", - 'result': "
    \n\t

    \n
    \n
    \n\t
    \n\t\t

    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t
    \n\t
    \n
    \n
    \n\t
    \n
    \n", - }, - { - 'query': "(div>(ul*2)*2)+(#utilities)", - 'result': "
    \n\t
      \n\t
        \n\t
          \n\t
            \n
            \n
            \n", - }, - { - 'query': "table>(tr>td*3)*4", - 'result': "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n
            \n", - }, - { - 'query': "(((a#foo+a#bar)*2)*3)", - 'result': "\n\n\n\n\n\n\n\n\n\n\n\n", - }, - { - 'query': "div#box$*3>h3+p*2", - 'result': "
            \n\t

            \n\t

            \n\t

            \n
            \n
            \n\t

            \n\t

            \n\t

            \n
            \n
            \n\t

            \n\t

            \n\t

            \n
            \n" - }, - { - 'query': "div#box.foo$$$.bar$$$*3", - 'result': "
            \n
            \n
            \n", - }, - { - 'query': "div#box$*3>h3+p.bar*2|e", - 'result': "<div id=\"box1\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n", - }, - { - 'query': "div>div#page>p.title+p|c", - 'result': "
            \n\t\n\t
            \n\t\t\n\t\t

            \n\t\t\n\t\t

            \n\t
            \n\t\n
            \n", - }, - { - 'query': "link:css", - 'result': "\n", - }, - { - 'query': "a[title=\"Hello', world\" rel]", - 'result': "\n", - }, - { - 'query': "div>a#foo{bar}", - 'result': "\n", - }, - { - 'query': ".content{Hello!}", - 'result': "
            Hello!
            \n", - }, - { - 'query': "div.logo+(div#navigation)+(div#links)", - 'result': "
            \n
            \n
            \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': "

            header

            \nTextlinktext\nagain some textclick me!\nsome final text", - }, - { - 'query': "a{&}+div{&&}", - 'result': "&\n
            &&
            \n", - }, - { - 'query': "span$$$$\\,$$$$", - 'result': "", - }, - { - 'query': "foo span$$$$\\,$$$$", - 'result': "foo ", - }, - { - 'query': "foo span$$$$\\,$$$$ bar", - 'result': "foo bar", - }, - { - 'query': "foo $$$$\\ve\\,p\\$$$$bar baz", - 'result': "foo

            bar

            baz", - }, - { - 'query': "foo $$$$\\vee\\,p\\$$$$bar baz", - 'result': "foo

            bar baz

            ", - }, - { - 'query': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$", - 'result': "f
            \n\t
            \n\t\t
            \n\t\t\t
            \n\t\t\t\t

            aaa

            \n\t\t\t\t

            bbb

            \n\t\t\t
            \n\t\t\t

            ccc

            \n\t\t
            \n\t
            \n
            ", - }, - { - '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': "
            \n\t
            \n\t\t
            \n\t\t\t

            a

            \n\t\t\t

            b

            \n\t\t
            \n\t
            \n\t
            \n\t\t
            \n\t\t\t

            c

            \n\t\t\t

            d

            \n\t\t\t

            e

            \n\t\t\t
            \n\t\t\t\t

            f

            \n\t\t\t\t

            g

            \n\t\t\t
            \n\t\t\t

            h

            \n\t\t
            \n\t
            \n
            \n", - }, - { - 'query': "(div>(label+input))+div", - 'result': "
            \n\t\n\t\n
            \n
            \n", - }, - { - 'query': "test1\ntest2\ntest3$$$$\\ggVG\\,ul>li>span*>a\\$$$$", - 'result': "", - }, - { - 'query': "test1\ntest2\ntest3$$$$\\ggVG\\,input[type=input value=$#]*\\$$$$", - 'result': "\n\n", - }, - { - 'query': "div#id-$*5>div#id2-$", - 'result': "
            \n\t
            \n
            \n
            \n\t
            \n
            \n
            \n\t
            \n
            \n
            \n\t
            \n
            \n
            \n\t
            \n
            \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': "foo\n", - }, - ], - }, - { - 'name': 'split join tag', - 'tests': [ - { - 'query': "
            \n\t$$$$\\j$$$$\n
            ", - 'result': "
            \n\t\n
            ", - }, - { - 'query': "
            \n\tj$$$$/>\n
            ", - 'result': "
            \n\t\n
            ", - }, - ], - }, - { - 'name': 'toggle comment', - 'tests': [ - { - 'query': "
            \n\t$$$$\\/$$$$\n
            ", - 'result': "
            \n\t\n
            ", - }, - { - 'query': "
            \n\t\n
            ", - 'result': "
            \n\t\n
            ", - }, - ], - }, - { - 'name': 'image size', - 'tests': [ - { - 'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\,\\i$$$$", - 'result': "\"\"", - }, - { - 'query': "img[src=/logo.png]$$$$\\,\\i$$$$", - 'result': "\"\"", - }, - ], - }, - { - 'name': 'move next prev', - 'tests': [ - { - 'query': "foo+bar+baz[dankogai=\"\"]$$$$\\,\\gg0\\n\\n\\n\\Byw:%d _\\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$$$$\\j$$$$", - 'result': "%a ", - }, - { - 'query': "$$$$\\j$$$$%a ", - 'result': "%a $$$$", - }, - ], - }, - { - 'name': 'toggle comment', - 'tests': [ - { - 'query': "%a{ :href => \"http://www.google.com\"$$$$\\/$$$$ } hello", - 'result': "-# %a{ :href => \"http://www.google.com\" } hello", - }, - { - 'query': "-# %a{ :href => \"http://www.google.com\"$$$$\\/$$$$ } 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$$$$\\j$$$$", - 'result': "a", - }, - { - 'query': "a$$$$\\j$$$$", - 'result': "a\n | $$$$", - }, - ], - }, - { - 'name': 'toggle comment', - 'tests': [ - { - 'query': "a href=\"http://www.google.com\"$$$$\\/$$$$\n | hello", - 'result': "/a href=\"http://www.google.com\"\n | hello", - }, - { - 'query': "/a href=\"http://www.google.com\"$$$$\\/$$$$\n | hello", - 'result': "a href=\"http://www.google.com\"\n | hello", - }, - ], - }, - ], -}, -{ - 'type': 'xsl', - 'categories': [ - { - 'name': 'expand abbreviation', - 'tests': [ - { - 'query': "vari", - 'result': "\n", - }, - { - 'query': "ap>wp", - 'result': "\n\t\n\n", - }, - ], - }, - ], -}, -{ - 'type': 'xsd', - 'categories': [ - { - 'name': 'expand abbreviation', - 'tests': [ - { - 'query': "xsd:w3c", - 'result': "\n\n\t\n", - }, - ], - }, - ], -}, -{ - 'type': 'mustache', - 'categories': [ - { - 'name': 'expand abbreviation', - 'tests': [ - { - 'query': "div#{{foo}}", - 'result': "
            \n", - }, - { - 'query': "div.{{foo}}", - 'result': "
            \n", - }, - ], - }, - ], -}, -] -" vim:set et: diff --git a/sources_forked/zencoding/zencoding.vim.vimup b/sources_forked/zencoding/zencoding.vim.vimup deleted file mode 100755 index 72608e48..00000000 --- a/sources_forked/zencoding/zencoding.vim.vimup +++ /dev/null @@ -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 "," (Ctrl + y and Comma) - NOTE: Don't worry about key map. you can change it easily. - +------------------------------------- - | - | - | - | - | - | - | - | _ - | - | - +------------------------------------- - Type following - +------------------------------------- - | div#foo$*2>div.bar - +------------------------------------- - And type "," - +------------------------------------- - |
            - |
            _
            - |
            - |
            - |
            - |
            - | _ - +------------------------------------- - - 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 = '' - - 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 '' from ''. -- '0.28': | - This is an upgrade for ZenCoding.vim: supported 'Balance Tag Inward/Outward', 'Go to Next/Previous Edit Point', 'Update 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>lili'. 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 'b_'. -- '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 diff --git a/sources_non_forked/ack.vim/LICENSE b/sources_non_forked/ack.vim/LICENSE new file mode 100644 index 00000000..056ea36c --- /dev/null +++ b/sources_non_forked/ack.vim/LICENSE @@ -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 + 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 . 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 + + +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. diff --git a/sources_non_forked/ack.vim/README.md b/sources_non_forked/ack.vim/README.md index c2e87067..af8f522d 100644 --- a/sources_non_forked/ack.vim/README.md +++ b/sources_non_forked/ack.vim/README.md @@ -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 a :Ack! +``` + +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 diff --git a/sources_non_forked/ack.vim/autoload/ack.vim b/sources_non_forked/ack.vim/autoload/ack.vim index 12237e4e..dbf84572 100644 --- a/sources_non_forked/ack.vim/autoload/ack.vim +++ b/sources_non_forked/ack.vim/autoload/ack.vim @@ -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("") : 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 diff --git a/sources_non_forked/ack.vim/doc/ack.txt b/sources_non_forked/ack.vim/doc/ack.txt index bdef3227..22e884bc 100644 --- a/sources_non_forked/ack.vim/doc/ack.txt +++ b/sources_non_forked/ack.vim/doc/ack.txt @@ -4,6 +4,10 @@ Author: Antoine Imbert *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": "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 a :Ack! +< + 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': 'LpJp', + \ 'gv': 'LpJ' } +< + 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: diff --git a/sources_non_forked/ack.vim/doc/ack_quick_help.txt b/sources_non_forked/ack.vim/doc/ack_quick_help.txt index bcdf5160..94306a0e 100644 --- a/sources_non_forked/ack.vim/doc/ack_quick_help.txt +++ b/sources_non_forked/ack.vim/doc/ack_quick_help.txt @@ -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 ======================================== diff --git a/sources_non_forked/ack.vim/plugin/ack.vim b/sources_non_forked/ack.vim/plugin/ack.vim index da3ea9ab..202ae2ea 100644 --- a/sources_non_forked/ack.vim/plugin/ack.vim +++ b/sources_non_forked/ack.vim/plugin/ack.vim @@ -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', ) command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd', ) command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep', ) diff --git a/sources_non_forked/ag.vim/README.md b/sources_non_forked/ag.vim/README.md index c0e92cbe..e02a4d3e 100644 --- a/sources_non_forked/ag.vim/README.md +++ b/sources_non_forked/ag.vim/README.md @@ -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=" --vimgrep" + let g:ag_prg=" --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) diff --git a/sources_non_forked/ag.vim/autoload/ag.vim b/sources_non_forked/ag.vim/autoload/ag.vim index 6703396b..432ef444 100644 --- a/sources_non_forked/ag.vim/autoload/ag.vim +++ b/sources_non_forked/ag.vim/autoload/ag.vim @@ -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 /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 diff --git a/sources_non_forked/ctrlp.vim/.gitignore b/sources_non_forked/ctrlp.vim/.gitignore index 06fcd832..3dc7cfe1 100644 --- a/sources_non_forked/ctrlp.vim/.gitignore +++ b/sources_non_forked/ctrlp.vim/.gitignore @@ -2,5 +2,6 @@ *.zip note.txt tags +tags-cn .hg* tmp/* diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim index 19ac1463..b0146a36 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim @@ -86,9 +86,18 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'status_func': ['s:status', {}], \ 'tabpage_position': ['s:tabpage', 'ac'], \ 'use_caching': ['s:caching', 1], - \ 'use_migemo': ['s:migemo', 0], \ 'user_command': ['s:usrcmd', ''], + \ 'validate': ['s:validate', ''], \ 'working_path_mode': ['s:pathmode', 'ra'], + \ 'line_prefix': ['s:lineprefix', '> '], + \ 'open_single_match': ['s:opensingle', []], + \ 'brief_prompt': ['s:brfprt', 0], + \ 'match_current_file': ['s:matchcrfile', 0], + \ 'match_natural_name': ['s:matchnatural', 0], + \ 'compare_lim': ['s:compare_lim', 3000], + \ 'bufname_mod': ['s:bufname_mod', ':t'], + \ 'bufpath_mod': ['s:bufpath_mod', ':~:.:h'], + \ 'formatline_func': ['s:flfunc', 's:formatline(v:val)'], \ }, { \ 'open_multiple_files': 's:opmul', \ 'regexp': 's:regexp', @@ -141,6 +150,7 @@ let [s:lcmap, s:prtmaps] = ['nn ', { \ 'CreateNewFile()': [''], \ 'MarkToOpen()': [''], \ 'OpenMulti()': [''], + \ 'YankLine()': [], \ 'PrtExit()': ['', '', ''], \ }] @@ -148,8 +158,6 @@ if !has('gui_running') cal add(s:prtmaps['PrtBS()'], remove(s:prtmaps['PrtCurLeft()'], 0)) en -let s:compare_lim = 3000 - let s:ficounts = {} let s:ccex = s:pref.'clear_cache_on_exit' @@ -162,6 +170,9 @@ let s:fpats = { \ '^\S\\?$': '\\?', \ } +let s:has_conceal = has('conceal') +let s:bufnr_width = 3 + " Keypad let s:kprange = { \ 'Plus': '+', @@ -181,7 +192,24 @@ let s:hlgrps = { \ 'PrtBase': 'Comment', \ 'PrtText': 'Normal', \ 'PrtCursor': 'Constant', + \ 'BufferNr': 'Constant', + \ 'BufferInd': 'Normal', + \ 'BufferHid': 'Comment', + \ 'BufferHidMod': 'String', + \ 'BufferVis': 'Normal', + \ 'BufferVisMod': 'Identifier', + \ 'BufferCur': 'Question', + \ 'BufferCurMod': 'WarningMsg', + \ 'BufferPath': 'Comment', \ } + +" lname, sname of the basic(non-extension) modes +let s:coretypes = filter([ + \ ['files', 'fil'], + \ ['buffers', 'buf'], + \ ['mru files', 'mru'], +\ ], 'index(g:ctrlp_types, v:val[1])!=-1') + " Get the options {{{2 fu! s:opts(...) unl! s:usrign s:usrcmd s:urprtmaps @@ -219,6 +247,7 @@ fu! s:opts(...) for each in ['byfname', 'regexp'] | if exists(each) let s:{each} = {each} en | endfo + if !exists('g:ctrlp_tilde_homedir') | let g:ctrlp_tilde_homedir = 0 | en if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en let s:maxdepth = min([s:maxdepth, 100]) let s:glob = s:showhidden ? '.*\|*' : '*' @@ -283,16 +312,17 @@ fu! s:Open() sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va) en | endfo if s:opmul != '0' && has('signs') - sign define ctrlpmark text=+> texthl=Search + sign define ctrlpmark text=+> texthl=CtrlPMark + hi def link CtrlPMark Search en cal s:setupblank() endf -fu! s:Close() +fu! s:Close(exit) cal s:buffunc(0) if winnr('$') == 1 bw! - el + elsei a:exit try | bun! cat | clo! | endt cal s:unmarksigns() @@ -305,7 +335,7 @@ fu! s:Close() if s:winres[1] >= &lines && s:winres[2] == winnr('$') exe s:winres[0].s:winres[0] en - unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr + unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:init s:savestr \ s:mrbs s:did_exp cal ctrlp#recordhist() cal s:execextvar('exit') @@ -343,7 +373,9 @@ fu! ctrlp#files() " Get the list of files if empty(lscmd) if !ctrlp#igncwd(s:dyncwd) + cal s:InitCustomFuncs() cal s:GlobPath(s:fnesc(s:dyncwd, 'g', ','), 0) + cal s:CloseCustomFuncs() en el sil! cal ctrlp#progress('Indexing...') @@ -369,6 +401,18 @@ fu! ctrlp#files() retu g:ctrlp_allfiles endf +fu! s:InitCustomFuncs() + if s:igntype == 4 && has_key(s:usrign, 'func-init') && s:usrign['func-init'] != '' + exe call(s:usrign['func-init'], []) + en +endf + +fu! s:CloseCustomFuncs() + if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != '' + exe call(s:usrign['func-close'], []) + en +endf + fu! s:GlobPath(dirs, depth) let entries = split(globpath(a:dirs, s:glob), "\n") let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] @@ -384,14 +428,21 @@ fu! s:UserCmd(lscmd) let do_ign = \ type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore'] if do_ign && ctrlp#igncwd(s:cwd) | retu | en - if exists('+ssl') && &ssl + if exists('+ssl') && &ssl && &shell !~ 'sh' let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')] en - if has('win32') || has('win64') + if (has('win32') || has('win64')) && match(&shellcmdflag, "/") != -1 let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '') en let path = exists('*shellescape') ? shellescape(path) : path - let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n") + if (has('win32') || has('win64')) && match(&shell, 'sh') != -1 + let path = tr(path, '\', '/') + en + if has('patch-7.4-597') && !(has('win32') || has('win64')) + let g:ctrlp_allfiles = systemlist(printf(lscmd, path)) + el + let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n") + en if exists('+ssl') && exists('ssl') let &ssl = ssl cal map(g:ctrlp_allfiles, 'tr(v:val, "\\", "/")') @@ -439,9 +490,27 @@ fu! s:lsCmd() en endf " - Buffers {{{1 +fu! s:bufparts(bufnr) + let idc = (a:bufnr == bufnr('#') ? '#' : '') " alternative + let idc .= (getbufvar(a:bufnr, '&mod') ? '+' : '') " modified + let idc .= (getbufvar(a:bufnr, '&ma') ? '' : '-') " nomodifiable + let idc .= (getbufvar(a:bufnr, '&ro') ? '=' : '') " readonly + + " flags for highlighting + let hiflags = (bufwinnr(a:bufnr) != -1 ? '*' : '') " visible + let hiflags .= (getbufvar(a:bufnr, '&mod') ? '+' : '') " modified + let hiflags .= (a:bufnr == s:crbufnr ? '!' : '') " current + + let bname = bufname(a:bufnr) + let bname = (bname == '' ? '[No Name]' : fnamemodify(bname, s:bufname_mod)) + + let bpath = empty(s:bufpath_mod) ? '' : fnamemodify(bufname(a:bufnr), s:bufpath_mod).s:lash() + + retu [idc, hiflags, bname, bpath] +endf fu! ctrlp#buffers(...) - let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))' - \ .' && getbufvar(v:val, "&bl")'), 's:compmreb') + let ids = sort(filter(range(1, bufnr('$')), '(empty(getbufvar(v:val, "&bt"))' + \ .' || s:isneovimterminal(v:val)) && getbufvar(v:val, "&bl")'), 's:compmreb') if a:0 && a:1 == 'id' retu ids el @@ -463,9 +532,12 @@ fu! s:MatchIt(items, pat, limit, exc) \ : s:martcs.a:pat for item in a:items let id += 1 - try | if !( s:ispath && item == a:exc ) && call(s:mfunc, [item, pat]) >= 0 - cal add(lines, item) - en | cat | brea | endt + try + if (s:matchcrfile || !( s:ispath && item == a:exc )) && + \call(s:mfunc, [item, pat]) >= 0 + cal add(lines, item) + en + cat | brea | endt if a:limit > 0 && len(lines) >= a:limit | brea | en endfo let s:mdata = [s:dyncwd, s:itemtype, s:regexp, s:sublist(a:items, id, -1)] @@ -497,9 +569,6 @@ endf fu! s:SplitPattern(str) let str = a:str - if s:migemo && s:regexp && len(str) > 0 && executable('cmigemo') - let str = s:migemo(str) - en let s:savestr = str if s:regexp let pat = s:regexfilter(str) @@ -533,6 +602,7 @@ fu! s:Render(lines, pat) let height = min([max([s:mw_min, s:res_count]), s:winmaxh]) let pat = s:byfname() ? split(a:pat, '^[^;]\+\\\@ winheight(0) | cal s:BuildPrompt(0) | en + let pos = exists('*getcurpos') ? getcurpos() : getpos('.') + cal s:BuildPrompt(0) + cal setpos('.', pos) endf fu! s:PrtSelectJump(char) @@ -789,8 +867,9 @@ fu! s:PrtSelectJump(char) let [jmpln, s:jmpchr] = [npos == -1 ? pos : npos, [chr, npos]] en exe 'keepj norm!' ( jmpln + 1 ).'G' - if s:nolim != 1 | let s:cline = line('.') | en - if line('$') > winheight(0) | cal s:BuildPrompt(0) | en + let pos = exists('*getcurpos') ? getcurpos() : getpos('.') + cal s:BuildPrompt(0) + cal setpos('.', pos) en endf " Misc {{{2 @@ -799,12 +878,13 @@ fu! s:PrtFocusMap(char) endf fu! s:PrtClearCache() - if s:itemtype == 0 + let ct = s:curtype() + if ct == 'fil' cal ctrlp#clr() - elsei s:itemtype > 2 + elsei s:itemtype >= len(s:coretypes) cal ctrlp#clr(s:statypes[s:itemtype][1]) en - if s:itemtype == 2 + if ct == 'mru' let g:ctrlp_lines = ctrlp#mrufiles#refresh() el cal ctrlp#setlines() @@ -815,22 +895,26 @@ fu! s:PrtClearCache() endf fu! s:PrtDeleteEnt() - if s:itemtype == 2 + let ct = s:curtype() + if ct == 'mru' cal s:PrtDeleteMRU() + elsei ct == 'buf' + cal s:delbuf() elsei type(s:getextvar('wipe')) == 1 cal s:delent(s:getextvar('wipe')) en endf fu! s:PrtDeleteMRU() - if s:itemtype == 2 + if s:curtype() == 'mru' cal s:delent('ctrlp#mrufiles#remove') en endf fu! s:PrtExit() + exe bufwinnr(s:bufnr).'winc w' if bufnr('%') == s:bufnr && bufname('%') == 'ControlP' - noa cal s:Close() + noa cal s:Close(1) noa winc p en endf @@ -875,7 +959,7 @@ fu! s:MapSpecs() if !( exists('s:smapped') && s:smapped == s:bufnr ) " Correct arrow keys in terminal if ( has('termresponse') && v:termresponse =~ "\" ) - \ || &term =~? '\vxterm|','\B ','\C ','\D '] exe s:lcmap.' ['.each endfo @@ -888,15 +972,25 @@ fu! s:MapSpecs() endf fu! s:KeyLoop() + let [t_ve, guicursor] = [&t_ve, &guicursor] wh exists('s:init') && s:keyloop - redr - let nr = getchar() + try + set t_ve= + set guicursor=a:NONE + let nr = getchar() + fina + let &t_ve = t_ve + let &guicursor = guicursor + endt let chr = !type(nr) ? nr2char(nr) : nr if nr >=# 0x20 cal s:PrtFocusMap(chr) el let cmd = matchstr(maparg(chr), ':\zs.\+\ze$') - exe ( cmd != '' ? cmd : 'norm '.chr ) + try + exe ( cmd != '' ? cmd : 'norm '.chr ) + cat + endt en endw endf @@ -920,10 +1014,10 @@ fu! s:ToggleByFname() endf fu! s:ToggleType(dir) - let max = len(g:ctrlp_ext_vars) + 2 + let max = len(g:ctrlp_ext_vars) + len(s:coretypes) - 1 let next = s:walker(max, s:itemtype, a:dir) - cal ctrlp#syntax() cal ctrlp#setlines(next) + cal ctrlp#syntax() cal s:PrtSwitcher() endf @@ -959,23 +1053,19 @@ fu! s:SetWD(args) if has_key(a:args, 'dir') && a:args['dir'] != '' cal ctrlp#setdir(a:args['dir']) | retu en - let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode + let pmodes = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()] - if s:crfile =~ '^.\+://' | retu | en - if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 ) - \ || ( !type(pmode) && pmode ) - if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en - cal ctrlp#setdir(s:crfpath) - en - if pmode =~ 'r' || pmode == 2 - let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] - let spath = pmode =~ 'd' ? s:dyncwd : pmode =~ 'w' ? s:cwd : s:crfpath - if type(s:rmarkers) == 3 && !empty(s:rmarkers) - if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu | en - cal filter(markers, 'index(s:rmarkers, v:val) < 0') - en - cal s:findroot(spath, markers, 0, 0) + if (!type(pmodes)) + let pmodes = + \ pmodes == 0 ? '' : + \ pmodes == 1 ? 'a' : + \ pmodes == 2 ? 'r' : + \ 'c' en + let spath = pmodes =~ 'd' ? s:dyncwd : pmodes =~ 'w' ? s:cwd : s:crfpath + for pmode in split(pmodes, '\zs') + if ctrlp#setpathmode(pmode, spath) | retu | en + endfo endf " * AcceptSelection() {{{1 fu! ctrlp#acceptfile(...) @@ -990,18 +1080,15 @@ fu! ctrlp#acceptfile(...) if !type(line) let [filpath, bufnr, useb] = [line, line, 1] el - let filpath = fnamemodify(line, ':p') - if s:nonamecond(line, filpath) - let bufnr = str2nr(matchstr(line, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) - let [filpath, useb] = [bufnr, 1] - el - let bufnr = bufnr('^'.filpath.'$') + let [bufnr, filpath] = s:bufnrfilpath(line) + if bufnr == filpath + let useb = 1 en en cal s:PrtExit() let tail = s:tail() let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$') - if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0 + if bufnr > 0 && ( !empty(s:jmptobuf) && s:jmptobuf =~ md ) \ && !( md == 'e' && bufnr == bufnr('%') ) let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)] let buftab = ( s:jmptobuf =~# '[tTVH]' || s:jmptobuf > 1 ) @@ -1067,7 +1154,7 @@ fu! s:AcceptSelection(action) if subm | if s:SpecInputs(str) | retu | en | en " Get the selected line let line = ctrlp#getcline() - if !subm && !s:itemtype && line == '' && line('.') > s:offset + if !subm && s:curtype() != 'fil' && line == '' && line('.') > s:offset \ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$' cal s:CreateNewFile(md) | retu en @@ -1077,7 +1164,7 @@ fu! s:AcceptSelection(action) let actfunc = s:openfunc[s:ctype] let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list' el - if s:itemtype < 3 + if s:itemtype < len(s:coretypes) let [actfunc, type] = ['ctrlp#acceptfile', 'dict'] el let [actfunc, exttype] = [s:getextvar('accept'), s:getextvar('act_farg')] @@ -1122,11 +1209,19 @@ fu! s:CreateNewFile(...) endf " * OpenMulti() {{{1 fu! s:MarkToOpen() + let ct = s:curtype() if s:bufnr <= 0 || s:opmul == '0' - \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 ) + \ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 ) retu en let line = ctrlp#getcline() + + " Do not allow to mark modified or current buffer + let bufnr = s:bufnrfilpath(line)[0] + if (ct == 'buf' && s:delbufcond(bufnr)) + retu + en + if empty(line) | retu | en let filpath = s:ispath ? fnamemodify(line, ':p') : line if exists('s:marked') && s:dictindex(s:marked, filpath) > 0 @@ -1156,7 +1251,7 @@ endf fu! s:OpenMulti(...) let has_marked = exists('s:marked') if ( !has_marked && a:0 ) || s:opmul == '0' || !s:ispath - \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 ) + \ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 ) retu -1 en " Get the options @@ -1235,6 +1330,18 @@ fu! s:OpenMulti(...) unl! s:tabct endf +fu! s:YankLine(...) + let @" = s:getinput() + let has_marked = exists('s:marked') + if !has_marked + let line = ctrlp#getcline() + if line == '' | retu | en + let marked = { 1 : fnamemodify(line, ':p') } + en + let @" = join(values(has_marked ? s:marked : marked), "\n") + cal s:PrtExit() +endf + fu! s:OpenNoMarks(md, line) if a:md == 'a' let [s:marked, key] = [{}, 1] @@ -1283,7 +1390,16 @@ endf fu! s:compmreb(...) " By last entered time (bufnr) let [id1, id2] = [index(s:mrbs, a:1), index(s:mrbs, a:2)] - retu id1 == id2 ? 0 : id1 > id2 ? 1 : -1 + if id1 == id2 + return 0 + endif + if id1 < 0 + return 1 + endif + if id2 < 0 + return -1 + endif + return id1 > id2 ? 1 : -1 endf fu! s:compmref(...) @@ -1330,7 +1446,8 @@ fu! s:shortest(lens) endf fu! s:mixedsort(...) - if s:itemtype == 1 + let ct = s:curtype() + if ct == 'buf' let pat = '[\/]\?\[\d\+\*No Name\]$' if a:1 =~# pat && a:2 =~# pat | retu 0 elsei a:1 =~# pat | retu 1 @@ -1341,10 +1458,10 @@ fu! s:mixedsort(...) let ms = [] if s:res_count < 21 let ms += [s:compfnlen(a:1, a:2)] - if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en + if ct !~ '^\(buf\|mru\)$' | let ms += [s:comptime(a:1, a:2)] | en if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en en - if s:itemtype =~ '^[12]$' + if ct =~ '^\(buf\|mru\)$' let ms += [s:compmref(a:1, a:2)] let cln = cml ? cln : 0 en @@ -1369,11 +1486,7 @@ endf " Statusline {{{2 fu! ctrlp#statusline() if !exists('s:statypes') - let s:statypes = [ - \ ['files', 'fil'], - \ ['buffers', 'buf'], - \ ['mru files', 'mru'], - \ ] + let s:statypes = copy(s:coretypes) if !empty(g:ctrlp_ext_vars) cal map(copy(g:ctrlp_ext_vars), \ 'add(s:statypes, [ v:val["lname"], v:val["sname"] ])') @@ -1432,19 +1545,29 @@ endf " Line formatting {{{3 fu! s:formatline(str) let str = a:str - if s:itemtype == 1 - let filpath = fnamemodify(str, ':p') - let bufnr = s:nonamecond(str, filpath) - \ ? str2nr(matchstr(str, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) - \ : bufnr('^'.filpath.'$') - let idc = ( bufnr == bufnr('#') ? '#' : '' ) - \ . ( getbufvar(bufnr, '&ma') ? '' : '-' ) - \ . ( getbufvar(bufnr, '&ro') ? '=' : '' ) - \ . ( getbufvar(bufnr, '&mod') ? '+' : '' ) - let str .= idc != '' ? ' '.idc : '' + let ct = s:curtype() + if ct == 'buf' + let bufnr = s:bufnrfilpath(str)[0] + let parts = s:bufparts(bufnr) + let str = printf('%'.s:bufnr_width.'s', bufnr) + if s:has_conceal + let str .= printf(' %-13s %s%-36s', + \ ''.parts[0].'', + \ ''.parts[1], '{'.parts[2].'}') + if (!empty(s:bufpath_mod)) + let str .= printf(' %s', ''.parts[3].'') + en + el + let str .= printf(' %-5s %-30s %s', + \ parts[0], + \ parts[2]) + if (!empty(s:bufpath_mod)) + let str .= printf(' %s', parts[3]) + en + en en - let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str) - retu '> '.( cond ? s:pathshorten(str) : str ) + let cond = ct != 'buf' &&s:ispath && ( s:winw - 4 ) < s:strwidth(str) + retu s:lineprefix.( cond ? s:pathshorten(str) : str ) endf fu! s:pathshorten(str) @@ -1498,7 +1621,7 @@ fu! s:lash(...) endf fu! s:ispathitem() - retu s:itemtype < 3 || ( s:itemtype > 2 && s:getextvar('type') == 'path' ) + retu s:itemtype < len(s:coretypes) || s:getextvar('type') == 'path' endf fu! ctrlp#igncwd(cwd) @@ -1532,9 +1655,21 @@ fu! ctrlp#dirnfile(entries) endf fu! s:usrign(item, type) - retu s:igntype == 1 ? a:item =~ s:usrign - \ : s:igntype == 4 && has_key(s:usrign, a:type) && s:usrign[a:type] != '' - \ ? a:item =~ s:usrign[a:type] : 0 + if s:igntype == 1 | retu a:item =~ s:usrign | en + if s:igntype == 2 + if call(s:usrign, [a:item, a:type]) + retu 1 + en + elsei s:igntype == 4 + if has_key(s:usrign, a:type) && s:usrign[a:type] != '' + \ && a:item =~ s:usrign[a:type] + retu 1 + elsei has_key(s:usrign, 'func') && s:usrign['func'] != '' + \ && call(s:usrign['func'], [a:item, a:type]) + retu 1 + en + en + retu 0 endf fu! s:samerootsyml(each, isfile, cwd) @@ -1544,8 +1679,16 @@ fu! s:samerootsyml(each, isfile, cwd) endf fu! ctrlp#rmbasedir(items) + if a:items == [] + retu a:items + en let cwd = s:dyncwd.s:lash() - if a:items != [] && !stridx(a:items[0], cwd) + let first = a:items[0] + if has('win32') || has('win64') + let cwd = tr(cwd, '\', '/') + let first = tr(first, '\', '/') + en + if !stridx(first, cwd) let idx = strlen(cwd) retu map(a:items, 'strpart(v:val, idx)') en @@ -1586,6 +1729,23 @@ fu! s:findroot(curr, mark, depth, type) retu [] endf +fu! ctrlp#setpathmode(pmode, ...) + if a:pmode == 'c' || ( a:pmode == 'a' && stridx(s:crfpath, s:cwd) < 0 ) + if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en + cal ctrlp#setdir(s:crfpath) + retu 1 + elsei a:pmode == 'r' + let spath = a:0 ? a:1 : s:crfpath + let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] + if type(s:rmarkers) == 3 && !empty(s:rmarkers) + cal filter(markers, 'index(s:rmarkers, v:val) < 0') + let markers = s:rmarkers + markers + en + if s:findroot(spath, markers, 0, 0) != [] | retu 1 | en + en + retu 0 +endf + fu! ctrlp#setdir(path, ...) let cmd = a:0 ? a:1 : 'lc!' sil! exe cmd s:fnesc(a:path, 'c') @@ -1609,12 +1769,27 @@ endf fu! ctrlp#syntax() if ctrlp#nosy() | retu | en for [ke, va] in items(s:hlgrps) | cal ctrlp#hicheck('CtrlP'.ke, va) | endfo - if synIDattr(synIDtrans(hlID('Normal')), 'bg') !~ '^-1$\|^$' - sil! exe 'hi CtrlPLinePre '.( has("gui_running") ? 'gui' : 'cterm' ).'fg=bg' + let bgColor=synIDattr(synIDtrans(hlID('Normal')), 'bg') + if bgColor !~ '^-1$\|^$' + sil! exe 'hi CtrlPLinePre guifg='.bgColor.' ctermfg='.bgColor en sy match CtrlPNoEntries '^ == NO ENTRIES ==$' if hlexists('CtrlPLinePre') - sy match CtrlPLinePre '^>' + exe "sy match CtrlPLinePre '^".escape(get(g:, 'ctrlp_line_prefix', '>'),'^$.*~\')."'" + en + + if s:curtype() == 'buf' && s:has_conceal + sy region CtrlPBufferNr matchgroup=CtrlPLinePre start='^>\s\+' end='\s' + sy region CtrlPBufferInd concealends matchgroup=Ignore start='' end='' + sy region CtrlPBufferRegion concealends matchgroup=Ignore start='' end='' + \ contains=CtrlPBufferHid,CtrlPBufferHidMod,CtrlPBufferVis,CtrlPBufferVisMod,CtrlPBufferCur,CtrlPBufferCurMod + sy region CtrlPBufferHid concealends matchgroup=Ignore start='\s*{' end='}' contained + sy region CtrlPBufferHidMod concealends matchgroup=Ignore start='+\s*{' end='}' contained + sy region CtrlPBufferVis concealends matchgroup=Ignore start='\*\s*{' end='}' contained + sy region CtrlPBufferVisMod concealends matchgroup=Ignore start='\*+\s*{' end='}' contained + sy region CtrlPBufferCur concealends matchgroup=Ignore start='\*!\s*{' end='}' contained + sy region CtrlPBufferCurMod concealends matchgroup=Ignore start='\*+!\s*{' end='}' contained + sy region CtrlPBufferPath concealends matchgroup=Ignore start='' end='' en endf @@ -1622,12 +1797,55 @@ fu! s:highlight(pat, grp) if s:matcher != {} | retu | en cal clearmatches() if !empty(a:pat) && s:ispath - let pat = s:regexp ? substitute(a:pat, '\\\@ \\zs', 'g') : a:pat - if s:byfname - let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g') - let pat = substitute(pat, '\$\@ \\zs', 'g') + cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).pat) + el + let pat = a:pat + + " get original characters so we can rebuild pat + let chars = split(pat, '\[\^\\\?.\]\\{-}') + + " Build a pattern like /a.*b.*c/ from abc (but with .\{-} non-greedy + " matchers instead) + let pat = join(chars, '.\{-}') + " Ensure we match the last version of our pattern + let ending = '\(.*'.pat.'\)\@!' + " Case sensitive? + let beginning = ( s:martcs == '' ? '\c' : '\C' ).'^.*' + if s:byfname() + " Make sure there are no slashes in our match + let beginning = beginning.'\([^\/]*$\)\@=' + en + + for i in range(len(chars)) + " Surround our current target letter with \zs and \ze so it only + " actually matches that one letter, but has all preceding and trailing + " letters as well. + " \zsa.*b.*c + " a\(\zsb\|.*\zsb)\ze.*c + let charcopy = copy(chars) + if i == 0 + let charcopy[i] = '\zs'.charcopy[i].'\ze' + let middle = join(charcopy, '.\{-}') + el + let before = join(charcopy[0:i-1], '.\{-}') + let after = join(charcopy[i+1:-1], '.\{-}') + let c = charcopy[i] + " for abc, match either ab.\{-}c or a.*b.\{-}c in that order + let cpat = '\(\zs'.c.'\|'.'.*\zs'.c.'\)\ze.*' + let middle = before.cpat.after + en + + " Now we matchadd for each letter, the basic form being: + " ^.*\zsx\ze.*$, but with our pattern we built above for the letter, + " and a negative lookahead ensuring that we only highlight the last + " occurrence of our letters. We also ensure that our matcher is case + " insensitive or sensitive depending. + cal matchadd(a:grp, beginning.middle.ending) + endfo en - cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).pat) + cal matchadd('CtrlPLinePre', '^>') en endf @@ -1735,15 +1953,34 @@ fu! s:bufwins(bufnr) retu winns endf -fu! s:nonamecond(str, filpath) - retu a:str =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(a:filpath) - \ && bufnr('^'.a:filpath.'$') < 1 +fu! s:isabs(path) + if (has('win32') || has('win64')) + return a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]' + el + return a:path =~ '^[/\\]' + en +endf + +fu! s:bufnrfilpath(line) + if s:isabs(a:line) || a:line =~ '^\~[/\\]' + let filpath = a:line + el + let filpath = s:dyncwd.s:lash().a:line + en + let filpath = fnamemodify(filpath, ':p') + let bufnr = bufnr('^'.filpath.'$') + if (a:line =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(filpath) && bufnr < 1) + let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) + let filpath = bufnr + en + retu [bufnr, filpath] endf fu! ctrlp#normcmd(cmd, ...) + let buftypes = [ 'quickfix', 'help' ] if a:0 < 2 && s:nosplit() | retu a:cmd | en let norwins = filter(range(1, winnr('$')), - \ 'empty(getbufvar(winbufnr(v:val), "&bt"))') + \ 'index(buftypes, getbufvar(winbufnr(v:val), "&bt")) == -1 || s:isneovimterminal(winbufnr(v:val))') for each in norwins let bufnr = winbufnr(each) if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft')) @@ -1775,6 +2012,9 @@ fu! s:setupblank() if v:version > 702 setl nornu noudf cc=0 en + if s:has_conceal + setl cole=2 cocu=nc + en endf fu! s:leavepre() @@ -1906,12 +2146,13 @@ fu! s:modevar() endf fu! s:nosort() - retu s:matcher != {} || s:nolim == 1 || ( s:itemtype == 2 && s:mrudef ) - \ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort + let ct = s:curtype() + retu s:matcher != {} || s:nolim == 1 || ( ct == 'mru' && s:mrudef ) + \ || ( ct =~ '^\(buf\|mru\)$' && s:prompt == ['', '', ''] ) || !s:dosort endf fu! s:byfname() - retu s:ispath && s:byfname + retu s:curtype() != 'buf' && s:ispath && s:byfname endf fu! s:narrowable() @@ -1946,22 +2187,6 @@ fu! s:getinput(...) retu spi == 'c' ? prt[0] : join(prt, '') endf -fu! s:migemo(str) - let [str, rtp] = [a:str, s:fnesc(&rtp, 'g')] - let dict = s:glbpath(rtp, printf("dict/%s/migemo-dict", &enc), 1) - if !len(dict) - let dict = s:glbpath(rtp, "dict/migemo-dict", 1) - en - if len(dict) - let [tokens, str, cmd] = [split(str, '\s'), '', 'cmigemo -v -w %s -d %s'] - for token in tokens - let rtn = system(printf(cmd, shellescape(token), shellescape(dict))) - let str .= !v:shell_error && strlen(rtn) > 0 ? '.*'.rtn : token - endfo - en - retu str -endf - fu! s:strwidth(str) retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str) endf @@ -2005,6 +2230,33 @@ fu! s:delent(rfunc) cal s:BuildPrompt(1) unl s:force endf + +fu! s:delbufcond(bufnr) + retu getbufvar(a:bufnr, "&mod") || a:bufnr == s:crbufnr +endf + +fu! s:delbuf() + let lines = [] + if exists('s:marked') + let lines = values(s:marked) + cal s:unmarksigns() + unl s:marked + el + let lines += [ctrlp#getcline()] + en + for line in lines + let bufnr = s:bufnrfilpath(line)[0] + if (s:delbufcond(bufnr)) + con + en + exe 'bd '. bufnr + endfo + cal s:PrtClearCache() +endf + +fu! s:isneovimterminal(buf) + retu has('nvim') && getbufvar(a:buf, "&bt") == "terminal" +endf " Entering & Exiting {{{2 fu! s:getenv() let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]] @@ -2097,7 +2349,13 @@ fu! s:matchfname(item, pat) retu len(a:pat) == 1 ? mfn : len(a:pat) == 2 ? \ ( mfn >= 0 && ( len(parts) == 2 ? match(parts[0], a:pat[1]) : -1 ) >= 0 \ ? 0 : -1 ) : -1 - en +endf + +fu! s:matchbuf(item, pat) + let bufnr = s:bufnrfilpath(a:item)[0] + let parts = s:bufparts(bufnr) + let item = bufnr.parts[0].parts[2].s:lash().parts[3] + retu match(item, a:pat) endf fu! s:matchtabs(item, pat) @@ -2110,17 +2368,30 @@ endf fu! s:buildpat(lst) let pat = a:lst[0] - for item in range(1, len(a:lst) - 1) - let pat .= '[^'.a:lst[item - 1].']\{-}'.a:lst[item] - endfo + if s:matchnatural == 1 + for item in range(1, len(a:lst) - 1) + let c = a:lst[item - 1] + let pat .= (c == '/' ? '[^/]\{-}' : '[^'.c.'/]\{-}').a:lst[item] + endfo + else + for item in range(1, len(a:lst) - 1) + let pat .= '[^'.a:lst[item - 1].']\{-}'.a:lst[item] + endfo + en retu pat endf +fu! s:curtype() + return s:CurTypeName()[1] +endf + fu! s:mfunc() let mfunc = 'match' if s:byfname() let mfunc = 's:matchfname' - elsei s:itemtype > 2 + elsei s:curtype() == 'buf' + let mfunc = 's:matchbuf' + elsei s:itemtype >= len(s:coretypes) let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' } if has_key(matchtypes, s:matchtype) let mfunc = matchtypes[s:matchtype] @@ -2133,6 +2404,7 @@ fu! s:mmode() let matchmodes = { \ 'match': 'full-line', \ 's:matchfname': 'filename-only', + \ 's:matchbuf': 'full-line', \ 's:matchtabs': 'first-non-tab', \ 's:matchtabe': 'until-last-tab', \ } @@ -2178,7 +2450,7 @@ fu! s:insertcache(str) endf " Extensions {{{2 fu! s:mtype() - retu s:itemtype > 2 ? s:getextvar('type') : 'path' + retu s:itemtype >= len(s:coretypes) ? s:getextvar('type') : 'path' endf fu! s:execextvar(key) @@ -2189,11 +2461,11 @@ fu! s:execextvar(key) endf fu! s:getextvar(key) - if s:itemtype > 2 - let vars = g:ctrlp_ext_vars[s:itemtype - 3] + if s:itemtype >= len(s:coretypes) && len(g:ctrlp_ext_vars) > 0 + let vars = g:ctrlp_ext_vars[s:itemtype - len(s:coretypes)] retu has_key(vars, a:key) ? vars[a:key] : -1 en - retu -1 + retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1) endf fu! ctrlp#getcline() @@ -2206,6 +2478,10 @@ fu! ctrlp#getmarkedlist() retu exists('s:marked') ? values(s:marked) : [] endf +fu! ctrlp#clearmarkedlist() + let s:marked = {} +endf + fu! ctrlp#exit() cal s:PrtExit() endf @@ -2240,13 +2516,32 @@ endf fu! ctrlp#setlines(...) if a:0 | let s:itemtype = a:1 | en cal s:modevar() - let types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()'] + let inits = {'fil': 'ctrlp#files()', 'buf': 'ctrlp#buffers()', 'mru': 'ctrlp#mrufiles#list()'} + let types = map(copy(g:ctrlp_types), 'inits[v:val]') if !empty(g:ctrlp_ext_vars) cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])') en let g:ctrlp_lines = eval(types[s:itemtype]) endf +" Returns [lname, sname] +fu! s:CurTypeName() + if s:itemtype < len(s:coretypes) + return filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0] + el + return [s:getextvar("lname"), s:getextvar('sname')] + en +endfu + +fu! s:ExitIfSingleCandidate() + if len(s:Update(s:prompt[0])) == 1 + call s:AcceptSelection('e') + call ctrlp#exit() + return 1 + en + return 0 +endfu + fu! ctrlp#init(type, ...) if exists('s:init') || s:iscmdwin() | retu | en let [s:ermsg, v:errmsg] = [v:errmsg, ''] @@ -2256,18 +2551,33 @@ fu! ctrlp#init(type, ...) cal s:SetWD(a:0 ? a:1 : {}) cal s:MapNorms() cal s:MapSpecs() + if type(a:type) == 0 + let type = a:type + el + let type = index(g:ctrlp_types, a:type) + if type == -1 + call ctrlp#exit() + retu + en + en + cal ctrlp#setlines(s:settype(type)) cal ctrlp#syntax() - cal ctrlp#setlines(s:settype(a:type)) cal s:SetDefTxt() + let curName = s:CurTypeName() + let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0 + if shouldExitSingle && s:ExitIfSingleCandidate() + return 0 + en cal s:BuildPrompt(1) if s:keyloop | cal s:KeyLoop() | en + return 1 endf " - Autocmds {{{1 if has('autocmd') aug CtrlPAug au! au BufEnter ControlP cal s:checkbuf() - au BufLeave ControlP noa cal s:Close() + au BufLeave ControlP noa cal s:Close(0) au VimLeavePre * cal s:leavepre() aug END en diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/autoignore.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/autoignore.vim new file mode 100644 index 00000000..ec2329e0 --- /dev/null +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/autoignore.vim @@ -0,0 +1,173 @@ +" ============================================================================= +" File: autoload/ctrlp/autoignore.vim +" Description: Auto-ignore Extension +" Author: Ludovic Chabant +" ============================================================================= + + +" 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 diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim index 89bda895..f7fc14dc 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim @@ -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) diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/buffertag.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/buffertag.vim index a38cad56..7894f3f2 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp/buffertag.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/buffertag.vim @@ -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 diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/mrufiles.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/mrufiles.vim index a1821114..32473dad 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp/mrufiles.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/mrufiles.vim @@ -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('', 1)) + au BufWinEnter,BufWinLeave,BufWritePost * cal s:record(expand('', 1)) au QuickFixCmdPre *vimgrep* let s:locked = 1 au QuickFixCmdPost *vimgrep* let s:locked = 0 au VimLeavePre * cal s:savetofile(s:mergelists()) diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/tag.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/tag.vim index 626363a4..31504dcc 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp/tag.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/tag.vim @@ -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 diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx new file mode 100644 index 00000000..ac4fa3b6 --- /dev/null +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx @@ -0,0 +1,1570 @@ +*ctrlp.txt* 模糊的 文件, 缓冲区, 最近最多使用, 标签, ... 检索. v1.79 +*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'* +=============================================================================== +# # +# :::::::: ::::::::::: ::::::::: ::: ::::::::: # +# :+: :+: :+: :+: :+: :+: :+: :+: # +# +:+ +:+ +:+ +:+ +:+ +:+ +:+ # +# +#+ +#+ +#++:++#: +#+ +#++:++#+ # +# +#+ +#+ +#+ +#+ +#+ +#+ # +# #+# #+# #+# #+# #+# #+# #+# # +# ######## ### ### ### ########## ### # +# # +=============================================================================== +名词对照(译注) + + buffer:缓冲区 mapping:按键绑定 + mru:最近最多使用 prompt:提示符面板 + tag:标签 tab:页签 + tab:制表符 + +=============================================================================== +内容 *ctrlp-content* + + 1. 介绍.............................................|ctrlp-intro| + 2. 选项.............................................|ctrlp-options| + 3. 命令.............................................|ctrlp-commands| + 4. 按键绑定.........................................|ctrlp-mappings| + 5. 输入格式.........................................|ctrlp-input-formats| + 6. 扩展.............................................|ctrlp-extensions| + +=============================================================================== +介绍 *ctrlp-intro* + +带有直观接口的全路径模糊文件, 缓冲区, 最近最多使用, 标签, ... 检索。 +使用纯净的Vimscript编写,可以运行在MacVim,gVim和版本号7.0以上的Vim中。 +全面支持Vim的正则表达式 |regexp| 作为搜索模式,内建最近最多使用文件监测, +项目根目录定位和更多特性。 + +开启可选的扩展(标记,目录,rtscript...),参考 |ctrlp-extensions| 。 + +=============================================================================== +OPTIONS *ctrlp-options* + +总览:~ + + |loaded_ctrlp|................禁用插件。 + |ctrlp_map|...................默认按键绑定。 + |ctrlp_cmd|...................默认按键绑定调用的命令。 + |ctrlp_by_filename|...........是否默认开启文件名模式。 + |ctrlp_regexp|................是否默认开启正则表达式模式。 + |ctrlp_match_window|..........匹配窗口的显示位置。 + |ctrlp_switch_buffer|.........如果文件已在缓冲区中打开,跳转到该打开的缓冲区。 + |ctrlp_reuse_window|..........重用特殊窗口(帮助、快速修复 |quickfix| ,等等)。 + |ctrlp_tabpage_position|......新标签页出现的位置。 + |ctrlp_working_path_mode|.....如何设置CtrlP的本地工作目录。 + |ctrlp_root_markers|..........额外的,高优先级的根目录标识。 + |ctrlp_use_caching|...........针对每个会话,设置是否开启缓存的。 + |ctrlp_clear_cache_on_exit|...退出Vim后是否保留缓存。 + |ctrlp_cache_dir|.............缓存目录的位置。 + |ctrlp_show_hidden|...........是否显示隐藏文件和隐藏文件夹。 + |ctrlp_custom_ignore|.........使用 |globpath()| 时自定义忽略的文件或目录。 + |ctrlp_max_files|.............扫描文件的最大数目。 + |ctrlp_max_depth|.............扫描目录的最大层数。 + |ctrlp_user_command|..........使用外部的扫描工具。 + |ctrlp_max_history|...........历史提示符面板中保留的最大条目数。 + |ctrlp_open_new_file|.........由创建的文件的打开方式。 + |ctrlp_open_multiple_files|...由选择的文件的打开方式。 + |ctrlp_arg_map|...............是否拦截 命令。 + |ctrlp_follow_symlinks|.......是否跟随链接。 + |ctrlp_lazy_update|...........停止输入时才更新。 + |ctrlp_default_input|.........为提示符面板提供一个种子。 + |ctrlp_abbrev|................输入缩写。 + |ctrlp_key_loop|..............为多字节输入开启输入事件循环。 + |ctrlp_prompt_mappings|.......改变提示符面板内部的按键绑定。 + |ctrlp_line_prefix|...........ctrlp 窗口中为每一行添加前缀。 + |ctrlp_open_single_match|.....当只有一个候选时自动接受。 + |ctrlp_brief_prompt|..........提示符为空的时候使用退出 CtrlP。 + |ctrlp_match_current_file|....在匹配条目中包含当前文件。 + + 最近最多使用模式: + |ctrlp_mruf_max|..............记录的最近最多使用的最大数据。 + |ctrlp_mruf_exclude|..........需要被排除的文件。 + |ctrlp_mruf_include|..........需要被记录的文件。 + |ctrlp_mruf_relative|.........只显示在工作目录内的最近最多使用。 + |ctrlp_tilde_homedir|.........保存 home 目录中的 MRU 的目录路径为波浪扩展的形式 ~/。 + |ctrlp_mruf_default_order|....禁用排序。 + |ctrlp_mruf_case_sensitive|...最近最多使用文件是否大小写敏感。 + |ctrlp_mruf_save_on_update|...只要有一个新的条目添加,就保存到磁盘。 + + 缓冲模式: + |ctrlp_bufname_mod|...........文件名部分修饰符。 + |ctrlp_bufpath_mod|...........文件路径部分修饰符。 + + 缓冲标签模式: (开启此模式,参考 |ctrlp-extensions| ) + |g:ctrlp_buftag_ctags_bin|....兼容的ctags二进制程序的位置。 + |g:ctrlp_buftag_systemenc|....ctags命令的编码。 + |g:ctrlp_buftag_types|........添加新的文件类型和设置命令行参数。 + + 高级选项: + |ctrlp_open_func|.............使用自定义的打开文件的函数。 + |ctrlp_status_func|...........改变CtrlP的两个状态栏 + |ctrlp_buffer_func|...........在CtrlP的缓冲区内调用自定义的函数。 + |ctrlp_match_func|............替换内建的匹配算法。 + +------------------------------------------------------------------------------- +详细描述和默认值:~ + + *'g:ctrlp_map'* +使用该选项来改变普通模式 |Normal| 下调用CtrlP的按键绑定: > + let g:ctrlp_map = '' +< + + *'g:ctrlp_cmd'* + +设置当按下上面的按键绑定时,使用的默认打开命令: > + let g:ctrlp_cmd = 'CtrlP' +< + + *'g:loaded_ctrlp'* +使用该选项完全禁用插件: > + let g:loaded_ctrlp = 1 +< + + *'g:ctrlp_by_filename'* +修改该选项为1,设置默认为按文件名搜索(否则为全路径): > + let g:ctrlp_by_filename = 0 +< +在提示符面板内可以使用 来切换。 + + *'g:ctrlp_regexp'* +修改该选项为1,设置默认为使用正则表达式匹配。: > + let g:ctrlp_regexp = 0 +< +在提示符面板内可以使用 来切换。 + + *'g:ctrlp_match_window'* +改变匹配窗口的位置,结果的排列顺序,最小和最大高度: > + let g:ctrlp_match_window = '' +< +例子: > + let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10' +< +位置: (默认:底部) + top - 在屏幕顶部显示匹配窗口。 + bottom - 在屏幕底部显示匹配窗口。 + +结果的排列顺序: (默认: btt) + order:ttb - 从顶部到底部。 + order:btt - 从底部到顶部。 + +最小和最大高度: + min:{n} - 最少显示 {n} 行 (默认: 1). + max:{n} - 最多显示 {n} 行 (默认: 10). + +结果集的最大数目: + results:{n} - 列出最多 {n} 条结果 (默认: 和最大高度同步). + +注意: 当一个设置项没有被设置时,将会使用默认值。 + + *'g:ctrlp_switch_buffer'* +当尝试打开一个文件时,如果它已经在某个窗口被打开,CtrlP会尝试跳到那个窗口,而 +不是新打开一个实例。: > + let g:ctrlp_switch_buffer = 'Et' +< + e - 当 被按下时跳转,但是只跳转到当前页签内的窗口内。 + t - 当 被按下时跳转, 但是只跳转到其它标签的窗口内。 + v - 类似 "e", 但是当 被按下时跳转。 + h - 类似 "e", 但是当 被按下时跳转。 + E, T, V, H - 行为类似 "e", "t", "v", and "h", 但是跳转到任何地方的窗口中。 + 0 或者 - 禁用这项功能。 + + *'g:ctrlp_reuse_window'* +当使用 打开新文件时,CtrlP避免在插件,帮助,快速修复创建的窗口中打开该文 +件。使用该选项来设置一些例外: > + let g:ctrlp_reuse_window = 'netrw' +< +接受的值可以为特殊缓冲区的名字的一部分,文件类型或者缓冲区类型使用正则表达式来 +指定匹配模式。 +例子: > + let g:ctrlp_reuse_window = 'netrw\|help\|quickfix' +< + + *'g:ctrlp_tabpage_position'* +新打开页签的位置: > + let g:ctrlp_tabpage_position = 'ac' +< + a - 后面。 + b - 前面。 + c - 当前页签。 + l - 最后一个页签。 + f - 第一个页签。 + + *'g:ctrlp_working_path_mode'* +当启动时,CtrlP依据这个变量来设置它的工作目录: > + let g:ctrlp_working_path_mode = 'ra' +< + c - 当前文件所在的目录。 + a - 当前文件所在的目录,除非这个目录为当前工作目录的子目录 + r - 包含下列文件或者目录的最近的祖先目录: + .git .hg .svn .bzr _darcs + w - 用来修饰r:使用当前工作目录而不是当前文件所在目录进行查找 + 0 或者 - 禁用这项功能。 + +注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者 +"c" 的行为(作为备选)。 + +注意 #2: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。 + + *'g:ctrlp_root_markers'* +使用该选项来设置自定义的根目录标记作为对默认标记(.hg, .svn, .bzr, and _darcs) +的补充。自定义的标记具有优先权: > + let g:ctrlp_root_markers = [''] +< +注意: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。 + + *'g:ctrlp_use_caching'* +启用/禁用每个会话的缓存: > + let g:ctrlp_use_caching = 1 +< + 0 - 禁用缓存。 + 1 - 启用缓存。 + n - 当大于1时,禁用缓存,使用该数值作为重新启用缓存的限制条件。 + +注意: 当在CtrlP中时你可以使用 来快速的清除缓存。 + + *'g:ctrlp_clear_cache_on_exit'* +设置该选项为0通过退出Vim时不删除缓存文件来启用跨会话的缓存: > + let g:ctrlp_clear_cache_on_exit = 1 +< + + *'g:ctrlp_cache_dir'* +设置存储缓存文件的目录: > + let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp' +< + + *'g:ctrlp_show_hidden'* +如果你想CtrlP扫描隐藏文件和目录,设置该选项为1: > + let g:ctrlp_show_hidden = 0 +< +注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 + + *'ctrlp-wildignore'* +你可以使用Vim的 |'wildignore'| 来从结果集中排序文件或目录。 +例子: > + " 排除版本控制文件 + set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX + set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash') +< +注意 #1: 每个目录设置前的字符 `*/` 是必须的。 + +注意 #2: |wildignore| 影响 |expand()| , |globpath()| 和 |glob()| 的结果,这些函数被很 +多插件用来在系统中执行查找。(例如和版本控制系统有关的插件在查找.git/、.hg/等, +一些其他插件用来在Windows上查找外部的*.exe工具),所以要修改 |wildignore| 时请先 +考虑清楚。 + + *'g:ctrlp_custom_ignore'* +作为对 |'wildignore'| 的补充,用来设置你只是想在CtrlP中隐藏的文件和目录。使用正 +则表达式来指定匹配模式: > + let g:ctrlp_custom_ignore = '' +< +例子: > + let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' + let g:ctrlp_custom_ignore = { + \ 'dir': '\v[\/]\.(git|hg|svn)$', + \ 'file': '\v\.(exe|so|dll)$', + \ 'link': 'SOME_BAD_SYMBOLIC_LINKS', + \ } + let g:ctrlp_custom_ignore = { + \ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@ + let g:ctrlp_max_files = 10000 +< +注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 + + *'g:ctrlp_max_depth'* +目录树递归的最大层数: > + let g:ctrlp_max_depth = 40 +< +注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 + + *'g:ctrlp_user_command'* +指定用来代替Vim的 |globpath()| 的外部工具来列出文件,使用 %s 代表目标目录: > + let g:ctrlp_user_command = '' +< +例子: > + let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux + let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows +< +你也可以使用 'grep', 'findstr' 或者其它东西来过滤结果集。 +例子: > + let g:ctrlp_user_command = + \ 'find %s -type f | grep -v -P "\.jpg$|/tmp/"' " MacOSX/Linux + let g:ctrlp_user_command = + \ 'dir %s /-n /b /s /a-d | findstr /v /l ".jpg \\tmp\\"' " Windows +< +在扫描一个大型项目时,在仓库目录中使用版本控制系统的列出命令会加快扫描速度: > + let g:ctrlp_user_command = [root_marker, listing_command, fallback_command] + let g:ctrlp_user_command = { + \ 'types': { + \ 1: [root_marker_1, listing_command_1], + \ n: [root_marker_n, listing_command_n], + \ }, + \ 'fallback': fallback_command, + \ 'ignore': 0 or 1 + \ } +< +一些例子: > + " 单个版本控制系统,列出命令不会列出没有被追踪的文件: + let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files'] + let g:ctrlp_user_command = ['.hg', 'hg --cwd %s locate -I .'] + + " 多个版本控制系统: + let g:ctrlp_user_command = { + \ 'types': { + \ 1: ['.git', 'cd %s && git ls-files'], + \ 2: ['.hg', 'hg --cwd %s locate -I .'], + \ }, + \ 'fallback': 'find %s -type f' + \ } + + " 单个版本控制系统,列出命令列出没有被追踪的文件(较慢): + let g:ctrlp_user_command = + \ ['.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 + + let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') ' + \ . 'do hg --cwd %s status -numac -I . %%a'] " Windows +< +注意 #1: 在 |Dictionary| 格式, 'fallback' 和 'ignore' 是可选的,在 |List| 格式, +备选命令是可选的。 + +注意 #2: 如果备选命令是空的或者属性 'fallback' 没有定义,当扫描仓库之外目录时, +|globpath()| 会被使用。 + +注意 #3: 除非使用了 |Dictionary| 格式并且 'ignore' 被定义并且设置为1,当这些自 +定义的命令被使用时 |wildignore| 和 |g:ctrlp_custom_ignore| 选项不会生效。没有出现 +时,'ignore' 被默认设置为0来保留使用外部命令的性能优势。 + +注意 #4: 当改变了选项的变量类型时,记得先 |:unlet| ,或者重启Vim来避免这个错误: +"E706: Variable type mismatch" 。 + +注意 #5: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。 + + *'g:ctrlp_max_history'* +你希望CtrlP记录的用户输入历史的最大数目。默认值是Vim的全局选项 |'history'| : > + let g:ctrlp_max_history = &history +< +设置为0来禁用提示符面板的历史。使用 来浏览历史。 + + *'g:ctrlp_open_new_file'* +使用该选项指定当使用 打开新建的文件时,文件的打开方式: > + let g:ctrlp_open_new_file = 'v' +< + t - 在新页签中。 + h - 在新的水平分割窗口。 + v - 在新的竖直分割窗口。 + r - 在当前窗口。 + + *'g:ctrlp_open_multiple_files'* +如果非0, 会启用使用 打开多个文件: > + let g:ctrlp_open_multiple_files = 'v' +< +例子: > + let g:ctrlp_open_multiple_files = '2vjr' +< +对于数字: + - 如果指定,会被用来作为打开文件时创建的窗口或者页签的最大数量(剩余的会在隐 + 藏的缓冲区中打开)。 + - 如果没有指定, 会打开所有文件,每个在一个新的窗口或者页签中。 + +对于字母: + t - 每个文件在一个新页签中。 + h - 每个文件在一个新的水平分割窗口中。 + v - 每个文件在一个新的竖直分割窗口中。 + i - 所有的文件在隐藏的缓冲区中。 + j - 打开以后,跳转到第一个打开的页签或者窗口。 + r - 在当前窗口打开第一个文件,其他文件根据同时出现的"h","v"和"t"中的一个, + 在新的分割窗口或者页签中打开。 + + *'g:ctrlp_arg_map'* +当设置为1时, 会接收一个额外的键值作为参数,来覆盖默认行为: > + let g:ctrlp_arg_map = 0 +< +按下 或者 会提示一次按键。按键可以是: + t - 在新标签页中打开。 + h - 每个文件在一个新的水平分割窗口中。 + v - 每个文件在一个新的竖直分割窗口中。 + i - 所有的文件在隐藏的缓冲区中(只有 生效)。 + c - 清楚标记的文件(只有 生效)。 + r - 在当前窗口中打开(只有 生效)。 + , , - 取消并且回到提示符面板。 + - 使用 |g:ctrlp_open_new_file| 和 |g:ctrlp_open_multiple_files| 指定的默 + 认行为。 + + + *'g:ctrlp_follow_symlinks'* +如果非0,当列出文件时CtrlP会跟随链接: > + let g:ctrlp_follow_symlinks = 0 +< + 0 - 不要跟随链接。 + 1 - 跟随但是忽略内部循环的链接,避免重复。 + 2 - 无差别的跟随所有链接。 + +注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 + + *'g:ctrlp_lazy_update'* +设置为1将开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口: > + let g:ctrlp_lazy_update = 0 +< +如果设置为1,在250毫秒后更新。如果大于1,数字会被作为延迟时间使用。 + + *'g:ctrlp_default_input'* +设置为1将为提示符面板提供当前文件的相对路径作为种子: > + let g:ctrlp_default_input = 0 +< +如果不指定1或0,如果选项的值是字符串,会被用来作为默认输入: > + let g:ctrlp_default_input = 'anystring' +< +这个选项可以和 |g:ctrlp_open_single_match| 配合使用。 + + + *'g:ctrlp_match_current_file'* +在匹配条目中包含当前文件: + let g:ctrlp_match_current_file = 1 + +默认情况下,当前文件不包含在列表中。 + +注意: 当使用 |g:ctrlp_match_func| 时不会应用这个选项。 + + + *'g:ctrlp_abbrev'* +定义可以在提示面包内被扩展(内部的或者可见的)的输入缩写: > + let g:ctrlp_abbrev = {} +< +例子: > + let g:ctrlp_abbrev = { + \ 'gmode': 'i', + \ 'abbrevs': [ + \ { + \ 'pattern': '^cd b', + \ 'expanded': '@cd ~/.vim/bundle', + \ 'mode': 'pfrz', + \ }, + \ { + \ 'pattern': '\(^@.\+\|\\\@ 创建新文件时(使用扩展后的字符串作为文件名)。 + c - 当使用 自动补全目录名时(在自动补全之前立即扩展模式)。 + 或者未定义 - 总是启用。 + +注意: 缩写条目按顺序求值,后求值的条目会覆盖先求值的条目;当 'gmode' 为"t"时, +包括他自己。 + + *'g:ctrlp_key_loop'* +一个实验性的特性。设置该选项为1将为多字节字符开启输入事件循环: > + let g:ctrlp_key_loop = 0 +< +注意 #1: 当设置时,该选项会重置 |g:ctrlp_lazy_update| 选项。 + +注意 #2: 你可以在提示符面板使用自定义的按键绑定切换这个特性: > + let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': [''] } +< + + *'g:ctrlp_prompt_mappings'* +使用该选项来自定义CtrlP的提示窗口内的按键绑定为你喜欢的方式。你只需要保留你改 +变值(在[]内部)的行: > + let g:ctrlp_prompt_mappings = { + \ 'PrtBS()': ['', ''], + \ 'PrtDelete()': [''], + \ 'PrtDeleteWord()': [''], + \ 'PrtClear()': [''], + \ 'PrtSelectMove("j")': ['', ''], + \ 'PrtSelectMove("k")': ['', ''], + \ 'PrtSelectMove("t")': ['', ''], + \ 'PrtSelectMove("b")': ['', ''], + \ 'PrtSelectMove("u")': ['', ''], + \ 'PrtSelectMove("d")': ['', ''], + \ 'PrtHistory(-1)': [''], + \ 'PrtHistory(1)': [''], + \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'], + \ 'AcceptSelection("h")': ['', '', ''], + \ 'AcceptSelection("t")': [''], + \ 'AcceptSelection("v")': ['', ''], + \ 'ToggleFocus()': [''], + \ 'ToggleRegex()': [''], + \ 'ToggleByFname()': [''], + \ 'ToggleType(1)': ['', ''], + \ 'ToggleType(-1)': ['', ''], + \ 'PrtExpandDir()': [''], + \ 'PrtInsert("c")': ['', ''], + \ 'PrtInsert()': [''], + \ 'PrtCurStart()': [''], + \ 'PrtCurEnd()': [''], + \ 'PrtCurLeft()': ['', '', ''], + \ 'PrtCurRight()': ['', ''], + \ 'PrtClearCache()': [''], + \ 'PrtDeleteEnt()': [''], + \ 'CreateNewFile()': [''], + \ 'MarkToOpen()': [''], + \ 'OpenMulti()': [''], + \ 'PrtExit()': ['', '', ''], + \ } +< +注意: 如果按 后光标向左移动一个字符而不是删除一个字符,在你的.vimrc中添加 +下面的设置来禁用插件默认的 绑定: > + let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['', ''] } +< + + *'g:ctrlp_line_prefix'* +这个前缀会被加到ctrlp的条目列表中每一行的前面。 +默认值: > + let g:ctrlp_line_prefix = '> ' +< + + *'g:ctrlp_open_single_match'* +当CtrlP处于列表中配置的模式中时,如果只有一个候选条目,CtrlP会直接接受该条目。 +例子: > + let g:ctrlp_open_single_match = ['buffer tags', 'buffer'] +< +目前这个选项的作用是和 |g:ctrlp_default_input| 一起,使用类似下面的函数,在使用 +前设置,使用完后还原: > + fu! tagsUnderCursor() + try + let default_input_save = get(g:, 'ctrlp_default_input', '') + let g:ctrlp_default_input = expand('') + CtrlPBufTagAll + finally + if exists('default_input_save') + let g:ctrlp_default_input = default_input_save + endif + endtry + endfu +> +< +---------------------------------------- +MRU mode options:~ + + *'g:ctrlp_mruf_max'* +指定你希望CtrlP记录的最近打开的文件历史的数目: > + let g:ctrlp_mruf_max = 250 +< + + *'g:ctrlp_mruf_exclude'* +你不希望CtrlP记录的文件。使用正则表达式来指定模式: > + let g:ctrlp_mruf_exclude = '' +< +例子: > + let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*' " MacOSX/Linux + let g:ctrlp_mruf_exclude = '^C:\\dev\\tmp\\.*' " Windows +< + + *'g:ctrlp_mruf_include'* +如果你想让CtrlP只记录某些文件,在这里指定: > + let g:ctrlp_mruf_include = '' +< +例子: > + let g:ctrlp_mruf_include = '\.py$\|\.rb$' +< + *'g:ctrlp_tilde_homedir'* +将这个选项设置为1来把所有的 MRU 文件路径中 $HOME 目录下的 $HOME/$filepath 保存 +为 ~/$filepath ,而不是 $HOME/$filepath : > + let g:ctrlp_tilde_homedir = 0 +< +注意: 对所有通过 :CtrlPBookmarkDirAdd! 保存的也有效 + + *'g:ctrlp_mruf_relative'* +设置该选项为1将只显示在当前工作目录内的最近最多使用文件: > + let g:ctrlp_mruf_relative = 0 +< +注意: 你可以在提示符面板使用自定义的按键绑定切换这个特性: > + let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': [''] } +< + + *'g:ctrlp_mruf_default_order'* +设置该选项为1将在最近最多使用模式搜索时禁用排序: > + let g:ctrlp_mruf_default_order = 0 +< + + *'g:ctrlp_mruf_case_sensitive'* +将该选项和你的文件系统大小写敏感性保持一致来避免重复的最近最多使用条目: > + let g:ctrlp_mruf_case_sensitive = 1 +< + + *'g:ctrlp_mruf_save_on_update'* +设置该选项为 0 禁止 CtrlP 每当有一个新条目增加就把最近最多使用列表保存到磁盘 +文件,而是在退出Vim时才保存: > + let g:ctrlp_mruf_save_on_update = 1 +< + *'g:ctrlp_bufname_mod'* +根据修饰符修改文件名部分。参见 |filename-modifiers| 。 > + let g:ctrlp_bufname_mod = ':t' +< + *'g:ctrlp_bufpath_mod'* +根据修饰符修改文件路径部分。参见 |filename-modifiers| 。 > + let g:ctrlp_bufpath_mod = ':~:.:h' +< +---------------------------------------- +高级选项:~ + + *'g:ctrlp_open_func'* +使用一个自定义函数来打开选定的文件: > + let g:ctrlp_open_func = {} +< +例子: > + let g:ctrlp_open_func = { + \ 'files' : 'Function_Name_1', + \ 'buffers' : 'Function_Name_2', + \ 'mru files' : 'Function_Name_3', + \ } +< +函数结构: > + function! Function_Name(action, line) + " 参数: + " | + " +- a:action : 打开的动作: + " | + 'e' : 用户按下 (默认) + " | + 'h' : 用户按下 (默认) + " | + 'v' : 用户按下 (默认) + " | + 't' : 用户按下 (默认) + " | + 'x' : 用户使用 终端对话框 (默认) 选择"e[x]ternal"。 + " | + " +- a:line : 选择的文件。 + + endfunction +< +注意: 当使用打开多个文件时无效。 + +例子: 当 被按下时在默认浏览器中打开HTML文件,否则在Vim中打开 > + function! HTMLOpenFunc(action, line) + if a:action =~ '^[tx]$' && fnamemodify(a:line, ':e') =~? '^html\?$' + + " 获取文件名 + let filename = fnameescape(fnamemodify(a:line, ':p')) + + " 关闭CtrlP + call ctrlp#exit() + + " 打开文件 + silent! execute '!xdg-open' filename + + elseif a:action == 'x' && fnamemodify(a:line, ':e') !~? '^html\?$' + + " 不是HTML文件,再次模拟 按键并且等待新的输入 + call feedkeys("\") + + else + + " 使用CtrlP的默认的打开文件的函数 + call call('ctrlp#acceptfile', [a:action, a:line]) + + endif + endfunction + + let g:ctrlp_open_func = { 'files': 'HTMLOpenFunc' } +< + + *'g:ctrlp_status_func'* +为CtrlP窗口使用自定义的状态栏: > + let g:ctrlp_status_func = {} +< +例子: > + let g:ctrlp_status_func = { + \ 'main': 'Function_Name_1', + \ 'prog': 'Function_Name_2', + \ } +< +函数结构: > + " 主状态栏 + function! Function_Name_1(focus, byfname, regex, prev, item, next, marked) + " 参数: + " | + " +- a:focus : 提示符面板的焦点: "prt" 或者 "win"。 + " | + " +- a:byfname : 在文件名模式还是全路径模式: "file" 或者 "path"。 + " | + " +- a:regex : 是否在正则表达式模式: 1 or 0。 + " | + " +- a:prev : 前一个搜索模式。 + " | + " +- a:item : 当前的搜索模式。 + " | + " +- a:next : 下一个搜索模式。 + " | + " +- a:marked : 被标记文件的数目,或者一个逗号分隔的被标记的文件名列表。 + + return full_statusline + endfunction + + " 状态栏进度条 + function! Function_Name_2(str) + " a:str : 一个当前已扫描的文件数,或者一个当前扫描目录和用户命令的字符串。 + + return full_statusline + endfunction +< +一个可用的例子,参见 https://gist.github.com/1610859 。 + + *'g:ctrlp_buffer_func'* +指定一个会在启动或者退出CtrlP缓冲区时被调用的函数: > + let g:ctrlp_buffer_func = {} +< +例子: > + let g:ctrlp_buffer_func = { + \ 'enter': 'Function_Name_1', + \ 'exit': 'Function_Name_2', + \ } +< + + *'g:ctrlp_match_func'* +为CtrlP设置一个额外的模糊匹配函数: > + let g:ctrlp_match_func = {} +< +例子: > + let g:ctrlp_match_func = { 'match': 'Function_Name' } +< +函数结构: > + function! Function_Name(items, str, limit, mmode, ispath, crfile, regex) + " 参数: + " | + " +- a:items : 搜索条目的全列表。 + " | + " +- a:str : 用户输入的字符串。 + " | + " +- a:limit : 匹配窗口的最大高度。可以用来限制返回的条目数量。 + " | + " +- a:mmode : 在匹配模式。可以是下列字符串之一: + " | + "full-line": 匹配整行。 + " | + "filename-only": 只匹配文件名。 + " | + "first-non-tab": 匹配到第一个制表符。 + " | + "until-last-tab": 匹配到最后一个制表符。 + " | + " +- a:ispath : 搜索文件,缓冲区,最近最多使用,混合,目录和rtscript模. + " | 式时为1。其它为0。 + " | + " +- a:crfile : 当前窗口中的文件。当a:ispath为1时应该被搜索结果排除在外 + " | + " +- a:regex : 是否在正则表达式模式: 1 or 0. + + return list_of_matched_items + endfunction +< + +注意: 你可以通过 { 'arg_type': 'dict' } 扩展上面的任何选项,这样就可以通过 +一个字典类型的参数来传递所有的函数参数。使用参数名作为字典的键值。 + +例子: > + let g:ctrlp_status_func = { + \ 'arg_type' : 'dict', + \ 'enter': 'Function_Name_1', + \ 'exit': 'Function_Name_2', + \ } + + function! Function_Name_1(dict) + " where dict == { + " \ 'focus': value, + " \ 'byfname': value, + " \ 'regex': value, + " \ ... + " } + endfunction +< + *'g:ctrlp_brief_prompt'* +当设置为 1 时, 提示符后为空时按 会退出 CtrlP 。 + + *ctrlp-default-value* +另外,你可以使用下面的方式来改变默认值。 +例子: > + let g:ctrlp_path_nolim = 1 + +这样可以让无限制模式匹配“路径”类型。 +=============================================================================== +命令 *ctrlp-commands* + + *:CtrlP* +:CtrlP [起始目录] + 用文件搜索模式打开CtrlP。 + + 如果没有给定参数,|g:ctrlp_working_path_mode| 会被用来决定起始目录。 + + 在输入时你可以使用 自动补全[起始目录]。 + + *:CtrlPBuffer* +:CtrlPBuffer + 用缓冲区搜索模式打开CtrlP。 + + *:CtrlPMRU* +:CtrlPMRU + 用最近最多使用模式打开CtrlP。 + + *:CtrlPLastMode* +:CtrlPLastMode [--dir] + 用上一次使用的模式打开CtrlP。当提供了"--dir"参数,也重用上一次的工作目录。 + + *:CtrlPRoot* +:CtrlPRoot + 行为类似使用了 |g:ctrlp_working_path_mode| = 'r' 并且忽略了该变量的当前值的 + |:CtrlP| 命令。 + + *:CtrlPClearCache* +:CtrlPClearCache + 清除当前工作目录的缓存。和在CtrlP内按 效果一样。 + 使用 |g:ctrlp_use_caching| 来启用或禁用缓存。 + + *:CtrlPClearAllCaches* +:CtrlPClearAllCaches + 删除在 |g:ctrlp_cache_dir| 中定义的缓存目录中的所有缓存文件。 + +------------------------------------------------------------------------------- +由扩展提供的命令参见 |ctrlp-extensions| 。 + +=============================================================================== +按键绑定 *ctrlp-mappings* + + *'ctrlp-'* + + 普通模式 |Normal| 下默认以文件搜索模式打开CtrlP提示符面板。 + +---------------------------------------- +已经在提示符面板中:~ + + + 在全路径搜索和文件名搜索间切换。 + 注意: 在文件名搜索模式,提示符面板的提示符是'>d>',而不是'>>>' + + *'ctrlp-fullregexp'* + 在字符串搜索模式和正则表达式模式之间切换。 + 注意: 在全正则表达式模式,提示符面板的提示符是'r>>',而不是'>>>' + + 详细参见: |input-formats| (指引)和 |g:ctrlp_regexp_search| 选项。 + + , 'forward' 前进 + + 切换到序列里面的 'next' 后一个搜索模式。 + + , 'backward' 后退 + + 切换到序列里面的 'previous' 前一个搜索模式。 + + *'ctrlp-autocompletion'* + 自动补全在提示符面板的当前工作路径中的目录名。 + + + 在匹配窗口和提示符面板之间切换焦点。 + + , + + 退出CtrlP。 + +移动:~ + + , + + 向下移动。 + + , + + 向上移动。 + + + 移动光标到提示符面板的 'start' 开头。 + + + 移动光标到提示符面板的 'end' 末尾。 + + , + , + + 向左 'left' 移动一个字符。 + + , + + 向右 'right' 移动一个字符。 + +编辑:~ + + , + + 删除前一个字符。 + + + 删除当前字符。 + + + 删除前一个单词。 + + + 清除输入。 + +浏览输入历史:~ + + + 提示符面板历史里的下一个字符串。 + + + 提示符面板历史里的上一个字符串。 + +打开/创建文件:~ + + + 如果可能的话在 'current' 当前窗口打开选择的文件。 + + + 在 'tab' 新标签打开选择的文件。 + Open the selected file in a new 'tab'. + + + 在 'vertical' 竖直分割窗口打开选择的文件。 + + , + , + + 在 'horizontal' 水平分割窗口打开选择的文件。 + + + 创建一个新文件和它的父目录。 + +打开多个文件:~ + + + - 标记/取消标记一个被 打开的文件。 + - 标记/取消标记一个被 在它的目录被创建的文件。 + + + - 打开被 标记的文件。 + - 当没有文件被 标记时,使用下列选项打开一个终端对话框: + + 打开被选择的文件: + t - 在新标签页中打开。 + v - 在一个竖直分割窗口中。 + h - 在一个水平分割窗口中。 + r - 在当前窗口中打开。 + i - 在隐藏的缓冲区中。 + x - (可选的)使用 |g:ctrlp_open_func| 中定义的函数。 + + 其它选项 (未显示): + a - 标记匹配窗口中的所有文件。 + d - 改变CtrlP的工作目录到被选择的文件的目录并切换到文件搜索模式。 + +功能按键绑定:~ + + + - 刷新匹配窗口并且清除当前目录的缓存。 + - 从最近最多使用中移除被删除的文件。 + + + 最近最多使用模式: + - 清除最近最多使用列表。 + - 删除被 标记的最近最多使用条目。 + 缓冲区模式: + - 删除光标下的条目或者删除被 标记的多个条目。 + +粘贴:~ + + , *'ctrlp-pasting'* + + 将剪贴板中的文本粘贴到提示符窗口中。 + + + 打开一个终端对话框来粘贴 ,搜索寄存器的文本,上一次可视 + 化模式的选择,剪贴板或者任何寄存器到提示符面板中。 + +使用 |g:ctrlp_prompt_mappings| 选择你自己的绑定。 + +---------------------------------------- +当焦点在匹配窗口中时(使用 来切换):~ + + a-z + 0-9 + ~^-=;`',.+!@#$%&_(){}[] + 在匹配第一个字符的行中循环。 + +=============================================================================== +输入格式 *ctrlp-input-formats* + +提示符面板的输入格式:~ + +a) 字符串。 + + 例如: 'abc' 被内部理解为 'a[^a]\{-}b[^b]\{-}c' + +b) 在正则表达式模式,输入字符串被按照Vim的正则表达式模式 |pattern| 来对待,不 + 进行任何修改。 + + 例如: 'abc\d*efg' 会被解读为 'abc\d*efg'。 + + 如何启用正则表达式模式参见 |ctrlp-fullregexp| (按键绑定)和 + |g:ctrlp_regexp_search| (选项)。 + +c) 字符串末尾使用一个冒号':'跟随一个Vim命令来在打开那个文件后执行该命令。如果 + 你需要使用':'的字面意思,使用反斜杠转义'\:'。但打开多个文件时,命令会在每 + 个打开文件上执行。 + + 例如: 使用':45'跳转到第45行。 + + 使用':/any\:string'跳转到'any:string'第一次出现的地方。 + + 使用':+setf\ myfiletype|50'来设置文件类型为 'myfiletype',然后跳转 + 到第50行。 + + 使用':diffthis'当打开多个文件时在前四个文件上调用 |:diffthis| 。 + + 参见: Vim的 |++opt| 和 |+cmd|. + +d) 提交两个点号 '..' 来进入上级目录。如果想进入向上多级目录,每多一级使用一个 + 额外的点号: +> + 输入 解释为 + .. ../ + ... ../../ + .... ../../../ +< + 注意: 如果父目录很大并且没有被缓存,可能会很慢。 + + 你可以使用'@cd path/'来改变CtrlP的工作目录为path/。使用'@cd %:h'来改变为当 + 前文件的目录。 + +e) 类似的,提交'/'或者'\'来查找或者跳转到项目的根目录。 + + 如果项目很大,使用版本控制系统的列出命令来寻找文件可能会加速初始化扫描。( + 更多细节参见 |g:ctrlp_user_command| )。 + + 注意: d) 和 e) 只在文件,目录和混合模式生效。 + +f) 输入一个不存在的文件名并且按下 来创建文件。如果使用 标记了一个 + 文件,将会在被标记的文件的目录下创建这个新文件。 + + 例如: 使用 'newdir/newfile.txt' 会创建一个名为'newdir'的目录和一个名为 + 'newfile.txt'的文件。 + + 如果一个条目'some/old/dirs/oldfile.txt'被 标记,然后 'newdir' + 和'newfile.txt'会在'some/old/dirs'下被创建。最终的路径会像下面这样 + 'some/old/dirs/newdir/newfile.txt'. + + 注意: 在Windows下使用 '\' 代替 '/' (如果 |'shellslash'| 选项没有设置)。 + +g) 在文件名模式(使用 切换)下,你可以使用被逗号分隔的一个主要的模式和 + 一个改善的模式。两个模式在正则表达式模式下像(a)或(b)那样工作。 + +h) 使用?打开帮助文件。 + +=============================================================================== +扩展 *ctrlp-extensions* + +扩展是可选的。把它的名字添加到变量g:ctrlp_extensions中来开启扩展: > + let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript', + \ 'undo', 'line', 'changes', 'mixed', 'bookmarkdir'] +< +扩展的名字在变量中出现的顺序会是在使用命令 切换时扩展在状态栏中出 +现的顺序。 + +可用的扩展:~ + + *:CtrlPTag* + * 标记模式:~ + - 名称: 'tag' + - 命令: ":CtrlPTag" + - 在一个生成的标记文件中搜索标签,跳转到标签定义。使用Vim的 |'tags'| 来指定 + 标签文件的位置和名称。 + 例如: set tags+=doc/tags + + *:CtrlPBufTag* + *:CtrlPBufTagAll* + * 缓冲区标签模式:~ + - 名称: 'buffertag' + - 命令: ":CtrlPBufTag [缓冲区]", + ":CtrlPBufTagAll"。 + - 在当前缓冲区或者所有列出的缓冲区中搜索标签并且跳转到定义。需要 + |exuberant_ctags| 或者兼容的程序。 + + *:CtrlPQuickfix* + * 快速修复模式:~ + - 名称: 'quickfix' + - 命令: ":CtrlPQuickfix" + - 在当前的快速修复错误列表中搜索条目并且跳转过去。 + + *:CtrlPDir* + * 目录模式:~ + - 名称: 'dir' + - 命令: ":CtrlPDir [起始muu]" + - 搜索目录并且将其作为工作目录。 + - 按键绑定: + + 为CtrlP修改工作目录并且保持打开状态。 + + 修改全局的工作目录(退出)。 + + 为当前窗口修改工作目录(退出)。 + + 修改全局工作目录为CtrlP的当前工作目录(退出)。 + + *:CtrlPRTS* + * 运行时脚本模式:~ + - 名称: 'rtscript' + - 命令: ":CtrlPRTS" + - 在运行时路径中寻找文件(vimscripts, docs, snippets...)。 + + *:CtrlPUndo* + * 撤销模式:~ + - 名称: 'undo' + - 命令: ":CtrlPUndo" + - 浏览撤销历史。 + + *:CtrlPLine* + * 行模式:~ + - 名称: 'line' + - 命令: ":CtrlPLine [缓冲区]" + - 在所有列出的缓冲区或者在指定的 [buffer] 缓冲区内搜索一行内容。 + + *:CtrlPChange* + *:CtrlPChangeAll* + * 修改列表模式:~ + - 名称: 'changes' + - 命令: ":CtrlPChange [缓冲区]", + ":CtrlPChangeAll". + - 在当前缓冲区或者在所有列出的缓冲区内搜索最近的修改并跳转。 + + *:CtrlPMixed* + * 混合模式:~ + - 名称: 'mixed' + - 命令: ":CtrlPMixed" + - 同时在文件,缓冲区和最近最多修改中搜索。 + + *:CtrlPBookmarkDir* + *:CtrlPBookmarkDirAdd* + * 书签目录模式:~ + - 名称: 'bookmarkdir' + - 命令: ":CtrlPBookmarkDir", + ":CtrlPBookmarkDirAdd [目录] [标题]". + ":CtrlPBookmarkDirAdd! [目录] [标题]". + - 搜索一个被书签标记的目录并将其作为工作目录。 + - 以指定的[标题]添加[目录]到 CtrlPBookmarkDir 中,如果没有给出[标题]或 + 者[目录],会请求用户输入。 + - 以指定的[标题]添加[目录]到 CtrlPBookmarkDir 中,如果没有给出目录,则 + 默认为当前目录( [CWD] ),如果没有给出[标题] ,会请求用户输入。 + + 最新的用来添加所有最近使用过的目录到 CtrlPBookmarkDir 列表中的自动命令 + 如下 + > + augroup CtrlPDirMRU + autocmd! + autocmd FileType * if &modifiable | execute 'silent CtrlPBookmarkDirAdd! %:p:h' | endif + augroup END +< + + - 按键绑定: + + 为CtrlP修改工作目录并且保持打开状态,并且切换到文件搜索模式。 + + 修改全局的工作目录(退出)。 + + 为当前窗口修改工作目录(退出)。 + + + - 清除书签列表。 + - 删除被 标记的书签条目。 + + *ctrlp-autoignore-extension* + * 自动忽略模式:~ + - 名称: 'autoignore' + + - 这个扩展并不会添加新命令。它支持通过项目根目录中的 `.ctrlpignore` 文件为 + 每个项目设置忽略模式 (就像属于单个项目的 |ctrlp_custom_ignore|)。基本 + 上就像 CtrlP 的 `.gitignore` 或者 `.hgignore`。 + + 注意: 当使用 |g:ctrlp_user_command| 自动忽略模式不起作用。 + + 注意: `.ctrlpignore` 会被当做根目录的标识(参见 |g:ctrlp_root_markers|). + + - 忽略文件的语法: + 空行,以 `#` (注释)开头的行会被忽略。 + + 其他行会被当做正则表达式。 匹配模式如何被使用参见 *string-match* 。 + 任意条目,只要匹配到任意匹配模式,就会从 CtrlP 中搜索结果中忽略。 + + 例子: + + \.tmp$ + ^generated/ + local\.cfg + + 注意: 即使在 Windows 上模式也应该使用反斜线。 + + 你也可以像下面那样使用 glob 命令风格的语法: + + syntax:wildignore + *.tar.gz + *.tmp + + 这样会在搜索文件时临时的把每一个匹配模式添加到 |'wildignore'| + 中,结束时移除。 + + 你也可以通过下面的方式切换回默认的正则表达式为基础的模式: + + syntax:regexp + + 你也可以只为某一条目类型(文件、目录...)设置匹配模式: + + dir:build + file:foo\.txt + + 这样只会忽略包含 "build" 的目录和包含 "foo.txt" 的文件。不会忽略带 + 有 "build" 的文件或者反过来。 + + 注意: 如果为了忽略名为 "build" 的目录,而不是『任何』包含 "build" + 的目录,你可以使用下面的正则: ^build$ + + - 常见问题: + 问: 为什么 CtrlP 不能直接支持原生的 `.gitignore` or `.hgignore` ? + + 答: 这些文件初看起来好像已经包含了所有你想从 CtrlP 中排除的文件。但是 + 通常情况下,这些文件和你想在 CtrlP 中的配置会有一些不同。这些配置文件 + 列出了不能被包含到版本控制中的文件。这些不能被包含到版本控制中的文件 + 包括了你想忽略的,但是同时可能也包含了你不想忽略的:本地设置,外部包 + 和依赖,等等。作者觉得支持多种语法与只是简单的复制/粘贴几行忽略规则比 + 起来比较麻烦。如果你不这么觉得可以随时提交补丁 :) + + 问: 我开启了 |ctrlp-autoignore-extension|, 或者编辑了 `.ctrlpignore` + 但是这些新模式并没有起作用。我哪里做错了? + + 答: 可能什么都没做错!CtrlP 可以为了快速的响应缓存搜索结果。你可以按 + 强制刷新。如果 `.ctrlpignore` 改动过,这样也会使用新的匹配模式。 + +---------------------------------------- +缓冲标签模式选项:~ + + *'g:ctrlp_buftag_ctags_bin'* +如果ctags没有在环境变量中配置,使用该选项来指定它的位置: > + let g:ctrlp_buftag_ctags_bin = '' +< + + *'g:ctrlp_buftag_systemenc'* +将该选项与你的操作系统的编码(非Vim的)保持一致。默认值使用Vim的全局 +|'encoding'| 选项: > + let g:ctrlp_buftag_systemenc = &encoding +< + + *'g:ctrlp_buftag_types'* +使用该选项来在ctags, jsctags...中为指定的文件格式设置参数: > + let g:ctrlp_buftag_types = '' +< +例子: > + let g:ctrlp_buftag_types = { + \ 'erlang' : '--language-force=erlang --erlang-types=drmf', + \ 'javascript' : { + \ 'bin': 'jsctags', + \ 'args': '-f -', + \ }, + \ } +< + +=============================================================================== +自定义 *ctrlp-customization* + +高亮:~ + * CtrlP缓冲区的设置: + CtrlPNoEntries : 当没有匹配被发现时的消息(错误)。 + CtrlPMatch : 匹配模式(标识)。 + CtrlPLinePre : 匹配窗口的行前缀'>'。 + CtrlPPrtBase : 提示符窗口的基础(注释)。 + CtrlPPrtText : 提示符窗口的文本 (|hl-Normal|)。 + CtrlPPrtCursor : 提示符窗口的光标在文本上移动时(常量)。 + + * 缓冲区浏览模式: + CtrlPBufferNr : 缓冲区编号 + CtrlPBufferInd : '+', '-', '=' 和 '#' 指示符 (参见 |:buffers|) + CtrlPBufferHid : 隐藏缓冲区 + CtrlPBufferHidMod : 隐藏和被编辑过的缓冲区 + CtrlPBufferVis : 可见的缓冲区 + CtrlPBufferVisMod : 可见的和被编辑过的缓冲区 + CtrlPBufferCur : 当前缓冲区 + CtrlPBufferCurMod : 当前和被编辑过的缓冲区 + CtrlPBufferPath : 缓冲区路径 + + * 在扩展中: + CtrlPTabExtra : 每一行中不匹配的部分(注释)。 + CtrlPBufName : 条目所属的缓冲区名称(|hl-Directory|)。 + CtrlPTagKind : 缓冲区标签模式中标签的类型(|hl-Title|)。 + CtrlPqfLineCol : 快速修复模式中行和列的序号(注释)。 + CtrlPUndoT : 撤销模式的流逝时间(|hl-Directory|)。 + CtrlPUndoBr : 撤销模式的方括号(注释)。 + CtrlPUndoNr : 撤销模式的方括号中的数字(字符串)。 + CtrlPUndoSv : 文件被保存的点(注释)。 + CtrlPUndoPo : 撤销树中的当前位置(|hl-Title|)。 + CtrlPBookmark : 书签的名称(标识)。 + +状态栏:~ + * 高亮组: + CtrlPMode1 : 'file' 或 'path' 或 'line',和当前模式(字符)。 + CtrlPMode2 : 'prt' 或 'win', 'regex',工作目录 |hl-LineNr| 。 + CtrlPStats : 扫描状态(函数)。 + + 重新构建状态栏,参见 |g:ctrlp_status_func| 。 + +=============================================================================== +其它选项 *ctrlp-miscellaneous-configs* + +* 为 |g:ctrlp_user_command| 使用 |wildignore| : +> + function! s:wig2cmd() + " 修改wildignore为空格或者|分隔的组 + " 例如: .aux .out .toc .jpg .bmp .gif + " 或者 .aux$\|.out$\|.toc$\|.jpg$\|.bmp$\|.gif$ + let pats = ['[*\/]*\([?_.0-9A-Za-z]\+\)\([*\/]*\)\(\\\@ 提交) + +* 一个独立的函数,设置项目的根目录为工作目录,如果没有找到根目录的话使用当前文 +* 件的父目录。 +> + function! s:setcwd() + let cph = expand('%:p:h', 1) + if cph =~ '^.\+://' | retu | en + for mkr in ['.git/', '.hg/', '.svn/', '.bzr/', '_darcs/', '.vimprojects'] + let wd = call('find'.(mkr =~ '/$' ? 'dir' : 'file'), [mkr, cph.';']) + if wd != '' | let &acd = 0 | brea | en + endfo + exe 'lc!' fnameescape(wd == '' ? cph : substitute(wd, mkr.'$', '.', '')) + endfunction + + autocmd BufEnter * call s:setcwd() +< +(需要 Vim 7.1.299+) + +* 使用 |count| 来使用同样的按键绑定调用不同的命令: +> + let g:ctrlp_cmd = 'exe "CtrlP".get(["", "Buffer", "MRU"], v:count)' +< + +=============================================================================== +开发人员 *ctrlp-credits* + +最初由 Kien Nguyen 开发。现在由 Github 上 ctrlpvim 组织的成员 +维护(https://github.com/orgs/ctrlpvim/people) 。在Vim的 |license| 下发行。 + +项目主页: http://ctrlpvim.github.com/ctrlp.vim +Git 仓库: https://github.com/ctrlpvim/ctrlp.vim + +------------------------------------------------------------------------------- +感谢所有通过github,bitbucket或电子邮件提供想法,报告bug或者帮助debugging的人。 + +特别感谢:~ + + * Woojong Koh + * Simon Ruderich + * Yasuhiro Matsumoto + * Ken Earley + * Kyo Nagashima + * Zak Johnson + * Diego Viola + * Piet Delport + * Thibault Duplessis + * Kent Sibilev + * Tacahiroy + * Luca Pette + * Seth Fowler + * Lowe Thiderman + * Christopher Fredén + * Zahary Karadjov + * Jo De Boeck + * Rudi Grinberg + * Timothy Mellor + * Sergey Vlasov + +=============================================================================== +更新日志 *ctrlp-changelog* + + + 新的支持高亮的缓冲区浏览模式 (建议 |+conceal|) + + 新选项: |g:ctrlp_bufname_mod|, + |g:ctrlp_bufpath_mod| + + 结合 *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* 和 + *g:ctrlp_max_height* 到 |g:ctrlp_match_window| 。 + + 新选项: |g:ctrlp_match_window| 。 + +在2012/11/30之前~ + + + 新选项: |g:ctrlp_abbrev|, + |g:ctrlp_key_loop|, + |g:ctrlp_open_func|, + |g:ctrlp_tabpage_position|, + |g:ctrlp_mruf_save_on_update| + + 重命名: + *g:ctrlp_dotfiles* -> |g:ctrlp_show_hidden| 。 + + 修改 |g:ctrlp_switch_buffer| 和 |g:ctrlp_working_path_mode|的类型 + (旧值仍然工作)。 + + 当 |g:ctrlp_user_command| 是一个字典时,为其增加一个新的键: 'ignore'。 + +在2012/06/15之前~ + + + |g:ctrlp_follow_symlinks| 的新值: 2。 + + |g:ctrlp_open_multiple_files| 的新值: 'j'。 + + 允许使用 , , 打开被 标记的文件。 + + 扩展 '..' (|ctrlp-input-formats| (d)) + + 新的输入格式: '@cd' (|ctrlp-input-formats| (d)) + +在2012/04/30之前~ + + + 新选项: |g:ctrlp_mruf_default_order| + + 新特性: 被书签标记的目录的扩展。 + + 新命令: |:CtrlPBookmarkDir| + |:CtrlPBookmarkDirAdd| + +在2012/04/15之前~ + + + 新选项: |g:ctrlp_buffer_func|,CtrlP缓冲区的回调函数。 + + 移除 : g:ctrlp_mruf_last_entered,使其作为最近最多使用的默认行为。 + + 新命令: |:CtrlPLastMode|,以上一次使用的模式打开CtrlP。 + |:CtrlPMixed|,在文件,缓冲区和最近最多使用中搜索。 + +在2012/03/31之前~ + + + 新选项: |g:ctrlp_default_input|, 进入CtrlP后的默认输入。 + |g:ctrlp_match_func|,允许使用自定义的模糊查找工具。 + + 重命名: + *ClearCtrlPCache* -> |CtrlPClearCache| + *ClearAllCtrlPCaches* -> |CtrlPClearAllCaches| + *ResetCtrlP* -> |CtrlPReload| + +在2012/03/02之前~ + + + 重命名: + *g:ctrlp_regexp_search* -> |g:ctrlp_regexp|, + *g:ctrlp_dont_split* -> |g:ctrlp_reuse_window|, + *g:ctrlp_jump_to_buffer* -> |g:ctrlp_switch_buffer|。 + + 重命名和微调: + *g:ctrlp_open_multi* -> |g:ctrlp_open_multiple_files|。 + + 过时 *g:ctrlp_highlight_match* + + 扩展 |g:ctrlp_user_command| 支持多个命令。 + + 新选项: |g:ctrlp_mruf_last_entered| 修改最近最多使用为最近进入。 + +在2012/01/15之前~ + + + 新按键绑定: 交换 . 现在用来补全在当前工作目录内的目 + 录名。 + + 新选项: |g:ctrlp_arg_map| 使 可以接收一个参数。 + |g:ctrlp_status_func| 自定义状态栏。 + |g:ctrlp_mruf_relative| 在当前工作目录内显示最近最多使用。 + + 扩展 g:ctrlp_open_multi 增加新选项值: tr, hr, vr。 + + 扩展 |g:ctrlp_custom_ignore| 指定过滤目录,文件和链接。 + +在2012/01/05之前~ + + + 新特性: 缓冲区标记扩展。 + + 新命令: |:CtrlPBufTag|, |:CtrlPBufTagAll|。 + + 新选项: |g:ctrlp_cmd|, + |g:ctrlp_custom_ignore| + +在2011/11/30之前~ + + + 新特性: 标签,快速修复和目录扩展。 + + 新命令: |:CtrlPTag|, |:CtrlPQuickfix|, |:CtrlPDir|。 + + 新选项: |g:ctrlp_use_migemo|, + |g:ctrlp_lazy_update|, + |g:ctrlp_follow_symlinks| + +在2011/11/13之前~ + + + 新的特殊输入: '/' 和 '\' 查找根目录 (|ctrlp-input-formats| (e)) + + 移除 ctrlp#SetWorkingPath()。 + + 移除 *g:ctrlp_mru_files* ,使最近最多使用模式变为永久的。 + + 扩展 g:ctrlp_open_multi,添加打开文件的新方式。 + + 新选项: g:ctrlp_dont_split, + |g:ctrlp_mruf_case_sensitive| + +在2011/10/30之前~ + + + 新特性: 支持自定义扩展。 + 也会从最近最多使用列表中移除不存在的文件。 + + 新选项: g:ctrlp_jump_to_buffer + +在2011/10/12之前~ + + + 新特性: 打开多个文件。 + 传递Vim的 |++opt| 和 |+cmd| 到新打开的文件 + (|ctrlp-input-formats| (c)) + 为 |:CtrlP| [起始目录]自动补全每个目录 + + 新按键绑定: 标记/取消标记一个被 打开的文件。 + 打开所有被标记的文件。 + + 新选项: g:ctrlp_open_multi + + 移除 *g:ctrlp_persistent_input* *g:ctrlp_live_update* and 。 + +在2011/09/29之前~ + + + 新按键绑定: , 输入历史中的前一个/后一个字符串。 + 创建一个新的文件和它的父目录。 + + 新选项: |g:ctrlp_open_new_file|, + |g:ctrlp_max_history| + + 添加一个新的在横向分割窗口打开的绑定: + +在2011/09/19之前~ + + + 新命令: ResetCtrlP + + 新选项: |g:ctrlp_max_files|, + |g:ctrlp_max_depth|, + g:ctrlp_live_update + + 新按键绑定: + +在2011/09/12之前~ + + + 添加在匹配窗口内循环匹配行的功能。 + + 扩展 g:ctrlp_persistent_input的行为 + + 扩展 |:CtrlP| 的行为 + + 新选项: |g:ctrlp_dotfiles|, + |g:ctrlp_clear_cache_on_exit|, + g:ctrlp_highlight_match, + |g:ctrlp_user_command| + + 新的特殊输入: '..' (|ctrlp-input-formats| (d)) + + 新按键绑定: 。 + + 新命令: |:CtrlPCurWD|, + |:CtrlPCurFile|, + |:CtrlPRoot| + + + 新特性: 在最近最常使用的文件列表中搜索 + + 新按键绑定: 。 + + 扩展 的行为。 + + 新选项: g:ctrlp_mru_files, + |g:ctrlp_mruf_max|, + |g:ctrlp_mruf_exclude|, + |g:ctrlp_mruf_include| + + 新命令: |:CtrlPMRU| + +第一版发布于: 2011/09/06~ + +=============================================================================== +vim:ft=help:et:ts=2:sw=2:sts=2:norl diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt index e697b937..4cc6017d 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt @@ -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 . + |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 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 - 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_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()': [''] } < - *'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 mapping: > let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['', ''] } < + *'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! tagsUnderCursor() + try + let default_input_save = get(g:, 'ctrlp_default_input', '') + let g:ctrlp_default_input = expand('') + 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()': [''] } < - *'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 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. - - Wipe the MRU list. - - Delete MRU entries marked by . + MRU mode: + - Wipe the list. + - Delete entries marked by . + Buffer mode: + - Delete entry under the cursor or delete multiple entries marked by . + 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: + 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 . + *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 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 . Distributed under Vim's |license|. +Originally developed by Kien Nguyen . 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 * Rudi Grinberg * Timothy Mellor + * Sergey Vlasov =============================================================================== 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|. diff --git a/sources_non_forked/ctrlp.vim/plugin/ctrlp.vim b/sources_non_forked/ctrlp.vim/plugin/ctrlp.vim index c7b8fa3f..9f2bb147 100644 --- a/sources_non_forked/ctrlp.vim/plugin/ctrlp.vim +++ b/sources_non_forked/ctrlp.vim/plugin/ctrlp.vim @@ -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 = '' | en if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en -com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': }) -com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': }) +com! -n=? -com=dir CtrlP cal ctrlp#init('fil', { 'dir': }) +com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init('mru', { 'dir': }) -com! -bar CtrlPBuffer cal ctrlp#init(1) +com! -bar CtrlPBuffer cal ctrlp#init('buf') com! -n=? CtrlPLastMode cal ctrlp#init(-1, { '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(':'.g:ctrlp_cmd.'', 'n') - exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.'' +exe 'nn (ctrlp) :'.g:ctrlp_cmd.'' + +if g:ctrlp_map != '' && !hasmapto('(ctrlp)') + exe 'map' g:ctrlp_map '(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, )) + \ cal ctrlp#init(ctrlp#line#cmd('buf', )) com! -n=? -com=buffer CtrlPChange - \ cal ctrlp#init(ctrlp#changes#cmd(0, )) + \ cal ctrlp#init(ctrlp#changes#cmd('fil', )) 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', ) +com! -n=? -com=dir -bang CtrlPBookmarkDirAdd + \ cal ctrlp#call('ctrlp#bookmarkdir#add', '', ) " vim:ts=2:sw=2:sts=2 diff --git a/sources_non_forked/ctrlp.vim/readme.md b/sources_non_forked/ctrlp.vim/readme.md index bcd07c7f..66fc9e8c 100644 --- a/sources_non_forked/ctrlp.vim/readme.md +++ b/sources_non_forked/ctrlp.vim/readme.md @@ -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 diff --git a/sources_non_forked/goyo.vim/autoload/goyo.vim b/sources_non_forked/goyo.vim/autoload/goyo.vim index 9d3d1eb5..3e014667 100644 --- a/sources_non_forked/goyo.vim/autoload/goyo.vim +++ b/sources_non_forked/goyo.vim/autoload/goyo.vim @@ -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 (goyo-resize) :call resize_pads() + 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("\(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 diff --git a/sources_forked/zencoding/.gitignore b/sources_non_forked/lightline.vim/.gitignore old mode 100755 new mode 100644 similarity index 100% rename from sources_forked/zencoding/.gitignore rename to sources_non_forked/lightline.vim/.gitignore diff --git a/sources_non_forked/lightline.vim/.travis.yml b/sources_non_forked/lightline.vim/.travis.yml new file mode 100644 index 00000000..ae4b73fb --- /dev/null +++ b/sources_non_forked/lightline.vim/.travis.yml @@ -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 diff --git a/sources_non_forked/lightline.vim/LICENSE b/sources_non_forked/lightline.vim/LICENSE new file mode 100644 index 00000000..3000b844 --- /dev/null +++ b/sources_non_forked/lightline.vim/LICENSE @@ -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. diff --git a/sources_non_forked/lightline.vim/README.md b/sources_non_forked/lightline.vim/README.md new file mode 100644 index 00000000..03f5da1b --- /dev/null +++ b/sources_non_forked/lightline.vim/README.md @@ -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 <bf> 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. diff --git a/sources_non_forked/lightline.vim/autoload/lightline.vim b/sources_non_forked/lightline.vim/autoload/lightline.vim new file mode 100644 index 00000000..045e2b85 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline.vim @@ -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', "\": 'V-BLOCK', + \ 'c': 'COMMAND', 's': 'SELECT', 'S': 'S-LINE', "\": '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', "\": 'visual', + \ 'c': 'command', 's': 'select', 'S': 'select', "\": '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 diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim new file mode 100644 index 00000000..de23eb5f --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim new file mode 100644 index 00000000..170aa93e --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor.vim new file mode 100644 index 00000000..429439d8 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_dark.vim new file mode 100644 index 00000000..0a70b348 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_dark.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_light.vim new file mode 100644 index 00000000..aef0b865 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_light.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim new file mode 100644 index 00000000..82559669 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim new file mode 100644 index 00000000..89031802 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim new file mode 100644 index 00000000..31c27f35 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim new file mode 100644 index 00000000..5b81a316 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim new file mode 100644 index 00000000..5124eccb --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/default.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/default.vim new file mode 100644 index 00000000..ee9835c8 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/default.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim new file mode 100644 index 00000000..15b2b35b --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/landscape.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/landscape.vim new file mode 100644 index 00000000..68d09209 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/landscape.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerline.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerline.vim new file mode 100644 index 00000000..40e48d43 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerline.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim new file mode 100644 index 00000000..ca2d5a09 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim new file mode 100644 index 00000000..577177e2 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim new file mode 100644 index 00000000..96192476 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim b/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim new file mode 100644 index 00000000..82617b20 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/autoload/lightline/tab.vim b/sources_non_forked/lightline.vim/autoload/lightline/tab.vim new file mode 100644 index 00000000..f2accc11 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/tab.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/doc/lightline.txt b/sources_non_forked/lightline.vim/doc/lightline.txt new file mode 100644 index 00000000..c151bddb --- /dev/null +++ b/sources_non_forked/lightline.vim/doc/lightline.txt @@ -0,0 +1,1280 @@ +*lightline.txt* A light and configurable statusline/tabline for Vim + +Version: 0.0 +Author: itchyny (https://github.com/itchyny) +License: MIT License +Repository: https://github.com/itchyny/lightline.vim +Last Change: 2016/08/09 06:22:39. + +CONTENTS *lightline-contents* + +Introduction |lightline-introduction| +Spirit |lightline-spirit| +Option |lightline-option| +Font |lightline-font| +Function |lightline-function| +Component Expansion |lightline-component-expansion| +Colorscheme |lightline-colorscheme| +Examples |lightline-examples| +Nice Examples |lightline-nice-examples| +Powerful Example |lightline-powerful-example| +Troubleshooting |lightline-troubleshooting| +Changelog |lightline-changelog| + +============================================================================== +INTRODUCTION *lightline-introduction* + +The *lightline* plugin is a light and configurable statusline/tabline for Vim. + +------------------------------------------------------------------------------ +SPIRIT *lightline-spirit* + + 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. + + You might find this plugin is not so useful by default. This plugin + does not provide the branch information, which is a very basic + component in existing plugins. The reason is that branch component is + one of plugin-crossing settings so users should write the settings + using the APIs of the both plugins. Hospitality makes a plugin messy. + Good APIs keep a plugin clean. + +------------------------------------------------------------------------------ +OPTIONS *lightline-option* + + g:lightline *g:lightline* + All the options are stored into this global variable. + + g:lightline.active *g:lightline.active* + g:lightline.inactive *g:lightline.inactive* + g:lightline.tabline *g:lightline.tabline* + Dictionaries to specify the statusline/tabline components. + The components are gathered from either |g:lightline.component|, + |g:lightline.component_function| or + |g:lightline.component_expand|. + Note that right groups of components are stored from right to + left. The default values are: +> + let g:lightline.active = { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'readonly', 'filename', 'modified' ] ], + \ 'right': [ [ 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] } + let g:lightline.inactive = { + \ 'left': [ [ 'filename' ] ], + \ 'right': [ [ 'lineinfo' ], + \ [ 'percent' ] ] } + let g:lightline.tabline = { + \ 'left': [ [ 'tabs' ] ], + \ 'right': [ [ 'close' ] ] } +< + g:lightline.tab *g:lightline.tab* + Dictionaries to specify the components in each tabs. + The components are gathered from either + |g:lightline.tab_component| or + |g:lightline.tab_component_function|. + The default values are: +> + let g:lightline.tab = { + \ 'active': [ 'tabnum', 'filename', 'modified' ], + \ 'inactive': [ 'tabnum', 'filename', 'modified' ] } +< + g:lightline.component *g:lightline.component* + Dictionary for statusline/tabline components. + The default value is: +> + let g:lightline.component = { + \ 'mode': '%{lightline#mode()}', + \ 'absolutepath': '%F', + \ 'relativepath': '%f', + \ 'filename': '%t', + \ 'modified': '%M', + \ 'bufnum': '%n', + \ 'paste': '%{&paste?"PASTE":""}', + \ 'readonly': '%R', + \ 'charvalue': '%b', + \ 'charvaluehex': '%B', + \ 'fileencoding': '%{&fenc!=#""?&fenc:&enc}', + \ 'fileformat': '%{&ff}', + \ 'filetype': '%{&ft!=#""?&ft:"no ft"}', + \ 'percent': '%3p%%', + \ 'percentwin': '%P', + \ 'spell': '%{&spell?&spelllang:""}', + \ 'lineinfo': '%3l:%-2v', + \ 'line': '%l', + \ 'column': '%c' + \ 'close': '%999X X ' } +< + g:lightline.component_visible_condition *g:lightline.component_visible_condition* + Dictionary of boolean expressions for the components. + Each expression should correspond to the condition each + component have non-zero length. + The default value is: +> + let g:lightline.component_visible_condition = { + \ 'modified': '&modified||!&modifiable', + \ 'readonly': '&readonly', + \ 'paste': '&paste', + \ 'spell': '&spell' } +< + Users are recommended to set this option together with the + component itself. + + g:lightline.component_function *g:lightline.component_function* + Another dictionary for components. This is more convenient + because the user does not have to set both component and + component_visible_condition. If a component set to both component and + component_function, the setting of component_function has priority. + For example, if you want a component for read-only mark, which + disappears in help windows: +> + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'myreadonly', 'filename', 'modified' ] ], + \ }, + \ 'component_function': { + \ 'myreadonly': 'LightLineReadonly' + \ }, + \ } + function! LightLineReadonly() + return &ft !~? 'help' && &readonly ? 'RO' : '' + endfunction +< + g:lightline.component_expand *g:lightline.component_expand* + Another dictionary for components. You can create a component + which has a special color. For example, error components or + warning components. The functions should return one of: + + a string + + an array of three elements: + [[ left ], [ middle ], [ right ]] + The component in this dictionary has priority over + |g:lightline.component| and |g:lightline.component_function|. + Note that the return string is appended to the statusline + string without any conversion. So you should replace all the + % signs with %%. Otherwise, lightline will be disabled in case + the text has a % sign. + (example: return substitute(text, '%', '%%', 'g')). + See |lightline-component-expansion| for more detail. +> + let g:lightline.component_expand = { + \ 'tabs': 'lightline#tabs' } +< + g:lightline.component_type *g:lightline.component_type* + A dictionary to specify the types for components in + |g:lightline.component_expand|. The types are used to specify + the color. Specifically, the type raw is used to specify a + component which should not be wrapped by item group: %(...%). + The default value is: > + + let g:lightline.component_type = { + \ 'tabs': 'tabsel', + \ 'close': 'raw' } +< + g:lightline.tab_component *g:lightline.tab_component* + A dictionary for components in one tab. + The default value is: > + + let g:lightline.tab_component = {} +< + g:lightline.tab_component_function *g:lightline.tab_component_function* + Another dictionary for components in one tab. + A function specified as a tab component takes one argument: + the tab [count]. + The default value is: +> + let g:lightline.tab_component_function = { + \ 'filename': 'lightline#tab#filename', + \ 'modified': 'lightline#tab#modified', + \ 'readonly': 'lightline#tab#readonly', + \ 'tabnum': 'lightline#tab#tabnum' } +< + g:lightline.colorscheme *g:lightline.colorscheme* + The colorscheme for lightline.vim. + Currently, wombat, solarized, powerline, jellybeans, Tomorrow, + Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Eighties, + PaperColor, seoul256, landscape and 16color are available. + The default value is: +> + let g:lightline.colorscheme = 'default' +< + Note that the default colorscheme is exactly the same as the + powerline theme. + + g:lightline.mode_map *g:lightline.mode_map* + A dictionary of names for the modes. The keys are the return + values of |mode()|. + The default value is: +> + let g:lightline.mode_map = { + \ 'n' : 'NORMAL', + \ 'i' : 'INSERT', + \ 'R' : 'REPLACE', + \ 'v' : 'VISUAL', + \ 'V' : 'V-LINE', + \ "\": 'V-BLOCK', + \ 'c' : 'COMMAND', + \ 's' : 'SELECT', + \ 'S' : 'S-LINE', + \ "\": 'S-BLOCK', + \ 't': 'TERMINAL', + \ } +< + When you search a word, you get into the command mode. But if + you want to keep the mode indicator as 'NORMAL', add > + let g:lightline = { 'mode_map': { 'c': 'NORMAL' } } +< to your .vimrc. + + g:lightline.separator *g:lightline.separator* + g:lightline.subseparator *g:lightline.subseparator* + Dictionaries to store separators. + The default value is +> + let g:lightline.separator = { 'left': '', 'right': '' } + let g:lightline.subseparator = { 'left': '|', 'right': '|' } +< + g:lightline.tabline_separator *g:lightline.tabline_separator* + g:lightline.tabline_subseparator *g:lightline.tabline_subseparator* + Dictionaries to store separators for the tabline. + The default value is +> + let g:lightline.tabline_separator = g:lightline.separator + let g:lightline.tabline_subseparator = g:lightline.subseparator +< + g:lightline.enable *g:lightline.enable* + A dictionary to specify which feature is turned on. + The default value is +> + let g:lightline.enable = { + \ 'statusline': 1, + \ 'tabline': 1 + \ } +< + +============================================================================== +FONT *lightline-font* +You can use the patched font you used for |vim-powerline| and |powerline|. + +The patched fonts for |powerline| are available at +https://github.com/Lokaltog/powerline-fonts + +A tutorial to create a patched font for |vim-powerline| is available at +https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher + +If you have installed the patched font for |powerline|, following settings look +nice. +> + let g:lightline = { + \ 'component': { + \ 'lineinfo': ' %3l:%-2v', + \ }, + \ 'component_function': { + \ 'readonly': 'LightLineReadonly', + \ 'fugitive': 'LightLineFugitive' + \ }, + \ 'separator': { 'left': '', 'right': '' }, + \ 'subseparator': { 'left': '', 'right': '' } + \ } + function! LightLineReadonly() + return &readonly ? '' : '' + endfunction + function! LightLineFugitive() + if exists('*fugitive#head') + let branch = fugitive#head() + return branch !=# '' ? ''.branch : '' + endif + return '' + endfunction +< +If you have installed the patched font for |vim-powerline|, following settings +look nice. +> + let g:lightline = { + \ 'component': { + \ 'lineinfo': '⭡ %3l:%-2v', + \ }, + \ 'component_function': { + \ 'readonly': 'LightLineReadonly', + \ 'fugitive': 'LightLineFugitive' + \ }, + \ 'separator': { 'left': '⮀', 'right': '⮂' }, + \ 'subseparator': { 'left': '⮁', 'right': '⮃' } + \ } + function! LightLineReadonly() + return &readonly ? '⭤' : '' + endfunction + function! LightLineFugitive() + if exists('*fugitive#head') + let branch = fugitive#head() + return branch !=# '' ? '⭠ '.branch : '' + endif + return '' + endfunction +< +If the statusline does not correctly show the special characters, use the +unicode numbers. For |powerline| font users: +> + \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, + \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" } +< +For |vim-powerline| font users: +> + \ 'separator': { 'left': "\u2b80", 'right': "\u2b82" }, + \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" } +< +See |lightline-problem-9| for more detail. +============================================================================== +FUNCTION *lightline-function* +Exposed functions for lightline.vim. + + lightline#mode() *lightline#mode()* + Returns the mode of the Vim using |g:lightline.mode_map|. + + lightline#init() *lightline#init()* + Initializes the internal state from |g:lightline|. + + lightline#colorscheme() *lightline#colorscheme()* + Initializes the colorscheme and the highlight groups. + + lightline#update() *lightline#update()* + Updates all the statuslines of existing windows. + + lightline#update_once() *lightline#update_once()* + Updates the statuslines only once. + + lightline#enable() *lightline#enable()* + Enables |lightline|. + + lightline#disable() *lightline#disable()* + Disables |lightline|. + + lightline#toggle() *lightline#toggle()* + Toggles |lightline|. + + lightline#link([mode]) *lightline#link()* + Creates links of the highlight groups for the active window. + This function accepts an optional argument. It should be one + of the return value of |mode()|. + + lightline#highlight() *lightline#highlight()* + Set the highlight groups. + + lightline#statusline({inactive}) *lightline#statusline()* + Returns |statusline| strings. If the argument is 0, it returns + the statusline for active window, and the statusline for + inactive window otherwise. + + lightline#tabline() *lightline#tabline()* + Returns the tabline string. + + lightline#concatenate({list}, {num}) *lightline#concatenate()* + A string concatenation function. Concatenating all the strings + in {list} using the sub-separator of lightline. If {num} is 0, + then the left sub-separator is used. Otherwise, the right + sub-separator is used. + + lightline#palette() *lightline#palette()* + Returns the palette data. + +============================================================================== +COMPONENT EXPANSION *lightline-component-expansion* +You can create components, which have specific colors. This section gives an +example using |syntastic|. + +If you want to add the |syntastic| flag to the statusline, an easy example is: +> + " Example A + let g:lightline = { + \ 'active': { + \ 'right': [ [ 'lineinfo', 'syntastic' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] + \ }, + \ 'component_function': { + \ 'syntastic': 'SyntasticStatuslineFlag', + \ } + \ } + let g:syntastic_mode_map = { 'mode': 'passive', + \ 'active_filetypes': ['c', 'cpp'] } +< +However, the color of the syntastic component is the same as the lineinfo +component. + +In order to change the syntastic component more outstanding, you have to use +|g:lightline.component_expand|. See the following example: +> + " Example B + let g:lightline = { + \ 'active': { + \ 'right': [ [ 'syntastic', 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] + \ }, + \ 'component_expand': { + \ 'syntastic': 'SyntasticStatuslineFlag', + \ }, + \ 'component_type': { + \ 'syntastic': 'error', + \ } + \ } + let g:syntastic_mode_map = { 'mode': 'passive' } + augroup AutoSyntastic + autocmd! + autocmd BufWritePost *.c,*.cpp call s:syntastic() + augroup END + function! s:syntastic() + SyntasticCheck + call lightline#update() + endfunction +< +In order to understand the above codes, you firstly should know how the +colorschemes work in lightline.vim. Open the following file. + autoload/lightline/colorscheme/powerline.vim +The colorscheme is created by one dictionary: s:p (abbreviation for palette). +See the value of s:p.normal.right. +> + let s:p.normal.right = [ ['gray5', 'gray10'], + \ ['gray9', 'gray4'], + \ ['gray8', 'gray2'] ] +< +This array corresponds to the structure of g:lightline.active.right. Recall +the example A. +> + " Example A + let g:lightline.active.right = [ [ 'lineinfo', 'syntastic' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] +< +The colors are ([fgcolor, bgcolor): +> + (0) [ 'lineinfo', 'syntastic' ] --- s:p.normal.right[0] = ['gray5', 'gray10'] + (1) [ 'percent' ] --- s:p.normal.right[1] = ['gray9', 'gray4'] + (2) [ 'fileformat', 'fileencoding', 'filetype' ] --- s:p.normal.right[2] = ['gray8', 'gray2'] +< +Recall the example B. +> + " Example B + let g:lightline.active.right = [ [ 'syntastic', 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] +< +If a component is specified in |g:lightline.component_expand|, lightline.vim +expands the components before setting to statusline/tabline. In this example, +the syntastic component is expanded using the |SyntasticStatuslineFlag| function. +This function returns a {string}. Let us call it `syntastic_flag`. +> + let syntastic_flag = SyntasticStatuslineFlag() +< +The syntastic component is now expanded, so it go up to one component group. +The type of the syntastic component is error, and the palette has error +colors, the result is: +> + " Expanded result of Example B + (error) [ syntastic_flag ] --- s:p.normal.error[0] = ['gray9', 'brightestred'] + (0) [ 'lineinfo' ] --- s:p.normal.right[0] = ['gray5', 'gray10'] + (1) [ 'percent' ] --- s:p.normal.right[1] = ['gray9', 'gray4'] + (2) [ 'fileformat', 'fileencoding', 'filetype' ] --- s:p.normal.right[2] = ['gray8', 'gray2'] +< +Thus the syntastic component has the red color. + + +Another example for |g:lightline.component_expand| is the tabs component. +Actually, the expand feature is created for the tabs component. +> + let g:lightline.tabline.left = [ [ 'tabs' ] ] + let g:lightline.component_expand = { + \ 'tabs': 'lightline#tabs' } +< +Create three tabs and select the middle tab. Then execute +> + echo lightline#tabs() + " [['%1T%{lightline#onetab(1,0)}'], + " ['%2T%{lightline#onetab(2,1)}'], + " ['%3T%{lightline#onetab(3,0)}%T']] +< +It returns an array of three elements. The expanded result is: +> + " Expanded result of tabline + (0) ['%1T%{lightline#onetab(1,0)}'] --- s:p.tabline.left[0] = ['gray9', 'gray4'] + (tabsel) ['%2T%{lightline#onetab(2,1)}'] --- s:p.tabline.tabsel[0] = ['gray9', 'gray1'] + (0) ['%3T%{lightline#onetab(3,0)}%T'] --- s:p.tabline.left[0] = ['gray9', 'gray4'] +< +If the tabline components are +> + let g:lightline.tabline.left = [ [ 'A', 'B', 'tabs', 'C', 'D' ] ] +< +then the expanded result is: +> + (0) ['A', 'B', '%1T%{lightline#onetab(1,0)}'] --- s:p.tabline.left[0] + (tabsel) ['%2T%{lightline#onetab(2,1)}'] --- s:p.tabline.tabsel[0] + (0) ['%3T%{lightline#onetab(3,0)}%T', 'C', 'D'] --- s:p.tabline.left[0] +< +In summary, when a function in |g:lightline.component_expand| returns an +array of three elements, the first element and the last element remains as a +part of existing component group. And the middle element goes up to new +component group. +------------------------------------------------------------------------------ +COLORSCHEME *lightline-colorscheme* +You can configure the colorscheme of lightline. For example, +> + let g:lightline = { + \ 'colorscheme': 'wombat', + \ } +< +The colorscheme files are found in the directory + + lightline.vim/autoload/lightline/colorscheme/ + +In each file, one global variable is defined. For example, in the landscape.vim +file, you see +> + let g:lightline#colorscheme#landscape#palette = s:p +< +In the file, the colors for the landscape colorscheme are defined. For example, +> + let s:p.normal.left = [ ['#0000ff', '#ffffff', 21, 231, 'bold' ], [ '#ffffff', '#0000ff', 231, 21 ] ] +< +defines the colors for the components on the left hand side, in normal mode. +> + let s:p.tabline.tabsel = [ [ '#dadada', '#121212', 253, 233 ] ] +< +defines the colors for the selected tab in tabline. In general, each palette +follows the following style: +> + let s:p.{mode}.{where} = [ [ {guifg}, {guibg}, {cuifg}, {cuibg} ], ... ] +< + + +Now, you can create your own colorscheme for lightline. Create a +yourcolorscheme.vim at + + {one of the paths in &rtp}/autoload/lightline/colorscheme/yourcolorscheme.vim + +The following code gives the minimal palette definition for lightline. +> + let s:p = {'normal': {}} + let s:p.normal.left = [ [ ... ] ] + let s:p.normal.right = [ [ ... ] ] + let s:p.normal.middle = [ [ ... ] ] + let g:lightline#colorscheme#yourcolorscheme#palette = s:p +< +And if you add the colorscheme configuration to your .vimrc(_vimrc), +> + let g:lightline = { + \ 'colorscheme': 'yourcolorscheme', + \ } +< +you find it possible to change the lightline colors as you wish. + +Moreover, if you want to change the colors based on the mode of vim, write +something like this: +> + let s:p.insert.left = [ [ ... ] ] + let s:p.insert.right = [ [ ... ] ] + let s:p.replace.left = [ [ ... ] ] + let s:p.replace.right = [ [ ... ] ] + ... + ... +< +For expanded components, you are recommended to define the following two +colors. +> + let s:p.normal.error = [ [ ... ] ] + let s:p.normal.warning = [ [ ... ] ] +< +For the complete list of components the color of which you should define in +your colorscheme, see the colorscheme files in lightline. + +It is sometimes painful to write all the colors for both gui and cui. +Actually, lightline has some useful functions for writing colorschemes. For +example, see + lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim +this colorscheme is defined using only gui color numbers. And convert to the +normal colorscheme form using: +> + let g:lightline#colorscheme#Tomorrow_Night#palette = lightline#colorscheme#fill(s:p) +< +This function fills the cui colors for a palette which has only gui colors, or +vice versa. However, note that using the convenient function sources an +additional Vim script file (autoload/lightline/colorscheme.vim), which causes +a little slow down. If you want to avoid this situation, write all the colors +as done in autoload/lightline/colorscheme/landscape.vim; firstly create the +colorscheme using the fill function, and see the result, in a sense, the +compiled version of your colorscheme. +> + echo g:lightline#colorscheme#yourcolorscheme#palette +< +Then copy and paste the result to the colorscheme file. + +============================================================================== +EXAMPLES *lightline-examples* +You can configure the appearance of statusline. +Write the following examples in you .vimrc(_vimrc). + +In order to change the colorscheme: +> + let g:lightline = { + \ 'colorscheme': 'wombat', + \ } +< + +In order to define your own component: +> + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'myfilename' ] ] + \ }, + \ 'component_function': { + \ 'myfilename': 'LightLineFilename', + \ 'myreadonly': 'LightLineReadonly', + \ 'mymodified': 'LightLineModified', + \ } + \ } + function! LightLineFilename() + return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') . + \ (&ft == 'vimfiler' ? vimfiler#get_status_string() : + \ &ft == 'unite' ? unite#get_status_string() : + \ '' != expand('%:t') ? expand('%:t') : '[No Name]') . + \ ('' != LightLineModified() ? ' ' . LightLineModified() : '') + endfunction + function! LightLineReadonly() + return &ft !~? 'help' && &readonly ? 'RO' : '' + endfunction + function! LightLineModified() + return &modifiable && &modified ? '+' : '' + endfunction +< + +Separators settings: +> + let g:lightline = { + \ 'separator': { 'left': '', 'right': '' }, + \ 'subseparator': { 'left': '|', 'right': '|' } + \ } +< + +For |powerline| font users: +> + let g:lightline = { + \ 'separator': { 'left': '', 'right': '' }, + \ 'subseparator': { 'left': '', 'right': '' } + \ } +< + +For |vim-powerline| font users: +> + let g:lightline = { + \ 'separator': { 'left': '⮀', 'right': '⮂' }, + \ 'subseparator': { 'left': '⮁', 'right': '⮃' } + \ } +< + +------------------------------------------------------------------------------ +NICE EXAMPLES *lightline-nice-examples* + +A nice example for non-patched font users. +> + let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] + \ }, + \ 'component_function': { + \ 'fugitive': 'LightLineFugitive', + \ 'filename': 'LightLineFilename' + \ } + \ } + function! LightLineModified() + return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-' + endfunction + function! LightLineReadonly() + return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : '' + 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' && exists('*fugitive#head') + return fugitive#head() + endif + return '' + endfunction +< +A nice example for |vim-powerline| font users: +> + let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] + \ }, + \ 'component_function': { + \ 'fugitive': 'LightLineFugitive', + \ 'filename': 'LightLineFilename' + \ }, + \ 'separator': { 'left': '⮀', 'right': '⮂' }, + \ 'subseparator': { 'left': '⮁', 'right': '⮃' } + \ } + function! LightLineModified() + return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-' + endfunction + function! LightLineReadonly() + return &ft !~? 'help\|vimfiler' && &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' && exists('*fugitive#head') + let branch = fugitive#head() + return branch !=# '' ? '⭠ '.branch : '' + endif + return '' + endfunction +< + +------------------------------------------------------------------------------ +POWERFUL EXAMPLE *lightline-powerful-example* + +For users who uses lots of plugins: +> + 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 +< +------------------------------------------------------------------------------ +TROUBLESHOOTING *lightline-troubleshooting* + +Problem 1: |lightline-problem-1| + How to install this plugin. + +Problem 2: |lightline-problem-2| + How to update this plugin. + +Problem 3: |lightline-problem-3| + How to uninstall this plugin. + +Problem 4: |lightline-problem-4| + Cool statuslines appear only on |:vsp|. + +Problem 5: |lightline-problem-5| + The statusline does not seem to be correctly colored. + +Problem 6: |lightline-problem-6| + How to install a patched font. + +Problem 7: |lightline-problem-7| + Right triangles do not stick to the right components with the + patched font. + +Problem 8: |lightline-problem-8| + Triangles do not appear. Triangles look weird. + +Problem 9: |lightline-problem-9| + Where can I find the list of all the cool characters for patched fonts? + +Problem 10: |lightline-problem-10| + Cool statusline disappears in |unite|, |vimfiler| and |vimshell| + buffers. + +Problem 11: |lightline-problem-11| + Cool statusline disappears in |CtrlP|, |Tagbar| buffers. + +Problem 12: |lightline-problem-12| + How to make the plus sign red like |powerline|? + +Problem 13: |lightline-problem-13| + How to change the lightline colorscheme on the fly. + +Problem 14: |lightline-problem-14| + The 'E541' warning appears on the right hand side. + Many components disable the statusline of lightline. + +Problem 15: |lightline-problem-15| + Do not deal with the tabline. + Do not use the fancy separators in the tabline. + +Problem 16: |lightline-problem-16| + When changed the component to a function component to an expanding + component, the statusline of lightline is sometimes disabled. + +Problem 17: |lightline-problem-17| + Found a bug of this plugin. + Got many errors while using this plugin. + Vim hangs while using this plugin. + Want this plugin to be more configurable. + This troubleshooting is not helpful. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +Problem 1: *lightline-problem-1* + How to install this plugin. + + If you are to install this plugin manually: + + 1. Put all the files under $VIM. + + If you are using |vim-pathogen|, install this plugin with the + following command. +> + git clone https://github.com/itchyny/lightline.vim \ + ~/.vim/bundle/lightline.vim +< + If you are to install this plugin using |Vundle|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + Plugin 'itchyny/lightline.vim' +< + 2. Install with |:PluginInstall|. + + If you are to install this plugin using |NeoBundle|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + NeoBundle 'itchyny/lightline.vim' +< + 2. Install with |:NeoBundleInstall|. + + If you are to install this plugin using |vim-plug|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + Plug 'itchyny/lightline.vim' +< + 2. Install with |:PlugInstall|. + +Problem 2: *lightline-problem-2* + How to update this plugin. + + If you have installed this plugin manually: + + 1. Access https://github.com/itchyny/lightline.vim . + 2. Download the latest scripts. + 3. Place the scripts as written in Problem 1. + + If you have installed this plugin using Vundle: + + 1. Execute |:PluginUpdate|. + + If you have installed this plugin using NeoBundle: + + 1. Execute |:NeoBundleUpdate|. + + If you have installed this plugin using vim-plug: + + 1. Execute |:PlugUpdate|. + +Problem 3: *lightline-problem-3* + How to uninstall this plugin. + + If you have installed this plugin manually: + + 1. Remove all the lightline.*s under $VIM. + + If you have installed this plugin using Vundle: + + 1. Remove the :Plugin 'itchyny/lightline.vim' + configuration from your .vimrc(_vimrc). + 2. Update with |:PluginClean|. + + If you have installed this plugin using NeoBundle: + + 1. Remove the :NeoBundle 'itchyny/lightline.vim' + configuration from your .vimrc(_vimrc). + 2. Update with |:NeoBundleClean|. + + If you have installed this plugin using vim-plug: + + 1. Remove the :Plug 'itchyny/lightline.vim' + configuration from your .vimrc(_vimrc). + 2. Update with |:PlugClean|. + +Problem 4: *lightline-problem-4* + Cool statuslines appear only on |:vsp|. + + Add the following setting to your .vimrc(_vimrc). +> + set laststatus=2 +< +Problem 5: *lightline-problem-5* + The statusline does not seem to be correctly colored. + + Add +> + export TERM=xterm-256color +< + to your .*shrc and add +> + if !has('gui_running') + set t_Co=256 + endif +< + to your .vimrc(_vimrc). + +Problem 6: *lightline-problem-6* + How to install a patched font. + + There are two kinds of patched fonts: + + + The patched fonts for |vim-powerline| + (https://github.com/Lokaltog/vim-powerline): + follow the guide https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher + + The patched fonts for |powerline| + (https://github.com/Lokaltog/powerline): + download from https://github.com/Lokaltog/powerline-fonts + +Problem 7: *lightline-problem-7* + Right triangles do not stick to the right components with patched + font. + + Remove the following setting from your .vimrc(_vimrc). +> + set ambiwidth=double +< + If you want to keep this setting, try the patched font for + |vim-powerline|. + +Problem 8: *lightline-problem-8* + Triangles do not appear. Triangles look weird. + + If the triangles do not appear (but you get some spaces or + weird characters like or ¿), firstly try adding +> + scriptencoding utf-8 + set encoding=utf-8 +< + to the head of your .vimrc(_vimrc). Still you have weird + characters, use the unicode numbers. For |powerline| font + users: +> + \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, + \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" } +< + For |vim-powerline| font users: +> + \ 'separator': { 'left': "\u2b80", 'right': "\u2b82" }, + \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" } +< + The full list of unicode numbers for fancy characters is shown + in |lightline-problem-9|. + + If the triangles are shown in appropriate characters but the + colors do not look correctly, see the following. + If you are using iTerm2, change the following settings. + + + 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. + +Problem 9: *lightline-problem-9* + Where can I find the list of all the cool characters for patched fonts? + + 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) + +Problem 10: *lightline-problem-10* + Cool statusline disappears on |unite|, |vimfiler| and |vimshell| + buffers. + + Add the following settings to your .vimrc(_vimrc). +> + let g:unite_force_overwrite_statusline = 0 + let g:vimfiler_force_overwrite_statusline = 0 + let g:vimshell_force_overwrite_statusline = 0 +< +Problem 11: *lightline-problem-11* + Cool statusline disappears in |CtrlP|, |Tagbar| buffers. + + Add the following settings to your .vimrc(_vimrc). +> + let g:ctrlp_status_func = { + \ 'main': 'CtrlPStatusFunc_1', + \ 'prog': 'CtrlPStatusFunc_2', + \ } + function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked) + 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 + return lightline#statusline(0) + endfunction +< + See |lightline-powerful-example| for more cool settings for + these plugins. + +Problem 12: *lightline-problem-12* + How to make the plus sign red like |powerline|? + + Use the following setings. +> + let g:lightline = { + \ 'component': { + \ 'modified': '%#ModifiedColor#%{LightLineModified()}', + \ } + \ } + function! LightLineModified() + let map = { 'V': 'n', "\": 'n', 's': 'n', 'v': 'n', "\": 'n', 'c': 'n', 'R': 'n'} + let mode = get(map, mode()[0], mode()[0]) + let bgcolor = {'n': [240, '#585858'], 'i': [31, '#0087af']} + let color = get(bgcolor, mode, bgcolor.n) + exe printf('hi ModifiedColor ctermfg=196 ctermbg=%d guifg=#ff0000 guibg=%s term=bold cterm=bold', + \ color[0], color[1]) + return &modified ? '+' : &modifiable ? '' : '-' + endfunction +< + It's surely complicated. There's no easy API to do a thing + like this. But it means that your request does not match + the spirit of lightline. + +Problem 13: *lightline-problem-13* + How to change the lightline colorscheme on the fly. + + Add the following settings to your .vimrc(_vimrc). +> + augroup LightLineColorscheme + autocmd! + autocmd ColorScheme * call s:lightline_update() + augroup END + function! s:lightline_update() + if !exists('g:loaded_lightline') + return + endif + try + if g:colors_name =~# 'wombat\|solarized\|landscape\|jellybeans\|seoul256\|Tomorrow' + let g:lightline.colorscheme = + \ substitute(substitute(g:colors_name, '-', '_', 'g'), '256.*', '', '') + call lightline#init() + call lightline#colorscheme() + call lightline#update() + endif + catch + endtry + endfunction +< +Problem 14: *lightline-problem-14* + The 'E541' warning appears on the right hand side. + Many components disable the statusline of lightline. + + The number of items in statusline/tabline is limited to 80 + (see |E541|). You cannot register too much components. + +Problem 15: *lightline-problem-15* + Do not deal with the tabline. + Do not use the fancy separators in the tabline. + + You can disable the tabline feature of lightline.vim using: +> + let g:lightline = { + \ 'enable': { 'tabline': 0 }, + \ } +< + If you don't like the separators in the tabline, use: +> + let g:lightline = { + \ 'tabline_separator': { 'left': "", 'right': "" }, + \ 'tabline_subseparator': { 'left': "", 'right': "" }, + \ } +< +Problem 16: *lightline-problem-16* + When changed the component to a function component to an expanding + component, the statusline of lightline is sometimes disabled. + + When you changed from +> + \ 'component_function': { + \ 'my': 'My', + \ } +< + to +> + \ 'component_expand': { + \ 'my': 'My', + \ } +< + the statusline of lightline is disabled unexpectedly. + In such a case, the text returned by 'My' function may include + the '%' character. Replace all the '%' signs with '%%'. +> + function My() + ... + return substitute(text, '%', '%%', 'g') + endfunction +< +Problem 17: *lightline-problem-17* + Found a bug of this plugin. + Got many errors while using this plugin. + Vim hangs while using this plugin. + Want this plugin to be more configurable. + This troubleshooting is not helpful. + + Report/Request the issue/feature at + https://github.com/itchyny/lightline.vim/issues. + +============================================================================== +CHANGELOG *lightline-changelog* + +0.0 2013-08-21, ... + - Initial commit and implementation + +============================================================================== +vim:tw=78:sw=4:ts=8:ft=help:norl:noet: diff --git a/sources_non_forked/lightline.vim/plugin/lightline.vim b/sources_non_forked/lightline.vim/plugin/lightline.vim new file mode 100644 index 00000000..f396010b --- /dev/null +++ b/sources_non_forked/lightline.vim/plugin/lightline.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/.themisrc b/sources_non_forked/lightline.vim/test/.themisrc new file mode 100644 index 00000000..c226c089 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/.themisrc @@ -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("\%d_%s", s:sid('autoload/lightline.vim'), a:name)) +endfunction diff --git a/sources_non_forked/lightline.vim/test/concatenate.vim b/sources_non_forked/lightline.vim/test/concatenate.vim new file mode 100644 index 00000000..6fd2723a --- /dev/null +++ b/sources_non_forked/lightline.vim/test/concatenate.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/error.vim b/sources_non_forked/lightline.vim/test/error.vim new file mode 100644 index 00000000..8fdabf46 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/error.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/expand.vim b/sources_non_forked/lightline.vim/test/expand.vim new file mode 100644 index 00000000..c2fc0ab9 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/expand.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/highlight.vim b/sources_non_forked/lightline.vim/test/highlight.vim new file mode 100644 index 00000000..fe5182a3 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/highlight.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/link.vim b/sources_non_forked/lightline.vim/test/link.vim new file mode 100644 index 00000000..ca867536 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/link.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/mode.vim b/sources_non_forked/lightline.vim/test/mode.vim new file mode 100644 index 00000000..53280f51 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/mode.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/onetab.vim b/sources_non_forked/lightline.vim/test/onetab.vim new file mode 100644 index 00000000..529d8332 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/onetab.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/subseparator.vim b/sources_non_forked/lightline.vim/test/subseparator.vim new file mode 100644 index 00000000..02cac4cc --- /dev/null +++ b/sources_non_forked/lightline.vim/test/subseparator.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/tabline.vim b/sources_non_forked/lightline.vim/test/tabline.vim new file mode 100644 index 00000000..0a9879f6 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/tabline.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/tabs.vim b/sources_non_forked/lightline.vim/test/tabs.vim new file mode 100644 index 00000000..92c2c08f --- /dev/null +++ b/sources_non_forked/lightline.vim/test/tabs.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/toggle.vim b/sources_non_forked/lightline.vim/test/toggle.vim new file mode 100644 index 00000000..c6042a86 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/toggle.vim @@ -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 diff --git a/sources_non_forked/lightline.vim/test/uniq.vim b/sources_non_forked/lightline.vim/test/uniq.vim new file mode 100644 index 00000000..cdfaec09 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/uniq.vim @@ -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 diff --git a/sources_non_forked/nerdtree/CHANGELOG b/sources_non_forked/nerdtree/CHANGELOG new file mode 100644 index 00000000..2e08dd2a --- /dev/null +++ b/sources_non_forked/nerdtree/CHANGELOG @@ -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 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 + " (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 would fail if was relative and + didnt start with a ./ or ../ Thanks to James Kanze. + - make the q mapping work with secondary (:e 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 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 '' mapping to 'i' + - change the 'H' mapping to 'I' + - lots of refactoring diff --git a/sources_non_forked/nerdtree/LICENCE b/sources_non_forked/nerdtree/LICENCE new file mode 100644 index 00000000..8b1a9d81 --- /dev/null +++ b/sources_non_forked/nerdtree/LICENCE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +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. diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown index 0317e624..3fb9ee70 100644 --- a/sources_non_forked/nerdtree/README.markdown +++ b/sources_non_forked/nerdtree/README.markdown @@ -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 :NERDTreeToggle +--- > 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 = '▾' diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim index 37d7d105..3ad2a031 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -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 diff --git a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim index 1f922df1..2aa3bece 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim @@ -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('') - command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('') + command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('') + command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('') command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() - command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('') + command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') 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() diff --git a/sources_non_forked/nerdtree/doc/NERD_tree.txt b/sources_non_forked/nerdtree/doc/NERD_tree.txt index cfc8ed9b..bf1ab5a8 100644 --- a/sources_non_forked/nerdtree/doc/NERD_tree.txt +++ b/sources_non_forked/nerdtree/doc/NERD_tree.txt @@ -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 < -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 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 - " (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 would fail if was relative and - didnt start with a ./ or ../ Thanks to James Kanze. - - make the q mapping work with secondary (:e 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 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 '' 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. diff --git a/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim b/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim index 8a94b256..81242605 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim @@ -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 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim index 2d6a5c2e..952811c1 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim @@ -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('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('', b:NERDTree) command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render() command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) 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 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim index 55f3dd75..73a30f7a 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim @@ -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 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim b/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim index b445f8ad..00041b85 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim @@ -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) diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim index 3a6b3924..00947cdb 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -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 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/path.vim b/sources_non_forked/nerdtree/lib/nerdtree/path.vim index 2af07ddb..674ca03e 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/path.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -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 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim index 765982df..48e9bda3 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim @@ -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 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim index b4924d78..adb0e96b 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim @@ -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 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim index 22e450c8..094fa0f9 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -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."\" ,\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 []\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 diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim b/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim index e7a7c532..c53650a5 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim @@ -2,7 +2,6 @@ " File: exec_menuitem.vim " Description: plugin for NERD Tree that provides an execute file menu item " Maintainer: Martin Grenfell -" 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 diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim index e99a85be..20a9fcd3 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -2,7 +2,6 @@ " File: fs_menu.vim " Description: plugin for the NERD Tree that provides a file system menu " Maintainer: Martin Grenfell -" 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: diff --git a/sources_non_forked/nerdtree/plugin/NERD_tree.vim b/sources_non_forked/nerdtree/plugin/NERD_tree.vim index 966838c3..0bcfe968 100644 --- a/sources_non_forked/nerdtree/plugin/NERD_tree.vim +++ b/sources_non_forked/nerdtree/plugin/NERD_tree.vim @@ -1,8 +1,6 @@ " ============================================================================ " File: NERD_tree.vim -" Description: vim global plugin that provides a nice tree explorer " Maintainer: Martin Grenfell -" Last Change: 28 December, 2011 " 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 @@ -50,6 +48,7 @@ call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) call s:initVariable("g:NERDTreeSortHiddenFirst", 1) call s:initVariable("g:NERDTreeChDirMode", 0) +call s:initVariable("g:NERDTreeCreatePrefix", "silent") call s:initVariable("g:NERDTreeMinimalUI", 0) if !exists("g:NERDTreeIgnore") let g:NERDTreeIgnore = ['\~$'] @@ -67,7 +66,14 @@ call s:initVariable("g:NERDTreeShowFiles", 1) call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) -call s:initVariable("g:NERDTreeDirArrows", !nerdtree#runningWindows()) + +if !nerdtree#runningWindows() + call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") + call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") +else + call s:initVariable("g:NERDTreeDirArrowExpandable", "+") + call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") +endif call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") @@ -79,12 +85,14 @@ else endif endif +call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") + if !exists('g:NERDTreeStatusline') "the exists() crap here is a hack to stop vim spazzing out when "loading a session that was created with an open nerd tree. It spazzes - "because it doesnt store b:NERDTreeRoot (its a b: var, and its a hash) - let g:NERDTreeStatusline = "%{exists('b:NERDTreeRoot')?b:NERDTreeRoot.path.str():''}" + "because it doesnt store b:NERDTree(its a b: var, and its a hash) + let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}" endif call s:initVariable("g:NERDTreeWinPos", "left") @@ -188,7 +196,7 @@ function! NERDTreeFocus() if g:NERDTree.IsOpen() call g:NERDTree.CursorToTreeWin() else - call g:NERDTreeCreator.TogglePrimary("") + call g:NERDTreeCreator.ToggleTabTree("") endif endfunction diff --git a/sources_non_forked/nerdtree/syntax/nerdtree.vim b/sources_non_forked/nerdtree/syntax/nerdtree.vim index 5f7b49cc..d2a94834 100644 --- a/sources_non_forked/nerdtree/syntax/nerdtree.vim +++ b/sources_non_forked/nerdtree/syntax/nerdtree.vim @@ -1,6 +1,6 @@ let s:tree_up_dir_line = '.. (up a dir)' syn match NERDTreeIgnore #\~# -syn match NERDTreeIgnore #\[RO\]# +exec 'syn match NERDTreeIgnore #\['.g:NERDTreeGlyphReadOnly.'\]#' "highlighting for the .. (up dir) line at the top of the tree execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" @@ -22,42 +22,19 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighing for directory nodes and file nodes syn match NERDTreeDirSlash #/# containedin=NERDTreeDir -if g:NERDTreeDirArrows - syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile +exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile' +exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile' - syn match NERDTreeDir #[^▾▸ ].*/# - syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark - syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile +let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~').escape(g:NERDTreeDirArrowExpandable, '~') +exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' +syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark +exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' - "highlighting for readonly files - syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile +"highlighting for readonly files +exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' - syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile - syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir -else - "highlighting for the ~/+ symbols for the directory nodes - syn match NERDTreeClosable #\~\<# - syn match NERDTreeClosable #\~\.# - syn match NERDTreeOpenable #+\<# - syn match NERDTreeOpenable #+\.#he=e-1 - - "highlighting for the tree structural parts - syn match NERDTreePart #|# - syn match NERDTreePart #`# - syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart - - syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable - syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark - syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - - "highlighting for readonly files - syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreePart,NERDTreePartFile - - syn match NERDTreeFlags #-\[.\]# containedin=NERDTreeFile,NERDTreePartFile - syn match NERDTreeFlags #[+~]\zs\[.\]# containedin=NERDTreeDir -endif +syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile +syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir syn match NERDTreeCWD #^[ +" Allows Nginx to interact with uWSGI processes and control what parameters are passed to the process. +syn keyword ngxDirectiveThirdParty uwsgi_bind +syn keyword ngxDirectiveThirdParty uwsgi_buffer_size +syn keyword ngxDirectiveThirdParty uwsgi_buffering +syn keyword ngxDirectiveThirdParty uwsgi_buffers +syn keyword ngxDirectiveThirdParty uwsgi_busy_buffers_size +syn keyword ngxDirectiveThirdParty uwsgi_cache +syn keyword ngxDirectiveThirdParty uwsgi_cache_bypass +syn keyword ngxDirectiveThirdParty uwsgi_cache_key +syn keyword ngxDirectiveThirdParty uwsgi_cache_lock +syn keyword ngxDirectiveThirdParty uwsgi_cache_lock_timeout +syn keyword ngxDirectiveThirdParty uwsgi_cache_methods +syn keyword ngxDirectiveThirdParty uwsgi_cache_min_uses +syn keyword ngxDirectiveThirdParty uwsgi_cache_path +syn keyword ngxDirectiveThirdParty uwsgi_cache_use_stale +syn keyword ngxDirectiveThirdParty uwsgi_cache_valid +syn keyword ngxDirectiveThirdParty uwsgi_connect_timeout +syn keyword ngxDirectiveThirdParty uwsgi_hide_header +syn keyword ngxDirectiveThirdParty uwsgi_ignore_client_abort +syn keyword ngxDirectiveThirdParty uwsgi_ignore_headers +syn keyword ngxDirectiveThirdParty uwsgi_intercept_errors +syn keyword ngxDirectiveThirdParty uwsgi_max_temp_file_size +syn keyword ngxDirectiveThirdParty uwsgi_modifier1 +syn keyword ngxDirectiveThirdParty uwsgi_modifier2 +syn keyword ngxDirectiveThirdParty uwsgi_next_upstream +syn keyword ngxDirectiveThirdParty uwsgi_no_cache +syn keyword ngxDirectiveThirdParty uwsgi_param +syn keyword ngxDirectiveThirdParty uwsgi_pass +syn keyword ngxDirectiveThirdParty uwsgi_pass_header +syn keyword ngxDirectiveThirdParty uwsgi_pass_request_body +syn keyword ngxDirectiveThirdParty uwsgi_pass_request_headers +syn keyword ngxDirectiveThirdParty uwsgi_read_timeout +syn keyword ngxDirectiveThirdParty uwsgi_send_timeout +syn keyword ngxDirectiveThirdParty uwsgi_store +syn keyword ngxDirectiveThirdParty uwsgi_store_access +syn keyword ngxDirectiveThirdParty uwsgi_string +syn keyword ngxDirectiveThirdParty uwsgi_temp_file_write_size +syn keyword ngxDirectiveThirdParty uwsgi_temp_path + " highlight hi link ngxComment Comment diff --git a/sources_non_forked/nginx-vim/README.md b/sources_non_forked/nginx-vim/README.md deleted file mode 100755 index 8124452e..00000000 --- a/sources_non_forked/nginx-vim/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# nginx syntax files for Vim. - -Copied into a directory to play well with pathogen. - -* Original: http://www.vim.org/scripts/script.php?script_id=1886 - - diff --git a/sources_non_forked/nginx-vim/ftdetect/nginx.vim b/sources_non_forked/nginx-vim/ftdetect/nginx.vim deleted file mode 100755 index d12c2bf1..00000000 --- a/sources_non_forked/nginx-vim/ftdetect/nginx.vim +++ /dev/null @@ -1,2 +0,0 @@ -au BufRead,BufNewFile /etc/nginx/* set ft=nginx -au BufRead,BufNewFile /usr/local/nginx/conf/* set ft=nginx diff --git a/sources_non_forked/nginx-vim/syntax/nginx.vim b/sources_non_forked/nginx-vim/syntax/nginx.vim deleted file mode 100755 index ccd47680..00000000 --- a/sources_non_forked/nginx-vim/syntax/nginx.vim +++ /dev/null @@ -1,664 +0,0 @@ -" Vim syntax file -" Language: nginx.conf - -if exists("b:current_syntax") - finish -end - -setlocal iskeyword+=. -setlocal iskeyword+=/ -setlocal iskeyword+=: - -syn match ngxVariable '\$\w\w*' -syn match ngxVariableBlock '\$\w\w*' contained -syn match ngxVariableString '\$\w\w*' contained -syn region ngxBlock start=+^+ end=+{+ contains=ngxComment,ngxDirectiveBlock,ngxVariableBlock,ngxString oneline -syn region ngxString start=+"+ end=+"+ skip=+\\\\\|\\"+ contains=ngxVariableString oneline -syn region ngxString start=+'+ end=+'+ skip=+\\\\\|\\'+ contains=ngxVariableString oneline -syn match ngxComment ' *#.*$' - -syn keyword ngxBoolean on -syn keyword ngxBoolean off - -syn keyword ngxDirectiveBlock http contained -syn keyword ngxDirectiveBlock mail contained -syn keyword ngxDirectiveBlock events contained -syn keyword ngxDirectiveBlock server contained -syn keyword ngxDirectiveBlock types contained -syn keyword ngxDirectiveBlock location contained -syn keyword ngxDirectiveBlock upstream contained -syn keyword ngxDirectiveBlock charset_map contained -syn keyword ngxDirectiveBlock limit_except contained -syn keyword ngxDirectiveBlock if contained -syn keyword ngxDirectiveBlock geo contained -syn keyword ngxDirectiveBlock map contained - -syn keyword ngxDirectiveImportant include -syn keyword ngxDirectiveImportant root -syn keyword ngxDirectiveImportant server -syn keyword ngxDirectiveImportant server_name -syn keyword ngxDirectiveImportant listen -syn keyword ngxDirectiveImportant internal -syn keyword ngxDirectiveImportant proxy_pass -syn keyword ngxDirectiveImportant memcached_pass -syn keyword ngxDirectiveImportant fastcgi_pass -syn keyword ngxDirectiveImportant try_files - -syn keyword ngxDirectiveControl break -syn keyword ngxDirectiveControl return -syn keyword ngxDirectiveControl rewrite -syn keyword ngxDirectiveControl set - -syn keyword ngxDirectiveError error_page -syn keyword ngxDirectiveError post_action - -syn keyword ngxDirectiveDeprecated connections -syn keyword ngxDirectiveDeprecated imap -syn keyword ngxDirectiveDeprecated open_file_cache_retest -syn keyword ngxDirectiveDeprecated optimize_server_names -syn keyword ngxDirectiveDeprecated satisfy_any - -syn keyword ngxDirective accept_mutex -syn keyword ngxDirective accept_mutex_delay -syn keyword ngxDirective access_log -syn keyword ngxDirective add_after_body -syn keyword ngxDirective add_before_body -syn keyword ngxDirective add_header -syn keyword ngxDirective addition_types -syn keyword ngxDirective aio -syn keyword ngxDirective alias -syn keyword ngxDirective allow -syn keyword ngxDirective ancient_browser -syn keyword ngxDirective ancient_browser_value -syn keyword ngxDirective auth_basic -syn keyword ngxDirective auth_basic_user_file -syn keyword ngxDirective auth_http -syn keyword ngxDirective auth_http_header -syn keyword ngxDirective auth_http_timeout -syn keyword ngxDirective autoindex -syn keyword ngxDirective autoindex_exact_size -syn keyword ngxDirective autoindex_localtime -syn keyword ngxDirective charset -syn keyword ngxDirective charset_types -syn keyword ngxDirective client_body_buffer_size -syn keyword ngxDirective client_body_in_file_only -syn keyword ngxDirective client_body_in_single_buffer -syn keyword ngxDirective client_body_temp_path -syn keyword ngxDirective client_body_timeout -syn keyword ngxDirective client_header_buffer_size -syn keyword ngxDirective client_header_timeout -syn keyword ngxDirective client_max_body_size -syn keyword ngxDirective connection_pool_size -syn keyword ngxDirective create_full_put_path -syn keyword ngxDirective daemon -syn keyword ngxDirective dav_access -syn keyword ngxDirective dav_methods -syn keyword ngxDirective debug_connection -syn keyword ngxDirective debug_points -syn keyword ngxDirective default_type -syn keyword ngxDirective degradation -syn keyword ngxDirective degrade -syn keyword ngxDirective deny -syn keyword ngxDirective devpoll_changes -syn keyword ngxDirective devpoll_events -syn keyword ngxDirective directio -syn keyword ngxDirective directio_alignment -syn keyword ngxDirective empty_gif -syn keyword ngxDirective env -syn keyword ngxDirective epoll_events -syn keyword ngxDirective error_log -syn keyword ngxDirective eventport_events -syn keyword ngxDirective expires -syn keyword ngxDirective fastcgi_bind -syn keyword ngxDirective fastcgi_buffer_size -syn keyword ngxDirective fastcgi_buffers -syn keyword ngxDirective fastcgi_busy_buffers_size -syn keyword ngxDirective fastcgi_cache -syn keyword ngxDirective fastcgi_cache_key -syn keyword ngxDirective fastcgi_cache_methods -syn keyword ngxDirective fastcgi_cache_min_uses -syn keyword ngxDirective fastcgi_cache_path -syn keyword ngxDirective fastcgi_cache_use_stale -syn keyword ngxDirective fastcgi_cache_valid -syn keyword ngxDirective fastcgi_catch_stderr -syn keyword ngxDirective fastcgi_connect_timeout -syn keyword ngxDirective fastcgi_hide_header -syn keyword ngxDirective fastcgi_ignore_client_abort -syn keyword ngxDirective fastcgi_ignore_headers -syn keyword ngxDirective fastcgi_index -syn keyword ngxDirective fastcgi_intercept_errors -syn keyword ngxDirective fastcgi_max_temp_file_size -syn keyword ngxDirective fastcgi_next_upstream -syn keyword ngxDirective fastcgi_param -syn keyword ngxDirective fastcgi_pass_header -syn keyword ngxDirective fastcgi_pass_request_body -syn keyword ngxDirective fastcgi_pass_request_headers -syn keyword ngxDirective fastcgi_read_timeout -syn keyword ngxDirective fastcgi_send_lowat -syn keyword ngxDirective fastcgi_send_timeout -syn keyword ngxDirective fastcgi_split_path_info -syn keyword ngxDirective fastcgi_store -syn keyword ngxDirective fastcgi_store_access -syn keyword ngxDirective fastcgi_temp_file_write_size -syn keyword ngxDirective fastcgi_temp_path -syn keyword ngxDirective fastcgi_upstream_fail_timeout -syn keyword ngxDirective fastcgi_upstream_max_fails -syn keyword ngxDirective flv -syn keyword ngxDirective geoip_city -syn keyword ngxDirective geoip_country -syn keyword ngxDirective google_perftools_profiles -syn keyword ngxDirective gzip -syn keyword ngxDirective gzip_buffers -syn keyword ngxDirective gzip_comp_level -syn keyword ngxDirective gzip_disable -syn keyword ngxDirective gzip_hash -syn keyword ngxDirective gzip_http_version -syn keyword ngxDirective gzip_min_length -syn keyword ngxDirective gzip_no_buffer -syn keyword ngxDirective gzip_proxied -syn keyword ngxDirective gzip_static -syn keyword ngxDirective gzip_types -syn keyword ngxDirective gzip_vary -syn keyword ngxDirective gzip_window -syn keyword ngxDirective if_modified_since -syn keyword ngxDirective ignore_invalid_headers -syn keyword ngxDirective image_filter -syn keyword ngxDirective image_filter_buffer -syn keyword ngxDirective image_filter_jpeg_quality -syn keyword ngxDirective image_filter_transparency -syn keyword ngxDirective imap_auth -syn keyword ngxDirective imap_capabilities -syn keyword ngxDirective imap_client_buffer -syn keyword ngxDirective index -syn keyword ngxDirective ip_hash -syn keyword ngxDirective keepalive_requests -syn keyword ngxDirective keepalive_timeout -syn keyword ngxDirective kqueue_changes -syn keyword ngxDirective kqueue_events -syn keyword ngxDirective large_client_header_buffers -syn keyword ngxDirective limit_conn -syn keyword ngxDirective limit_conn_log_level -syn keyword ngxDirective limit_rate -syn keyword ngxDirective limit_rate_after -syn keyword ngxDirective limit_req -syn keyword ngxDirective limit_req_log_level -syn keyword ngxDirective limit_req_zone -syn keyword ngxDirective limit_zone -syn keyword ngxDirective lingering_time -syn keyword ngxDirective lingering_timeout -syn keyword ngxDirective lock_file -syn keyword ngxDirective log_format -syn keyword ngxDirective log_not_found -syn keyword ngxDirective log_subrequest -syn keyword ngxDirective map_hash_bucket_size -syn keyword ngxDirective map_hash_max_size -syn keyword ngxDirective master_process -syn keyword ngxDirective memcached_bind -syn keyword ngxDirective memcached_buffer_size -syn keyword ngxDirective memcached_connect_timeout -syn keyword ngxDirective memcached_next_upstream -syn keyword ngxDirective memcached_read_timeout -syn keyword ngxDirective memcached_send_timeout -syn keyword ngxDirective memcached_upstream_fail_timeout -syn keyword ngxDirective memcached_upstream_max_fails -syn keyword ngxDirective merge_slashes -syn keyword ngxDirective min_delete_depth -syn keyword ngxDirective modern_browser -syn keyword ngxDirective modern_browser_value -syn keyword ngxDirective msie_padding -syn keyword ngxDirective msie_refresh -syn keyword ngxDirective multi_accept -syn keyword ngxDirective open_file_cache -syn keyword ngxDirective open_file_cache_errors -syn keyword ngxDirective open_file_cache_events -syn keyword ngxDirective open_file_cache_min_uses -syn keyword ngxDirective open_file_cache_valid -syn keyword ngxDirective open_log_file_cache -syn keyword ngxDirective output_buffers -syn keyword ngxDirective override_charset -syn keyword ngxDirective perl -syn keyword ngxDirective perl_modules -syn keyword ngxDirective perl_require -syn keyword ngxDirective perl_set -syn keyword ngxDirective pid -syn keyword ngxDirective pop3_auth -syn keyword ngxDirective pop3_capabilities -syn keyword ngxDirective port_in_redirect -syn keyword ngxDirective postpone_gzipping -syn keyword ngxDirective postpone_output -syn keyword ngxDirective protocol -syn keyword ngxDirective proxy -syn keyword ngxDirective proxy_bind -syn keyword ngxDirective proxy_buffer -syn keyword ngxDirective proxy_buffer_size -syn keyword ngxDirective proxy_buffering -syn keyword ngxDirective proxy_buffers -syn keyword ngxDirective proxy_busy_buffers_size -syn keyword ngxDirective proxy_cache -syn keyword ngxDirective proxy_cache_key -syn keyword ngxDirective proxy_cache_methods -syn keyword ngxDirective proxy_cache_min_uses -syn keyword ngxDirective proxy_cache_path -syn keyword ngxDirective proxy_cache_use_stale -syn keyword ngxDirective proxy_cache_valid -syn keyword ngxDirective proxy_connect_timeout -syn keyword ngxDirective proxy_headers_hash_bucket_size -syn keyword ngxDirective proxy_headers_hash_max_size -syn keyword ngxDirective proxy_hide_header -syn keyword ngxDirective proxy_ignore_client_abort -syn keyword ngxDirective proxy_ignore_headers -syn keyword ngxDirective proxy_intercept_errors -syn keyword ngxDirective proxy_max_temp_file_size -syn keyword ngxDirective proxy_method -syn keyword ngxDirective proxy_next_upstream -syn keyword ngxDirective proxy_pass_error_message -syn keyword ngxDirective proxy_pass_header -syn keyword ngxDirective proxy_pass_request_body -syn keyword ngxDirective proxy_pass_request_headers -syn keyword ngxDirective proxy_read_timeout -syn keyword ngxDirective proxy_redirect -syn keyword ngxDirective proxy_send_lowat -syn keyword ngxDirective proxy_send_timeout -syn keyword ngxDirective proxy_set_body -syn keyword ngxDirective proxy_set_header -syn keyword ngxDirective proxy_ssl_session_reuse -syn keyword ngxDirective proxy_store -syn keyword ngxDirective proxy_store_access -syn keyword ngxDirective proxy_temp_file_write_size -syn keyword ngxDirective proxy_temp_path -syn keyword ngxDirective proxy_timeout -syn keyword ngxDirective proxy_upstream_fail_timeout -syn keyword ngxDirective proxy_upstream_max_fails -syn keyword ngxDirective random_index -syn keyword ngxDirective read_ahead -syn keyword ngxDirective real_ip_header -syn keyword ngxDirective recursive_error_pages -syn keyword ngxDirective request_pool_size -syn keyword ngxDirective reset_timedout_connection -syn keyword ngxDirective resolver -syn keyword ngxDirective resolver_timeout -syn keyword ngxDirective rewrite_log -syn keyword ngxDirective rtsig_overflow_events -syn keyword ngxDirective rtsig_overflow_test -syn keyword ngxDirective rtsig_overflow_threshold -syn keyword ngxDirective rtsig_signo -syn keyword ngxDirective satisfy -syn keyword ngxDirective secure_link_secret -syn keyword ngxDirective send_lowat -syn keyword ngxDirective send_timeout -syn keyword ngxDirective sendfile -syn keyword ngxDirective sendfile_max_chunk -syn keyword ngxDirective server_name_in_redirect -syn keyword ngxDirective server_names_hash_bucket_size -syn keyword ngxDirective server_names_hash_max_size -syn keyword ngxDirective server_tokens -syn keyword ngxDirective set_real_ip_from -syn keyword ngxDirective smtp_auth -syn keyword ngxDirective smtp_capabilities -syn keyword ngxDirective smtp_client_buffer -syn keyword ngxDirective smtp_greeting_delay -syn keyword ngxDirective so_keepalive -syn keyword ngxDirective source_charset -syn keyword ngxDirective ssi -syn keyword ngxDirective ssi_ignore_recycled_buffers -syn keyword ngxDirective ssi_min_file_chunk -syn keyword ngxDirective ssi_silent_errors -syn keyword ngxDirective ssi_types -syn keyword ngxDirective ssi_value_length -syn keyword ngxDirective ssl -syn keyword ngxDirective ssl_certificate -syn keyword ngxDirective ssl_certificate_key -syn keyword ngxDirective ssl_ciphers -syn keyword ngxDirective ssl_client_certificate -syn keyword ngxDirective ssl_crl -syn keyword ngxDirective ssl_dhparam -syn keyword ngxDirective ssl_engine -syn keyword ngxDirective ssl_prefer_server_ciphers -syn keyword ngxDirective ssl_protocols -syn keyword ngxDirective ssl_session_cache -syn keyword ngxDirective ssl_session_timeout -syn keyword ngxDirective ssl_verify_client -syn keyword ngxDirective ssl_verify_depth -syn keyword ngxDirective starttls -syn keyword ngxDirective stub_status -syn keyword ngxDirective sub_filter -syn keyword ngxDirective sub_filter_once -syn keyword ngxDirective sub_filter_types -syn keyword ngxDirective tcp_nodelay -syn keyword ngxDirective tcp_nopush -syn keyword ngxDirective thread_stack_size -syn keyword ngxDirective timeout -syn keyword ngxDirective timer_resolution -syn keyword ngxDirective types_hash_bucket_size -syn keyword ngxDirective types_hash_max_size -syn keyword ngxDirective underscores_in_headers -syn keyword ngxDirective uninitialized_variable_warn -syn keyword ngxDirective use -syn keyword ngxDirective user -syn keyword ngxDirective userid -syn keyword ngxDirective userid_domain -syn keyword ngxDirective userid_expires -syn keyword ngxDirective userid_mark -syn keyword ngxDirective userid_name -syn keyword ngxDirective userid_p3p -syn keyword ngxDirective userid_path -syn keyword ngxDirective userid_service -syn keyword ngxDirective valid_referers -syn keyword ngxDirective variables_hash_bucket_size -syn keyword ngxDirective variables_hash_max_size -syn keyword ngxDirective worker_connections -syn keyword ngxDirective worker_cpu_affinity -syn keyword ngxDirective worker_priority -syn keyword ngxDirective worker_processes -syn keyword ngxDirective worker_rlimit_core -syn keyword ngxDirective worker_rlimit_nofile -syn keyword ngxDirective worker_rlimit_sigpending -syn keyword ngxDirective worker_threads -syn keyword ngxDirective working_directory -syn keyword ngxDirective xclient -syn keyword ngxDirective xml_entities -syn keyword ngxDirective xslt_stylesheet -syn keyword ngxDirective xslt_types - -" 3rd party module list: -" http://wiki.nginx.org/Nginx3rdPartyModules - -" Accept Language Module -" Parses the Accept-Language header and gives the most suitable locale from a list of supported locales. -syn keyword ngxDirectiveThirdParty set_from_accept_language - -" Access Key Module -" Denies access unless the request URL contains an access key. -syn keyword ngxDirectiveThirdParty accesskey -syn keyword ngxDirectiveThirdParty accesskey_arg -syn keyword ngxDirectiveThirdParty accesskey_hashmethod -syn keyword ngxDirectiveThirdParty accesskey_signature - -" Auth PAM Module -" HTTP Basic Authentication using PAM. -syn keyword ngxDirectiveThirdParty auth_pam -syn keyword ngxDirectiveThirdParty auth_pam_service_name - -" Cache Purge Module -" Module adding ability to purge content from FastCGI and proxy caches. -syn keyword ngxDirectiveThirdParty fastcgi_cache_purge -syn keyword ngxDirectiveThirdParty proxy_cache_purge - -" Chunkin Module -" HTTP 1.1 chunked-encoding request body support for Nginx. -syn keyword ngxDirectiveThirdParty chunkin -syn keyword ngxDirectiveThirdParty chunkin_keepalive -syn keyword ngxDirectiveThirdParty chunkin_max_chunks_per_buf -syn keyword ngxDirectiveThirdParty chunkin_resume - -" Circle GIF Module -" Generates simple circle images with the colors and size specified in the URL. -syn keyword ngxDirectiveThirdParty circle_gif -syn keyword ngxDirectiveThirdParty circle_gif_max_radius -syn keyword ngxDirectiveThirdParty circle_gif_min_radius -syn keyword ngxDirectiveThirdParty circle_gif_step_radius - -" Drizzle Module -" Make nginx talk directly to mysql, drizzle, and sqlite3 by libdrizzle. -syn keyword ngxDirectiveThirdParty drizzle_connect_timeout -syn keyword ngxDirectiveThirdParty drizzle_dbname -syn keyword ngxDirectiveThirdParty drizzle_keepalive -syn keyword ngxDirectiveThirdParty drizzle_module_header -syn keyword ngxDirectiveThirdParty drizzle_pass -syn keyword ngxDirectiveThirdParty drizzle_query -syn keyword ngxDirectiveThirdParty drizzle_recv_cols_timeout -syn keyword ngxDirectiveThirdParty drizzle_recv_rows_timeout -syn keyword ngxDirectiveThirdParty drizzle_send_query_timeout -syn keyword ngxDirectiveThirdParty drizzle_server - -" Echo Module -" Brings 'echo', 'sleep', 'time', 'exec' and more shell-style goodies to Nginx config file. -syn keyword ngxDirectiveThirdParty echo -syn keyword ngxDirectiveThirdParty echo_after_body -syn keyword ngxDirectiveThirdParty echo_before_body -syn keyword ngxDirectiveThirdParty echo_blocking_sleep -syn keyword ngxDirectiveThirdParty echo_duplicate -syn keyword ngxDirectiveThirdParty echo_end -syn keyword ngxDirectiveThirdParty echo_exec -syn keyword ngxDirectiveThirdParty echo_flush -syn keyword ngxDirectiveThirdParty echo_foreach_split -syn keyword ngxDirectiveThirdParty echo_location -syn keyword ngxDirectiveThirdParty echo_location_async -syn keyword ngxDirectiveThirdParty echo_read_request_body -syn keyword ngxDirectiveThirdParty echo_request_body -syn keyword ngxDirectiveThirdParty echo_reset_timer -syn keyword ngxDirectiveThirdParty echo_sleep -syn keyword ngxDirectiveThirdParty echo_subrequest -syn keyword ngxDirectiveThirdParty echo_subrequest_async - -" Events Module -" Privides options for start/stop events. -syn keyword ngxDirectiveThirdParty on_start -syn keyword ngxDirectiveThirdParty on_stop - -" EY Balancer Module -" Adds a request queue to Nginx that allows the limiting of concurrent requests passed to the upstream. -syn keyword ngxDirectiveThirdParty max_connections -syn keyword ngxDirectiveThirdParty max_connections_max_queue_length -syn keyword ngxDirectiveThirdParty max_connections_queue_timeout - -" Fancy Indexes Module -" Like the built-in autoindex module, but fancier. -syn keyword ngxDirectiveThirdParty fancyindex -syn keyword ngxDirectiveThirdParty fancyindex_exact_size -syn keyword ngxDirectiveThirdParty fancyindex_footer -syn keyword ngxDirectiveThirdParty fancyindex_header -syn keyword ngxDirectiveThirdParty fancyindex_localtime -syn keyword ngxDirectiveThirdParty fancyindex_readme -syn keyword ngxDirectiveThirdParty fancyindex_readme_mode - -" GeoIP Module (DEPRECATED) -" Country code lookups via the MaxMind GeoIP API. -syn keyword ngxDirectiveThirdParty geoip_country_file - -" Headers More Module -" Set and clear input and output headers...more than "add"! -syn keyword ngxDirectiveThirdParty more_clear_headers -syn keyword ngxDirectiveThirdParty more_clear_input_headers -syn keyword ngxDirectiveThirdParty more_set_headers -syn keyword ngxDirectiveThirdParty more_set_input_headers - -" HTTP Push Module -" Turn Nginx into an adept long-polling HTTP Push (Comet) server. -syn keyword ngxDirectiveThirdParty push_buffer_size -syn keyword ngxDirectiveThirdParty push_listener -syn keyword ngxDirectiveThirdParty push_message_timeout -syn keyword ngxDirectiveThirdParty push_queue_messages -syn keyword ngxDirectiveThirdParty push_sender - -" HTTP Redis Module > -" Redis support.> -syn keyword ngxDirectiveThirdParty redis_bind -syn keyword ngxDirectiveThirdParty redis_buffer_size -syn keyword ngxDirectiveThirdParty redis_connect_timeout -syn keyword ngxDirectiveThirdParty redis_next_upstream -syn keyword ngxDirectiveThirdParty redis_pass -syn keyword ngxDirectiveThirdParty redis_read_timeout -syn keyword ngxDirectiveThirdParty redis_send_timeout - -" HTTP JavaScript Module -" Embedding SpiderMonkey. Nearly full port on Perl module. -syn keyword ngxDirectiveThirdParty js -syn keyword ngxDirectiveThirdParty js_filter -syn keyword ngxDirectiveThirdParty js_filter_types -syn keyword ngxDirectiveThirdParty js_load -syn keyword ngxDirectiveThirdParty js_maxmem -syn keyword ngxDirectiveThirdParty js_require -syn keyword ngxDirectiveThirdParty js_set -syn keyword ngxDirectiveThirdParty js_utf8 - -" Log Request Speed -" Log the time it took to process each request. -syn keyword ngxDirectiveThirdParty log_request_speed_filter -syn keyword ngxDirectiveThirdParty log_request_speed_filter_timeout - -" Memc Module -" An extended version of the standard memcached module that supports set, add, delete, and many more memcached commands. -syn keyword ngxDirectiveThirdParty memc_buffer_size -syn keyword ngxDirectiveThirdParty memc_cmds_allowed -syn keyword ngxDirectiveThirdParty memc_connect_timeout -syn keyword ngxDirectiveThirdParty memc_flags_to_last_modified -syn keyword ngxDirectiveThirdParty memc_next_upstream -syn keyword ngxDirectiveThirdParty memc_pass -syn keyword ngxDirectiveThirdParty memc_read_timeout -syn keyword ngxDirectiveThirdParty memc_send_timeout -syn keyword ngxDirectiveThirdParty memc_upstream_fail_timeout -syn keyword ngxDirectiveThirdParty memc_upstream_max_fails - -" Mogilefs Module -" Implements a MogileFS client, provides a replace to the Perlbal reverse proxy of the original MogileFS. -syn keyword ngxDirectiveThirdParty mogilefs_connect_timeout -syn keyword ngxDirectiveThirdParty mogilefs_domain -syn keyword ngxDirectiveThirdParty mogilefs_methods -syn keyword ngxDirectiveThirdParty mogilefs_noverify -syn keyword ngxDirectiveThirdParty mogilefs_pass -syn keyword ngxDirectiveThirdParty mogilefs_read_timeout -syn keyword ngxDirectiveThirdParty mogilefs_send_timeout -syn keyword ngxDirectiveThirdParty mogilefs_tracker - -" MP4 Streaming Lite Module -" Will seek to a certain time within H.264/MP4 files when provided with a 'start' parameter in the URL. -syn keyword ngxDirectiveThirdParty mp4 - -" Nginx Notice Module -" Serve static file to POST requests. -syn keyword ngxDirectiveThirdParty notice -syn keyword ngxDirectiveThirdParty notice_type - -" Phusion Passenger -" Easy and robust deployment of Ruby on Rails application on Apache and Nginx webservers. -syn keyword ngxDirectiveThirdParty passenger_base_uri -syn keyword ngxDirectiveThirdParty passenger_default_user -syn keyword ngxDirectiveThirdParty passenger_enabled -syn keyword ngxDirectiveThirdParty passenger_log_level -syn keyword ngxDirectiveThirdParty passenger_max_instances_per_app -syn keyword ngxDirectiveThirdParty passenger_max_pool_size -syn keyword ngxDirectiveThirdParty passenger_pool_idle_time -syn keyword ngxDirectiveThirdParty passenger_root -syn keyword ngxDirectiveThirdParty passenger_ruby -syn keyword ngxDirectiveThirdParty passenger_use_global_queue -syn keyword ngxDirectiveThirdParty passenger_user_switching -syn keyword ngxDirectiveThirdParty rack_env -syn keyword ngxDirectiveThirdParty rails_app_spawner_idle_time -syn keyword ngxDirectiveThirdParty rails_env -syn keyword ngxDirectiveThirdParty rails_framework_spawner_idle_time -syn keyword ngxDirectiveThirdParty rails_spawn_method - -" RDS JSON Module -" Help ngx_drizzle and other DBD modules emit JSON data. -syn keyword ngxDirectiveThirdParty rds_json -syn keyword ngxDirectiveThirdParty rds_json_content_type -syn keyword ngxDirectiveThirdParty rds_json_format -syn keyword ngxDirectiveThirdParty rds_json_ret - -" RRD Graph Module -" This module provides an HTTP interface to RRDtool's graphing facilities. -syn keyword ngxDirectiveThirdParty rrd_graph -syn keyword ngxDirectiveThirdParty rrd_graph_root - -" Secure Download -" Create expiring links. -syn keyword ngxDirectiveThirdParty secure_download -syn keyword ngxDirectiveThirdParty secure_download_fail_location -syn keyword ngxDirectiveThirdParty secure_download_path_mode -syn keyword ngxDirectiveThirdParty secure_download_secret - -" SlowFS Cache Module -" Module adding ability to cache static files. -syn keyword ngxDirectiveThirdParty slowfs_big_file_size -syn keyword ngxDirectiveThirdParty slowfs_cache -syn keyword ngxDirectiveThirdParty slowfs_cache_key -syn keyword ngxDirectiveThirdParty slowfs_cache_min_uses -syn keyword ngxDirectiveThirdParty slowfs_cache_path -syn keyword ngxDirectiveThirdParty slowfs_cache_purge -syn keyword ngxDirectiveThirdParty slowfs_cache_valid -syn keyword ngxDirectiveThirdParty slowfs_temp_path - -" Strip Module -" Whitespace remover. -syn keyword ngxDirectiveThirdParty strip - -" Substitutions Module -" A filter module which can do both regular expression and fixed string substitutions on response bodies. -syn keyword ngxDirectiveThirdParty subs_filter -syn keyword ngxDirectiveThirdParty subs_filter_types - -" Supervisord Module -" Module providing nginx with API to communicate with supervisord and manage (start/stop) backends on-demand. -syn keyword ngxDirectiveThirdParty supervisord -syn keyword ngxDirectiveThirdParty supervisord_inherit_backend_status -syn keyword ngxDirectiveThirdParty supervisord_name -syn keyword ngxDirectiveThirdParty supervisord_start -syn keyword ngxDirectiveThirdParty supervisord_stop - -" Upload Module -" Parses multipart/form-data allowing arbitrary handling of uploaded files. -syn keyword ngxDirectiveThirdParty upload_aggregate_form_field -syn keyword ngxDirectiveThirdParty upload_buffer_size -syn keyword ngxDirectiveThirdParty upload_cleanup -syn keyword ngxDirectiveThirdParty upload_limit_rate -syn keyword ngxDirectiveThirdParty upload_max_file_size -syn keyword ngxDirectiveThirdParty upload_max_output_body_len -syn keyword ngxDirectiveThirdParty upload_max_part_header_len -syn keyword ngxDirectiveThirdParty upload_pass -syn keyword ngxDirectiveThirdParty upload_pass_args -syn keyword ngxDirectiveThirdParty upload_pass_form_field -syn keyword ngxDirectiveThirdParty upload_set_form_field -syn keyword ngxDirectiveThirdParty upload_store -syn keyword ngxDirectiveThirdParty upload_store_access - -" Upload Progress Module -" Tracks and reports upload progress. -syn keyword ngxDirectiveThirdParty report_uploads -syn keyword ngxDirectiveThirdParty track_uploads -syn keyword ngxDirectiveThirdParty upload_progress -syn keyword ngxDirectiveThirdParty upload_progress_content_type -syn keyword ngxDirectiveThirdParty upload_progress_header -syn keyword ngxDirectiveThirdParty upload_progress_json_output -syn keyword ngxDirectiveThirdParty upload_progress_template - -" Upstream Fair Balancer -" Sends an incoming request to the least-busy backend server, rather than distributing requests round-robin. -syn keyword ngxDirectiveThirdParty fair -syn keyword ngxDirectiveThirdParty upstream_fair_shm_size - -" Upstream Consistent Hash -" Select backend based on Consistent hash ring. -syn keyword ngxDirectiveThirdParty consistent_hash - -" Upstream Hash Module -" Provides simple upstream load distribution by hashing a configurable variable. -syn keyword ngxDirectiveThirdParty hash -syn keyword ngxDirectiveThirdParty hash_again - -" XSS Module -" Native support for cross-site scripting (XSS) in an nginx. -syn keyword ngxDirectiveThirdParty xss_callback_arg -syn keyword ngxDirectiveThirdParty xss_get -syn keyword ngxDirectiveThirdParty xss_input_types -syn keyword ngxDirectiveThirdParty xss_output_type - -" highlight - -hi link ngxComment Comment -hi link ngxVariable Identifier -hi link ngxVariableBlock Identifier -hi link ngxVariableString PreProc -hi link ngxBlock Normal -hi link ngxString String - -hi link ngxBoolean Boolean -hi link ngxDirectiveBlock Statement -hi link ngxDirectiveImportant Type -hi link ngxDirectiveControl Keyword -hi link ngxDirectiveError Constant -hi link ngxDirectiveDeprecated Error -hi link ngxDirective Identifier -hi link ngxDirectiveThirdParty Special - -let b:current_syntax = "nginx" diff --git a/sources_non_forked/nginx.vim/README b/sources_non_forked/nginx.vim/README deleted file mode 100644 index 91ceb224..00000000 --- a/sources_non_forked/nginx.vim/README +++ /dev/null @@ -1,3 +0,0 @@ -This is a mirror of http://www.vim.org/scripts/script.php?script_id=1886 - -nginx.vim highlights configuration files for nginx, the high-performance web server (see http://nginx.net). diff --git a/sources_non_forked/rust.vim/.gitignore b/sources_non_forked/rust.vim/.gitignore new file mode 100644 index 00000000..0a56e3fc --- /dev/null +++ b/sources_non_forked/rust.vim/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_non_forked/rust.vim/README.md b/sources_non_forked/rust.vim/README.md new file mode 100644 index 00000000..481db9f3 --- /dev/null +++ b/sources_non_forked/rust.vim/README.md @@ -0,0 +1,30 @@ +# rust.vim + +## Description + +This is a vim plugin provides [Rust][r] file detection and syntax highlighting. + +It is synchronized daily to the vim support code in [rust-lang/rust][rr]'s +master branch via cronjob. + +## Installation + +### Using [Vundle][v] + +1. Add `Plugin 'wting/rust.vim'` to `~/.vimrc` +2. `vim +PluginInstall +qall` + +*Note:* Vundle will not automatically detect Rust files properly if `filetype +on` is executed before Vundle. Please check the [quickstart][vqs] for more +details. + +### Using [Pathogen][p] + +1. `cd ~/.vim/bundle` +2. `git clone https://github.com/wting/rust.vim.git` + +[rr]: https://github.com/rust-lang/rust +[p]: https://github.com/tpope/vim-pathogen +[r]: https://en.wikipedia.org/wiki/Rust_language +[v]: https://github.com/gmarik/vundle +[vqs]: https://github.com/gmarik/vundle#quick-start diff --git a/sources_non_forked/rust.vim/after/syntax/rust.vim b/sources_non_forked/rust.vim/after/syntax/rust.vim new file mode 100644 index 00000000..735c1e15 --- /dev/null +++ b/sources_non_forked/rust.vim/after/syntax/rust.vim @@ -0,0 +1,31 @@ +if !exists('g:rust_conceal') || !has('conceal') || &enc != 'utf-8' + finish +endif + +" For those who don't want to see `::`... +if exists('g:rust_conceal_mod_path') + syn match rustNiceOperator "::" conceal cchar=ㆍ +endif + +syn match rustRightArrowHead contained ">" conceal cchar=  +syn match rustRightArrowTail contained "-" conceal cchar=⟶ +syn match rustNiceOperator "->" contains=rustRightArrowHead,rustRightArrowTail + +syn match rustFatRightArrowHead contained ">" conceal cchar=  +syn match rustFatRightArrowTail contained "=" conceal cchar=⟹ +syn match rustNiceOperator "=>" contains=rustFatRightArrowHead,rustFatRightArrowTail + +syn match rustNiceOperator /\<\@!_\(_*\>\)\@=/ conceal cchar=′ + +" For those who don't want to see `pub`... +if exists('g:rust_conceal_pub') + syn match rustPublicSigil contained "pu" conceal cchar=* + syn match rustPublicRest contained "b" conceal cchar=  + syn match rustNiceOperator "pub " contains=rustPublicSigil,rustPublicRest +endif + +hi link rustNiceOperator Operator + +if !exists('g:rust_conceal_mod_path') + hi! link Conceal Operator +endif diff --git a/sources_non_forked/rust.vim/autoload/rust.vim b/sources_non_forked/rust.vim/autoload/rust.vim new file mode 100644 index 00000000..fe8e743e --- /dev/null +++ b/sources_non_forked/rust.vim/autoload/rust.vim @@ -0,0 +1,225 @@ +" Author: Kevin Ballard +" Description: Helper functions for Rust commands/mappings +" Last Modified: May 27, 2014 + +" Jump {{{1 + +function! rust#Jump(mode, function) range + let cnt = v:count1 + normal! m' + if a:mode ==# 'v' + norm! gv + endif + let foldenable = &foldenable + set nofoldenable + while cnt > 0 + execute "call Jump_" . a:function . "()" + let cnt = cnt - 1 + endwhile + let &foldenable = foldenable +endfunction + +function! s:Jump_Back() + call search('{', 'b') + keepjumps normal! w99[{ +endfunction + +function! s:Jump_Forward() + normal! j0 + call search('{', 'b') + keepjumps normal! w99[{% + call search('{') +endfunction + +" Run {{{1 + +function! rust#Run(bang, args) + if a:bang + let idx = index(a:args, '--') + if idx != -1 + let rustc_args = idx == 0 ? [] : a:args[:idx-1] + let args = a:args[idx+1:] + else + let rustc_args = a:args + let args = [] + endif + else + let rustc_args = [] + let args = a:args + endif + + let b:rust_last_rustc_args = rustc_args + let b:rust_last_args = args + + call s:WithPath(function("s:Run"), rustc_args, args) +endfunction + +function! s:Run(path, rustc_args, args) + try + let exepath = tempname() + if has('win32') + let exepath .= '.exe' + endif + + let rustc_args = [a:path, '-o', exepath] + a:rustc_args + + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + let output = system(shellescape(rustc) . " " . join(map(rustc_args, 'shellescape(v:val)'))) + if output != '' + echohl WarningMsg + echo output + echohl None + endif + if !v:shell_error + exe '!' . shellescape(exepath) . " " . join(map(a:args, 'shellescape(v:val)')) + endif + finally + if exists("exepath") + silent! call delete(exepath) + endif + endtry +endfunction + +" Expand {{{1 + +function! rust#Expand(bang, args) + if a:bang && !empty(a:args) + let pretty = a:args[0] + let args = a:args[1:] + else + let pretty = "expanded" + let args = a:args + endif + call s:WithPath(function("s:Expand"), pretty, args) +endfunction + +function! s:Expand(path, pretty, args) + try + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + let args = [a:path, '--pretty', a:pretty] + a:args + let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)"))) + if v:shell_error + echohl WarningMsg + echo output + echohl None + else + new + silent put =output + 1 + d + setl filetype=rust + setl buftype=nofile + setl bufhidden=hide + setl noswapfile + endif + endtry +endfunction + +function! rust#CompleteExpand(lead, line, pos) + if a:line[: a:pos-1] =~ '^RustExpand!\s*\S*$' + " first argument and it has a ! + let list = ["normal", "expanded", "typed", "expanded,identified", "flowgraph="] + if !empty(a:lead) + call filter(list, "v:val[:len(a:lead)-1] == a:lead") + endif + return list + endif + + return glob(escape(a:lead, "*?[") . '*', 0, 1) +endfunction + +" Emit {{{1 + +function! rust#Emit(type, args) + call s:WithPath(function("s:Emit"), a:type, a:args) +endfunction + +function! s:Emit(path, type, args) + try + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + let args = [a:path, '--emit', a:type, '-o', '-'] + a:args + let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)"))) + if v:shell_error + echohl WarningMsg + echo output + echohl None + else + new + silent put =output + 1 + d + if a:type == "ir" + setl filetype=llvm + elseif a:type == "asm" + setl filetype=asm + endif + setl buftype=nofile + setl bufhidden=hide + setl noswapfile + endif + endtry +endfunction + +" Utility functions {{{1 + +function! s:WithPath(func, ...) + try + let save_write = &write + set write + let path = expand('%') + let pathisempty = empty(path) + if pathisempty || !save_write + " use a temporary file named 'unnamed.rs' inside a temporary + " directory. This produces better error messages + let tmpdir = tempname() + call mkdir(tmpdir) + + let save_cwd = getcwd() + silent exe 'lcd' fnameescape(tmpdir) + + let path = 'unnamed.rs' + + let save_mod = &mod + set nomod + + silent exe 'keepalt write! ' . fnameescape(path) + if pathisempty + silent keepalt 0file + endif + else + update + endif + + call call(a:func, [path] + a:000) + finally + if exists("save_mod") | let &mod = save_mod | endif + if exists("save_write") | let &write = save_write | endif + if exists("save_cwd") | silent exe 'lcd' fnameescape(save_cwd) | endif + if exists("tmpdir") | silent call s:RmDir(tmpdir) | endif + endtry +endfunction + +function! rust#AppendCmdLine(text) + call setcmdpos(getcmdpos()) + let cmd = getcmdline() . a:text + return cmd +endfunction + +function! s:RmDir(path) + " sanity check; make sure it's not empty, /, or $HOME + if empty(a:path) + echoerr 'Attempted to delete empty path' + return 0 + elseif a:path == '/' || a:path == $HOME + echoerr 'Attempted to delete protected path: ' . a:path + return 0 + endif + silent exe "!rm -rf " . shellescape(a:path) +endfunction + +" }}}1 + +" vim: set noet sw=4 ts=4: diff --git a/sources_non_forked/rust.vim/compiler/cargo.vim b/sources_non_forked/rust.vim/compiler/cargo.vim new file mode 100644 index 00000000..ed487a30 --- /dev/null +++ b/sources_non_forked/rust.vim/compiler/cargo.vim @@ -0,0 +1,65 @@ +" Vim compiler file +" Compiler: Cargo Compiler +" Maintainer: Damien Radtke +" Latest Revision: 2014 Sep 24 + +if exists('current_compiler') + finish +endif +runtime compiler/rustc.vim +let current_compiler = "cargo" + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal +endif + +if exists('g:cargo_makeprg_params') + execute 'CompilerSet makeprg=cargo\ '.escape(g:cargo_makeprg_params, ' \|"').'\ $*' +else + CompilerSet makeprg=cargo\ $* +endif + +" Allow a configurable global Cargo.toml name. This makes it easy to +" support variations like 'cargo.toml'. +let s:cargo_manifest_name = get(g:, 'cargo_manifest_name', 'Cargo.toml') + +function! s:is_absolute(path) + return a:path[0] == '/' || a:path =~ '[A-Z]\+:' +endfunction + +let s:local_manifest = findfile(s:cargo_manifest_name, '.;') +if s:local_manifest != '' + let s:local_manifest = fnamemodify(s:local_manifest, ':p:h').'/' + augroup cargo + au! + au QuickfixCmdPost make call s:FixPaths() + augroup END + + " FixPaths() is run after Cargo, and is used to change the file paths + " to be relative to the current directory instead of Cargo.toml. + function! s:FixPaths() + let qflist = getqflist() + let manifest = s:local_manifest + for qf in qflist + if !qf.valid + let m = matchlist(qf.text, '(file://\(.*\))$') + if !empty(m) + let manifest = m[1].'/' + " Manually strip another slash if needed; usually just an + " issue on Windows. + if manifest =~ '^/[A-Z]\+:/' + let manifest = manifest[1:] + endif + endif + continue + endif + let filename = bufname(qf.bufnr) + if s:is_absolute(filename) + continue + endif + let qf.filename = simplify(manifest.filename) + call remove(qf, 'bufnr') + endfor + call setqflist(qflist, 'r') + endfunction +endif diff --git a/sources_non_forked/rust.vim/compiler/rustc.vim b/sources_non_forked/rust.vim/compiler/rustc.vim new file mode 100644 index 00000000..f9b854ed --- /dev/null +++ b/sources_non_forked/rust.vim/compiler/rustc.vim @@ -0,0 +1,33 @@ +" Vim compiler file +" Compiler: Rust Compiler +" Maintainer: Chris Morgan +" Latest Revision: 2013 Jul 12 + +if exists("current_compiler") + finish +endif +let current_compiler = "rustc" + +let s:cpo_save = &cpo +set cpo&vim + +if exists(":CompilerSet") != 2 + command -nargs=* CompilerSet setlocal +endif + +if exists("g:rustc_makeprg_no_percent") && g:rustc_makeprg_no_percent == 1 + CompilerSet makeprg=rustc +else + CompilerSet makeprg=rustc\ \% +endif + +CompilerSet errorformat= + \%f:%l:%c:\ %t%*[^:]:\ %m, + \%f:%l:%c:\ %*\\d:%*\\d\ %t%*[^:]:\ %m, + \%-G%f:%l\ %s, + \%-G%*[\ ]^, + \%-G%*[\ ]^%*[~], + \%-G%*[\ ]... + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/sources_non_forked/rust.vim/doc/rust.txt b/sources_non_forked/rust.vim/doc/rust.txt new file mode 100644 index 00000000..e117b0c1 --- /dev/null +++ b/sources_non_forked/rust.vim/doc/rust.txt @@ -0,0 +1,178 @@ +*rust.txt* Filetype plugin for Rust + +============================================================================== +CONTENTS *rust* *ft-rust* + +1. Introduction |rust-intro| +2. Settings |rust-settings| +3. Commands |rust-commands| +4. Mappings |rust-mappings| + +============================================================================== +INTRODUCTION *rust-intro* + +This plugin provides syntax and supporting functionality for the Rust +filetype. + +============================================================================== +SETTINGS *rust-settings* + +This plugin has a few variables you can define in your vimrc that change the +behavior of the plugin. + + *g:rustc_path* +g:rustc_path~ + Set this option to the path to rustc for use in the |:RustRun| and + |:RustExpand| commands. If unset, "rustc" will be located in $PATH: > + let g:rustc_path = $HOME."/bin/rustc" +< + + *g:rustc_makeprg_no_percent* +g:rustc_makeprg_no_percent~ + Set this option to 1 to have 'makeprg' default to "rustc" instead of + "rustc %": > + let g:rustc_makeprg_no_percent = 1 +< + + *g:rust_conceal* +g:rust_conceal~ + Set this option to turn on the basic |conceal| support: > + let g:rust_conceal = 1 +< + + *g:rust_conceal_mod_path* +g:rust_conceal_mod_path~ + Set this option to turn on |conceal| for the path connecting token + "::": > + let g:rust_conceal_mod_path = 1 +< + + *g:rust_conceal_pub* +g:rust_conceal_pub~ + Set this option to turn on |conceal| for the "pub" token: > + let g:rust_conceal_pub = 1 +< + + *g:rust_recommended_style* +g:rust_recommended_style~ + Set this option to enable vim indentation and textwidth settings to + conform to style conventions of the rust standard library (i.e. use 4 + spaces for indents and sets 'textwidth' to 99). This option is enabled + by default. To disable it: > + let g:rust_recommended_style = 0 +< + + *g:rust_fold* +g:rust_fold~ + Set this option to turn on |folding|: > + let g:rust_fold = 1 +< + Value Effect ~ + 0 No folding + 1 Braced blocks are folded. All folds are open by + default. + 2 Braced blocks are folded. 'foldlevel' is left at the + global value (all folds are closed by default). + + *g:rust_bang_comment_leader* +g:rust_bang_comment_leader~ + Set this option to 1 to preserve the leader on multi-line doc comments + using the /*! syntax: > + let g:rust_bang_comment_leader = 1 +< + + *g:ftplugin_rust_source_path* +g:ftplugin_rust_source_path~ + Set this option to a path that should be prepended to 'path' for Rust + source files: > + let g:ftplugin_rust_source_path = $HOME.'/dev/rust' +< + + *g:cargo_manifest_name* +g:cargo_manifest_name~ + Set this option to the name of the manifest file for your projects. If + not specified it defaults to 'Cargo.toml' : > + let g:cargo_manifest_name = 'Cargo.toml' +< + +============================================================================== +COMMANDS *rust-commands* + +:RustRun [args] *:RustRun* +:RustRun! [rustc-args] [--] [args] + Compiles and runs the current file. If it has unsaved changes, + it will be saved first using |:update|. If the current file is + an unnamed buffer, it will be written to a temporary file + first. The compiled binary is always placed in a temporary + directory, but is run from the current directory. + + The arguments given to |:RustRun| will be passed to the + compiled binary. + + If ! is specified, the arguments are passed to rustc instead. + A "--" argument will separate the rustc arguments from the + arguments passed to the binary. + + If |g:rustc_path| is defined, it is used as the path to rustc. + Otherwise it is assumed rustc can be found in $PATH. + +:RustExpand [args] *:RustExpand* +:RustExpand! [TYPE] [args] + Expands the current file using --pretty and displays the + results in a new split. If the current file has unsaved + changes, it will be saved first using |:update|. If the + current file is an unnamed buffer, it will be written to a + temporary file first. + + The arguments given to |:RustExpand| will be passed to rustc. + This is largely intended for specifying various --cfg + configurations. + + If ! is specified, the first argument is the expansion type to + pass to rustc --pretty. Otherwise it will default to + "expanded". + + If |g:rustc_path| is defined, it is used as the path to rustc. + Otherwise it is assumed rustc can be found in $PATH. + +:RustEmitIr [args] *:RustEmitIr* + Compiles the current file to LLVM IR and displays the results + in a new split. If the current file has unsaved changes, it + will be saved first using |:update|. If the current file is an + unnamed buffer, it will be written to a temporary file first. + + The arguments given to |:RustEmitIr| will be passed to rustc. + + If |g:rustc_path| is defined, it is used as the path to rustc. + Otherwise it is assumed rustc can be found in $PATH. + +:RustEmitAsm [args] *:RustEmitAsm* + Compiles the current file to assembly and displays the results + in a new split. If the current file has unsaved changes, it + will be saved first using |:update|. If the current file is an + unnamed buffer, it will be written to a temporary file first. + + The arguments given to |:RustEmitAsm| will be passed to rustc. + + If |g:rustc_path| is defined, it is used as the path to rustc. + Otherwise it is assumed rustc can be found in $PATH. + +============================================================================== +MAPPINGS *rust-mappings* + +This plugin defines mappings for |[[| and |]]| to support hanging indents. + +It also has a few other mappings: + + *rust_* + Executes |:RustRun| with no arguments. + Note: This binding is only available in MacVim. + + *rust_* + Populates the command line with |:RustRun|! using the + arguments given to the last invocation, but does not + execute it. + Note: This binding is only available in MacVim. + +============================================================================== + vim:tw=78:sw=4:noet:ts=8:ft=help:norl: diff --git a/sources_non_forked/rust.vim/ftdetect/rust.vim b/sources_non_forked/rust.vim/ftdetect/rust.vim new file mode 100644 index 00000000..bf685d43 --- /dev/null +++ b/sources_non_forked/rust.vim/ftdetect/rust.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.rs set filetype=rust diff --git a/sources_non_forked/rust.vim/ftplugin/rust.vim b/sources_non_forked/rust.vim/ftplugin/rust.vim new file mode 100644 index 00000000..5d556994 --- /dev/null +++ b/sources_non_forked/rust.vim/ftplugin/rust.vim @@ -0,0 +1,150 @@ +" Language: Rust +" Description: Vim syntax file for Rust +" Maintainer: Chris Morgan +" Maintainer: Kevin Ballard +" Last Change: Jul 07, 2014 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let s:save_cpo = &cpo +set cpo&vim + +" Variables {{{1 + +" The rust source code at present seems to typically omit a leader on /*! +" comments, so we'll use that as our default, but make it easy to switch. +" This does not affect indentation at all (I tested it with and without +" leader), merely whether a leader is inserted by default or not. +if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader == 1 + " Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why, + " but without it, */ gets indented one space even if there were no + " leaders. I'm fairly sure that's a Vim bug. + setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,:// +else + setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,:// +endif +setlocal commentstring=//%s +setlocal formatoptions-=t formatoptions+=croqnl +" j was only added in 7.3.541, so stop complaints about its nonexistence +silent! setlocal formatoptions+=j + +" smartindent will be overridden by indentexpr if filetype indent is on, but +" otherwise it's better than nothing. +setlocal smartindent nocindent + +if !exists("g:rust_recommended_style") || g:rust_recommended_style == 1 + setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab + setlocal textwidth=99 +endif + +" This includeexpr isn't perfect, but it's a good start +setlocal includeexpr=substitute(v:fname,'::','/','g') + +" NOT adding .rc as it's being phased out (0.7) +setlocal suffixesadd=.rs + +if exists("g:ftplugin_rust_source_path") + let &l:path=g:ftplugin_rust_source_path . ',' . &l:path +endif + +if exists("g:loaded_delimitMate") + if exists("b:delimitMate_excluded_regions") + let b:rust_original_delimitMate_excluded_regions = b:delimitMate_excluded_regions + endif + let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate' +endif + +if has("folding") && exists('g:rust_fold') && g:rust_fold != 0 + let b:rust_set_foldmethod=1 + setlocal foldmethod=syntax + if g:rust_fold == 2 + setlocal foldlevel< + else + setlocal foldlevel=99 + endif +endif + +if has('conceal') && exists('g:rust_conceal') + let b:rust_set_conceallevel=1 + setlocal conceallevel=2 +endif + +" Motion Commands {{{1 + +" Bind motion commands to support hanging indents +nnoremap [[ :call rust#Jump('n', 'Back') +nnoremap ]] :call rust#Jump('n', 'Forward') +xnoremap [[ :call rust#Jump('v', 'Back') +xnoremap ]] :call rust#Jump('v', 'Forward') +onoremap [[ :call rust#Jump('o', 'Back') +onoremap ]] :call rust#Jump('o', 'Forward') + +" Commands {{{1 + +" See |:RustRun| for docs +command! -nargs=* -complete=file -bang -bar -buffer RustRun call rust#Run(0, []) + +" See |:RustExpand| for docs +command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -bar -buffer RustExpand call rust#Expand(0, []) + +" See |:RustEmitIr| for docs +command! -nargs=* -bar -buffer RustEmitIr call rust#Emit("ir", []) + +" See |:RustEmitAsm| for docs +command! -nargs=* -bar -buffer RustEmitAsm call rust#Emit("asm", []) + +" Mappings {{{1 + +" Bind ⌘R in MacVim to :RustRun +nnoremap :RustRun +" Bind ⌘⇧R in MacVim to :RustRun! pre-filled with the last args +nnoremap :RustRun! =join(b:rust_last_rustc_args)erust#AppendCmdLine(' -- ' . join(b:rust_last_args)) + +if !exists("b:rust_last_rustc_args") || !exists("b:rust_last_args") + let b:rust_last_rustc_args = [] + let b:rust_last_args = [] +endif + +" Cleanup {{{1 + +let b:undo_ftplugin = " + \ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< + \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth< + \|if exists('b:rust_original_delimitMate_excluded_regions') + \|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions + \|unlet b:rust_original_delimitMate_excluded_regions + \|else + \|unlet! b:delimitMate_excluded_regions + \|endif + \|if exists('b:rust_set_foldmethod') + \|setlocal foldmethod< foldlevel< + \|unlet b:rust_set_foldmethod + \|endif + \|if exists('b:rust_set_conceallevel') + \|setlocal conceallevel< + \|unlet b:rust_set_conceallevel + \|endif + \|unlet! b:rust_last_rustc_args b:rust_last_args + \|delcommand RustRun + \|delcommand RustExpand + \|delcommand RustEmitIr + \|delcommand RustEmitAsm + \|nunmap + \|nunmap + \|nunmap [[ + \|nunmap ]] + \|xunmap [[ + \|xunmap ]] + \|ounmap [[ + \|ounmap ]] + \" + +" }}}1 + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set noet sw=4 ts=4: diff --git a/sources_non_forked/rust.vim/indent/rust.vim b/sources_non_forked/rust.vim/indent/rust.vim new file mode 100644 index 00000000..300d7dac --- /dev/null +++ b/sources_non_forked/rust.vim/indent/rust.vim @@ -0,0 +1,196 @@ +" Vim indent file +" Language: Rust +" Author: Chris Morgan +" Last Change: 2014 Sep 13 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal cindent +setlocal cinoptions=L0,(0,Ws,J1,j1 +setlocal cinkeys=0{,0},!^F,o,O,0[,0] +" Don't think cinwords will actually do anything at all... never mind +setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern + +" Some preliminary settings +setlocal nolisp " Make sure lisp indenting doesn't supersede us +setlocal autoindent " indentexpr isn't much help otherwise +" Also do indentkeys, otherwise # gets shoved to column 0 :-/ +setlocal indentkeys=0{,0},!^F,o,O,0[,0] + +setlocal indentexpr=GetRustIndent(v:lnum) + +" Only define the function once. +if exists("*GetRustIndent") + finish +endif + +" Come here when loading the script the first time. + +function! s:get_line_trimmed(lnum) + " Get the line and remove a trailing comment. + " Use syntax highlighting attributes when possible. + " NOTE: this is not accurate; /* */ or a line continuation could trick it + let line = getline(a:lnum) + let line_len = strlen(line) + if has('syntax_items') + " If the last character in the line is a comment, do a binary search for + " the start of the comment. synID() is slow, a linear search would take + " too long on a long line. + if synIDattr(synID(a:lnum, line_len, 1), "name") =~ 'Comment\|Todo' + let min = 1 + let max = line_len + while min < max + let col = (min + max) / 2 + if synIDattr(synID(a:lnum, col, 1), "name") =~ 'Comment\|Todo' + let max = col + else + let min = col + 1 + endif + endwhile + let line = strpart(line, 0, min - 1) + endif + return substitute(line, "\s*$", "", "") + else + " Sorry, this is not complete, nor fully correct (e.g. string "//"). + " Such is life. + return substitute(line, "\s*//.*$", "", "") + endif +endfunction + +function! s:is_string_comment(lnum, col) + if has('syntax_items') + for id in synstack(a:lnum, a:col) + let synname = synIDattr(id, "name") + if synname == "rustString" || synname =~ "^rustComment" + return 1 + endif + endfor + else + " without syntax, let's not even try + return 0 + endif +endfunction + +function GetRustIndent(lnum) + + " Starting assumption: cindent (called at the end) will do it right + " normally. We just want to fix up a few cases. + + let line = getline(a:lnum) + + if has('syntax_items') + let synname = synIDattr(synID(a:lnum, 1, 1), "name") + if synname == "rustString" + " If the start of the line is in a string, don't change the indent + return -1 + elseif synname =~ '\(Comment\|Todo\)' + \ && line !~ '^\s*/\*' " not /* opening line + if synname =~ "CommentML" " multi-line + if line !~ '^\s*\*' && getline(a:lnum - 1) =~ '^\s*/\*' + " This is (hopefully) the line after a /*, and it has no + " leader, so the correct indentation is that of the + " previous line. + return GetRustIndent(a:lnum - 1) + endif + endif + " If it's in a comment, let cindent take care of it now. This is + " for cases like "/*" where the next line should start " * ", not + " "* " as the code below would otherwise cause for module scope + " Fun fact: " /*\n*\n*/" takes two calls to get right! + return cindent(a:lnum) + endif + endif + + " cindent gets second and subsequent match patterns/struct members wrong, + " as it treats the comma as indicating an unfinished statement:: + " + " match a { + " b => c, + " d => e, + " f => g, + " }; + + " Search backwards for the previous non-empty line. + let prevlinenum = prevnonblank(a:lnum - 1) + let prevline = s:get_line_trimmed(prevlinenum) + while prevlinenum > 1 && prevline !~ '[^[:blank:]]' + let prevlinenum = prevnonblank(prevlinenum - 1) + let prevline = s:get_line_trimmed(prevlinenum) + endwhile + if prevline[len(prevline) - 1] == "," + \ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]' + \ && prevline !~ '^\s*fn\s' + \ && prevline !~ '([^()]\+,$' + " Oh ho! The previous line ended in a comma! I bet cindent will try to + " take this too far... For now, let's normally use the previous line's + " indent. + + " One case where this doesn't work out is where *this* line contains + " square or curly brackets; then we normally *do* want to be indenting + " further. + " + " Another case where we don't want to is one like a function + " definition with arguments spread over multiple lines: + " + " fn foo(baz: Baz, + " baz: Baz) // <-- cindent gets this right by itself + " + " Another case is similar to the previous, except calling a function + " instead of defining it, or any conditional expression that leaves + " an open paren: + " + " foo(baz, + " baz); + " + " if baz && (foo || + " bar) { + " + " There are probably other cases where we don't want to do this as + " well. Add them as needed. + return indent(prevlinenum) + endif + + if !has("patch-7.4.355") + " cindent before 7.4.355 doesn't do the module scope well at all; e.g.:: + " + " static FOO : &'static [bool] = [ + " true, + " false, + " false, + " true, + " ]; + " + " uh oh, next statement is indented further! + + " Note that this does *not* apply the line continuation pattern properly; + " that's too hard to do correctly for my liking at present, so I'll just + " start with these two main cases (square brackets and not returning to + " column zero) + + call cursor(a:lnum, 1) + if searchpair('{\|(', '', '}\|)', 'nbW', + \ 's:is_string_comment(line("."), col("."))') == 0 + if searchpair('\[', '', '\]', 'nbW', + \ 's:is_string_comment(line("."), col("."))') == 0 + " Global scope, should be zero + return 0 + else + " At the module scope, inside square brackets only + "if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum + if line =~ "^\\s*]" + " It's the closing line, dedent it + return 0 + else + return &shiftwidth + endif + endif + endif + endif + + " Fall back on cindent, which does it mostly right + return cindent(a:lnum) +endfunction diff --git a/sources_non_forked/rust.vim/plugin/rust.vim b/sources_non_forked/rust.vim/plugin/rust.vim new file mode 100644 index 00000000..4ec4f33d --- /dev/null +++ b/sources_non_forked/rust.vim/plugin/rust.vim @@ -0,0 +1,22 @@ +" Vim syntastic plugin helper +" Language: Rust +" Maintainer: Andrew Gallant + +if exists("g:loaded_syntastic_rust_filetype") + finish +endif +let g:loaded_syntastic_rust_filetype = 1 +let s:save_cpo = &cpo +set cpo&vim + +" This is to let Syntastic know about the Rust filetype. +" It enables tab completion for the 'SyntasticInfo' command. +" (This does not actually register the syntax checker.) +if exists('g:syntastic_extra_filetypes') + call add(g:syntastic_extra_filetypes, 'rust') +else + let g:syntastic_extra_filetypes = ['rust'] +endif + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/rust.vim/syntax/rust.vim b/sources_non_forked/rust.vim/syntax/rust.vim new file mode 100644 index 00000000..a37b7b6d --- /dev/null +++ b/sources_non_forked/rust.vim/syntax/rust.vim @@ -0,0 +1,262 @@ +" Vim syntax file +" Language: Rust +" Maintainer: Patrick Walton +" Maintainer: Ben Blum +" Maintainer: Chris Morgan +" Last Change: January 5, 2015 + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Syntax definitions {{{1 +" Basic keywords {{{2 +syn keyword rustConditional match if else +syn keyword rustOperator as + +syn match rustAssert "\(); + +" This is merely a convention; note also the use of [A-Z], restricting it to +" latin identifiers rather than the full Unicode uppercase. I have not used +" [:upper:] as it depends upon 'noignorecase' +"syn match rustCapsIdent display "[A-Z]\w\(\w\)*" + +syn match rustOperator display "\%(+\|-\|/\|*\|=\|\^\|&\||\|!\|>\|<\|%\)=\?" +" This one isn't *quite* right, as we could have binary-& with a reference +syn match rustSigil display /&\s\+[&~@*][^)= \t\r\n]/he=e-1,me=e-1 +syn match rustSigil display /[&~@*][^)= \t\r\n]/he=e-1,me=e-1 +" This isn't actually correct; a closure with no arguments can be `|| { }`. +" Last, because the & in && isn't a sigil +syn match rustOperator display "&&\|||" + +syn match rustMacro '\w\(\w\)*!' contains=rustAssert,rustPanic +syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustPanic + +syn match rustEscapeError display contained /\\./ +syn match rustEscape display contained /\\\([nrt0\\'"]\|x\x\{2}\)/ +syn match rustEscapeUnicode display contained /\\\(u\x\{4}\|U\x\{8}\)/ +syn match rustEscapeUnicode display contained /\\u{\x\{1,6}}/ +syn match rustStringContinuation display contained /\\\n\s*/ +syn region rustString start=+b"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeError,rustStringContinuation +syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustStringContinuation,@Spell +syn region rustString start='b\?r\z(#*\)"' end='"\z1' contains=@Spell + +syn region rustAttribute start="#!\?\[" end="\]" contains=rustString,rustDerive +syn region rustDerive start="derive(" end=")" contained contains=rustTrait + +" Number literals +syn match rustDecNumber display "\<[0-9][0-9_]*\%([iu]\%(s\|8\|16\|32\|64\)\)\=" +syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(s\|8\|16\|32\|64\)\)\=" +syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(s\|8\|16\|32\|64\)\)\=" +syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(s\|8\|16\|32\|64\)\)\=" + +" Special case for numbers of the form "1." which are float literals, unless followed by +" an identifier, which makes them integer literals with a method call or field access, +" or by another ".", which makes them integer literals followed by the ".." token. +" (This must go first so the others take precedence.) +syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\|\.\)\@!" +" To mark a number as a normal float, it must have at least one of the three things integral values don't have: +" a decimal point and more numbers; an exponent; and a type suffix. +syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\=" +syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\(f32\|f64\)\=" +syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)" + +" For the benefit of delimitMate +syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt0\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime +syn region rustGenericRegion display start=/<\%('\|[^[cntrl:][:space:][:punct:]]\)\@=')\S\@=/ end=/>/ contains=rustGenericLifetimeCandidate +syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime + +"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting +syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" +syn match rustCharacterInvalid display contained /b\?'\zs[\n\r\t']\ze'/ +" The groups negated here add up to 0-255 but nothing else (they do not seem to go beyond ASCII). +syn match rustCharacterInvalidUnicode display contained /b'\zs[^[:cntrl:][:graph:][:alnum:][:space:]]\ze'/ +syn match rustCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=rustEscape,rustEscapeError,rustCharacterInvalid,rustCharacterInvalidUnicode +syn match rustCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\|u{\x\{1,6}}\)\)'/ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustCharacterInvalid + +syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell +syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell +syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell +syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell +syn region rustCommentBlockNest matchgroup=rustCommentBlock start="/\*" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell contained transparent +syn region rustCommentBlockDocNest matchgroup=rustCommentBlockDoc start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell contained transparent +" FIXME: this is a really ugly and not fully correct implementation. Most +" importantly, a case like ``/* */*`` should have the final ``*`` not being in +" a comment, but in practice at present it leaves comments open two levels +" deep. But as long as you stay away from that particular case, I *believe* +" the highlighting is correct. Due to the way Vim's syntax engine works +" (greedy for start matches, unlike Rust's tokeniser which is searching for +" the earliest-starting match, start or end), I believe this cannot be solved. +" Oh you who would fix it, don't bother with things like duplicating the Block +" rules and putting ``\*\@ +" +" See for details on how to add an external Syntastic checker: +" https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide#external + +if exists("g:loaded_syntastic_rust_rustc_checker") + finish +endif +let g:loaded_syntastic_rust_rustc_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_rust_rustc_GetLocList() dict + let makeprg = self.makeprgBuild({ 'args': '-Zparse-only' }) + + let errorformat = + \ '%E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,' . + \ '%W%f:%l:%c: %\d%#:%\d%# %.%\{-}warning:%.%\{-} %m,' . + \ '%C%f:%l %m,' . + \ '%-Z%.%#' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'rust', + \ 'name': 'rustc'}) + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/syntastic/CONTRIBUTING.md b/sources_non_forked/syntastic/CONTRIBUTING.md index 378b53b3..1949415e 100644 --- a/sources_non_forked/syntastic/CONTRIBUTING.md +++ b/sources_non_forked/syntastic/CONTRIBUTING.md @@ -11,11 +11,11 @@ ## 1. Bug reports / GitHub issues Please note that the preferred channel for posting bug reports is the -[issue tracker at GitHub][0]. Reports posted elsewhere are less likely +[issue tracker at GitHub][bug_tracker]. Reports posted elsewhere are less likely to be seen by the core team. When reporting a bug make sure you search the existing GitHub issues -for the same/similar issues. If you find one, feel free to add a `+1` +for the same/similar issues. If you find one, feel free to add a `+1` comment with any additional information that may help us solve the issue. @@ -26,7 +26,7 @@ When creating a new issue be sure to state the following: * the version of syntastic you are using (see `:SyntasticInfo`). For syntax checker bugs also state the version of the checker executable -that you are using. Adding debugging information is typically useful +that you are using. Adding debugging information is typically useful too: * open a file handled by your checker; @@ -38,15 +38,15 @@ too: ## 2. Submitting a patch -Before you consider adding features to syntastic, _please_ spend a few -minutes (re-)reading the latest version of the [manual][1]. Syntastic -is changing rapidly at times, and it's quite possible that some of the -features you want to add exist already. +Before you consider adding features to syntastic, _please_ spend a few minutes +(re-)reading the latest version of the [manual][manual]. Syntastic is changing +rapidly at times, and it's possible that some features you want to add exist +already. To submit a patch: -* fork the [repo][2] on GitHub; -* make a [topic branch][3] and start hacking; +* fork the [repo][github] on GitHub; +* make a [topic branch][branches] and start hacking; * submit a pull request based off your topic branch. Small, focused patches are preferred. @@ -54,7 +54,7 @@ Small, focused patches are preferred. Large changes to the code should be discussed with the core team first. Create an issue and explain your plan and see what we say. -Also make sure to update the manual whenever applicable. Nobody can use +Also, make sure to update the manual whenever applicable. Nobody can use features that aren't documented. @@ -69,14 +69,14 @@ Follow the coding conventions/styles used in the syntastic core: * don't use `l:` prefixes for variables unless actually required (i.e. almost never); * code for maintainability; we would rather a function be a couple of -lines longer and have (for example) some [explaining variables][4] to +lines longer and have (for example) some [explaining variables][variables] to aid readability. ## 4. Syntax checker notes -Make sure to read the [guide][5] if you plan to add new syntax checkers. +Make sure to read the [guide][guide] if you plan to add new syntax checkers. Use the existing checkers as templates, rather than writing everything from scratch. @@ -97,9 +97,9 @@ let errorformat = \ '%-G%.%#' ``` -[0]: https://github.com/scrooloose/syntastic/issues -[1]: https://github.com/scrooloose/syntastic/blob/master/doc/syntastic.txt -[2]: https://github.com/scrooloose/syntastic -[3]: https://github.com/dchelimsky/rspec/wiki/Topic-Branches#using-topic-branches-when-contributing-patches -[4]: http://www.refactoring.com/catalog/extractVariable.html -[5]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide +[bug_tracker]: https://github.com/scrooloose/syntastic/issues +[manual]: https://github.com/scrooloose/syntastic/blob/master/doc/syntastic.txt +[github]: https://github.com/scrooloose/syntastic +[branches]: https://github.com/dchelimsky/rspec/wiki/Topic-Branches#using-topic-branches-when-contributing-patches +[variables]: http://www.refactoring.com/catalog/extractVariable.html +[guide]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide diff --git a/sources_non_forked/syntastic/README.markdown b/sources_non_forked/syntastic/README.markdown index b9e08c4e..5523d088 100644 --- a/sources_non_forked/syntastic/README.markdown +++ b/sources_non_forked/syntastic/README.markdown @@ -25,19 +25,22 @@ 3. [Recommended settings](#settings) 4. [FAQ](#faq) 4.1. [I installed syntastic but it isn't reporting any errors...](#faqinfo) -4.2. [The `python` checker complains about syntactically valid Python 3 constructs...](#faqpython3) -4.3. [Are there any local checkers for HTML5 that I can use with syntastic?](#faqhtml5) -4.4. [The `perl` checker has stopped working...](#faqperl) -4.5. [What happened to the `rustc` checker?](#faqrust) -4.6. [What happened to the `xcrun` checker?](#faqxcrun) -4.7. [I run a checker and the location list is not updated...](#faqloclist) -4.7. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist) -4.8. [How can I pass additional arguments to a checker?](#faqargs) -4.9. [Syntastic supports several checkers for my filetype - how do I tell which one(s) to use?](#faqcheckers) -4.10. [What is the difference between syntax checkers and style checkers?](#faqstyle) -4.11. [I have enabled multiple checkers for the current filetype. How can I display all of the errors from all of the checkers together?](#faqaggregate) -4.12. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext) -4.13. [The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?](#faqbdelete) +4.2. [How can I check scripts written for different versions of Python?](#faqpython) +4.3. [How can I check scripts written for different versions of Ruby?](#faqruby) +4.4. [Are there any local checkers for HTML5 that I can use with syntastic?](#faqhtml5) +4.5. [The `perl` checker has stopped working...](#faqperl) +4.6. [What happened to the `rustc` checker?](#faqrust) +4.7. [What happened to the `tsc` checker?](#faqtsc) +4.8. [What happened to the `xcrun` checker?](#faqxcrun) +4.9. [I run a checker and the location list is not updated...](#faqloclist) +4.9. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist) +4.10. [How can I pass additional arguments to a checker?](#faqargs) +4.11. [Syntastic supports several checkers for my filetype - how do I tell which one(s) to use?](#faqcheckers) +4.12. [What is the difference between syntax checkers and style checkers?](#faqstyle) +4.13. [I have enabled multiple checkers for the current filetype. How can I display all errors from all checkers together?](#faqaggregate) +4.14. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext) +4.15. [My favourite checker needs to load a configuration file from the project's root rather than the current directory...](#faqconfig) +4.16. [The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?](#faqbdelete) 5. [Resources](#otherresources) - - - @@ -46,35 +49,38 @@ ## 1\. Introduction -Syntastic is a syntax checking plugin for [Vim][13] that runs files through +Syntastic is a syntax checking plugin for [Vim][vim] that runs files through external syntax checkers and displays any resulting errors to the user. This can be done on demand, or automatically as files are saved. If syntax errors are detected, the user is notified and is happy because they didn't have to compile their code or execute their script to find them. -At the time of this writing, syntastic has checking plugins for ActionScript, -Ada, API Blueprint, AppleScript, AsciiDoc, ASM, BEMHTML, Bro, Bourne shell, C, +At the time of this writing, syntastic has checking plugins for ACPI +Source Language, ActionScript, Ada, Ansible configurations, API Blueprint, +AppleScript, AsciiDoc, Assembly languages, BEMHTML, Bro, Bourne shell, C, C++, C#, Cabal, Chef, CoffeeScript, Coco, Coq, CSS, Cucumber, CUDA, D, Dart, -DocBook, Dust, Elixir, Erlang, eRuby, Fortran, Gentoo metadata, GLSL, Go, Haml, -Haskell, Haxe, Handlebars, HSS, HTML, Java, JavaScript, JSON, JSX, LESS, Lex, -Limbo, LISP, LLVM intermediate language, Lua, Markdown, MATLAB, Mercury, NASM, -Nix, Objective-C, Objective-C++, OCaml, Perl, Perl POD, PHP, gettext Portable -Object, OS X and iOS property lists, Puppet, Python, R, Racket, Relax NG, -reStructuredText, RPM spec, Ruby, SASS/SCSS, Scala, Slim, SML, Sphinx, Tcl, -TeX, Texinfo, Twig, TypeScript, Vala, Verilog, VHDL, VimL, xHtml, XML, XSLT, -YACC, YAML, z80, Zope page templates, and zsh. See the [wiki][3] for details -about the corresponding supported checkers. +DocBook, Dockerfile, Dust, Elixir, Erlang, eRuby, Fortran, Gentoo metadata, +GLSL, Go, Haml, Haskell, Haxe, Handlebars, HSS, HTML, Java, JavaScript, JSON, +JSX, LESS, Lex, Limbo, LISP, LLVM intermediate language, Lua, Markdown, +MATLAB, Mercury, NASM, Nix, Objective-C, Objective-C++, OCaml, Perl, Perl +POD, PHP, gettext Portable Object, OS X and iOS property lists, Pug (formerly +Jade), Puppet, Python, QML, R, Racket, RDF TriG, RDF Turtle, Relax NG, +reStructuredText, RPM spec, Ruby, SASS/SCSS, Scala, Slim, SML, Solidity, +Sphinx, SQL, Stylus, Tcl, TeX, Texinfo, Twig, TypeScript, Vala, Verilog, +VHDL, VimL, xHtml, XML, XSLT, XQuery, YACC, YAML, YANG data models, z80, Zope +page templates, and Zsh. See the [manual][checkers] for details about the +corresponding supported checkers (`:help syntastic-checkers` in Vim). -A number of third-party Vim plugins also provide checkers for syntastic, -for example: [omnisharp-vim][25], [rust.vim][12], [syntastic-extras][26], -[syntastic-more][27], [vim-crystal][29], [vim-eastwood][28], and -[vim-swift][24]. +A number of third-party Vim plugins also provide checkers for syntastic, for +example: [merlin][merlin], [omnisharp-vim][omnisharp], [rust.vim][rust], +[syntastic-extras][myint], [syntastic-more][roktas], [tsuquyomi][tsuquyomi], +[vim-crystal][crystal], [vim-eastwood][eastwood], and [vim-swift][swift]. Below is a screenshot showing the methods that Syntastic uses to display syntax -errors. Note that, in practise, you will only have a subset of these methods +errors. Note that, in practise, you will only have a subset of these methods enabled. -![Screenshot 1][0] +![Screenshot 1][screenshot] 1. Errors are loaded into the location list for the corresponding window. 2. When the cursor is on a line containing an error, the error message is echoed in the command window. @@ -92,7 +98,7 @@ enabled. ### 2.1\. Requirements Syntastic itself has rather relaxed requirements: it doesn't have any external -dependencies, and it needs a version of [Vim][13] compiled with a few common +dependencies, and it needs a version of [Vim][vim] compiled with a few common features: `autocmd`, `eval`, `file_in_path`, `modify_fname`, `quickfix`, `reltime`, and `user_commands`. Not all possible combinations of features that include the ones above make equal sense on all operating systems, but Vim @@ -100,28 +106,35 @@ version 7 or later with the "normal", "big", or "huge" feature sets should be fine. Syntastic should work with any modern plugin managers for Vim, such as -[NeoBundle][14], [Pathogen][1], [Vim-Addon-Manager][15], [Vim-Plug][16], or -[Vundle][17]. Instructions for installing syntastic with [Pathogen][1] are +[NeoBundle][neobundle], [Pathogen][pathogen], [Vim-Addon-Manager][vam], [Vim-Plug][plug], or +[Vundle][vundle]. Instructions for installing syntastic with [Pathogen][pathogen] are included below for completeness. +Starting with Vim version 7.4.1486 you can also load syntastic using the +standard mechanism of packages, without the help of third-party plugin managers +(see `:help packages` in Vim for details). Beware however that, while support +for packages has been added in Vim 7.4.1384, the functionality needed by +syntastic is present only in versions 7.4.1486 and later. + Last but not least: syntastic doesn't know how to do any syntax checks by itself. In order to get meaningful results you need to install external checkers corresponding to the types of files you use. Please consult the -[wiki][3] for a list of supported checkers. +[manual][checkers] (`:help syntastic-checkers` in Vim) for a list of supported +checkers. ### 2.2\. Installing syntastic with Pathogen -If you already have [Pathogen][1] working then skip [Step 1](#step1) and go to +If you already have [Pathogen][pathogen] working then skip [Step 1](#step1) and go to [Step 2](#step2). #### 2.2.1\. Step 1: Install pathogen.vim -First I'll show you how to install Tim Pope's [Pathogen][1] so that it's easy to -install syntastic. Do this in your terminal so that you get the `pathogen.vim` +First I'll show you how to install Tim Pope's [Pathogen][pathogen] so that it's easy to +install syntastic. Do this in your terminal so that you get the `pathogen.vim` file and the directories it needs: ```sh mkdir -p ~/.vim/autoload ~/.vim/bundle && \ @@ -140,14 +153,14 @@ You now have pathogen installed and can put syntastic into `~/.vim/bundle` like this: ```sh cd ~/.vim/bundle && \ -git clone https://github.com/scrooloose/syntastic.git +git clone --depth=1 https://github.com/scrooloose/syntastic.git ``` Quit vim and start it back up to reload it, then type: ```vim :Helptags ``` If you get an error when you do this, then you probably didn't install -[Pathogen][1] right. Go back to [Step 1](#step1) and make sure you did the +[Pathogen][pathogen] right. Go back to [Step 1](#step1) and make sure you did the following: 1. Created both the `~/.vim/autoload` and `~/.vim/bundle` directories. @@ -159,10 +172,10 @@ following: ## 3\. Recommended settings -Syntastic has a large number of options that can be configured, and the -defaults are not particularly well suitable for new users. It is recommended -that you start by adding the following lines to your `vimrc` file, and return -to them after reading the manual (see `:help syntastic` in Vim): +Syntastic has numerous options that can be configured, and the defaults +are not particularly well suitable for new users. It is recommended +that you start by adding the following lines to your `vimrc` file, and +return to them after reading the manual (see `:help syntastic` in Vim): ```vim set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} @@ -183,11 +196,12 @@ let g:syntastic_check_on_wq = 0 __4.1. Q. I installed syntastic but it isn't reporting any errors...__ A. The most likely reason is that none of the syntax checkers that it requires -is installed. For example: by default, python requires either `flake8` or -`pylint` to be installed and in your `$PATH`. To see which executables are -supported, look at the [wiki][3]. Note that aliases do not work; the actual -executables must be available in your `$PATH`. Symbolic links are okay though. -You can see syntastic's idea of available checkers by running `:SyntasticInfo`. +are installed. For example: by default, python requires either `flake8` or +`pylint` to be installed and in your `$PATH`. Read the [manual][checkers] +(`:help syntastic-checkers` in Vim) to find out what executables are +supported. Note that aliases do not work; the actual executables must be +available in your `$PATH`. Symbolic links are okay though. You can see +syntastic's idea of available checkers by running `:SyntasticInfo`. A second probable reason is that none of the available checkers are enabled. Syntastic comes preconfigured with a default list of enabled checkers @@ -214,76 +228,105 @@ on Windows. Finally, another reason it could fail is that either the command line options or the error output for a syntax checker may have changed. In this case, make sure you have the latest version of the syntax checker installed. If it still -fails then post an [issue][4] - or better yet, create a pull request. +fails then post an [issue][bug_tracker] - or better yet, create a pull request. - + -__4.2. Q. The `python` checker complains about syntactically valid Python 3 constructs...__ +__4.2. Q. How can I check scripts written for different versions of Python?__ -A. Configure the `python` checker to call a Python 3 interpreter rather than -Python 2, e.g: -```vim -let g:syntastic_python_python_exec = '/path/to/python3' -``` +A. Install a Python version manager such as [virtualenv][virtualenv] +or [pyenv][pyenv], activate the environment for the relevant version +of Python, and install in it the checkers you want to use. Set +`g:syntastic_python_checkers` accordingly in your `vimrc`, and run [Vim][vim] +from the virtual environment. + +If you're starting Vim from a desktop manager rather than from a terminal you +might need to write wrapper scripts around your checkers, to activate the +virtual environment before running the actual checks. Then you'll need to +point the relevant `g:syntastic_python__exec` variables to the wrapper +scripts. + + + +__4.3. Q. How can I check scripts written for different versions of Ruby?__ + +A. Install a Ruby version manager such as [rvm][rvm] or [rbenv][rbenv], +activate the environment for the relevant version of Ruby, and install in it +the checkers you want to use. Set `g:syntastic_ruby_checkers` accordingly in +your `vimrc`, and run [Vim][vim] from the virtual environment. + +If you're starting Vim from a desktop manager rather than from a terminal you +might need to write wrapper scripts around your checkers, to activate the +virtual environment before running the actual checks. Then you'll need to +point the relevant `g:syntastic_ruby__exec` variables to the wrapper +scripts. -__4.3. Q. Are there any local checkers for HTML5 that I can use with syntastic?__ +__4.4. Q. Are there any local checkers for HTML5 that I can use with syntastic?__ -[HTML Tidy][18] has a fork named [HTML Tidy for HTML5][19]. It's a drop -in replacement, and syntastic can use it without changes. Just install it +[HTML Tidy][tidy_old] has a fork named [HTML Tidy for HTML5][tidy]. It's a drop +in replacement, and syntastic can use it without changes. Just install it somewhere and point `g:syntastic_html_tidy_exec` to its executable: ```vim let g:syntastic_html_tidy_exec = 'tidy5' ``` -Alternatively, you can install [vnu.jar][21] from the [validator.nu][20] -project and run it as a [HTTP server][23]: +Alternatively, you can install [vnu.jar][vnu_jar] from the [validator.nu][vnu] +project and run it as a [HTTP server][vnu_server]: ```sh $ java -Xss512k -cp /path/to/vnu.jar nu.validator.servlet.Main 8888 ``` -Then you can [configure][22] syntastic to use it: +Then you can configure syntastic to use it: ```vim let g:syntastic_html_validator_api = 'http://localhost:8888/' ``` -__4.4. Q. The `perl` checker has stopped working...__ +__4.5. Q. The `perl` checker has stopped working...__ A. The `perl` checker runs `perl -c` against your file, which in turn __executes__ any `BEGIN`, `UNITCHECK`, and `CHECK` blocks, and any `use` -statements in your file (cf. [perlrun][10]). This is probably fine if you -wrote the file yourself, but it's a security problem if you're checking third -party files. Since there is currently no way to disable this behaviour while -still producing useful results, the checker is now disabled by default. To -(re-)enable it, make sure the `g:syntastic_perl_checkers` list includes `perl`, -and set `g:syntastic_enable_perl_checker` to 1 in your `vimrc`: +statements in your file (cf. [perlrun][perlrun]). This is probably fine if you +wrote the file yourself, but it's a security problem if you're checking +third-party files. Since there is currently no way to disable this behaviour +while still producing useful results, the checker is now disabled by default. +To (re-)enable it, make sure the `g:syntastic_perl_checkers` list includes +`perl`, and set `g:syntastic_enable_perl_checker` to 1 in your `vimrc`: ```vim let g:syntastic_enable_perl_checker = 1 ``` -__4.5. Q. What happened to the `rustc` checker?__ +__4.6. Q. What happened to the `rustc` checker?__ -A. It is now part of the [rust.vim][12] plugin. If you install this plugin the +A. It is now part of the [rust.vim][rust] plugin. If you install this plugin the checker should be picked up automatically by syntastic. + + +__4.7. Q. What happened to the `tsc` checker?__ + +A. It didn't meet people's expectations and it has been removed. Please +consider using the external checker [tsuquyomi][tsuquyomi] instead. If you +install this plugin the checker should be picked up automatically by syntastic. + -__4.6. Q. What happened to the `xcrun` checker?__ +__4.8. Q. What happened to the `xcrun` checker?__ A. The `xcrun` checker used to have a security problem and it has been removed. -A better checker for __Swift__ is part of the [vim-swift][24] plugin. If you +A better checker for __Swift__ is part of the [vim-swift][swift] plugin. If you install this plugin the checker should be picked up automatically by syntastic. -__4.7. Q. I run a checker and the location list is not updated...__ -__4.7. Q. I run`:lopen` or `:lwindow` and the error window is empty...__ +__4.9. Q. I run a checker and the location list is not updated...__ +__4.9. Q. I run`:lopen` or `:lwindow` and the error window is empty...__ A. By default the location list is changed only when you run the `:Errors` -command, in order to minimise conflicts with other plugins. If you want the +command, in order to minimise conflicts with other plugins. If you want the location list to always be updated when you run the checkers, add this line to your `vimrc`: ```vim @@ -292,7 +335,7 @@ let g:syntastic_always_populate_loc_list = 1 -__4.8. Q. How can I pass additional arguments to a checker?__ +__4.10. Q. How can I pass additional arguments to a checker?__ A. Almost all syntax checkers use the `makeprgBuild()` function. Those checkers that do can be configured using global variables. The general form of the @@ -308,7 +351,7 @@ See `:help syntastic-checker-options` for more information. -__4.9. Q. Syntastic supports several checkers for my filetype - how do I tell it +__4.11. Q. Syntastic supports several checkers for my filetype - how do I tell it which one(s) to use?__ A. Stick a line like this in your `vimrc`: @@ -316,8 +359,8 @@ A. Stick a line like this in your `vimrc`: let g:syntastic__checkers = [''] ``` -To see the list of supported checkers for your filetype look at the -[wiki][3]. +To see the list of supported checkers for your filetype read the +[manual][checkers] (`:help syntastic-checkers` in Vim). e.g. Python has the following checkers, among others: `flake8`, `pyflakes`, `pylint` and a native `python` checker. @@ -349,7 +392,7 @@ filetype of the current file is `php`). -__4.10. Q. What is the difference between syntax checkers and style checkers?__ +__4.12. Q. What is the difference between syntax checkers and style checkers?__ A. The errors and warnings they produce are highlighted differently and can be filtered by different rules, but otherwise the distinction is pretty much @@ -366,7 +409,7 @@ nature, produce both kinds of messages. Syntastic is not smart enough to be able to sort out these things by itself. In fact it's more useful to look at this from the perspective of filtering -unwanted messages, rather than as an indicator of severity levels. The +unwanted messages, rather than as an indicator of severity levels. The distinction between syntax and style is orthogonal to the distinction between errors and warnings, and thus you can turn off messages based on level, on type, or both. @@ -379,8 +422,8 @@ See `:help syntastic_quiet_messages` for details. -__4.11. Q. I have enabled multiple checkers for the current filetype. How can I -display all of the errors from all of the checkers together?__ +__4.13. Q. I have enabled multiple checkers for the current filetype. How can I +display all errors from all checkers together?__ A. Set `g:syntastic_aggregate_errors` to 1 in your `vimrc`: ```vim @@ -391,19 +434,38 @@ See `:help syntastic-aggregating-errors` for more details. -__4.12. Q. How can I jump between the different errors without using the location +__4.14. Q. How can I jump between the different errors without using the location list at the bottom of the window?__ A. Vim provides several built-in commands for this. See `:help :lnext` and `:help :lprevious`. If you use these commands a lot then you may want to add shortcut mappings to -your `vimrc`, or install something like [unimpaired][2], which provides such +your `vimrc`, or install something like [unimpaired][unimpaired], which provides such mappings (among other things). + + +__4.15. My favourite checker needs to load a configuration file from the +project's root rather than the current directory...__ + +A. You can set up an `autocmd` to search for the configuration file in the +current directory and upwards, and add it to the checker's options when found. +For example for `jscs`: + +```vim +function! FindConfig(prefix, what, where) + let cfg = findfile(a:what, escape(a:where, ' ') . ';') + return cfg !=# '' ? ' ' . a:prefix . ' ' . shellescape(cfg) : '' +endfunction + +autocmd FileType javascript let b:syntastic_javascript_jscs_args = + \ get(g:, 'syntastic_javascript_jscs_args', '') . + \ FindConfig('-c', '.jscsrc', expand(':p:h', 1)) +``` -__4.13. Q. The error window is closed automatically when I :quit the current buffer +__4.16. Q. The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?__ A. There is no safe way to handle that situation automatically, but you can @@ -419,46 +481,55 @@ cabbrev bd =(getcmdtype()==#':' && getcmdpos()==1 ? 'lclose\|bdele ## 5\. Resources The preferred place for posting suggestions, reporting bugs, and general -discussions related to syntastic is the [issue tracker at GitHub][4]. -A guide for writing syntax checkers can be found in the [wiki][11]. -There are also a dedicated [google group][5], and a -[syntastic tag at StackOverflow][6]. +discussions related to syntastic is the [issue tracker at GitHub][bug_tracker]. +A guide for writing syntax checkers can be found in the [wiki][guide]. +There are also a dedicated [google group][google_group], and a +[syntastic tag at StackOverflow][stack_overflow]. Syntastic aims to provide a common interface to syntax checkers for as many -languages as possible. For particular languages, there are, of course, other -plugins that provide more functionality than syntastic. You might want to take -a look at [jedi-vim][7], [python-mode][8], or [YouCompleteMe][9]. +languages as possible. For particular languages, there are, of course, other +plugins that provide more functionality than syntastic. You might want to take +a look at [ghcmod-vim][ghcmod], [jedi-vim][jedi], [python-mode][python_mode], [vim-go][vimgo], or +[YouCompleteMe][ycm]. -[0]: https://github.com/scrooloose/syntastic/raw/master/_assets/screenshot_1.png -[1]: https://github.com/tpope/vim-pathogen -[2]: https://github.com/tpope/vim-unimpaired -[3]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checkers -[4]: https://github.com/scrooloose/syntastic/issues -[5]: https://groups.google.com/group/vim-syntastic -[6]: http://stackoverflow.com/questions/tagged/syntastic -[7]: https://github.com/davidhalter/jedi-vim -[8]: https://github.com/klen/python-mode -[9]: http://valloric.github.io/YouCompleteMe/ -[10]: http://perldoc.perl.org/perlrun.html#*-c* -[11]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide -[12]: https://github.com/rust-lang/rust.vim -[13]: http://www.vim.org/ -[14]: https://github.com/Shougo/neobundle.vim -[15]: https://github.com/MarcWeber/vim-addon-manager -[16]: https://github.com/junegunn/vim-plug/ -[17]: https://github.com/gmarik/Vundle.vim -[18]: http://tidy.sourceforge.net/ -[19]: http://www.htacg.org/tidy-html5/ -[20]: http://about.validator.nu/ -[21]: https://github.com/validator/validator/releases/latest -[22]: https://github.com/scrooloose/syntastic/wiki/HTML%3A---validator -[23]: http://validator.github.io/validator/#standalone -[24]: https://github.com/kballard/vim-swift -[25]: https://github.com/OmniSharp/omnisharp-vim -[26]: https://github.com/myint/syntastic-extras -[27]: https://github.com/roktas/syntastic-more -[28]: https://github.com/venantius/vim-eastwood -[29]: https://github.com/rhysd/vim-crystal +[screenshot]: https://github.com/scrooloose/syntastic/raw/master/_assets/screenshot_1.png + +[bug_tracker]: https://github.com/scrooloose/syntastic/issues +[checkers]: https://github.com/scrooloose/syntastic/blob/master/doc/syntastic-checkers.txt +[crystal]: https://github.com/rhysd/vim-crystal +[eastwood]: https://github.com/venantius/vim-eastwood +[ghcmod]: https://github.com/eagletmt/ghcmod-vim +[google_group]: https://groups.google.com/group/vim-syntastic +[guide]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide +[jedi]: https://github.com/davidhalter/jedi-vim +[merlin]: https://github.com/the-lambda-church/merlin +[myint]: https://github.com/myint/syntastic-extras +[neobundle]: https://github.com/Shougo/neobundle.vim +[omnisharp]: https://github.com/OmniSharp/omnisharp-vim +[pathogen]: https://github.com/tpope/vim-pathogen +[perlrun]: http://perldoc.perl.org/perlrun.html#*-c* +[plug]: https://github.com/junegunn/vim-plug/ +[pyenv]: https://github.com/yyuu/pyenv +[python_mode]: https://github.com/klen/python-mode +[rbenv]: https://github.com/rbenv/rbenv +[roktas]: https://github.com/roktas/syntastic-more +[rust]: https://github.com/rust-lang/rust.vim +[rvm]: https://rvm.io/ +[stack_overflow]: http://stackoverflow.com/questions/tagged/syntastic +[swift]: https://github.com/kballard/vim-swift +[tidy]: http://www.htacg.org/tidy-html5/ +[tidy_old]: http://tidy.sourceforge.net/ +[tsuquyomi]: https://github.com/Quramy/tsuquyomi/ +[unimpaired]: https://github.com/tpope/vim-unimpaired +[vam]: https://github.com/MarcWeber/vim-addon-manager +[vim]: http://www.vim.org/ +[vimgo]: https://github.com/fatih/vim-go +[virtualenv]: https://virtualenv.pypa.io/en/stable/ +[vnu]: http://about.validator.nu/ +[vnu_jar]: https://github.com/validator/validator/releases/latest +[vnu_server]: http://validator.github.io/validator/#standalone +[vundle]: https://github.com/gmarik/Vundle.vim +[ycm]: http://valloric.github.io/YouCompleteMe/