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/ + +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets b/sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets index d08d72eb..fcb82985 100644 --- a/sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets +++ b/sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets @@ -151,14 +151,7 @@ if err != nil { ${0} endsnippet -# error snippet -snippet errt "Error test fatal " !b -if err != nil { - t.Fatal(err) -} -${0} -endsnippet - +# error multiple return snippet errn, "Error return with two return values" !b if err != nil { return ${1:nil}, err @@ -166,6 +159,23 @@ if err != nil { ${0} endsnippet +# error panic +snippet errp "Error panic" !b +if err != nil { + panic(${1}) +} +${0} +endsnippet + +# error test +snippet errt "Error test fatal " !b +if err != nil { + t.Fatal(err) +} +${0} +endsnippet + +# error handle snippet errh "Error handle and return" !b if err != nil { ${1} @@ -174,8 +184,14 @@ if err != nil { ${0} endsnippet +# json field tag snippet json "\`json:key\`" -\`json:"${1:keyName}"\` +\`json:"${1:`!v go#util#snippetcase(matchstr(getline("."), '\w\+'))`}"\` +endsnippet + +# yaml field tag +snippet yaml "\`yaml:key\`" +\`yaml:"${1:`!v go#util#snippetcase(matchstr(getline("."), '\w\+'))`}"\` endsnippet # fallthrough @@ -327,6 +343,18 @@ func Test${1:Function}(t *testing.T) { } endsnippet +snippet hf "http.HandlerFunc" !b +func ${1:handler}(w http.ResponseWriter, r *http.Request) { + ${0:fmt.Fprintf(w, "hello world")} +} +endsnippet + +snippet hhf "mux.HandleFunc" !b +${1:http}.HandleFunc("${2:/}", func(w http.ResponseWriter, r *http.Request) { + ${0:fmt.Fprintf(w, "hello world")} +}) +endsnippet + # quick test server snippet tsrv "httptest.NewServer" ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -351,6 +379,21 @@ if err != nil { } endsnippet +snippet example "func ExampleXYZ() { ... }" +func Example${1:Method}() { + ${0:${VISUAL}} + // Output: +} +endsnippet + +snippet benchmark "func BenchmarkXYZ(b *testing.B) { ... }" +func Benchmark${1:Method}(b *testing.B) { + for i := 0; i < b.N; i++ { + ${0:${VISUAL}} + } +} +endsnippet + # variable declaration snippet var "var x Type [= ...]" var ${1:x} ${2:Type}${3: = ${0:value}} @@ -372,7 +415,6 @@ if !reflect.DeepEqual(${1:expected}, ${2:actual}) { } endsnippet - global !p import re diff --git a/sources_non_forked/vim-go/gosnippets/snippets/go.snip b/sources_non_forked/vim-go/gosnippets/snippets/go.snip index f7f23363..942a82e0 100644 --- a/sources_non_forked/vim-go/gosnippets/snippets/go.snip +++ b/sources_non_forked/vim-go/gosnippets/snippets/go.snip @@ -124,6 +124,7 @@ abbr if err != nil { ... } if err != nil { return err } + ${0} # error snippet in TestFunc snippet errt abbr if err != nil { ... } @@ -135,11 +136,10 @@ abbr if err != nil { ... } snippet errn, abbr if err != nil { return [...], err } if err != nil { - return ${2}$1, err + return ${1:nil}, err } ${0} - # error snippet handle and return snippet errh abbr if err != nil { return } @@ -149,10 +149,24 @@ abbr if err != nil { return } } ${0} +# error snippet with panic +snippet errp +abbr if err != nil { ... } + if err != nil { + panic(${1}) + } + ${0} + # json snippet snippet json abbr \`json:key\` \`json:"${1:keyName}"\` + +# yaml snippet +snippet yaml +abbr \`yaml:key\` + \`yaml:"${1:keyName}"\` + # fallthrough snippet ft abbr fallthrough @@ -304,6 +318,19 @@ abbr if err != nil { t.Fatalf(...) } if err != nil { t.Fatalf("${1}") } +# test example +snippet example + func Example${1:Method}() { + ${0} + // Output: + } +# test benchmark +snippet benchmark + func Benchmark${1:Method}(b *testing.B) { + for i := 0; i < b.N; i++ { + ${0} + } + } # variable declaration snippet var abbr var x Type [= ...] @@ -322,3 +349,15 @@ abbr equals: test two identifiers with DeepEqual fmt.Printf("%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\n\n", filepath.Base(file), line, $1, $2) t.FailNow() } + +snippet hf +abbr http.HandlerFunc + func ${1:handler}(w http.ResponseWriter, r *http.Request) { + ${0:fmt.Fprintf(w, "hello world")} + } + +snippet hhf +abbr mux.HandleFunc(...) + ${1:http}.HandleFunc("${2:/}", func(w http.ResponseWriter, r *http.Request) { + ${0:fmt.Fprintf(w, "hello world")} + }) diff --git a/sources_non_forked/vim-go/indent/go.vim b/sources_non_forked/vim-go/indent/go.vim index a3fa2b7a..ba99d54d 100644 --- a/sources_non_forked/vim-go/indent/go.vim +++ b/sources_non_forked/vim-go/indent/go.vim @@ -9,7 +9,7 @@ " - general line splits (line ends in an operator) if exists("b:did_indent") - finish + finish endif let b:did_indent = 1 @@ -21,58 +21,58 @@ setlocal indentexpr=GoIndent(v:lnum) setlocal indentkeys+=<:>,0=},0=) if exists("*GoIndent") - finish + finish endif " use shiftwidth function only if it's available if exists('*shiftwidth') - func s:sw() - return shiftwidth() - endfunc + func s:sw() + return shiftwidth() + endfunc else - func s:sw() - return &sw - endfunc + func s:sw() + return &sw + endfunc endif function! GoIndent(lnum) - let prevlnum = prevnonblank(a:lnum-1) - if prevlnum == 0 - " top of file - return 0 - endif + let prevlnum = prevnonblank(a:lnum-1) + if prevlnum == 0 + " top of file + return 0 + endif - " grab the previous and current line, stripping comments. - let prevl = substitute(getline(prevlnum), '//.*$', '', '') - let thisl = substitute(getline(a:lnum), '//.*$', '', '') - let previ = indent(prevlnum) + " grab the previous and current line, stripping comments. + let prevl = substitute(getline(prevlnum), '//.*$', '', '') + let thisl = substitute(getline(a:lnum), '//.*$', '', '') + let previ = indent(prevlnum) - let ind = previ + let ind = previ - if prevl =~ '[({]\s*$' - " previous line opened a block - let ind += s:sw() - endif - if prevl =~# '^\s*\(case .*\|default\):$' - " previous line is part of a switch statement - let ind += s:sw() - endif - " TODO: handle if the previous line is a label. + if prevl =~ '[({]\s*$' + " previous line opened a block + let ind += s:sw() + endif + if prevl =~# '^\s*\(case .*\|default\):$' + " previous line is part of a switch statement + let ind += s:sw() + endif + " TODO: handle if the previous line is a label. - if thisl =~ '^\s*[)}]' - " this line closed a block - let ind -= s:sw() - endif + if thisl =~ '^\s*[)}]' + " this line closed a block + let ind -= s:sw() + endif - " Colons are tricky. - " We want to outdent if it's part of a switch ("case foo:" or "default:"). - " We ignore trying to deal with jump labels because (a) they're rare, and - " (b) they're hard to disambiguate from a composite literal key. - if thisl =~# '^\s*\(case .*\|default\):$' - let ind -= s:sw() - endif + " Colons are tricky. + " We want to outdent if it's part of a switch ("case foo:" or "default:"). + " We ignore trying to deal with jump labels because (a) they're rare, and + " (b) they're hard to disambiguate from a composite literal key. + if thisl =~# '^\s*\(case .*\|default\):$' + let ind -= s:sw() + endif - return ind + return ind endfunction -" vim:ts=4:sw=4:et +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/indent/gohtmltmpl.vim b/sources_non_forked/vim-go/indent/gohtmltmpl.vim index 50399f2b..d95cbc24 100644 --- a/sources_non_forked/vim-go/indent/gohtmltmpl.vim +++ b/sources_non_forked/vim-go/indent/gohtmltmpl.vim @@ -3,3 +3,44 @@ if exists("b:did_indent") endif runtime! indent/html.vim + +" Indent Golang HTML templates +setlocal indentexpr=GetGoHTMLTmplIndent(v:lnum) +setlocal indentkeys+==else,=end + +" Only define the function once. +if exists("*GetGoHTMLTmplIndent") + finish +endif + +function! GetGoHTMLTmplIndent(lnum) + " Get HTML indent + if exists('*HtmlIndent') + let ind = HtmlIndent() + else + let ind = HtmlIndentGet(a:lnum) + endif + + " The value of a single shift-width + if exists('*shiftwidth') + let sw = shiftwidth() + else + let sw = &sw + endif + + " If need to indent based on last line + let last_line = getline(a:lnum-1) + if last_line =~ '^\s*{{\s*\%(if\|else\|range\|with\|define\|block\).*}}' + let ind += sw + endif + + " End of FuncMap block + let current_line = getline(a:lnum) + if current_line =~ '^\s*{{\s*\%(else\|end\).*}}' + let ind -= sw + endif + + return ind +endfunction + +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/plugin/go.vim b/sources_non_forked/vim-go/plugin/go.vim index e28b060e..6c050083 100644 --- a/sources_non_forked/vim-go/plugin/go.vim +++ b/sources_non_forked/vim-go/plugin/go.vim @@ -1,138 +1,205 @@ " install necessary Go tools if exists("g:go_loaded_install") - finish + finish endif let g:go_loaded_install = 1 - " these packages are used by vim-go and can be automatically installed if " needed by the user with GoInstallBinaries let s:packages = [ - \ "github.com/nsf/gocode", - \ "golang.org/x/tools/cmd/goimports", - \ "github.com/rogpeppe/godef", - \ "golang.org/x/tools/cmd/oracle", - \ "golang.org/x/tools/cmd/gorename", - \ "github.com/golang/lint/golint", - \ "github.com/kisielk/errcheck", - \ "github.com/jstemmer/gotags", - \ ] + \ "github.com/nsf/gocode", + \ "github.com/alecthomas/gometalinter", + \ "golang.org/x/tools/cmd/goimports", + \ "golang.org/x/tools/cmd/guru", + \ "golang.org/x/tools/cmd/gorename", + \ "github.com/golang/lint/golint", + \ "github.com/rogpeppe/godef", + \ "github.com/kisielk/errcheck", + \ "github.com/jstemmer/gotags", + \ "github.com/klauspost/asmfmt/cmd/asmfmt", + \ "github.com/fatih/motion", + \ "github.com/zmb3/gogetdoc", + \ "github.com/josharian/impl", + \ ] " These commands are available on any filetypes command! GoInstallBinaries call s:GoInstallBinaries(-1) command! GoUpdateBinaries call s:GoInstallBinaries(1) command! -nargs=? -complete=dir GoPath call go#path#GoPath() - " GoInstallBinaries downloads and install all necessary binaries stated in the " packages variable. It uses by default $GOBIN or $GOPATH/bin as the binary " target install directory. GoInstallBinaries doesn't install binaries if they " exist, to update current binaries pass 1 to the argument. function! s:GoInstallBinaries(updateBinaries) - if $GOPATH == "" - echohl Error - echomsg "vim.go: $GOPATH is not set" - echohl None - return + if $GOPATH == "" + echohl Error + echomsg "vim.go: $GOPATH is not set" + echohl None + return + endif + + let err = s:CheckBinaries() + if err != 0 + return + endif + + let go_bin_path = go#path#BinPath() + + " change $GOBIN so go get can automatically install to it + let $GOBIN = go_bin_path + + " old_path is used to restore users own path + let old_path = $PATH + + " vim's executable path is looking in PATH so add our go_bin path to it + let $PATH = go_bin_path . go#util#PathListSep() . $PATH + + " when shellslash is set on MS-* systems, shellescape puts single quotes + " around the output string. cmd on Windows does not handle single quotes + " correctly. Unsetting shellslash forces shellescape to use double quotes + " instead. + let resetshellslash = 0 + if has('win32') && &shellslash + let resetshellslash = 1 + set noshellslash + endif + + let cmd = "go get -v " + if get(g:, "go_get_update", 1) != 0 + let cmd .= "-u " + endif + + let s:go_version = matchstr(go#util#System("go version"), '\d.\d.\d') + + " https://github.com/golang/go/issues/10791 + if s:go_version > "1.4.0" && s:go_version < "1.5.0" + let cmd .= "-f " + endif + + for pkg in s:packages + let basename = fnamemodify(pkg, ":t") + let binname = "go_" . basename . "_bin" + + let bin = basename + if exists("g:{binname}") + let bin = g:{binname} endif - let err = s:CheckBinaries() - if err != 0 - return + if !executable(bin) || a:updateBinaries == 1 + if a:updateBinaries == 1 + echo "vim-go: Updating ". basename .". Reinstalling ". pkg . " to folder " . go_bin_path + else + echo "vim-go: ". basename ." not found. Installing ". pkg . " to folder " . go_bin_path + endif + + + let out = go#util#System(cmd . shellescape(pkg)) + if go#util#ShellError() != 0 + echo "Error installing ". pkg . ": " . out + endif endif + endfor - let go_bin_path = go#path#BinPath() - - " change $GOBIN so go get can automatically install to it - let $GOBIN = go_bin_path - - " old_path is used to restore users own path - let old_path = $PATH - - " vim's executable path is looking in PATH so add our go_bin path to it - let $PATH = $PATH . go#util#PathListSep() .go_bin_path - - " when shellslash is set on MS-* systems, shellescape puts single quotes - " around the output string. cmd on Windows does not handle single quotes - " correctly. Unsetting shellslash forces shellescape to use double quotes - " instead. - let resetshellslash = 0 - if has('win32') && &shellslash - let resetshellslash = 1 - set noshellslash - endif - - let cmd = "go get -u -v " - - let s:go_version = matchstr(system("go version"), '\d.\d.\d') - - " https://github.com/golang/go/issues/10791 - if s:go_version > "1.4.0" && s:go_version < "1.5.0" - let cmd .= "-f " - endif - - for pkg in s:packages - let basename = fnamemodify(pkg, ":t") - let binname = "go_" . basename . "_bin" - - let bin = basename - if exists("g:{binname}") - let bin = g:{binname} - endif - - if !executable(bin) || a:updateBinaries == 1 - if a:updateBinaries == 1 - echo "vim-go: Updating ". basename .". Reinstalling ". pkg . " to folder " . go_bin_path - else - echo "vim-go: ". basename ." not found. Installing ". pkg . " to folder " . go_bin_path - endif - - - let out = system(cmd . shellescape(pkg)) - if v:shell_error - echo "Error installing ". pkg . ": " . out - endif - endif - endfor - - " restore back! - let $PATH = old_path - if resetshellslash - set shellslash - endif + " restore back! + let $PATH = old_path + if resetshellslash + set shellslash + endif endfunction " CheckBinaries checks if the necessary binaries to install the Go tool " commands are available. function! s:CheckBinaries() - if !executable('go') - echohl Error | echomsg "vim-go: go executable not found." | echohl None - return -1 - endif + if !executable('go') + echohl Error | echomsg "vim-go: go executable not found." | echohl None + return -1 + endif - if !executable('git') - echohl Error | echomsg "vim-go: git executable not found." | echohl None - return -1 - endif + if !executable('git') + echohl Error | echomsg "vim-go: git executable not found." | echohl None + return -1 + endif endfunction " Autocommands " ============================================================================ +" +function! s:echo_go_info() + if !exists('v:completed_item') || empty(v:completed_item) + return + endif + let item = v:completed_item + + if !has_key(item, "info") + return + endif + + if empty(item.info) + return + endif + + redraws! | echo "vim-go: " | echohl Function | echon item.info | echohl None +endfunction + +function! s:auto_type_info() + " GoInfo automatic update + if get(g:, "go_auto_type_info", 0) + call go#complete#Info(1) + endif +endfunction + +function! s:auto_sameids() + " GoSameId automatic update + if get(g:, "go_auto_sameids", 0) + call go#guru#SameIds(-1) + endif +endfunction + +function! s:fmt_autosave() + " Go code formatting on save + if get(g:, "go_fmt_autosave", 1) + call go#fmt#Format(-1) + endif +endfunction + +function! s:asmfmt_autosave() + " Go asm formatting on save + if get(g:, "go_asmfmt_autosave", 1) + call go#asmfmt#Format() + endif +endfunction + +function! s:metalinter_autosave() + " run gometalinter on save + if get(g:, "go_metalinter_autosave", 0) + call go#lint#Gometa(1) + endif +endfunction + +function! s:template_autocreate() + " create new template from scratch + if get(g:, "go_template_autocreate", 1) + call go#template#create() + endif +endfunction augroup vim-go - autocmd! + autocmd! - " GoInfo automatic update - if get(g:, "go_auto_type_info", 0) - autocmd CursorHold *.go nested call go#complete#Info() - endif + autocmd CursorHold *.go call s:auto_type_info() + autocmd CursorHold *.go call s:auto_sameids() - " code formatting on save - if get(g:, "go_fmt_autosave", 1) - autocmd BufWritePre *.go call go#fmt#Format(-1) - endif + " Echo the identifier information when completion is done. Useful to see + " the signature of a function, etc... + if exists('##CompleteDone') + autocmd CompleteDone *.go call s:echo_go_info() + endif + autocmd BufWritePre *.go call s:fmt_autosave() + autocmd BufWritePre *.s call s:asmfmt_autosave() + autocmd BufWritePost *.go call s:metalinter_autosave() + autocmd BufNewFile *.go call s:template_autocreate() augroup END - -" vim:ts=4:sw=4:et +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/syntax/go.vim b/sources_non_forked/vim-go/syntax/go.vim index 0c606ecc..987485a0 100644 --- a/sources_non_forked/vim-go/syntax/go.vim +++ b/sources_non_forked/vim-go/syntax/go.vim @@ -10,9 +10,9 @@ " let OPTION_NAME = 0 " in your ~/.vimrc file to disable particular options. You can also write: " let OPTION_NAME = 1 -" to enable particular options. +" to enable particular options. " At present, all options default to on, except highlight of: -" functions, methods and structs. +" functions, methods, structs, operators, build constraints and interfaces. " " - go_highlight_array_whitespace_error " Highlights white space after "[]". @@ -25,6 +25,10 @@ " Highlights instances of tabs following spaces. " - go_highlight_trailing_whitespace_error " Highlights trailing white space. +" - go_highlight_string_spellcheck +" Specifies that strings should be spell checked +" - go_highlight_format_strings +" Highlights printf-style operators inside string literals. " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -52,34 +56,48 @@ if !exists("g:go_highlight_trailing_whitespace_error") endif if !exists("g:go_highlight_operators") - let g:go_highlight_operators = 0 + let g:go_highlight_operators = 0 endif if !exists("g:go_highlight_functions") - let g:go_highlight_functions = 0 + let g:go_highlight_functions = 0 endif if !exists("g:go_highlight_methods") - let g:go_highlight_methods = 0 + let g:go_highlight_methods = 0 endif -if !exists("g:go_highlight_structs") - let g:go_highlight_structs = 0 +if !exists("g:go_highlight_fields") + let g:go_highlight_fields = 0 +endif + +if !exists("g:go_highlight_types") + let g:go_highlight_types = 0 endif if !exists("g:go_highlight_build_constraints") - let g:go_highlight_build_constraints = 0 + let g:go_highlight_build_constraints = 0 +endif + +if !exists("g:go_highlight_string_spellcheck") + let g:go_highlight_string_spellcheck = 1 +endif + +if !exists("g:go_highlight_format_strings") + let g:go_highlight_format_strings = 1 +endif + +if !exists("g:go_highlight_generate_tags") + let g:go_highlight_generate_tags = 0 endif syn case match syn keyword goDirective package import -syn keyword goDeclaration var const type -syn keyword goDeclType struct interface +syn keyword goDeclaration var const hi def link goDirective Statement hi def link goDeclaration Keyword -hi def link goDeclType Keyword " Keywords within functions syn keyword goStatement defer go goto return break continue fallthrough @@ -105,14 +123,10 @@ hi def link goUnsignedInts Type hi def link goFloats Type hi def link goComplexes Type -" Treat func specially: it's a declaration at the start of a line, but a type -" elsewhere. Order matters here. -syn match goDeclaration /\/ - " Predefined functions and values -syn keyword goBuiltins append cap close complex copy delete imag len -syn keyword goBuiltins make new panic print println real recover +syn match goBuiltins /\<\v(append|cap|close|complex|copy|delete|imag|len)\ze\(/ +syn match goBuiltins /\<\v(make|new|panic|print|println|real|recover)\ze\(/ syn keyword goBoolean iota true false nil hi def link goBuiltins Keyword @@ -122,11 +136,18 @@ hi def link goBoolean Boolean syn keyword goTodo contained TODO FIXME XXX BUG syn cluster goCommentGroup contains=goTodo syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell -syn region goComment start="//" end="$" contains=@goCommentGroup,@Spell +syn region goComment start="//" end="$" contains=goGenerate,@goCommentGroup,@Spell hi def link goComment Comment hi def link goTodo Todo +if g:go_highlight_generate_tags != 0 + syn match goGenerateVariables contained /\(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/ + syn region goGenerate start="^\s*//go:generate" end="$" contains=goGenerateVariables + hi def link goGenerate PreProc + hi def link goGenerateVariables Special +endif + " Go escapes syn match goEscapeOctal display contained "\\[0-7]\{3}" syn match goEscapeC display contained +\\[abfnrtv\\'"]+ @@ -145,13 +166,21 @@ hi def link goEscapeError Error " Strings and their contents syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError -syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup -syn region goRawString start=+`+ end=+`+ -syn match goFormatSpecifier /%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)*[vTtbcdoqxXUeEfgGsp]/ contained containedin=goString +if g:go_highlight_string_spellcheck != 0 + syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup,@Spell + syn region goRawString start=+`+ end=+`+ contains=@Spell +else + syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup + syn region goRawString start=+`+ end=+`+ +endif + +if g:go_highlight_format_strings != 0 + syn match goFormatSpecifier /%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)*[vTtbcdoqxXUeEfgGsp]/ contained containedin=goString + hi def link goFormatSpecifier goSpecialString +endif hi def link goString String hi def link goRawString String -hi def link goFormatSpecifier goSpecialString " Characters; their contents syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU @@ -164,30 +193,31 @@ syn region goBlock start="{" end="}" transparent fold syn region goParen start='(' end=')' transparent " Integers -syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>" -syn match goHexadecimalInt "\<0x\x\+\>" -syn match goOctalInt "\<0\o\+\>" -syn match goOctalError "\<0\o*[89]\d*\>" +syn match goDecimalInt "\<-\=\d\+\%([Ee][-+]\=\d\+\)\=\>" +syn match goHexadecimalInt "\<-\=0[xX]\x\+\>" +syn match goOctalInt "\<-\=0\o\+\>" +syn match goOctalError "\<-\=0\o*[89]\d*\>" hi def link goDecimalInt Integer hi def link goHexadecimalInt Integer hi def link goOctalInt Integer +hi def link goOctalError Error hi def link Integer Number " Floating point -syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" -syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>" -syn match goFloat "\<\d\+[Ee][-+]\d\+\>" +syn match goFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=\>" +syn match goFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=\>" hi def link goFloat Float " Imaginary literals -syn match goImaginary "\<\d\+i\>" -syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>" -syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>" -syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>" +syn match goImaginary "\<-\=\d\+i\>" +syn match goImaginary "\<-\=\d\+[Ee][-+]\=\d\+i\>" +syn match goImaginaryFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=i\>" +syn match goImaginaryFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=i\>" hi def link goImaginary Number +hi def link goImaginaryFloat Float " Spaces after "[]" if g:go_highlight_array_whitespace_error != 0 @@ -197,9 +227,17 @@ endif " Spacing errors around the 'chan' keyword if g:go_highlight_chan_whitespace_error != 0 " receive-only annotation on chan type - syn match goSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@=" + " + " \(\\)\@\)\@\)\@=" + " send-only annotation on chan type - syn match goSpaceError display "\(\ (only pick chan when it doesn't come after an arrow) + " this prevents picking up '<-chan <-chan' but not 'chan <-' + syn match goSpaceError display "\(\(<-\)\@\)\@<=\s\+\(<-\)\@=" + " value-ignoring receives in a few contexts syn match goSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+" endif @@ -233,59 +271,122 @@ hi def link goSpaceError Error syn keyword goTodo contained NOTE hi def link goTodo Todo +syn match goVarArgs /\.\.\./ -" Operators; +" Operators; if g:go_highlight_operators != 0 - " match single-char operators: - + % < > ! & | ^ * = - " and corresponding two-char operators: -= += %= <= >= != &= |= ^= *= == - syn match goOperator /[-+%<>!&|^*=]=\?/ - " match / and /= - syn match goOperator /\/\%(=\|\ze[^/*]\)/ - " match two-char operators: << >> &^ - " and corresponding three-char operators: <<= >>= &^= - syn match goOperator /\%(<<\|>>\|&^\)=\?/ - " match remaining two-char operators: := && || <- ++ -- - syn match goOperator /:=\|||\|<-\|++\|--/ - " match ... - syn match goOperator /\.\.\./ -endif -hi def link goOperator Operator + " match single-char operators: - + % < > ! & | ^ * = + " and corresponding two-char operators: -= += %= <= >= != &= |= ^= *= == + syn match goOperator /[-+%<>!&|^*=]=\?/ + " match / and /= + syn match goOperator /\/\%(=\|\ze[^/*]\)/ + " match two-char operators: << >> &^ + " and corresponding three-char operators: <<= >>= &^= + syn match goOperator /\%(<<\|>>\|&^\)=\?/ + " match remaining two-char operators: := && || <- ++ -- + syn match goOperator /:=\|||\|<-\|++\|--/ + " match ... -" Functions; + hi def link goPointerOperator goOperator + hi def link goVarArgs goOperator +endif +hi def link goOperator Operator + +" Functions; if g:go_highlight_functions != 0 - syn match goFunction /\(func\s\+\)\@<=\w\+\((\)\@=/ - syn match goFunction /\()\s\+\)\@<=\w\+\((\)\@=/ + syn match goDeclaration /\/ nextgroup=goReceiver,goFunction skipwhite skipnl + syn match goReceiver /(\(\w\|[ *]\)\+)/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl + syn match goReceiverVar /\w\+/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained + syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl + syn match goReceiverType /\w\+/ contained + syn match goFunction /\w\+/ contained +else + syn keyword goDeclaration func endif -hi def link goFunction Function +hi def link goFunction Function -" Methods; +" Methods; if g:go_highlight_methods != 0 - syn match goMethod /\(\.\)\@<=\w\+\((\)\@=/ + syn match goMethod /\.\w\+\ze(/hs=s+1 endif -hi def link goMethod Type +hi def link goMethod Type -" Structs; -if g:go_highlight_structs != 0 - syn match goStruct /\(.\)\@<=\w\+\({\)\@=/ - syn match goStructDef /\(type\s\+\)\@<=\w\+\(\s\+struct\s\+{\)\@=/ +" Fields; +if g:go_highlight_fields != 0 + syn match goField /\.\w\+\([\ \n\r\:\)\[,]\)\@=/hs=s+1 endif -hi def link goStruct Function -hi def link goStructDef Function +hi def link goField Identifier + +" Structs & Interfaces; +if g:go_highlight_types != 0 + syn match goTypeConstructor /\<\w\+{/he=e-1 + syn match goTypeDecl /\/ nextgroup=goTypeName skipwhite skipnl + syn match goTypeName /\w\+/ contained nextgroup=goDeclType skipwhite skipnl + syn match goDeclType /\/ contained skipwhite skipnl + hi def link goReceiverType Type +else + syn keyword goDeclType struct interface + syn keyword goDeclaration type +endif +hi def link goTypeConstructor Type +hi def link goTypeName Type +hi def link goTypeDecl Keyword +hi def link goDeclType Keyword " Build Constraints if g:go_highlight_build_constraints != 0 - syn keyword goBuildOs contained ignore cgo android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows - syn keyword goBuildArch contained 386 amd64 amd64p32 arm - syn match goBuildDirective display contained "+build" - syn region goBuildComment start="//\s*+build" end="$" contains=goBuildDirective,goBuildOs,goBuildArch - syn region goBuildComment start="/\*\s*+build" end="\*/" contains=goBuildDirective,goBuildOs,goBuildArch + syn match goBuildKeyword display contained "+build" + " Highlight the known values of GOOS, GOARCH, and other +build options. + syn keyword goBuildDirectives contained + \ android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 + \ solaris windows 386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 + \ ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc + \ s390 s390x sparc sparc64 cgo ignore race + + " Other words in the build directive are build tags not listed above, so + " avoid highlighting them as comments by using a matchgroup just for the + " start of the comment. + " The rs=s+2 option lets the \s*+build portion be part of the inner region + " instead of the matchgroup so it will be highlighted as a goBuildKeyword. + syn region goBuildComment matchgroup=goBuildCommentStart + \ start="//\s*+build\s"rs=s+2 end="$" + \ contains=goBuildKeyword,goBuildDirectives + hi def link goBuildCommentStart Comment + hi def link goBuildDirectives Type + hi def link goBuildKeyword PreProc + + " One or more line comments that are followed immediately by a "package" + " declaration are treated like package documentation, so these must be + " matched as comments to avoid looking like working build constraints. + " The he, me, and re options let the "package" itself be highlighted by + " the usual rules. + syn region goPackageComment start=/\v(\/\/.*\n)+\s*package/ + \ end=/\v\n\s*package/he=e-7,me=e-7,re=e-7 + \ contains=@goCommentGroup,@Spell + hi def link goPackageComment Comment endif -hi def link goBuildComment Comment -hi def link goBuildOs Type -hi def link goBuildArch Type -hi def link goBuildDirective PreProc +" :GoCoverage commands +hi def link goCoverageNormalText Comment +function! s:hi() + " :GoSameIds + if &background == 'dark' + hi def goSameId term=bold cterm=bold ctermbg=white ctermfg=black guibg=white guifg=black + else + hi def goSameId term=bold cterm=bold ctermbg=14 guibg=Cyan + endif + + " :GoCoverage commands + hi def goCoverageCovered ctermfg=green guifg=#A6E22E + hi def goCoverageUncover ctermfg=red guifg=#F92672 +endfunction + +augroup vim-go-hi + autocmd! + autocmd ColorScheme * call s:hi() +augroup end +call s:hi() " Search backwards for a global declaration to start processing the syntax. "syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/ @@ -295,3 +396,5 @@ hi def link goBuildDirective PreProc syn sync minlines=500 let b:current_syntax = "go" + +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/syntax/godefstack.vim b/sources_non_forked/vim-go/syntax/godefstack.vim new file mode 100644 index 00000000..e4eefff4 --- /dev/null +++ b/sources_non_forked/vim-go/syntax/godefstack.vim @@ -0,0 +1,20 @@ +if exists("b:current_syntax") + finish +endif + +syn match godefStackComment '^".*' +syn match godefLinePrefix '^[>\s]\s' nextgroup=godefStackEntryNumber contains=godefStackCurrentPosition +syn match godefStackEntryNumber '\d\+' nextgroup=godefStackFilename skipwhite +syn match godefStackCurrentPosition '>' contained +syn match godefStackFilename '[^|]\+' contained nextgroup=godefStackEntryLocation +syn region godefStackEntryLocation oneline start='|' end='|' contained contains=godefStackEntryLocationNumber +syn match godefStackEntryLocationNumber '\d\+' contained display + +let b:current_syntax = "godefstack" + +hi def link godefStackComment Comment +hi def link godefStackCurrentPosition Special +hi def link godefStackFilename Directory +hi def link godefStackEntryLocationNumber LineNr + +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/syntax/godoc.vim b/sources_non_forked/vim-go/syntax/godoc.vim deleted file mode 100644 index 0fba2080..00000000 --- a/sources_non_forked/vim-go/syntax/godoc.vim +++ /dev/null @@ -1,47 +0,0 @@ -" Copyright 2011 The Go Authors. All rights reserved. -" Use of this source code is governed by a BSD-style -" license that can be found in the LICENSE file. - -if exists("b:current_syntax") - finish -endif - -syn case match - -syn match godocTitle "^\([A-Z][A-Z ]*\)$" -hi def link godocTitle Title - -" Single Line Definitions -syn match godocMethodRec /\i\+\ze)/ contained -syn match godocMethodName /) \zs\i\+\ze(/ contained -syn match godocMethod /^func \((\i\+ [^)]*)\) \i\+(/ contains=godocMethodRec,godocMethodName -syn match godocFunction /^func \zs\i\+\ze(/ - -syn match godocType /^type \zs\i\+\ze.*/ -syn match godocVar /^var \zs\i\+\ze.*/ -syn match godocConst /^const \zs\i\+\ze.*/ - -hi def link godocMethodRec Type -hi def link godocType Type -hi def link godocMethodName Function -hi def link godocFunction Function -hi def link godocVar Identifier -hi def link godocConst Identifier - -" Definition Blocks -syn region godocComment start="/\*" end="\*/" contained -syn region godocComment start="//" end="$" contained -syn match godocDefinition /^\s\+\i\+/ contained - -syn region godocVarBlock start=/^var (/ end=/^)/ contains=godocComment,godocDefinition -syn region godocConstBlock start=/^const (/ end=/^)/ contains=godocComment,godocDefinition -syn region godocTypeBlock start=/^type \i\+ \(interface\|struct\) {/ end=/^}/ matchgroup=godocType contains=godocComment,godocType - -hi def link godocComment Comment -hi def link godocDefinition Identifier - -syn sync minlines=500 - -let b:current_syntax = "godoc" - -" vim:ts=4 sts=2 sw=2: diff --git a/sources_non_forked/vim-go/syntax/gohtmltmpl.vim b/sources_non_forked/vim-go/syntax/gohtmltmpl.vim index 5aa6c98d..f53fbc67 100644 --- a/sources_non_forked/vim-go/syntax/gohtmltmpl.vim +++ b/sources_non_forked/vim-go/syntax/gohtmltmpl.vim @@ -1,9 +1,9 @@ if exists("b:current_syntax") - finish + finish endif if !exists("main_syntax") - let main_syntax = 'html' + let main_syntax = 'html' endif runtime! syntax/gotexttmpl.vim @@ -12,4 +12,4 @@ unlet b:current_syntax let b:current_syntax = "gohtmltmpl" -" vim:ts=4:sw=4:et +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/syntax/gotexttmpl.vim b/sources_non_forked/vim-go/syntax/gotexttmpl.vim index 50b4653d..de21d7fc 100644 --- a/sources_non_forked/vim-go/syntax/gotexttmpl.vim +++ b/sources_non_forked/vim-go/syntax/gotexttmpl.vim @@ -6,7 +6,7 @@ " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") - finish + finish endif syn case match @@ -37,7 +37,7 @@ hi def link goRawString String " Characters; their contents syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU -syn region goCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup +syn region goCharacter contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup hi def link goCharacter Character @@ -65,8 +65,8 @@ hi def link goImaginary Number syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary syn keyword gotplControl contained if else end range with template syn keyword gotplFunctions contained and html index js len not or print printf println urlquery eq ne lt le gt ge -syn match gotplVariable contained /\$[^ ]*\>/ -syn match goTplIdentifier contained /\.[^ ]*\>/ +syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ +syn match goTplIdentifier contained /\.[^\s}]+\>/ hi def link gotplControl Keyword hi def link gotplFunctions Function @@ -82,4 +82,4 @@ hi def link goTplComment Comment let b:current_syntax = "gotexttmpl" -" vim:ts=4:sw=4:et +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/syntax/vimgo.vim b/sources_non_forked/vim-go/syntax/vimgo.vim index d62791d3..3a2204c4 100644 --- a/sources_non_forked/vim-go/syntax/vimgo.vim +++ b/sources_non_forked/vim-go/syntax/vimgo.vim @@ -1,5 +1,5 @@ if exists("b:current_syntax") - finish + finish endif let b:current_syntax = "vimgo" @@ -9,3 +9,5 @@ syn region goTitle start="\%1l" end=":" hi def link goInterface Type hi def link goTitle Label + +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/t/coverlay.vim b/sources_non_forked/vim-go/t/coverlay.vim new file mode 100644 index 00000000..9d60c21d --- /dev/null +++ b/sources_non_forked/vim-go/t/coverlay.vim @@ -0,0 +1,191 @@ +" to execute, `rake test` on parent dir + +describe 'go#coverage#Buffer' + before + new + let g:curdir = expand(':p:h') . '/' + let g:srcpath = 't/fixtures/src/' + let g:sample = 'pkg1/sample.go' + let g:sampleabs = g:curdir . g:srcpath . 'pkg1/sample.go' + let g:samplecover = g:curdir . g:srcpath . 'pkg1/sample.out' + let g:go_gopath = g:curdir . 't/fixtures' + execute "badd " . g:srcpath . g:sample + execute "buffer " . bufnr("$") + end + after + execute "bprev" + execute "bdelete " . g:srcpath . g:sample + close! + end + + it 'puts match to the list' + call go#coverage#Buffer(0) + Expect len(go#coverlay#matches()) == 5 + call go#coverlay#Clearlay() + Expect len(go#coverlay#matches()) == 0 + + call go#coverage#Buffer(0) + Expect len(go#coverlay#matches()) == 5 + call go#coverlay#Clearlay() + Expect len(go#coverlay#matches()) == 0 + + call go#coverage#Buffer(0) + Expect len(go#coverlay#matches()) == 5 + call go#coverage#Buffer(0) + Expect len(go#coverlay#matches()) == 5 + call go#coverlay#Clearlay() + Expect len(go#coverlay#matches()) == 0 + end +end + +describe 'go#coverage#Buffer fail' + before + new + let g:curdir = expand(':p:h') . '/' + let g:srcpath = 't/fixtures/src/' + let g:sample = 'failtest/sample.go' + let g:sampletest = 'failtest/sample_test.go' + let g:sampleabs = g:curdir . g:srcpath . 'failtest/sample.go' + let g:go_gopath = g:curdir . 't/fixtures' + execute "badd " . g:srcpath . g:sample + execute "buffer " . bufnr("$") + end + after + execute "bprev" + execute "bdelete " . g:srcpath . g:sampletest + execute "bdelete " . g:srcpath . g:sample + end + + it 'does nothing if test fail' + call go#coverage#Buffer(0) + Expect len(go#coverlay#matches()) == 0 + Expect len(getqflist()) == 1 + end +end + +describe 'go#coverage#Buffer build fail' + before + new + let g:curdir = expand(':p:h') . '/' + let g:srcpath = 't/fixtures/src/' + let g:sample = 'buildfail/sample.go' + let g:sampleabs = g:curdir . g:srcpath . 'buildfail/sample.go' + let g:go_gopath = g:curdir . 't/fixtures' + execute "badd " . g:srcpath . g:sample + execute "buffer " . bufnr("$") + end + after + execute "bprev" + execute "bdelete " . g:srcpath . g:sample + end + + it 'does nothing if test fail' + call go#coverage#Buffer(0) + Expect len(go#coverlay#matches()) == 0 + end +end + +describe 'go#coverage#Buffer build test fail' + before + new + let g:curdir = expand(':p:h') . '/' + let g:srcpath = 't/fixtures/src/' + let g:sample = 'buildtestfail/sample.go' + let g:sampleabs = g:curdir . g:srcpath . 'buildtestfail/sample.go' + let g:go_gopath = g:curdir . 't/fixtures' + execute "badd " . g:srcpath . g:sample + execute "buffer " . bufnr("$") + end + after + execute "bprev" + execute "bdelete " . g:srcpath . g:sample + end + + it 'does nothing if test fail' + call go#coverage#Buffer(0) + Expect len(go#coverlay#matches()) == 0 + end +end + +describe 'go#coverlay#findbufnr' + before + new + let g:curdir = expand(':p:h') . '/' + let g:srcpath = 't/fixtures/src/' + let g:sample = 'pkg1/sample.go' + let g:sample2 = 'pkg2/sample.go' + let g:sampleabs = g:curdir . g:srcpath . 'pkg1/sample.go' + let g:sampleabs2 = g:curdir . g:srcpath . 'pkg2/sample.go' + let g:go_gopath = g:curdir . 't/fixtures' + execute "badd " . g:srcpath . g:sample + execute "badd " . g:srcpath . g:sample2 + end + after + execute "bdelete " . g:srcpath . g:sample2 + execute "bdelete " . g:srcpath . g:sample + close! + end + + it 'returns BUFNR if FILE is opened at BUFNR' + Expect go#coverlay#findbufnr('_' . g:sampleabs) == bufnr(g:sampleabs) + Expect go#coverlay#findbufnr(g:sample) == bufnr(g:sampleabs) + + Expect go#coverlay#findbufnr('_' . g:sampleabs2) == bufnr(g:sampleabs2) + Expect go#coverlay#findbufnr(g:sample2) == bufnr(g:sampleabs2) + end + + it 'returns -1 if FILE is not exists' + Expect go#coverlay#findbufnr('pkg1/NOTEXISTS.go') == -1 + Expect go#coverlay#findbufnr('_' . g:curdir . g:srcpath . 'pkg1/NOTEXISTS.go') == -1 + end +end + +describe 'go#coverlay#isopenedon' + before + new + let g:curdir = expand(':p:h') . '/' + let g:srcpath = 't/fixtures/src/' + let g:sample = 'pkg1/sample.go' + let g:sampleabs = g:curdir . g:srcpath . 'pkg1/sample.go' + let g:go_gopath = g:curdir . 't/fixtures' + execute "badd " . g:srcpath . g:sample + end + after + execute "bdelete " . g:srcpath . g:sample + close! + end + + it 'returns 1 if FILE is opened at BUFNR' + Expect go#coverlay#isopenedon('_' . g:sampleabs, bufnr(g:sampleabs)) == 1 + Expect go#coverlay#isopenedon(g:sample, bufnr(g:sampleabs)) == 1 + end + + it 'returns 0 if FILE is not opened at BUFNR' + Expect go#coverlay#isopenedon('_' . g:sampleabs, 42) == 0 + Expect go#coverlay#isopenedon(g:sample, 42) == 0 + end + + it 'returns 0 if FILE is not exists' + Expect go#coverlay#isopenedon('_' . g:curdir . g:srcpath . 'pkg1/NOTEXISTS', bufnr(g:sampleabs)) == 0 + Expect go#coverlay#isopenedon('pkg1/NOTEXISTS.go', bufnr(g:sampleabs)) == 0 + end +end + + + +describe 'go#coverlay#parsegocoverline' + it 'parses a go cover output line and returns as dict' + let d = {'file': 'f',"startline": "1", "startcol": "2", "endline": "3", "endcol": "4", "numstmt": "5", "cnt": "6"} + " file:startline.col,endline.col numstmt count + Expect go#coverlay#parsegocoverline("f:1.2,3.4 5 6") == d + end +end + +describe 'go#coverlay#genmatch' + it 'generate mark pattern from cover data' + let d = {'file': 'f',"startline": "1", "startcol": "2", "endline": "3", "endcol": "4", "numstmt": "5", "cnt": "6"} + Expect go#coverlay#genmatch(d) == {'group': 'covered', "pattern": '\%>1l\_^\s\+\%<3l\|\%1l\_^\s\+\|\%3l\_^\s\+\(\}$\)\@!', "priority": 6} + let d = {'file': 'f',"startline": "1", "startcol": "2", "endline": "3", "endcol": "4", "numstmt": "5", "cnt": "0"} + Expect go#coverlay#genmatch(d) == {'group': 'uncover', "pattern": '\%>1l\_^\s\+\%<3l\|\%1l\_^\s\+\|\%3l\_^\s\+\(\}$\)\@!', "priority": 5} + end +end diff --git a/sources_non_forked/vim-go/t/fixtures/src/buildfail/sample.go b/sources_non_forked/vim-go/t/fixtures/src/buildfail/sample.go new file mode 100644 index 00000000..45fc006a --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/buildfail/sample.go @@ -0,0 +1,13 @@ +// set gopath before +//go:generate go test --coverprofile=sample.out +// go1.5.3 example output: +// GOPATH=`pwd`/fixtures go test --coverprofile=log.out buildfail +// # buildfail +// /tmp/go-build264733986/buildfail/_test/_obj_test/sample.go:7: undefined: IT_SHOULD_BE_BUILD_FAILED +// /tmp/go-build264733986/buildfail/_test/_obj_test/sample.go:8: missing return at end of function +// FAIL buildfail [build failed] +package pkg + +func Sample() int { + IT_SHOULD_BE_BUILD_FAILED +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/buildfail/sample_test.go b/sources_non_forked/vim-go/t/fixtures/src/buildfail/sample_test.go new file mode 100644 index 00000000..2356d3ed --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/buildfail/sample_test.go @@ -0,0 +1,7 @@ +package pkg + +import "testing" + +func TestSample(t *testing.T) { + Sample() +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/buildtestfail/sample.go b/sources_non_forked/vim-go/t/fixtures/src/buildtestfail/sample.go new file mode 100644 index 00000000..792f1234 --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/buildtestfail/sample.go @@ -0,0 +1,7 @@ +// set gopath before +//go:generate go test --coverprofile=sample.out +package pkg + +func Sample() int { + return 1 +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/buildtestfail/sample_test.go b/sources_non_forked/vim-go/t/fixtures/src/buildtestfail/sample_test.go new file mode 100644 index 00000000..17c4d463 --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/buildtestfail/sample_test.go @@ -0,0 +1,15 @@ +// go1.5.3 example output: +// GOPATH=`pwd`/fixtures go test --coverprofile=log.out buildtestfail +// # buildtestfail +// fixtures/src/buildtestfail/sample_test.go:14: undefined: IT_SHOULD_BE_BUILD_FAILED +// FAIL buildtestfail [build failed] +// echo $? +// 2 + +package pkg + +import "testing" + +func TestSample(t *testing.T) { + IT_SHOULD_BE_BUILD_FAILED +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/failtest/sample.go b/sources_non_forked/vim-go/t/fixtures/src/failtest/sample.go new file mode 100644 index 00000000..5859e926 --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/failtest/sample.go @@ -0,0 +1,12 @@ +// set gopath before +//go:generate go test --coverprofile=sample.out +package pkg + +func Sample() int { + if false { + return 0 + } else if false { + return 0 + } + return 1 +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/failtest/sample_test.go b/sources_non_forked/vim-go/t/fixtures/src/failtest/sample_test.go new file mode 100644 index 00000000..7f1ade0d --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/failtest/sample_test.go @@ -0,0 +1,8 @@ +package pkg + +import "testing" + +func TestSample(t *testing.T) { + Sample() + t.Fatal("itwillfail") +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/parsefail/sample.go b/sources_non_forked/vim-go/t/fixtures/src/parsefail/sample.go new file mode 100644 index 00000000..e9f3faa9 --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/parsefail/sample.go @@ -0,0 +1,14 @@ +// set gopath before +//go:generate go test --coverprofile=sample.out +// go1.5.3 example output: +// GOPATH=`pwd`/fixtures go test --coverprofile=log.out parsefail +// # cover parsefail +// 2016/01/17 23:59:08 cover: /home/sey/vimfiles/_vim/bundle/vim-go-coverlay/t/fixtures/src/parsefail/sample.go: /home/sey/vimfiles/_vim/bundle/vim-go-coverlay/t/fixtures/src/parsefail/sample.go:10:1: expected declaration, found 'IDENT' PARSEFAIL +// FAIL parsefail [build failed] +// echo $? +// 2 +package pkg + +PARSEFAIL Sample() int { + return 0 +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/parsefail/sample_test.go b/sources_non_forked/vim-go/t/fixtures/src/parsefail/sample_test.go new file mode 100644 index 00000000..2356d3ed --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/parsefail/sample_test.go @@ -0,0 +1,7 @@ +package pkg + +import "testing" + +func TestSample(t *testing.T) { + Sample() +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample.go b/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample.go new file mode 100644 index 00000000..6ce94b39 --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample.go @@ -0,0 +1,12 @@ +// set gopath before +//go:generate go test --coverprofile=sample.out +package pkg1 + +func Sample() int { + if false { + return 0 + } else if false { + return 0 + } + return 1 +} diff --git a/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample.out b/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample.out new file mode 100644 index 00000000..909a63f1 --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample.out @@ -0,0 +1,6 @@ +mode: set +pkg1/sample.go:5.19,6.11 1 1 +pkg1/sample.go:11.2,11.10 1 1 +pkg1/sample.go:6.11,8.3 1 0 +pkg1/sample.go:8.3,8.18 1 1 +pkg1/sample.go:8.18,10.3 1 0 diff --git a/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample_test.go b/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample_test.go new file mode 100644 index 00000000..e39d7ba8 --- /dev/null +++ b/sources_non_forked/vim-go/t/fixtures/src/pkg1/sample_test.go @@ -0,0 +1,7 @@ +package pkg1 + +import "testing" + +func TestSample(t *testing.T) { + Sample() +} diff --git a/sources_non_forked/vim-go/templates/hello_world.go b/sources_non_forked/vim-go/templates/hello_world.go new file mode 100644 index 00000000..50e8d8d3 --- /dev/null +++ b/sources_non_forked/vim-go/templates/hello_world.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("vim-go") +} diff --git a/sources_non_forked/vim-indent-object/doc/indent-object.txt b/sources_non_forked/vim-indent-object/doc/indent-object.txt index 5b581020..b22c9865 100644 --- a/sources_non_forked/vim-indent-object/doc/indent-object.txt +++ b/sources_non_forked/vim-indent-object/doc/indent-object.txt @@ -86,6 +86,12 @@ this case if blank lines are ignored, then the entire file would be selected. Instead when code at the top level is being indented blank lines are considered to delimit the block. +This exceptional behaviour can be disabled by executing the following line +> + :let g:indent_object_except_first_level = 0 +< +(default is 1) + ============================================================================== ABOUT *idntobj-about* diff --git a/sources_non_forked/vim-indent-object/plugin/indent-object.vim b/sources_non_forked/vim-indent-object/plugin/indent-object.vim index afb8edd2..199b4338 100644 --- a/sources_non_forked/vim-indent-object/plugin/indent-object.vim +++ b/sources_non_forked/vim-indent-object/plugin/indent-object.vim @@ -10,10 +10,10 @@ " 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 @@ -41,6 +41,10 @@ let s:l1 = -1 let s:c0 = -1 let s:c1 = -1 +if !exists("g:indent_object_except_first_level") + let g:indent_object_except_first_level = 1 +endif + function! TextObject(inner, incbelow, vis, range, count) " Record the current state of the visual region. @@ -109,7 +113,10 @@ function! TextObject(inner, incbelow, vis, range, count) " Search backward for the first line with less indent than the target " indent (skipping blank lines). let blnk = getline(l_1) =~ "^\\s*$" - while l_1 > 0 && ((idnt == 0 && !blnk) || (idnt != 0 && (blnk || indent(l_1) >= idnt))) + while l_1 > 0 && (blnk || indent(l_1) >= idnt) + if g:indent_object_except_first_level && idnt == 0 && blnk + break + endif if !blnk || !a:inner let l_1o = l_1 endif @@ -121,7 +128,10 @@ function! TextObject(inner, incbelow, vis, range, count) " indent (skipping blank lines). let line_cnt = line("$") let blnk = getline(l2) =~ "^\\s*$" - while l2 <= line_cnt && ((idnt == 0 && !blnk) || (idnt != 0 && (blnk || indent(l2) >= idnt))) + while l2 <= line_cnt && (blnk || indent(l2) >= idnt) + if g:indent_object_except_first_level && idnt == 0 && blnk + break + endif if !blnk || !a:inner let l2o = l2 endif diff --git a/sources_non_forked/vim-less/README.md b/sources_non_forked/vim-less/README.md index edd219ac..9d5bdc1d 100644 --- a/sources_non_forked/vim-less/README.md +++ b/sources_non_forked/vim-less/README.md @@ -1,9 +1,5 @@ # VIM-LESS -**This project is looking for new contributors / a new maintainer. [issue 51](https://github.com/groenewege/vim-less/issues/51)** - ---- - This vim bundle adds syntax highlighting, indenting and autocompletion for the dynamic stylesheet language [LESS](http://lesscss.org). This bundle is compatible with [vim-css-color](https://github.com/skammer/vim-css-color), diff --git a/sources_non_forked/vim-less/ftplugin/less.vim b/sources_non_forked/vim-less/ftplugin/less.vim index c4da0a58..88a6e7b7 100644 --- a/sources_non_forked/vim-less/ftplugin/less.vim +++ b/sources_non_forked/vim-less/ftplugin/less.vim @@ -19,7 +19,7 @@ setlocal includeexpr=substitute(v:fname,'\\%(.*/\\\|^\\)\\zs','_','') setlocal omnifunc=csscomplete#CompleteCSS setlocal suffixesadd=.less setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,:// -setlocal fo=jcroql +setlocal fo=croql let &l:include = '^\s*@import\s\+\%(url(\)\=["'']\=' diff --git a/sources_non_forked/vim-markdown/README.markdown b/sources_non_forked/vim-markdown/README.markdown index 055b8de2..cd79315f 100644 --- a/sources_non_forked/vim-markdown/README.markdown +++ b/sources_non_forked/vim-markdown/README.markdown @@ -11,6 +11,15 @@ installing from this repository, add the following to your vimrc: autocmd BufNewFile,BufReadPost *.md set filetype=markdown +If you want to enable fenced code block syntax highlighting in your markdown +documents you can enable it in your `.vimrc` like so: + + let g:markdown_fenced_languages = ['html', 'python', 'bash=sh'] + +To disable markdown syntax concealing add the following to your vimrc: + + let g:markdown_syntax_conceal = 0 + ## License Copyright © Tim Pope. Distributed under the same terms as Vim itself. diff --git a/sources_non_forked/vim-markdown/ftplugin/markdown.vim b/sources_non_forked/vim-markdown/ftplugin/markdown.vim index e8627ccc..f406db58 100644 --- a/sources_non_forked/vim-markdown/ftplugin/markdown.vim +++ b/sources_non_forked/vim-markdown/ftplugin/markdown.vim @@ -9,7 +9,7 @@ endif runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim -setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s +setlocal comments=fb:*,fb:-,fb:+,n:> commentstring= setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]: diff --git a/sources_non_forked/vim-markdown/syntax/markdown.vim b/sources_non_forked/vim-markdown/syntax/markdown.vim index 8c981bbe..ad925cc2 100644 --- a/sources_non_forked/vim-markdown/syntax/markdown.vim +++ b/sources_non_forked/vim-markdown/syntax/markdown.vim @@ -18,14 +18,20 @@ unlet! b:current_syntax if !exists('g:markdown_fenced_languages') let g:markdown_fenced_languages = [] endif +let s:done_include = {} for s:type in map(copy(g:markdown_fenced_languages),'matchstr(v:val,"[^=]*$")') + if has_key(s:done_include, matchstr(s:type,'[^.]*')) + continue + endif if s:type =~ '\.' let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*') endif exe 'syn include @markdownHighlight'.substitute(s:type,'\.','','g').' syntax/'.matchstr(s:type,'[^.]*').'.vim' unlet! b:current_syntax + let s:done_include[matchstr(s:type,'[^.]*')] = 1 endfor unlet! s:type +unlet! s:done_include syn sync minlines=10 syn case ignore @@ -75,29 +81,38 @@ syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" conta syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline -let s:concealends = has('conceal') ? ' concealends' : '' -exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart' . s:concealends -exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart' . s:concealends -exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart,markdownItalic' . s:concealends -exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart,markdownItalic' . s:concealends -exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart' . s:concealends -exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart' . s:concealends +let s:concealends = '' +if has('conceal') && get(g:, 'markdown_syntax_conceal', 1) == 1 + let s:concealends = ' concealends' +endif +exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart,@Spell' . s:concealends +exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart,@Spell' . s:concealends +exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart,markdownItalic,@Spell' . s:concealends +exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart,markdownItalic,@Spell' . s:concealends +exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart,@Spell' . s:concealends +exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart,@Spell' . s:concealends syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart -syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*```.*$" end="^\s*```\ze\s*$" keepend +syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*```*.*$" end="^\s*```*\ze\s*$" keepend syn match markdownFootnote "\[^[^\]]\+\]" syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:" if main_syntax ==# 'markdown' + let s:done_include = {} for s:type in g:markdown_fenced_languages - exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') + if has_key(s:done_include, matchstr(s:type,'[^.]*')) + continue + endif + exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```*\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```*\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') + let s:done_include[matchstr(s:type,'[^.]*')] = 1 endfor unlet! s:type + unlet! s:done_include endif -syn match markdownEscape "\\[][\\`*_{}()#+.!-]" +syn match markdownEscape "\\[][\\`*_{}()<>#+.!-]" syn match markdownError "\w\@<=_\w\@=" hi def link markdownH1 htmlH1 diff --git a/sources_non_forked/vim-multiple-cursors/.travis.yml b/sources_non_forked/vim-multiple-cursors/.travis.yml index e99037a9..cfb198ab 100644 --- a/sources_non_forked/vim-multiple-cursors/.travis.yml +++ b/sources_non_forked/vim-multiple-cursors/.travis.yml @@ -1,7 +1,11 @@ +sudo: false language: ruby -rvm: - - 1.9.3 -before_install: sudo apt-get install vim-gtk + +addons: + apt: + packages: + - vim-gtk + before_script: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" diff --git a/sources_non_forked/vim-multiple-cursors/CONTRIBUTING.md b/sources_non_forked/vim-multiple-cursors/CONTRIBUTING.md new file mode 100644 index 00000000..878aa59b --- /dev/null +++ b/sources_non_forked/vim-multiple-cursors/CONTRIBUTING.md @@ -0,0 +1,23 @@ +# Problems summary + +## Expected + +## Environment Information + * OS: + * Neovim/Vim/Gvim version: + +## Provide a minimal .vimrc with less than 50 lines + + " Your minimal.vimrc + +## Generate a logfile if appropriate + + 1. export NVIM_PYTHON_LOG_FILE=/tmp/log + 2. export NVIM_PYTHON_LOG_LEVEL=DEBUG + 3. nvim -u minimal.vimrc + 4. recreate your issue + 5. cat /tmp/log_{PID} + +## Screen shot (if possible) + +## Upload the log file diff --git a/sources_non_forked/vim-multiple-cursors/Gemfile.lock b/sources_non_forked/vim-multiple-cursors/Gemfile.lock index 12bf0d65..e833b243 100644 --- a/sources_non_forked/vim-multiple-cursors/Gemfile.lock +++ b/sources_non_forked/vim-multiple-cursors/Gemfile.lock @@ -1,17 +1,22 @@ GEM remote: https://rubygems.org/ specs: - diff-lcs (1.2.4) - rake (10.0.4) - rspec (2.13.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - rspec-core (2.13.1) - rspec-expectations (2.13.0) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.1) - vimrunner (0.3.0) + diff-lcs (1.2.5) + rake (10.4.2) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.1) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) + vimrunner (0.3.1) PLATFORMS ruby @@ -20,3 +25,6 @@ DEPENDENCIES rake rspec vimrunner + +BUNDLED WITH + 1.10.6 diff --git a/sources_non_forked/vim-multiple-cursors/README.md b/sources_non_forked/vim-multiple-cursors/README.md index 2a991a18..26cb6d02 100644 --- a/sources_non_forked/vim-multiple-cursors/README.md +++ b/sources_non_forked/vim-multiple-cursors/README.md @@ -1,5 +1,7 @@ -# vim-multiple-cursors [![Build Status](https://travis-ci.org/terryma/vim-multiple-cursors.svg)](https://travis-ci.org/terryma/vim-multiple-cursors) - +# vim-multiple-cursors +[![Build Status](https://travis-ci.org/terryma/vim-multiple-cursors.svg)](https://travis-ci.org/terryma/vim-multiple-cursors) +[![Issue Stats](http://issuestats.com/github/terryma/vim-multiple-cursors/badge/pr?style=flat)](http://issuestats.com/github/terryma/vim-multiple-cursors) +[![Issue Stats](http://issuestats.com/github/terryma/vim-multiple-cursors/badge/issue?style=flat)](http://issuestats.com/github/terryma/vim-multiple-cursors) ## Contents - [About](#about) - [Features](#features) @@ -10,10 +12,11 @@ - [Interactions with other plugins](#interactions-with-other-plugins) - [Highlight](#highlight) - *[FAQ](#faq)* - - *[Known Issues](#known-issues)* + - *[Known issues](#known-issues)* + - *[Issue creation requirements](#issue-creation-requirements)* - [Changelog](#changelog) - [Contributing](#contributing) - - [Credit](#credit) + - [Credit](#credit) ###Contributors - [eapache](https://github.com/eapache) @@ -27,16 +30,22 @@ ### It's great for quick refactoring ![Example1](assets/example1.gif?raw=true) +Vim command sequence: `2Gfpcname` + ### Add a cursor to each line of your visual selection ![Example2](assets/example2.gif?raw=true) +Vim command sequence: `2Gvipi"",vipJ$r]Idays = [` + ### Do it backwards too! This is not just a replay of the above gif :) ![Example3](assets/example3.gif?raw=true) +Vim command sequence: `2Gdf[$r,0f,vc` + ### Add multiple cursors using regexes ![Example4](assets/example4.gif?raw=true) -To see what keystrokes are used for the above example, see [this issue](https://github.com/terryma/vim-multiple-cursors/issues/39). +To see what keystrokes are used for the above examples, see [the wiki page](https://github.com/terryma/vim-multiple-cursors/wiki/Keystrokes-for-example-gifs). ## Features - Live update in Insert mode @@ -132,6 +141,15 @@ normal mode will "fail to replay" when multiple cursors are active. For example, changing it from `{}` to `{'d':1}` makes normal-mode mappings beginning with `d` (such as `dw` to delete a word) work in multi-cursor mode. +### ```g:multi_cursor_visual_maps``` (Default: see below) +Default value: `{'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1}` + +Any key in this map (values are ignored) will cause multi-cursor _Visual_ mode +to pause for map completion just like normal vim. Otherwise keys mapped in +visual mode will "fail to replay" when multiple cursors are active. For example, +changing it from `{}` to `{'i':1}` makes visual-mode mappings beginning with `i` +(such as `it` to select an "inner tag block") work in multi-cursor mode. + The default list contents should work for anybody, unless they have remapped a key from an operator-pending command to a non-operator-pending command or vice versa. @@ -144,9 +162,9 @@ such as `j` as if they were operator-pending commands can break things. ### ```Multiple_cursors_before/Multiple_cursors_after``` (Default: `nothing`) -Other plugins may trigger on keypresses when in insert mode. These plugins +Other plugins may trigger on keypresses when in insert mode. These plugins generally provide a means to toggle their active state. These hooks allow -the user to provide functions in their .vimrc to do this when multiple-cursor-mode +the user to provide functions in their .vimrc to do this when multiple-cursor-mode is entered. For example, if you are using [Neocomplete](https://github.com/Shougo/neocomplete.vim), @@ -181,15 +199,27 @@ highlight link multiple_cursors_visual Visual ## FAQ -**Q** CTRL+n doesn't seem to work in gVIM? +#### **Q** CTRL+n doesn't seem to work in gVIM? **A** Try setting `set selection=inclusive` in your `~/.gvimrc` +#### **Q** How can I select `n` keywords with several keystrokes? I have tried `200` which does not work. + +**A** You can use :MultipleCursorsFind keyword. I have this binding in my vimrc: + +```VimL +nnoremap :MultipleCursorsFind / +vnoremap :MultipleCursorsFind / +``` + +This allows one to a) search for the keyword using `*` b) turn search results into cursors with `Alt-j`. + ## Known Issues - Select mode is not implemented -- I and A do not work in Visual mode yet (See #55) - - Single key command to switch to Insert mode such as c or s from Visual mode or i, a, I, A in Normal mode should work without any issues. **NOTE**: vim's Visual block mode also supports I and A commands, however they do not work in this plugin's Visual mode at the moment. For now, to use I and A, switch to normal mode by pressing v first. + +## Issue Creation Requirements + +This is a community supported project. Contributor's time is precious and limited. To ensure your issue is not closed out of hand, please ensure it meets the requirements outlined in [CONTRIBUTING.md](CONTRIBUTING.md). ## Changelog See [CHANGELOG.md](CHANGELOG.md) @@ -211,6 +241,4 @@ Obviously inspired by Sublime Text's [multiple selection][sublime-multiple-selec [emacs-multiple-cursors]:https://github.com/magnars/multiple-cursors.el - [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/terryma/vim-multiple-cursors/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - diff --git a/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim b/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim index 5763c7b4..0df3e8ae 100644 --- a/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim +++ b/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim @@ -218,9 +218,12 @@ function! multiple_cursors#find(start, end, pattern) let first = 1 while 1 if first + " Set `virtualedit` to 'onemore' for the first search to consistently + " match patterns like '$' + let saved_virtualedit = &virtualedit + let &virtualedit = "onemore" " First search starts from the current position let match = search(a:pattern, 'cW') - let first = 0 else let match = search(a:pattern, 'W') endif @@ -228,9 +231,26 @@ function! multiple_cursors#find(start, end, pattern) break endif let left = s:pos('.') - call search(a:pattern, 'ceW') + " Perform an intermediate backward search to correctly match patterns like + " '^' and '$' + let match = search(a:pattern, 'bceW') let right = s:pos('.') + " Reset the cursor and perform a normal search if the intermediate search + " wasn't successful + if !match || s:compare_pos(right, left) != 0 + call cursor(left) + call search(a:pattern, 'ceW') + let right = s:pos('.') + endif + if first + let &virtualedit = saved_virtualedit + let first = 0 + endif if s:compare_pos(right, pos2) > 0 + " Position the cursor at the end of the previous match so it'll be on a + " virtual cursor when multicursor mode is started. The `winrestview()` + " call below 'undoes' unnecessary repositionings + call search(a:pattern, 'be') break endif call s:cm.add(right, [left, right]) @@ -268,6 +288,7 @@ function! s:Cursor.new(position) let obj = copy(self) let obj.position = copy(a:position) let obj.visual = [] + let obj.saved_visual = [] " Stores text that was yanked after any commands in Normal or Visual mode let obj.paste_buffer_text = getreg('"') let obj.paste_buffer_type = getregtype('"') @@ -332,6 +353,7 @@ endfunction " Remove the visual selection and its highlight function! s:Cursor.remove_visual_selection() dict + let self.saved_visual = deepcopy(self.visual) let self.visual = [] " TODO(terryma): Move functionality into separate class call s:cm.remove_highlight(self.visual_hi_id) @@ -409,6 +431,7 @@ function! s:CursorManager.reset(restore_view, restore_setting, ...) dict let self.saved_winview = [] let self.start_from_find = 0 let s:char = '' + let s:saved_char = '' if a:restore_setting call self.restore_user_settings() endif @@ -507,7 +530,7 @@ function! s:CursorManager.update_current() dict " adjust other cursor locations if vdelta != 0 if self.current_index != self.size() - 1 - let cur_line_length = len(getline(cur.line())) + let cur_column_offset = (cur.column() - col('.')) * -1 let new_line_length = len(getline('.')) for i in range(self.current_index+1, self.size()-1) let hdelta = 0 @@ -519,7 +542,7 @@ function! s:CursorManager.update_current() dict if cur.line() == c.line() if vdelta > 0 " Added a line - let hdelta = cur_line_length * -1 + let hdelta = cur_column_offset else " Removed a line let hdelta = new_line_length @@ -626,6 +649,13 @@ function! s:CursorManager.restore_user_settings() dict call setreg('"', s:paste_buffer_temporary_text, s:paste_buffer_temporary_type) endfunction +" Reposition all cursors to the start or end of their region +function! s:CursorManager.reposition_all_within_region(start) dict + for c in self.cursors + call c.update_position(c.saved_visual[a:start ? 0 : 1]) + endfor +endfunction + " Reselect the current cursor's region in visual mode function! s:CursorManager.reapply_visual_selection() dict call s:select_in_visual_mode(self.get_current().visual) @@ -670,6 +700,9 @@ endfunction " This is the last user input that we're going to replicate, in its string form let s:char = '' +" This is either `I` or `A`, as input in Visual mode, that we're going to use +" to make the appropriate transition into Insert mode +let s:saved_char = '' " This is the mode the user is in before s:char let s:from_mode = '' " This is the mode the user is in after s:char @@ -853,7 +886,8 @@ function! s:process_user_input() " Grr this is frustrating. In Insert mode, between the feedkey call and here, " the current position could actually CHANGE for some odd reason. Forcing a " position reset here - call cursor(s:cm.get_current().position) + let cursor_position = s:cm.get_current() + call cursor(cursor_position.position) " Before applying the user input, we need to revert back to the mode the user " was in when the input was entered @@ -861,13 +895,14 @@ function! s:process_user_input() " Update the line length BEFORE applying any actions. TODO(terryma): Is there " a better place to do this? - call s:cm.get_current().update_line_length() + " let cursor_position = s:cm.get_current() + call cursor_position.update_line_length() let s:saved_linecount = line('$') " Restore unnamed register only in Normal mode. This should happen before user " input is processed. if s:from_mode ==# 'n' || s:from_mode ==# 'v' || s:from_mode ==# 'V' - call s:cm.get_current().restore_unnamed_register() + call cursor_position.restore_unnamed_register() endif " Apply the user input. Note that the above could potentially change mode, we @@ -898,12 +933,34 @@ endfunction " to be called to continue the fanout process function! s:detect_bad_input() if !s:valid_input + " To invoke the appropriate `(multiple-cursors-apply)` mapping, we + " need to revert back to the mode the user was in when the input was entered + call s:revert_mode(s:to_mode, s:from_mode) " We ignore the bad input and force invoke s:apply_user_input_next call feedkeys("\(multiple-cursors-apply)") let s:bad_input += 1 endif endfunction +" Complete transition into Insert mode when `I` or `A` is input in Visual mode +function! s:handle_visual_IA_to_insert() + if !empty(s:saved_char) && s:char =~# 'v\|V' && s:to_mode ==# 'n' + if s:saved_char ==# 'I' + call s:cm.reposition_all_within_region(1) + endif + call feedkeys(tolower(s:saved_char)) + let s:saved_char = '' + endif +endfunction + +" Begin transition into Insert mode when `I` or `A` is input in Visual mode +function! s:handle_visual_IA_to_normal() + if s:char =~# 'I\|A' && s:from_mode =~# 'v\|V' + let s:saved_char = s:char + let s:char = s:from_mode " spoof a 'v' or 'V' input to transiton from Visual into Normal mode + endif +endfunction + " Apply the user input at the next cursor location function! s:apply_user_input_next(mode) let s:valid_input = 1 @@ -931,6 +988,7 @@ function! s:apply_user_input_next(mode) call s:update_visual_markers(s:cm.get_current().visual) endif call feedkeys("\(multiple-cursors-wait)") + call s:handle_visual_IA_to_insert() else " Continue to next call feedkeys("\(multiple-cursors-input)") @@ -1050,8 +1108,8 @@ endfunction let s:retry_keys = "" function! s:display_error() if s:bad_input == s:cm.size() - \ && s:from_mode ==# 'n' - \ && has_key(g:multi_cursor_normal_maps, s:char[0]) + \ && ((s:from_mode ==# 'n' && has_key(g:multi_cursor_normal_maps, s:char[0])) + \ || (s:from_mode =~# 'v\|V' && has_key(g:multi_cursor_visual_maps, s:char[0]))) " we couldn't replay it anywhere but we're told it's the beginning of a " multi-character map like the `d` in `dw` let s:retry_keys = s:char @@ -1124,6 +1182,7 @@ function! s:wait_for_user_input(mode) let s:char = s:retry_keys . s:saved_keys if len(s:saved_keys) == 0 let s:char .= s:get_char() + call s:handle_visual_IA_to_normal() else let s:saved_keys = "" endif diff --git a/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt b/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt index 877f3f0b..422d5cf7 100644 --- a/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt +++ b/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt @@ -133,7 +133,7 @@ NOTE: Please make sure to always map something to |g:multi_cursor_quit_key|, otherwise you'll have a tough time quitting from multicursor mode. NOTE: Prior to version 1.3, the recommended way to map the keys is using the -expressoin quote syntax in Vim, using something like `"\"` or `"\"` +expression quote syntax in Vim, using something like `"\"` or `"\"` (see h: expr-quote). After 1.3, the recommended way is to use a raw string like above. If your key mappings don't appear to work, give the new syntax a try. @@ -177,6 +177,16 @@ normal mode will "fail to replay" when multiple cursors are active. For example, changing it from `{}` to `{'d':1}` makes normal-mode mappings beginning with `d` (such as `dw` to delete a word) work in multi-cursor mode. +*g:multi_cursor_visual_maps* (Default: ) + +Default value: `{'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1}` + +Any key in this map (values are ignored) will cause multi-cursor _Visual_ mode +to pause for map completion just like normal vim. Otherwise keys mapped in +visual mode will "fail to replay" when multiple cursors are active. For example, +changing it from `{}` to `{'i':1}` makes visual-mode mappings beginning with `i` +(such as `it` to select an "inner tag block") work in multi-cursor mode. + The default list contents should work for anybody, unless they have remapped a key from an operator-pending command to a non-operator-pending command or vice versa. diff --git a/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim b/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim index 538ae57b..6595bc35 100644 --- a/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim +++ b/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim @@ -1,7 +1,7 @@ "=============================================================================== " File: multiple_cursors.vim " Author: Terry Ma -" Description: Emulate Sublime Text's multi selection feature +" Description: Emulate Sublime Text's multi selection feature " Potential Features: " - Create a blinking cursor effect? Good place to do it would be instead of " waiting for user input, cycle through the highlight @@ -42,11 +42,14 @@ let s:settings_if_default = { let s:default_insert_maps = {} let s:default_normal_maps = {'!':1, '@':1, '=':1, 'q':1, 'r':1, 't':1, 'T':1, 'y':1, '[':1, ']':1, '\':1, 'd':1, 'f':1, 'F':1, 'g':1, '"':1, 'z':1, 'c':1, 'm':1, '<':1, '>':1} +let s:default_visual_maps = {'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1} let g:multi_cursor_insert_maps = \ get(g:, 'multi_cursor_insert_maps', s:default_insert_maps) let g:multi_cursor_normal_maps = \ get(g:, 'multi_cursor_normal_maps', s:default_normal_maps) +let g:multi_cursor_visual_maps = + \ get(g:, 'multi_cursor_visual_maps', s:default_visual_maps) call s:init_settings(s:settings) @@ -54,8 +57,12 @@ if g:multi_cursor_use_default_mapping call s:init_settings(s:settings_if_default) endif -if !exists('g:multi_cursor_start_word_key') && exists('g:multi_cursor_next_key') - let g:multi_cursor_start_word_key = g:multi_cursor_next_key +if !exists('g:multi_cursor_start_word_key') + if exists('g:multi_cursor_start_key') + let g:multi_cursor_start_word_key = g:multi_cursor_start_key + elseif exists('g:multi_cursor_next_key') + let g:multi_cursor_start_word_key = g:multi_cursor_next_key + endif endif " External mappings diff --git a/sources_non_forked/vim-multiple-cursors/spec/benchmark_spec.rb b/sources_non_forked/vim-multiple-cursors/spec/benchmark_spec.rb index 99ba6c4d..73c81c5b 100644 --- a/sources_non_forked/vim-multiple-cursors/spec/benchmark_spec.rb +++ b/sources_non_forked/vim-multiple-cursors/spec/benchmark_spec.rb @@ -58,6 +58,7 @@ end describe "Multiple Cursors" do let(:filename) { 'test.txt' } + let(:options) { [] } specify "#benchmark" do before <<-EOF diff --git a/sources_non_forked/vim-multiple-cursors/spec/multiple_cursors_spec.rb b/sources_non_forked/vim-multiple-cursors/spec/multiple_cursors_spec.rb index 03f34f66..9f83c219 100644 --- a/sources_non_forked/vim-multiple-cursors/spec/multiple_cursors_spec.rb +++ b/sources_non_forked/vim-multiple-cursors/spec/multiple_cursors_spec.rb @@ -17,7 +17,7 @@ def before(string) end def after(string) - get_file_content().should eq normalize_string_indent(string) + expect(get_file_content()).to eq normalize_string_indent(string) end def type(string) @@ -163,9 +163,35 @@ describe "Multiple Cursors when normal_maps is empty" do end +describe "Multiple Cursors when visual_maps is empty" do + let(:filename) { 'test.txt' } + let(:options) { ['let g:multi_cursor_visual_maps = {}'] } + + # Operator-pending commands are handled correctly thanks to their inclusion + # in `g:multi_cursor_visual_maps`. + # + # When an operator-pending command like 'f' is missing from that setting's + # value, then it should result in a no-op, but we should still remain in + # multicursor mode. + specify "#visual mode 'i'" do + before <<-EOF + hello world x + hello world x + EOF + + type 'fwfx' + + after <<-EOF + hello x + hello x + EOF + end + +end + describe "Multiple Cursors" do let(:filename) { 'test.txt' } - let(:options) { [] } + let(:options) { ['set autoindent'] } specify "#paste buffer normal x then p" do before <<-EOF @@ -324,6 +350,38 @@ describe "Multiple Cursors" do EOF end + specify "#multiple new lines on one line in insert mode" do + before <<-EOF + 'a','b','c','d','e' + EOF + + type 'f,vc' + + after <<-EOF + 'a' + 'b' + 'c' + 'd' + 'e' + EOF + end + + specify "#multiple new lines on one line in insert mode with indents" do + before <<-EOF + 'a','b','c','d','e' + EOF + + type '4if,vc:%s/^/^' + + after <<-EOF + ^ 'a' + ^ 'b' + ^ 'c' + ^ 'd' + ^ 'e' + EOF + end + specify "#normal mode 'o'" do before <<-EOF hello @@ -371,6 +429,48 @@ describe "Multiple Cursors" do EOF end + specify "#find command start-of-line" do + before <<-EOF + hello + world + + hello + world + EOF + + vim.normal ':MultipleCursorsFind ^' + type 'Ibegin' + + after <<-EOF + beginhello + beginworld + begin + beginhello + beginworld + EOF + end + + specify "#find command end-of-line" do + before <<-EOF + hello + world + + hello + world + EOF + + vim.normal ':MultipleCursorsFind $' + type 'Iend' + + after <<-EOF + helloend + worldend + end + helloend + worldend + EOF + end + specify "#visual line mode replacement" do before <<-EOF hello world @@ -417,6 +517,216 @@ describe "Multiple Cursors" do EOF end + specify "#visual mode 'i'" do + before <<-EOF + hi (hello world jan) bye + hi (hello world feb) bye + hi (hello world mar) bye + EOF + + type 'fwibcone' + + after <<-EOF + hi (one) bye + hi (one) bye + hi (one) bye + EOF + end + + specify "#visual mode 'a'" do + before <<-EOF + hi (hello world jan) bye + hi (hello world feb) bye + hi (hello world mar) bye + EOF + + type 'fwabcone' + + after <<-EOF + hi one bye + hi one bye + hi one bye + EOF + end + + specify "#visual mode 'f'" do + before <<-EOF + hi (hello world jan) bye + hi (hello world feb) bye + hi (hello world mar) bye + EOF + + type 'fwf)cone' + + after <<-EOF + hi (hello one bye + hi (hello one bye + hi (hello one bye + EOF + end + + specify "#visual mode 'F'" do + before <<-EOF + hi (hello world jan) bye + hi (hello world feb) bye + hi (hello world mar) bye + EOF + + type 'fwF(cbefore' + + after <<-EOF + hi beforeorld jan) bye + hi beforeorld feb) bye + hi beforeorld mar) bye + EOF + end + + specify "#visual mode 't'" do + before <<-EOF + hello.jan + hello hi.feb + hello hi bye.mar + EOF + + type 't.cone' + + after <<-EOF + one.jan + one.feb + one.mar + EOF + end + + specify "#visual mode 'T'" do + before <<-EOF + jan.world + feb.hi world + mar.bye hi world + EOF + + type 'fwT.cbefore' + + after <<-EOF + jan.beforeorld + feb.beforeorld + mar.beforeorld + EOF + end + + specify "#visual line mode 'f'" do + before <<-EOF + hello jan world + hello feb world + hello mar world + EOF + + type 'VfwvAafter' + + after <<-EOF + hello jan wafterorld + hello feb wafterorld + hello mar wafterorld + EOF + end + + specify "#visual mode 'I'" do + before <<-EOF + hello world jan + hello world feb + hello world mar + EOF + + type 'wIbefore' + + after <<-EOF + hello beforeworld jan + hello beforeworld feb + hello beforeworld mar + EOF + end + + specify "#visual mode 'A'" do + before <<-EOF + hello world jan + hello world feb + hello world mar + EOF + + type 'wAafter' + + after <<-EOF + hello worldafter jan + hello worldafter feb + hello worldafter mar + EOF + end + + specify "#resize regions visual mode 'I'" do + before <<-EOF + hello world jan + hello world feb + hello world mar + EOF + + type 'whhhIbefore' + + after <<-EOF + hello beforeworld jan + hello beforeworld feb + hello beforeworld mar + EOF + end + + specify "#resize regions visual mode 'A'" do + before <<-EOF + hello world jan + hello world feb + hello world mar + EOF + + type 'whhhAbefore' + + after <<-EOF + hello wobeforerld jan + hello wobeforerld feb + hello wobeforerld mar + EOF + end + + specify "#no word boundries visual mode 'I'" do + before <<-EOF + hello hibye world + hello hibye world + hello hibye world + EOF + + vim.normal ':MultipleCursorsFind bye' + type 'Ibefore' + + after <<-EOF + hello hibeforebye world + hello hibeforebye world + hello hibeforebye world + EOF + end + + specify "#variable-length regions visual mode 'I'" do + before <<-EOF + hello hii world + hello hiiii world + hello hiiiiii world + EOF + + vim.normal ':MultipleCursorsFind \' + type 'Ibefore' + + after <<-EOF + hello beforehii world + hello beforehiiii world + hello beforehiiiiii world + EOF + end + specify "#normal mode 'I'" do before <<-EOF hello diff --git a/sources_non_forked/vim-pug/README.markdown b/sources_non_forked/vim-pug/README.markdown new file mode 100644 index 00000000..c41f9ddd --- /dev/null +++ b/sources_non_forked/vim-pug/README.markdown @@ -0,0 +1,19 @@ +# vim-pug # + +Vim syntax highlighting for Pug (formerly Jade) templates. + +Installation +------------ + +I prefer to install plugins using Tim Pope's +[pathogen.vim](https://github.com/tpope/vim-pathogen). Installation using +pathogen is quite simple. + + cd ~/.vim/bundle + git clone git://github.com/digitaltoad/vim-pug.git + +If you do not want to use pathogen. You can always install vim-pug in the +normal manner by copying each directory to your ~/.vim directory. Make sure +not to overwrite any existing directory of the same name and instead copy only +the contents of the source directory to the directory of the same name in your +~/.vim directory. diff --git a/sources_non_forked/vim-pug/ftdetect/pug.vim b/sources_non_forked/vim-pug/ftdetect/pug.vim new file mode 100644 index 00000000..08d962fd --- /dev/null +++ b/sources_non_forked/vim-pug/ftdetect/pug.vim @@ -0,0 +1,5 @@ +" Pug +autocmd BufNewFile,BufReadPost *.pug set filetype=pug + +" Jade +autocmd BufNewFile,BufReadPost *.jade set filetype=pug diff --git a/sources_non_forked/vim-pug/ftplugin/pug.vim b/sources_non_forked/vim-pug/ftplugin/pug.vim new file mode 100644 index 00000000..db071fa1 --- /dev/null +++ b/sources_non_forked/vim-pug/ftplugin/pug.vim @@ -0,0 +1,57 @@ +" Vim filetype plugin +" Language: Pug +" Maintainer: Joshua Borton +" Credits: Tim Pope + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif + +let s:save_cpo = &cpo +set cpo-=C + +setlocal iskeyword+=- + +" Define some defaults in case the included ftplugins don't set them. +let s:undo_ftplugin = "" +let s:browsefilter = "All Files (*.*)\t*.*\n" +let s:match_words = "" + +runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim +unlet! b:did_ftplugin + +" Override our defaults if these were set by an included ftplugin. +if exists("b:undo_ftplugin") + let s:undo_ftplugin = b:undo_ftplugin + unlet b:undo_ftplugin +endif +if exists("b:browsefilter") + let s:browsefilter = b:browsefilter + unlet b:browsefilter +endif +if exists("b:match_words") + let s:match_words = b:match_words + unlet b:match_words +endif + +" Change the browse dialog on Win32 to show mainly Haml-related files +if has("gui_win32") + let b:browsefilter="Pug Files (*.pug)\t*.pug\n" . s:browsefilter +endif + +" Load the combined list of match_words for matchit.vim +if exists("loaded_matchit") + let b:match_words = s:match_words +endif + +setlocal comments=://-,:// commentstring=//\ %s + +setlocal suffixesadd+=.pug + +let b:undo_ftplugin = "setl cms< com< " + \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin + +let &cpo = s:save_cpo + +" vim:set sw=2: diff --git a/sources_non_forked/vim-pug/indent/pug.vim b/sources_non_forked/vim-pug/indent/pug.vim new file mode 100644 index 00000000..bc7f2b4b --- /dev/null +++ b/sources_non_forked/vim-pug/indent/pug.vim @@ -0,0 +1,70 @@ +" Vim indent file +" Language: Pug +" Maintainer: Joshua Borton +" Credits: Tim Pope (vim-pug) +" Last Change: 2010 Sep 22 + +if exists("b:did_indent") + finish +endif + +unlet! b:did_indent +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetPugIndent() +setlocal indentkeys=o,O,*,},],0),!^F + +" Only define the function once. +if exists("*GetPugIndent") + finish +endif + +let s:attributes = '\%((.\{-\})\)' +let s:tag = '\([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*' + +if !exists('g:pug_self_closing_tags') + let g:pug_self_closing_tags = 'meta|link|img|hr|br|input' +endif + +setlocal formatoptions+=r +setlocal comments+=n:\| + +function! GetPugIndent() + let lnum = prevnonblank(v:lnum-1) + if lnum == 0 + return 0 + endif + let line = substitute(getline(lnum),'\s\+$','','') + let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') + let lastcol = strlen(line) + let line = substitute(line,'^\s\+','','') + let indent = indent(lnum) + let cindent = indent(v:lnum) + let increase = indent + &sw + if indent == indent(lnum) + let indent = cindent <= indent ? -1 : increase + endif + + let group = synIDattr(synID(lnum,lastcol,1),'name') + + if line =~ '^!!!' + return indent + elseif line =~ '^/\%(\[[^]]*\]\)\=$' + return increase + elseif line =~ '^\%(if\|else\|unless\|for\|each\|block\|mixin\|append\|case\|when\)' + return increase + elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$' + return increase + elseif line == '-#' + return increase + elseif line =~? '^\v%('.g:pug_self_closing_tags.')>' + return indent + elseif group =~? '\v^%(pugAttributesDelimiter|pugClass|pugId|htmlTagName|htmlSpecialTagName|pugFilter|pugTagBlockChar)$' + return increase + else + return indent + endif +endfunction + +" vim:set sw=2: diff --git a/sources_non_forked/vim-pug/syntax/pug.vim b/sources_non_forked/vim-pug/syntax/pug.vim new file mode 100644 index 00000000..ee712dbb --- /dev/null +++ b/sources_non_forked/vim-pug/syntax/pug.vim @@ -0,0 +1,104 @@ +" Vim syntax file +" Language: Pug +" Maintainer: Joshua Borton +" Credits: Tim Pope +" Filenames: *.pug + +if exists("b:current_syntax") + finish +endif + +if !exists("main_syntax") + let main_syntax = 'pug' +endif + +silent! syntax include @htmlCoffeescript syntax/coffee.vim +unlet! b:current_syntax +silent! syntax include @htmlStylus syntax/stylus.vim +unlet! b:current_syntax +silent! syntax include @htmlCss syntax/css.vim +unlet! b:current_syntax +silent! syntax include @htmlMarkdown syntax/markdown.vim +unlet! b:current_syntax + +syn case match + +syn region javascriptParenthesisBlock start="(" end=")" contains=@htmlJavascript contained keepend +syn cluster htmlJavascript add=javascriptParenthesisBlock + +syn region pugJavascript matchgroup=pugJavascriptOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend +syn region pugJavascript matchgroup=pugJavascriptChar start="-" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend +syn cluster pugTop contains=pugBegin,pugComment,pugHtmlComment,pugJavascript +syn match pugBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=pugTag,pugClassChar,pugIdChar,pugPlainChar,pugJavascript,pugScriptConditional,pugScriptStatement,pugPipedText +syn match pugTag "+\?\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@pugComponent +syn cluster pugComponent contains=pugAttributes,pugIdChar,pugBlockExpansionChar,pugClassChar,pugPlainChar,pugJavascript,pugTagBlockChar,pugTagInlineText +syn match pugComment '\(\s\+\|^\)\/\/.*$' +syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" keepend +syn region pugHtmlConditionalComment start="" +syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,pugHtmlArg,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent +syn match pugClassChar "\." contained nextgroup=pugClass +syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar +syn match pugIdChar "#[[{]\@!" contained nextgroup=pugId +syn match pugClass "\%(\w\|-\)\+" contained nextgroup=@pugComponent +syn match pugId "\%(\w\|-\)\+" contained nextgroup=@pugComponent +syn region pugDocType start="^\s*\(!!!\|doctype\)" end="$" +" Unless I'm mistaken, syntax/html.vim requires +" that the = sign be present for these matches. +" This adds the matches back for pug. +syn keyword pugHtmlArg contained href title + +syn match pugPlainChar "\\" contained +syn region pugInterpolation matchgroup=pugInterpolationDelimiter start="[#!]{" end="}" contains=@htmlJavascript +syn match pugInterpolationEscape "\\\@[?!]\@!" +syn match pugScriptStatement "^\s*\<\%(each\|for\|block\|prepend\|append\|mixin\|extends\|include\)\>[?!]\@!" +syn region pugScriptLoopRegion start="^\s*\(for \)" end="$" contains=pugScriptLoopKeywords +syn keyword pugScriptLoopKeywords for in contained + +syn region pugJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,pugJavascriptTag,pugCoffeescriptFilter keepend + +syn region pugCoffeescriptFilter matchgroup=pugFilter start="^\z(\s*\):coffee-\?script\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained +syn region pugJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=pugBegin,pugTag +syn region pugCssBlock start="^\z(\s*\)style" nextgroup=@pugComponent,pugError end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCss keepend + +syn match pugError "\$" contained + +hi def link pugPlainChar Special +hi def link pugScriptConditional PreProc +hi def link pugScriptLoopKeywords PreProc +hi def link pugScriptStatement PreProc +hi def link pugHtmlArg htmlArg +hi def link pugAttributeString String +hi def link pugAttributesDelimiter Identifier +hi def link pugIdChar Special +hi def link pugClassChar Special +hi def link pugBlockExpansionChar Special +hi def link pugPipeChar Special +hi def link pugTagBlockChar Special +hi def link pugId Identifier +hi def link pugClass Type +hi def link pugInterpolationDelimiter Delimiter +hi def link pugInlineDelimiter Delimiter +hi def link pugFilter PreProc +hi def link pugDocType PreProc +hi def link pugComment Comment +hi def link pugCommentBlock Comment +hi def link pugHtmlConditionalComment pugComment + +let b:current_syntax = "pug" + +if main_syntax == "pug" + unlet main_syntax +endif diff --git a/sources_non_forked/vim-snipmate/Contributors.md b/sources_non_forked/vim-snipmate/Contributors.md index e06d6939..42064722 100644 --- a/sources_non_forked/vim-snipmate/Contributors.md +++ b/sources_non_forked/vim-snipmate/Contributors.md @@ -14,7 +14,9 @@ additional contributions from: * [asymmetric](https://github.com/asymmetric) * [bpugh](https://github.com/bpugh) * [bruno-](https://github.com/bruno-) +* [CharlesGueunet](https://github.com/CharlesGueunet) * [darkwise](https://github.com/darkwise) +* [dreviejo](https://github.com/dreviejo) * [fish-face](https://github.com/fish-face) * [henrik](https://github.com/henrik) * [holizz](https://github.com/holizz) @@ -37,7 +39,9 @@ additional contributions from: * [r00k](https://github.com/r00k) * [radicalbit](https://github.com/radicalbit) * [redpill](https://github.com/redpill) +* [rglassett](http://github.com/rglassett) * [robhudson](https://github.com/robhudson) +* [shinymayhem](https://github.com/shinymayhem) * [Shraymonks](https://github.com/shraymonks) * [sickill](https://github.com/sickill) * [statik](https://github.com/statik) diff --git a/sources_non_forked/vim-snipmate/README.md b/sources_non_forked/vim-snipmate/README.md index e11f4246..b47b56df 100644 --- a/sources_non_forked/vim-snipmate/README.md +++ b/sources_non_forked/vim-snipmate/README.md @@ -87,7 +87,7 @@ languages. For this we provide two options: scope aliases and the `:SnipMateLoadScope` command. Scope aliases simply say "whenever this scope is loaded, also load this other scope: - let g:snipMate = {} + let g:snipMate = get(g:, 'snipMate', {}) " Allow for vimrc re-sourcing let g:snipMate.scope_aliases = {} let g:snipMate.scope_aliases['ruby'] = 'ruby,rails' @@ -98,6 +98,16 @@ does `:SnipMateLoadScope rails` when editing a Rails project for example. ## Release Notes ## +### 0.89 - 2016-05-29 ### + +* Various regex updates to legacy parser +* Addition of double bang syntax to completely remove a snippet from lookup +* Group various SnipMate autocommands +* Support setting 'shiftwidth' to 0 +* Parser now operates linewise, adding some flexibility +* Mirror substitutions are more literal +* Mirror length is calculated correctly when substitutions occur + ### 0.88 - 2015-04-04 ### * Implement simple caching diff --git a/sources_non_forked/vim-snipmate/autoload/snipMate.vim b/sources_non_forked/vim-snipmate/autoload/snipMate.vim index 1209a174..74366fa8 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipMate.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipMate.vim @@ -28,7 +28,8 @@ function! snipMate#expandSnip(snip, version, col) abort let [snippet, b:snip_state.stops] = snipmate#parse#snippet(a:snip) " Build stop/mirror info let b:snip_state.stop_count = s:build_stops(snippet, b:snip_state.stops, lnum, col, indent) - let snipLines = snipMate#sniplist_str(snippet, b:snip_state.stops) + let snipLines = map(copy(snippet), + \ 'snipMate#sniplist_str(v:val, b:snip_state.stops)') else let snippet = snipmate#legacy#process_snippet(a:snip) let [b:snip_state.stops, b:snip_state.stop_count] = snipmate#legacy#build_stops(snippet, lnum, col - indent, indent) @@ -77,11 +78,11 @@ function! snipMate#expandSnip(snip, version, col) abort endfunction function! snipMate#placeholder_str(num, stops) abort - return snipMate#sniplist_str(a:stops[a:num].placeholder, a:stops)[0] + return snipMate#sniplist_str(a:stops[a:num].placeholder, a:stops) endfunction function! snipMate#sniplist_str(snippet, stops) abort - let lines = [''] + let str = '' let pos = 0 let add_to = 1 let seen_stops = [] @@ -90,110 +91,82 @@ function! snipMate#sniplist_str(snippet, stops) abort let item = a:snippet[pos] if type(item) == type('') - if add_to - let lines[-1] .= item - else - call add(lines, item) - endif - let add_to = 0 + let str .= item elseif type(item) == type([]) - let lines[-1] .= snipMate#placeholder_str(item[0], a:stops) - let add_to = 1 + let str .= snipMate#placeholder_str(item[0], a:stops) endif let pos += 1 unlet item " avoid E706 endwhile - return lines + return str endfunction function! s:build_stops(snippet, stops, lnum, col, indent) abort let stops = a:stops - let line = a:lnum + let lnum = a:lnum let col = a:col - for [id, dict] in items(stops) - for i in dict.instances - if len(i) > 1 && type(i[1]) != type({}) - if !has_key(dict, 'placeholder') - let dict.placeholder = i[1:] - else - unlet i[1:] - endif - endif - endfor - if !has_key(dict, 'placeholder') - let dict.placeholder = [] - let j = 0 - while len(dict.instances[j]) > 1 - let j += 1 - endwhile - call add(dict.instances[j], '') + for line in a:snippet + let col = s:build_loc_info(line, stops, lnum, col, []) + if line isnot a:snippet[-1] + let lnum += 1 + let col = a:indent endif - unlet dict.instances endfor - let [line, col] = s:build_loc_info(a:snippet, stops, line, col, a:indent) - " add zero tabstop if it doesn't exist and then link it to the highest stop " number let stops[0] = get(stops, 0, - \ { 'placeholder' : [], 'line' : line, 'col' : col }) + \ { 'placeholder' : [], 'line' : lnum, 'col' : col }) let stop_count = max(keys(stops)) + 2 let stops[stop_count - 1] = stops[0] return stop_count endfunction -function! s:build_loc_info(snippet, stops, line, col, indent) abort +function! s:build_loc_info(snippet, stops, lnum, col, seen_items) abort let stops = a:stops - let line = a:line + let lnum = a:lnum let col = a:col let pos = 0 let in_text = 0 + let seen_items = a:seen_items - while pos < len(a:snippet) - let item = a:snippet[pos] - + for item in a:snippet if type(item) == type('') - if in_text - let line += 1 - let col = a:indent - endif let col += len(item) - let in_text = 1 elseif type(item) == type([]) let id = item[0] - if len(item) > 1 && type(item[1]) != type({}) - let stops[id].line = line - let stops[id].col = col - let [line, col] = s:build_loc_info(item[1:], stops, line, col, a:indent) + let stub = item[-1] + let stub.line = lnum + let stub.col = col + call s:add_update_objects(stub, seen_items) + + if len(item) > 2 && type(item[1]) != type({}) + let col = s:build_loc_info(item[1:-2], stops, lnum, col, seen_items) else - call s:add_mirror(stops, id, line, col, item) let col += len(snipMate#placeholder_str(id, stops)) endif + let in_text = 0 endif - - let pos += 1 unlet item " avoid E706 - endwhile + endfor - return [line, col] + return col endfunction -function! s:add_mirror(stops, id, line, col, item) abort - let stops = a:stops - let item = a:item - let stops[a:id].mirrors = get(stops[a:id], 'mirrors', []) - let mirror = get(a:item, 1, {}) - let mirror.line = a:line - let mirror.col = a:col - call add(stops[a:id].mirrors, mirror) - if len(item) == 1 - call add(item, mirror) - endif +function! s:add_update_objects(object, targets) abort + let targets = a:targets + + for item in targets + let item.update_objects = get(item, 'update_objects', []) + call add(item.update_objects, a:object) + endfor + + call add(targets, a:object) endfunction " reads a .snippets file @@ -223,6 +196,9 @@ fun! snipMate#ReadSnippetsFile(file) abort if line[:6] == 'snippet' let inSnip = 1 let bang = (line[7] == '!') + if bang + let bang += line[8] == '!' + endif let trigger = strpart(line, 8 + bang) let name = '' let space = stridx(trigger, ' ') + 1 @@ -280,7 +256,9 @@ fun! s:AddScopeAliases(list) abort return keys(did) endf -au SourceCmd *.snippet,*.snippets call s:source_snippet() +augroup SnipMateSource + au SourceCmd *.snippet,*.snippets call s:source_snippet() +augroup END function! s:info_from_filename(file) abort let parts = split(fnamemodify(a:file, ':r'), '/') @@ -336,7 +314,10 @@ endfunction function! snipMate#SetByPath(dict, trigger, path, snippet, bang, snipversion) abort let d = a:dict - if !has_key(d, a:trigger) || a:bang + if a:bang == 2 + unlet! d[a:trigger] + return + elseif !has_key(d, a:trigger) || a:bang == 1 let d[a:trigger] = {} endif let d[a:trigger][a:path] = [a:snippet, a:snipversion] @@ -434,14 +415,13 @@ endf " used by both: completion and insert snippet fun! snipMate#GetSnippetsForWordBelowCursor(word, exact) abort - " Setup lookups: '1.2.3' becomes [1.2.3] + [3, 2.3] - let parts = split(a:word, '\W\zs') - " Since '\W\zs' results in splitting *after* a non-keyword character, the - " first \W stays connected to whatever's before it, so split it off - if !empty(parts) && parts[0] =~ '\W$' - let parts = [ parts[0][:-2], strpart(parts[0], len(parts[0]) - 1) ] - \ + parts[1:] - endif + " Split non-word characters into their own piece + " so 'foo.bar..baz' becomes ['foo', '.', 'bar', '.', '.', 'baz'] + " First split just after a \W and then split each resultant string just + " before a \W + let parts = filter(tlib#list#Flatten( + \ map(split(a:word, '\W\zs'), 'split(v:val, "\\ze\\W")')), + \ '!empty(v:val)') " Only look at the last few possibilities. Too many can be slow. if len(parts) > 5 let parts = parts[-5:] diff --git a/sources_non_forked/vim-snipmate/autoload/snipmate/jumping.vim b/sources_non_forked/vim-snipmate/autoload/snipmate/jumping.vim index 25db9614..aaf65ab5 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipmate/jumping.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipmate/jumping.vim @@ -113,7 +113,7 @@ function! s:state_update_changes() dict abort return self.remove() endif - call self.update(self.cur_stop, change_len) + call self.update(self.cur_stop, change_len, change_len) if !empty(self.mirrors) call self.update_mirrors(change_len) endif @@ -141,14 +141,37 @@ function! s:state_update_mirrors(change) dict abort endif endfor - call self.update(mirror, changeLen) + if has_key(mirror, 'oldSize') + " recover the old size deduce the endline + let oldSize = mirror.oldSize + else + " first time, we use the intitial size + let oldSize = strlen(newWord) + endif + " Split the line into three parts: the mirror, what's before it, and " what's after it. Then combine them using the new mirror string. " Subtract one to go from column index to byte index + let theline = getline(mirror.line) - let update = strpart(theline, 0, mirror.col - 1) - let update .= substitute(newWord, get(mirror, 'pat', ''), get(mirror, 'sub', ''), get(mirror, 'flags', '')) - let update .= strpart(theline, mirror.col + self.end_col - self.start_col - a:change - 1) + + " part before the current mirror + let beginline = strpart(theline, 0, mirror.col - 1) + + " current mirror transformation, and save size + let wordMirror= substitute(newWord, get(mirror, 'pat', ''), get(mirror, 'sub', ''), get(mirror, 'flags', '')) + let mirror.oldSize = strlen(wordMirror) + + " end of the line, use the oldSize because with the transformation, + " the size of the mirror can be different from those of the snippet + let endline = strpart(theline, mirror.col + oldSize -1) + + " Update other object on the line + call self.update(mirror, changeLen, mirror.oldSize - oldSize) + + " reconstruct the line + let update = beginline.wordMirror.endline + call setline(mirror.line, update) endfor @@ -179,17 +202,17 @@ function! s:state_find_update_objects(item) dict abort return item.update_objects endfunction -function! s:state_update(item, change_len) dict abort +function! s:state_update(item, change_len, mirror_change) dict abort let item = a:item - if exists('item.update_objects') - let to_update = item.update_objects - else - let to_update = self.find_update_objects(a:item) - let item.update_objects = to_update + if !exists('item.update_objects') + let item.update_objects = self.find_update_objects(a:item) endif + let to_update = item.update_objects for obj in to_update - let obj.col += a:change_len + " object does not necessarly have the same decalage + " than mirrors if mirrors use regexp + let obj.col += a:mirror_change if obj is self.cur_stop let self.start_col += a:change_len let self.end_col += a:change_len diff --git a/sources_non_forked/vim-snipmate/autoload/snipmate/legacy.vim b/sources_non_forked/vim-snipmate/autoload/snipmate/legacy.vim index c4d0a0b6..7ff39cbe 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipmate/legacy.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipmate/legacy.vim @@ -12,8 +12,7 @@ function! snipmate#legacy#process_snippet(snip) abort else let visual = '' endif - let snippet = substitute(snippet, '\n\(\t\+\).\{-\}\zs{VISUAL}', - \ substitute(escape(visual, '%\'), "\n", "\n\\\\1", 'g'), 'g') + let snippet = s:substitute_visual(snippet, visual) " Evaluate eval (`...`) expressions. " Backquotes prefixed with a backslash "\" are ignored. @@ -61,7 +60,7 @@ function! snipmate#legacy#process_snippet(snip) abort endw if &et " Expand tabs to spaces if 'expandtab' is set. - return substitute(snippet, '\t', repeat(' ', (&sts > 0) ? &sts : &sw), 'g') + return substitute(snippet, '\t', repeat(' ', snipmate#util#tabwidth()), 'g') endif return snippet endfunction @@ -87,7 +86,7 @@ function! snipmate#legacy#build_stops(snip, lnum, col, indent) abort let stops[i] = {} let stops[i].line = a:lnum + s:count(beforeTabStop, "\n") - let stops[i].col = a:indent + len(matchstr(withoutOthers, '\_^.*\ze'.s:sigil .'{'.i.'\D')) + let stops[i].col = a:indent + len(matchstr(withoutOthers, '[^\n]\{-}\ze'.s:sigil .'{'.i.'\D')) let stops[i].placeholder = 0 let stops[i].mirrors = [] if stops[i].line == a:lnum @@ -118,6 +117,16 @@ function! snipmate#legacy#build_stops(snip, lnum, col, indent) abort return [stops, i + 1] endfunction +function! s:substitute_visual(snippet, visual) abort + let lines = [] + for line in split(a:snippet, "\n") + let indent = matchstr(line, '^\t\+') + call add(lines, substitute(line, '{VISUAL}', + \ substitute(escape(a:visual, '%\'), "\n", "\n" . indent, 'g'), 'g')) + endfor + return join(lines, "\n") +endfunction + " Counts occurences of haystack in needle function! s:count(haystack, needle) abort let counter = 0 diff --git a/sources_non_forked/vim-snipmate/autoload/snipmate/parse.vim b/sources_non_forked/vim-snipmate/autoload/snipmate/parse.vim index 2dd60a3f..dd495e95 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipmate/parse.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipmate/parse.vim @@ -5,6 +5,7 @@ function! s:sfile() abort endfunction let s:parser_proto = {} +let s:special_chars = "$`\n" function! s:new_parser(text) abort let ret = copy(s:parser_proto) @@ -14,6 +15,7 @@ function! s:new_parser(text) abort let ret.indent = 0 let ret.value = [] let ret.vars = {} + let ret.stored_lines = [] call ret.advance() return ret endfunction @@ -82,35 +84,56 @@ function! s:parser_varend() dict abort endfunction function! s:parser_placeholder() dict abort - return self.parse('}') + let ret = self.text('}') + return empty(ret) ? [''] : ret endfunction function! s:parser_subst() dict abort let ret = {} - let ret.pat = join(self.text('/', 1)) + let ret.pat = self.pat() if self.same('/') - let ret.sub = join(self.text('/}')) + let ret.sub = self.pat(1) endif if self.same('/') - let ret.flags = join(self.text('}', 1)) + let ret.flags = self.pat(1) endif return ret endfunction +function! s:parser_pat(...) dict abort + let val = '' + + while self.pos < self.len + if self.same('\') + if self.next == '/' + let val .= '/' + call self.advance() + elseif a:0 && self.next == '}' + let val .= '}' + call self.advance() + else + let val .= '\' + endif + elseif self.next == '/' || a:0 && self.next == '}' + break + else + let val .= self.next + call self.advance() + endif + endwhile + + return val +endfunction + function! s:parser_expr() dict abort - let str = join(self.text('`', 1)) + let str = self.string('`') call self.same('`') return snipmate#util#eval(str) endfunction -function! s:parser_text(...) dict abort - let res = [] +function! s:parser_string(till, ...) dict abort let val = '' - if a:0 == 2 && a:2 - let till = '\V' . escape(a:1, '\') - else - let till = '[`$' . (a:0 ? a:1 : '') . ']' - endif + let till = '\V\[' . escape(a:till, '\') . ']' while self.pos < self.len if self.same('\') @@ -120,11 +143,6 @@ function! s:parser_text(...) dict abort call self.advance() elseif self.next =~# till break - elseif self.next == "\n" - call add(res, val) - let val = '' - let self.indent = 0 - call self.advance() elseif self.next == "\t" let self.indent += 1 let val .= s:indent(1) @@ -135,59 +153,81 @@ function! s:parser_text(...) dict abort endif endwhile - call add(res, val) - return res + return val endfunction -function! s:parser_parse(...) dict abort - let ret = a:0 ? [] : self.value +function! s:join_consecutive_strings(list) abort + let list = a:list + let pos = 0 + while pos + 1 < len(list) + if type(list[pos]) == type('') && type(list[pos+1]) == type('') + let list[pos] .= list[pos+1] + call remove(list, pos + 1) + else + let pos += 1 + endif + endwhile +endfunction + +function! s:parser_text(till) dict abort + let ret = [] + while self.pos < self.len + let lines = [] + if self.same('$') let var = self.var() if !empty(var) if var[0] is# 'VISUAL' - let add_to = s:visual_placeholder(var, self.indent) - if !empty(ret) && type(ret[-1]) == type('') - let ret[-1] .= add_to[0] - else - call add(ret, add_to[0]) - endif - call extend(ret, add_to[1:-1]) + let lines = s:visual_placeholder(var, self.indent) elseif var[0] >= 0 call add(ret, var) call self.add_var(var) endif endif elseif self.same('`') - let add_to = self.expr() - if !empty(ret) && type(ret[-1]) == type('') - let ret[-1] .= add_to - else - call add(ret, add_to) - endif + let lines = split(self.expr(), "\n", 1) else - let text = a:0 ? self.text(a:1) : self.text() - if exists('add_to') - let ret[-1] .= text[0] - call remove(text, 0) - unlet add_to - endif - call extend(ret, text) + let lines = [self.string(a:till . s:special_chars)] endif - if a:0 && self.next == a:1 + + if !empty(lines) + call add(ret, lines[0]) + call extend(self.stored_lines, lines[1:]) + endif + + " Empty lines are ignored if this is tested at the start of an iteration + if self.next ==# a:till break endif endwhile + + call s:join_consecutive_strings(ret) return ret endfunction -call extend(s:parser_proto, snipmate#util#add_methods(s:sfile(), 'parser', - \ [ 'advance', 'same', 'id', 'add_var', 'var', 'varend', - \ 'placeholder', 'subst', 'expr', 'text', 'parse' ]), 'error') +function! s:parser_line() dict abort + let ret = [] + if !empty(self.stored_lines) + call add(ret, remove(self.stored_lines, 0)) + else + call extend(ret, self.text("\n")) + call self.same("\n") + endif + let self.indent = 0 + return ret +endfunction + +function! s:parser_parse() dict abort + while self.pos < self.len || !empty(self.stored_lines) + let line = self.line() + call add(self.value, line) + endwhile +endfunction function! s:indent(count) abort if &expandtab - let shift = repeat(' ', (&sts > 0) ? &sts : &sw) + let shift = repeat(' ', snipmate#util#tabwidth()) else let shift = "\t" endif @@ -211,9 +251,59 @@ function! s:visual_placeholder(var, indent) abort return content endfunction -function! snipmate#parse#snippet(text) abort +function! s:parser_create_stubs() dict abort + + for [id, dict] in items(self.vars) + for i in dict.instances + if len(i) > 1 && type(i[1]) != type({}) + if !has_key(dict, 'placeholder') + let dict.placeholder = i[1:] + call add(i, dict) + else + unlet i[1:] + call s:create_mirror_stub(i, dict) + endif + else + call s:create_mirror_stub(i, dict) + endif + endfor + if !has_key(dict, 'placeholder') + let dict.placeholder = [] + let j = 0 + while len(dict.instances[j]) > 2 + let j += 1 + endwhile + let oldstub = remove(dict.instances[j], 1, -1)[-1] + call add(dict.instances[j], '') + call add(dict.instances[j], dict) + call filter(dict.mirrors, 'v:val isnot oldstub') + endif + unlet dict.instances + endfor + +endfunction + +function! s:create_mirror_stub(mirror, dict) + let mirror = a:mirror + let dict = a:dict + let stub = get(mirror, 1, {}) + call add(mirror, stub) + let dict.mirrors = get(dict, 'mirrors', []) + call add(dict.mirrors, stub) +endfunction + +function! snipmate#parse#snippet(text, ...) abort let parser = s:new_parser(a:text) call parser.parse() + if !(a:0 && a:1) + call parser.create_stubs() + endif unlet! b:snipmate_visual return [parser.value, parser.vars] endfunction + +call extend(s:parser_proto, snipmate#util#add_methods(s:sfile(), 'parser', + \ [ 'advance', 'same', 'id', 'add_var', 'var', 'varend', + \ 'line', 'string', 'create_stubs', 'pat', + \ 'placeholder', 'subst', 'expr', 'text', 'parse', + \ ]), 'error') diff --git a/sources_non_forked/vim-snipmate/autoload/snipmate/util.vim b/sources_non_forked/vim-snipmate/autoload/snipmate/util.vim index cb7ddc83..a80d3077 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipmate/util.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipmate/util.vim @@ -20,3 +20,11 @@ function! snipmate#util#eval(arg) endtry return type(ret) == type('') ? ret : string(ret) endfunction + +function! snipmate#util#tabwidth() + if &sts > 0 + return &sts + else + return exists('*shiftwidth') ? shiftwidth() : &sw + endif +endfunction diff --git a/sources_non_forked/vim-snipmate/doc/snipMate.txt b/sources_non_forked/vim-snipmate/doc/snipMate.txt index a8d321ed..230fe686 100644 --- a/sources_non_forked/vim-snipmate/doc/snipMate.txt +++ b/sources_non_forked/vim-snipmate/doc/snipMate.txt @@ -1,7 +1,6 @@ *SnipMate.txt* Plugin for using TextMate-style snippets in Vim. SnipMate *snippet* *snippets* *SnipMate* -Last Change: December 27, 2009 1. Description |SnipMate-description| 2. Usage |SnipMate-usage| @@ -158,7 +157,8 @@ g:snipMate.override file they were in. When this option is enabled (set to 1), the snippet originating in the last loaded file is kept, similar to how Vim - maps and other settings work. + maps and other settings work. Note: Load order + is determined by 'runtimepath'. g:snipMate['no_match_completion_feedkeys_chars'] A string inserted when no match for a trigger @@ -252,6 +252,9 @@ overridden on a per-snippet basis by defining the snippet with a bang (!): > expanded text more expanded text +Two bangs will remove the trigger entirely from SnipMate's lookup. In this +case any snippet text is unused. + Note: Hard tabs in the expansion text are required. When the snippet is expanded in the text and 'expandtab' is set, each tab will be replaced with spaces based on 'softtabstop' if nonzero or 'shiftwidth' otherwise. @@ -301,18 +304,19 @@ and so on. After expansion, SnipMate will jump to the first tab stop. From then on, the snipMateNextOrTrigger map will jump to the next higher numbered tabs top. -However, SnipMate will always stop at the zero tab stop $0. Once it jumps to +In the case of an ambiguity, for example if a stop occurs just before +a literal number, braces may be placed around the stop number to resolve it: +${3}79 is the third tab stop followed by the string "79". + +NOTE: In the version 0 snippet parser, the braces are mandatory. + + *SnipMate-zero-tabstop* +SnipMate will always stop at the special zero tab stop $0. Once it jumps to the zero tab stop, snippet expansion is finished. If the zero tab stop is not present in a definition, it will be put at the end. -In the case of an ambiguity, for example if a stop occurs just before a literal -number, braces may be placed around the stop number to resolve it: ${3}79 is -the third tab stop followed by the string "79". - -Note: In the version 0 snippet parser, the braces are mandatory. - -For example, to place the cursor first on the id of a
            tag, then on -its class, and finally end editing its contents: > +For example, to place the cursor first on the id of a
            tag, then on its +class, and finally end editing its contents: > snippet div
            @@ -499,6 +503,15 @@ Perhaps some of these features will be added in a later release. ============================================================================== CHANGELOG *SnipMate-changelog* +0.89 - 2016-05-29 +----------------- + +* Various regex updates to legacy parser Addition of double bang syntax to +* completely remove a snippet from lookup Group various SnipMate autocommands +* Support setting 'shiftwidth' to 0 Parser now operates linewise, adding some +* flexibility Mirror substitutions are more literal Mirror length is +* calculated correctly when substitutions occur + 0.88 - 2015-04-04 ----------------- diff --git a/sources_non_forked/vim-snipmate/plugin/snipMate.vim b/sources_non_forked/vim-snipmate/plugin/snipMate.vim index 246b542c..837f0dcc 100644 --- a/sources_non_forked/vim-snipmate/plugin/snipMate.vim +++ b/sources_non_forked/vim-snipmate/plugin/snipMate.vim @@ -28,12 +28,14 @@ if (!exists('g:snipMateSources')) let g:snipMateSources['default'] = funcref#Function('snipMate#DefaultPool') endif -au BufRead,BufNewFile *.snippet,*.snippets setlocal filetype=snippets -au FileType snippets if expand(':e') =~# 'snippet$' +augroup SnipMateDetect + au BufRead,BufNewFile *.snippet,*.snippets setlocal filetype=snippets + au FileType snippets if expand(':e') =~# 'snippet$' \ | setlocal syntax=snippet - \ | else - \ | setlocal syntax=snippets - \ | endif + \ | else + \ | setlocal syntax=snippets + \ | endif +augroup END inoremap snipMateNextOrTrigger =snipMate#TriggerSnippet() snoremap snipMateNextOrTrigger a=snipMate#TriggerSnippet() diff --git a/sources_non_forked/vim-snipmate/t/parser.vim b/sources_non_forked/vim-snipmate/t/parser.vim index 053bad8a..c5cf8739 100644 --- a/sources_non_forked/vim-snipmate/t/parser.vim +++ b/sources_non_forked/vim-snipmate/t/parser.vim @@ -2,27 +2,27 @@ describe 'snippet parser' before function! Parse(snippet, ...) - let [snip, stops] = snipmate#parse#snippet(a:snippet) - return a:0 ? [snip, stops] : snip + let [snip, stops] = snipmate#parse#snippet(a:snippet, (a:0 ? a:1 : 1)) + return (a:0 > 1 && a:2) ? [snip, stops] : snip endfunction let b:snipmate_visual = 'testvisual' end it 'parses numeric $id and ${id} vars as [id] lists' - let expect = [[1234567890]] + let expect = [[[1234567890]]] Expect Parse('$1234567890') == expect Expect Parse('${1234567890}') == expect end it 'disregards $ or ${ followed by a non-id' - Expect Parse('$x1') == ['x1'] - Expect Parse('${x}1') == ['x}1'] - Expect Parse('$VISUA1') == ['VISUA1'] - Expect Parse('${VISUA}1') == ['VISUA}1'] + Expect Parse('$x1') == [['x1']] + Expect Parse('${x}1') == [['x}1']] + Expect Parse('$VISUA1') == [['VISUA1']] + Expect Parse('${VISUA}1') == [['VISUA}1']] end it 'gathers references to each instance of each stop id' - let [snip, b:stops] = Parse('x$1x${2:x$1x}x$1x${1/a/b}x$VISUALx', 1) + let [snip, b:stops] = Parse('x$1x${2:x$1x}x$1x${1/a/b}x$VISUALx', 1, 1) function! InstanceFound(list) return !empty(filter(copy(b:stops[a:list[0]].instances), \ 'v:val is a:list')) @@ -36,81 +36,107 @@ describe 'snippet parser' unlet item " E732 endfor endfunction - call CheckList(snip) + call CheckList(snip[0]) end it 'parses mirror substitutions ${n/pat/sub} as [n, {...}]' - let expect = [[1, { 'pat' : 'abc', 'sub' : 'def' }]] + let expect = [[[1, { 'pat' : 'abc', 'sub' : 'def' }]]] Expect Parse('${1/abc/def}') == expect - let expect[0][1].flags = '' + let expect[0][0][1].flags = '' Expect Parse('${1/abc/def/}') == expect - let expect[0][1].flags = 'g' + let expect[0][0][1].flags = 'g' Expect Parse('${1/abc/def/g}') == expect end + it 'reads patterns literally except for "\/"' + Expect Parse('${1/\a\/b/\c\/d\}}') == [[[1, { 'pat' : '\a/b', 'sub' : '\c/d}' }]]] + end + it 'parses vars with placeholders as [id, placeholder] lists' - Expect Parse('${1:abc}') == [[1, 'abc']] + Expect Parse('${1:abc}') == [[[1, 'abc']]] end it 'evaluates backtick expressions' - Expect Parse('`fnamemodify("x.y", ":r")`') == ['x'] + Expect Parse('`fnamemodify("x.y", ":r")`') == [['x']] end it 'parses placeholders for vars and other specials' let text = 'a `fnamemodify("x.y", ":r")` ${2:(${3/a/b})}' let expect = ['a x ', [2, '(', [3, { 'pat' : 'a', 'sub' : 'b' }], ')']] - Expect Parse(text) == expect - Expect Parse(printf('${1:%s}', text)) == [[1] + expect] + Expect Parse(text) == [expect] + Expect Parse(printf('${1:%s}', text)) == [[[1] + expect]] end - it 'converts tabs according to &et, &sts, &sw' + it 'converts tabs according to &et, &sts, &sw, &ts' " &noet -> leave tabs alone setl noet - Expect Parse("abc\tdef\n\t\tghi") == ["abc\tdef", "\t\tghi"] + Expect Parse("abc\tdef\n\t\tghi") == [["abc\tdef"], ["\t\tghi"]] " &et -> &sts or &sw setl et sts=2 sw=3 - Expect Parse("abc\tdef\n\t\tghi") == ["abc def", " ghi"] + Expect Parse("abc\tdef\n\t\tghi") == [["abc def"], [" ghi"]] setl et sts=0 sw=3 - Expect Parse("abc\tdef\n\t\tghi") == ["abc def", " ghi"] + Expect Parse("abc\tdef\n\t\tghi") == [["abc def"], [" ghi"]] setl et sts=-1 sw=3 - Expect Parse("abc\tdef\n\t\tghi") == ["abc def", " ghi"] + Expect Parse("abc\tdef\n\t\tghi") == [["abc def"], [" ghi"]] + + " See #227 + if exists('*shiftwidth') + setl et sts=0 sw=0 ts=3 + Expect Parse("abc\tdef\n\t\tghi") == [["abc def"], [" ghi"]] + endif end it 'parses backslashes as escaping the next character or joining lines' - Expect Parse('x\x') == ['xx'] - Expect Parse('x\\x') == ['x\x'] - Expect Parse("x\\\nx") == ['xx'] - Expect Parse('x\$1') == ['x$1'] - Expect Parse('${1:\}}') == [[1, '}']] - Expect Parse('${1/\//\}}') == [[1, { 'pat' : '/', 'sub' : '}' }]] - Expect Parse('`fnamemodify("\`.x", ":r")`') == ['`'] - Expect Parse('\`x\`') == ['`x`'] + Expect Parse('x\x') == [['xx']] + Expect Parse('x\\x') == [['x\x']] + Expect Parse("x\\\nx") == [['xx']] + Expect Parse('x\$1') == [['x$1']] + Expect Parse('${1:\}}') == [[[1, '}']]] + Expect Parse('`fnamemodify("\`.x", ":r")`') == [['`']] + Expect Parse('\`x\`') == [['`x`']] end it 'splits text at newlines' - Expect Parse("x\nx") == ['x', 'x'] + Expect Parse("x\nx") == [['x'], ['x']] end it 'joins evaluated expressions to surrounding text on the same line' let g:foo = 'bar' - Expect Parse("x`g:foo`x") == ['xbarx'] - Expect Parse("x`g:foo`\nx") == ['xbar', 'x'] - Expect Parse("x\n`g:foo`x") == ['x', 'barx'] - end - - it 'adds empty strings before/after vars if at the start/end of a line' - Expect Parse("x$1\nx") == ['x', [1], '', 'x'] - Expect Parse("x\n$1x") == ['x', '', [1], 'x'] + Expect Parse("x`g:foo`x") == [['xbarx']] + Expect Parse("x`g:foo`\nx") == [['xbar'], ['x']] + Expect Parse("x\n`g:foo`x") == [['x'], ['barx']] end it 'expands $VISUAL placeholders with any indents' - Expect Parse("x$VISUALx") == ['xtestvisualx'] + Expect Parse("x$VISUALx") == [['xtestvisualx']] let b:snipmate_visual = " foo\nbar\n baz" setl noet - Expect Parse("\tx\n\t$VISUAL\nx") == ["\tx", "\t foo", "\tbar", "\t baz", "x"] + Expect Parse("\tx\n\t$VISUAL\nx") == [["\tx"], ["\t foo"], ["\tbar"], + \ ["\t baz"], ["x"]] + end + + it 'determines which var with an id is the stop' + let [snip, stops] = Parse("$1$1$1", 0, 1) + Expect snip == [[[1, "", stops[1]], [1, {}], [1, {}]]] + + let [snip, stops] = Parse("$1${1}$1", 0, 1) + Expect snip == [[[1, "", stops[1]], [1, {}], [1, {}]]] + + let [snip, stops] = Parse("$1${1:}$1", 0, 1) + Expect snip == [[[1, {}], [1, "", stops[1]], [1, {}]]] + + end + + it 'picks the first of many possible stops' + let [snip, stops] = Parse("$1${1:foo}${1:bar}", 0, 1) + Expect snip == [[[1, {}], [1, "foo", stops[1]], [1, {}]]] + end + + it 'represents empty lines as an empty string' + Expect Parse("foo\n\nbar") == [['foo'], [''], ['bar']] end end diff --git a/sources_non_forked/vim-snippets/README.md b/sources_non_forked/vim-snippets/README.md index f4160650..d4e83c33 100644 --- a/sources_non_forked/vim-snippets/README.md +++ b/sources_non_forked/vim-snippets/README.md @@ -60,6 +60,26 @@ improved by Adnan Zafar. So maybe time is not ready to make a final decision yet [github issue/discussion](https://github.com/honza/vim-snippets/issues/363) +Vendor Snippets +--------------- + +Additional library and framework snippets are available for UltiSnips users in +the `UltiSnips/` directory. These files are removed from the default language +namespaces to prevent them from all being loaded automatically. If there is a +separate library, framework, or package you would like to support open a pull +request! + +Additional snippets can be added to the current buffer with the +`:UltiSnipsAddFiletypes` command followed by the snippet name without the +"snippets" ending. For example, to add the JavaScript Jasmine snippets, run: +`:UltiSnipsAddFiletypes javascript-jasmine`. To have this snippet loaded +everytime a JavaScript file is opened or created you can add the command to your + -`.vim/ftplugin/javascript.vim` file. Another way is to add + `autocmd FileType js UltiSnipsAddFiletypes javascript-jasmine` in your `.vimrc`. + + +For more see the UltiSnips docs (`:help UltiSnips`). + Installation ------------ @@ -151,6 +171,7 @@ so that all users can benefit from them. People can list their snippet reposito * https://github.com/sudar/vim-arduino-snippets (snippets for Arduino files) * https://github.com/zedr/zope-snipmate-bundle.git (snippets for Python, TAL and ZCML) * https://github.com/bonsaiben/bootstrap-snippets (snippets for Twitter Bootstrap markup, in HTML and Haml) +* https://github.com/sniphpets (advanced snippets for PHP, Symfony 2/3, Doctrine and etc.) Installation using VAM: https://github.com/MarcWeber/vim-addon-manager @@ -216,6 +237,7 @@ This list is kept up-to-date on a best effort basis. * Python - [honza](http://github.com/honza) * Ruby - [taq](http://github.com/taq) * Scala - [gorodinskiy](https://github.com/gorodinskiy) +* Supercollider - [lpil](https://github.com/lpil) License ------- diff --git a/sources_non_forked/vim-snippets/UltiSnips/ada.snippets b/sources_non_forked/vim-snippets/UltiSnips/ada.snippets index cc35c2c2..bea2a6cd 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/ada.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/ada.snippets @@ -5,7 +5,9 @@ global !p def ada_case(word): out = word[0].upper() for i in range(1, len(word)): - if word[i - 1] == '_': + if word[i] == '-': + out = out + '.' + elif word[i - 1] == '_' or word[i - 1] == '-': out = out + word[i].upper() else: out = out + word[i] diff --git a/sources_non_forked/vim-snippets/UltiSnips/all.snippets b/sources_non_forked/vim-snippets/UltiSnips/all.snippets index fb6138a1..0e286e5a 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/all.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/all.snippets @@ -10,69 +10,7 @@ priority -60 # NICE BOXES # ############## global !p -import string, vim - -""" Maps a filetype to comment format used for boxes. -Automatically filled during usage""" -_commentDict = { } - -def _parse_comments(s): - """ Parses vim's comments option to extract comment format """ - i = iter(s.split(",")) - - rv = [] - try: - while True: - # get the flags and text of a comment part - flags, text = next(i).split(':', 1) - - if len(flags) == 0: - rv.append((text, text, text, "")) - # parse 3-part comment, but ignore those with O flag - elif 's' in flags and 'O' not in flags: - ctriple = [] - indent = "" - - if flags[-1] in string.digits: - indent = " " * int(flags[-1]) - ctriple.append(text) - - flags,text = next(i).split(':', 1) - assert(flags[0] == 'm') - ctriple.append(text) - - flags,text = next(i).split(':', 1) - assert(flags[0] == 'e') - ctriple.append(text) - ctriple.append(indent) - - rv.append(ctriple) - elif 'b' in flags: - if len(text) == 1: - rv.insert(0, (text,text,text, "")) - except StopIteration: - return rv - -def _get_comment_format(): - """ Returns a 4-element tuple representing the comment format for - the current file. """ - return _parse_comments(vim.eval("&comments"))[0] - - -def make_box(twidth, bwidth=None): - b, m, e, i = _get_comment_format() - bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2 - sline = b + m + bwidth_inner * m[0] + 2 * m[0] - nspaces = (bwidth_inner - twidth) // 2 - mlines = i + m + " " + " " * nspaces - mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m - eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e - return sline, mlines, mlinee, eline - -def foldmarker(): - "Return a tuple of (open fold marker, close fold marker)" - return vim.eval("&foldmarker").split(",") - +from vimsnippets import foldmarker, make_box, get_comment_format endglobal snippet box "A nice box with the current comment symbol" b @@ -102,17 +40,17 @@ $0 endsnippet snippet fold "Insert a vim fold marker" b -`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = _get_comment_format()[2]` +`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = get_comment_format()[2]` endsnippet snippet foldc "Insert a vim fold close marker" b -`!p snip.rv = _get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = _get_comment_format()[2]` +`!p snip.rv = get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = get_comment_format()[2]` endsnippet snippet foldp "Insert a vim fold marker pair" b -`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = _get_comment_format()[2]` +`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = get_comment_format()[2]` ${2:${VISUAL:Content}} -`!p snip.rv = _get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = _get_comment_format()[2]` +`!p snip.rv = get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = get_comment_format()[2]` endsnippet ########################## diff --git a/sources_non_forked/vim-snippets/UltiSnips/c.snippets b/sources_non_forked/vim-snippets/UltiSnips/c.snippets index 5c4299c6..c9894649 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/c.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/c.snippets @@ -8,10 +8,10 @@ snippet def "#define ..." #define ${1} endsnippet -snippet ifndef "#ifndef ... #define ... #endif" +snippet #ifndef "#ifndef ... #define ... #endif" #ifndef ${1/([A-Za-z0-9_]+).*/$1/} #define ${1:SYMBOL} ${2:value} -#endif +#endif /* ifndef $1 */ endsnippet snippet #if "#if #endif" b @@ -20,14 +20,6 @@ ${VISUAL}${0} #endif endsnippet -snippet inc "#include local header (inc)" -#include "${1:`!p snip.rv = snip.basename + '.h'`}" -endsnippet - -snippet Inc "#include <> (Inc)" -#include <${1:.h}> -endsnippet - snippet mark "#pragma mark (mark)" #if 0 ${1:#pragma mark - @@ -57,10 +49,6 @@ for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { } endsnippet -snippet enum "Enumeration" -enum ${1:name} { $0 }; -endsnippet - snippet once "Include header once only guard" #ifndef ${1:`!p if not snip.c: @@ -77,22 +65,6 @@ ${VISUAL}${0} #endif /* end of include guard: $1 */ endsnippet -snippet td "Typedef" -typedef ${1:int} ${2:MyCustomType}; -endsnippet - -snippet wh "while loop" -while(${1:/* condition */}) { - ${VISUAL}${0} -} -endsnippet - -snippet do "do...while loop (do)" -do { - ${VISUAL}${0} -} while(${1:/* condition */}); -endsnippet - snippet fprintf "fprintf ..." fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/} endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/coffee_jasmine.snippets b/sources_non_forked/vim-snippets/UltiSnips/coffee-jasmine.snippets similarity index 100% rename from sources_non_forked/vim-snippets/UltiSnips/coffee_jasmine.snippets rename to sources_non_forked/vim-snippets/UltiSnips/coffee-jasmine.snippets diff --git a/sources_non_forked/vim-snippets/UltiSnips/coffee-react.snippets b/sources_non_forked/vim-snippets/UltiSnips/coffee-react.snippets new file mode 100644 index 00000000..4cdb40f8 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/coffee-react.snippets @@ -0,0 +1,80 @@ +# +# CoffeeScript versions -- adapted from coffee-jasmine +# for some ReactJS matchers. +# +priority -50 + +extends coffee + +priority -49 + +snippet createClass "React define Class" b +${1:classname}Class = React.createClass + displayName: "$1" + render: -> + ${2} +$1 = React.createFactory($1) +endsnippet + +snippet PropTypes "React define propTypes" b +propTypes: -> + ${1:myVar}: React.PropTypes.${2:type}${3:.isRequired} +endsnippet + +snippet propType "React propType (key/value)" b +${1:myVar}: React.PropTypes.${2:type}${3:.isRequired} +${4} +endsnippet + +snippet setState "React setState" b +@setState + ${1:myvar}: ${2:myvalue} + ${3} +endsnippet + +snippet getInitialState "React define getInitialState" b +getInitialState: -> + ${1:myvar}: ${2:myvalue} + ${3} +endsnippet + +snippet getDefaultProps "React define getDefaultProps" b +getDefaultProps: -> + ${1:myvar}: ${2:myvalue} + ${3} +endsnippet + +snippet componentWillMount "React define componentWillMount" b +componentWillMount: -> + ${1} +endsnippet + +snippet componentDidMount "React define componentDidMount" b +componentDidMount: -> + ${1} +endsnippet + +snippet componentWillReceiveProps "React define componentWillReceiveProps" b +componentWillReceiveProps: (nextProps) -> + ${1} +endsnippet + +snippet shouldComponentUpdate "React define shouldComponentUpdate" b +shouldComponentUpdate: (nextProps, nextState) -> + ${1} +endsnippet + +snippet componentWillUpdate "React define componentWillUpdate" b +componentWillUpdate: (nextProps, nextState) -> + ${1} +endsnippet + +snippet componentDidUpdate "React define componentDidUpdate" b +componentDidUpdate: (prevProps, prevState) -> + ${1} +endsnippet + +snippet componentWillUnmount "React define componentWillUnmount" b +componentWillUnmount: -> + ${1} +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets b/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets index 467b2b57..75e7d062 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets @@ -94,3 +94,7 @@ endsnippet snippet log "Log" b console.log ${1:"${2:msg}"} endsnippet + +snippet kv "Key:value for object" b +${1:key}:${2:value} +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets b/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets index c2cb3d03..f7c2bd83 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets @@ -54,4 +54,20 @@ snippet tp "template (template)" template endsnippet +snippet cla "An entire .h generator" b +#ifndef ${2:`!v substitute(vim_snippets#Filename('$1_H','ClassName'),'.*','\U&\E','')`} +#define $2 + +class ${1:`!v substitute(substitute(vim_snippets#Filename('$1','ClassName'),'^.','\u&',''), '_\(\w\)', '\u\1', 'g')`} +{ +private: + ${3} + +public: + $1(); + virtual ~$1(); +}; + +#endif /* $2 */ +endsnippet # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/django.snippets b/sources_non_forked/vim-snippets/UltiSnips/django.snippets index 9d6ce279..0ba6c9d5 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/django.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/django.snippets @@ -1,238 +1,361 @@ priority -50 -# Generic Tags -snippet % -{% ${1} %}${2} +# This files will define django snippets from sublime text djaneiro +# FORMS SNIPPETS + +snippet form "Form" b +class ${1:FORMNAME}(forms.Form): + + ${2:# TODO: Define form fields here} endsnippet -snippet %% -{% ${1:tag_name} %} - ${2} -{% end$1 %} +snippet modelform "ModelForm" b +class ${1:MODELNAME}Form(forms.ModelForm): + + class Meta: + model = $1 endsnippet -snippet { -{{ ${1} }}${2} +snippet fbool "BooleanField" b +${1:FIELDNAME} = forms.BooleanField($2) endsnippet -# Template Tags - -snippet autoescape -{% autoescape ${1:off} %} - ${2} -{% endautoescape %} +snippet fchar "CharField" b +${1:FIELDNAME} = forms.CharField($2) endsnippet -snippet block -{% block ${1} %} - ${2} -{% endblock $1 %} +snippet fchoice "ChoiceField" b +${1:FIELDNAME} = forms.ChoiceField($2) endsnippet -snippet # -{# ${1:comment} #} +snippet fcombo "ComboField" b +${1:FIELDNAME} = forms.ComboField($2) endsnippet -snippet comment -{% comment %} - ${1} -{% endcomment %} +snippet fdate "DateField" b +${1:FIELDNAME} = forms.DateField($2) endsnippet -snippet cycle -{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +snippet fdatetime "DateTimeField" b +${1:FIELDNAME} = forms.DateTimeField($2) endsnippet -snippet debug -{% debug %} +snippet fdecimal "DecimalField" b +${1:FIELDNAME} = forms.DecimalField($2) endsnippet -snippet extends -{% extends "${1:base.html}" %} +snippet fmail "EmailField" b +${1:FIELDNAME} = forms.EmailField($2) endsnippet -snippet filter -{% filter ${1} %} - ${2} -{% endfilter %} +snippet ffile "FileField" b +${1:FIELDNAME} = forms.FileField($2) endsnippet -snippet firstof -{% firstof ${1} %} +snippet ffilepath "FilePathField" b +${1:FIELDNAME} = forms.FilePathField($2) endsnippet -snippet for -{% for ${1} in ${2} %} - ${3} -{% endfor %} +snippet ffloat "FloatField" b +${1:FIELDNAME} = forms.FloatField($2) endsnippet -snippet empty -{% empty %} - ${1} +snippet fip "IPAddressField" b +${1:FIELDNAME} = forms.IPAddressField($2) endsnippet -snippet if -{% if ${1} %} - ${2} -{% endif %} +snippet fimg "ImageField" b +${1:FIELDNAME} = forms.ImageField($2) endsnippet -snippet else -{% else %} - ${1} +snippet fint "IntegerField" b +${1:FIELDNAME} = forms.IntegerField($2) endsnippet -snippet ifchanged -{% ifchanged %}${1}{% endifchanged %} +snippet fmochoice "ModelChoiceField" b +${1:FIELDNAME} = forms.ModelChoiceField($2) endsnippet -snippet ifequal -{% ifequal ${1} ${2} %} - ${3} -{% endifequal %} +snippet fmomuchoice "ModelMultipleChoiceField" b +${1:FIELDNAME} = forms.ModelMultipleChoiceField($2) endsnippet -snippet ifnotequal -{% ifnotequal ${1} ${2} %} - ${3} -{% endifnotequal %} +snippet fmuval "MultiValueField" b +${1:FIELDNAME} = forms.MultiValueField($2) endsnippet -snippet include -{% include "${1}" %} +snippet fmuchoice "MultipleChoiceField" b +${1:FIELDNAME} = forms.MultipleChoiceField($2) endsnippet -snippet load -{% load ${1} %} +snippet fnullbool "NullBooleanField" b +${1:FIELDNAME} = forms.NullBooleanField($2) endsnippet -snippet now -{% now "${1:jS F Y H:i}" %} +snippet freg "RegexField" b +${1:FIELDNAME} = forms.RegexField($2) endsnippet -snippet regroup -{% regroup ${1} by ${2} as ${3} %} +snippet fslug "SlugField" b +${1:FIELDNAME} = forms.SlugField($2) endsnippet -snippet spaceless -{% spaceless %}${1}{% endspaceless %} +snippet fsdatetime "SplitDateTimeField" b +${1:FIELDNAME} = forms.SplitDateTimeField($2) endsnippet -snippet ssi -{% ssi ${1} %} +snippet ftime "TimeField" b +${1:FIELDNAME} = forms.TimeField($2) endsnippet -snippet trans -{% trans "${1:string}" %} +snippet ftchoice "TypedChoiceField" b +${1:FIELDNAME} = forms.TypedChoiceField($2) endsnippet -snippet url -{% url ${1} as ${2} %} +snippet ftmuchoice "TypedMultipleChoiceField" b +${1:FIELDNAME} = forms.TypedMultipleChoiceField($2) endsnippet -snippet widthratio -{% widthratio ${1:this_value} ${2:max_value} ${3:100} %} +snippet furl "URLField" b +${1:FIELDNAME} = forms.URLField($2) endsnippet -snippet with -{% with ${1} as ${2} %} +# MODELS SNIPPETS + +snippet model "Model" b +class ${1:MODELNAME}(models.Model): + ${0} + class Meta: + verbose_name = "$1" + verbose_name_plural = "$1s" + + def __str__(self): + return super($1, self).__str__() + endsnippet -# Template Filters +snippet modelfull "Model" b +class ${1:MODELNAME}(models.Model): + ${2:# TODO: Define fields here} -# Note: Since SnipMate can't determine which template filter you are -# expanding without the "|" character, these do not add the "|" -# character. These save a few keystrokes still. + class Meta: + verbose_name = "$1" + verbose_name_plural = "$1s" -# Note: Template tags that take no arguments are not implemented. + def __str__(self): + return super($1, self).__str__() + + def save(self): + return super($1, self).save() + + @models.permalink + def get_absolute_url(self): + return ('') + + ${3:# TODO: Define custom methods here} -snippet add -add:"${1}" endsnippet -snippet center -center:"${1}" +snippet mauto "AutoField" b +${1:FIELDNAME} = models.AutoField($2) endsnippet -snippet cut -cut:"${1}" +snippet mbigint "BigIntegerField" b +${1:FIELDNAME} = models.BigIntegerField($2) endsnippet -snippet date -date:"${1}" +snippet mbool "BooleanField" b +${1:FIELDNAME} = models.BooleanField($2) endsnippet -snippet default -default:"${1}" +snippet mchar "CharField" b +${1:FIELDNAME} = models.CharField($2, max_length=${3:50}) endsnippet -snippet defaultifnone -default_if_none:"${1}" +snippet mcoseint "CommaSeparatedIntegerField" b +${1:FIELDNAME} = models.CommaSeparatedIntegerField($2) endsnippet -snippet dictsort -dictsort:"${1}" +snippet mdate "DateField" b +${1:FIELDNAME} = models.DateField($2) endsnippet -snippet dictsortrev -dictsortreversed:"${1}" +snippet mdatetime "DateTimeField" b +${1:FIELDNAME} = models.DateTimeField($2) endsnippet -snippet divisibleby -divisibleby:"${1}" +snippet mdecimal "DecimalField" b +${1:FIELDNAME} = models.DecimalField(max_digits=${2:10}, decimal_places=${3:2}) endsnippet -snippet floatformat -floatformat:"${1}" +snippet memail "EmailField" b +${1:FIELDNAME} = models.EmailField($2) endsnippet -snippet getdigit -get_digit:"${1}" +snippet mfile "FileField" b +${1:FIELDNAME} = models.FileField($2) endsnippet -snippet join -join:"${1}" +snippet mfilepath "FilePathField" b +${1:FIELDNAME} = models.FilePathField($2) endsnippet -snippet lengthis -length_is:"${1}" +snippet mfloat "FloatField" b +${1:FIELDNAME} = models.FloatField($2) endsnippet -snippet pluralize -pluralize:"${1}" +snippet fk "ForeignKey" b +${1:FIELDNAME} = models.ForeignKey($2) endsnippet -snippet removetags -removetags:"${1}" +snippet mip "IPAddressField" b +${1:FIELDNAME} = models.IPAddressField($2) endsnippet -snippet slice -slice:"${1}" +snippet mimg "ImageField" b +${1:FIELDNAME} = models.ImageField($2) endsnippet -snippet stringformat -stringformat:"${1}" +snippet mint "IntegerField" b +${1:FIELDNAME} = models.IntegerField($2) endsnippet -snippet time -time:"${1}" +snippet m2m "ManyToManyField" b +${1:FIELDNAME} = models.ManyToManyField($2) endsnippet -snippet truncatewords -truncatewords:${1} +snippet mnullbool "NullBooleanField" b +${1:FIELDNAME} = models.NullBooleanField($2) endsnippet -snippet truncatewordshtml -truncatewords_html:${1} +snippet o2o "OneToOneField" b +${1:FIELDNAME} = models.OneToOneField($2) endsnippet -snippet urlizetrunc -urlizetrunc:${1} +snippet mphone "PhoneNumberField" b +${1:FIELDNAME} = models.PhoneNumberField($2) endsnippet -snippet wordwrap -wordwrap:${1} +snippet mposint "PositiveIntegerField" b +${1:FIELDNAME} = models.PositiveIntegerField($2) endsnippet -# vim:ft=snippets: +snippet mpossmallint "PositiveSmallIntegerField" b +${1:FIELDNAME} = models.PositiveSmallIntegerField($2) +endsnippet + +snippet mslug "SlugField" b +${1:FIELDNAME} = models.SlugField($2) +endsnippet + +snippet msmallint "SmallIntegerField" b +${1:FIELDNAME} = models.SmallIntegerField($2) +endsnippet + +snippet mtext "TextField" b +${1:FIELDNAME} = models.TextField($2) +endsnippet + +snippet mtime "TimeField" b +${1:FIELDNAME} = models.TimeField($2) +endsnippet + +snippet murl "URLField" b +${1:FIELDNAME} = models.URLField($2) +endsnippet + +snippet musstate "USStateField" b +${1:FIELDNAME} = models.USStateField($2) +endsnippet + +snippet mxml "XMLField" b +${1:FIELDNAME} = models.XMLField($2) +endsnippet + +# VIEWS SNIPPETS + +snippet adminview "Model Admin View" b +class ${1}Admin(admin.ModelAdmin): + ''' + Admin View for ${1} + ''' + list_display = ('${2}',) + list_filter = ('${3}',) + inlines = [ + ${4}Inline, + ] + raw_id_fields = ('${5}',) + readonly_fields = ('${6}',) + search_fields = ['${7}'] +admin.site.register(${1}, ${1}Admin) +endsnippet + +snippet createview "Generic Create View" b +class ${1:MODEL_NAME}CreateView(CreateView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet deleteview "Generic Delete View" b +class ${1:MODEL_NAME}DeleteView(DeleteView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet detailview "Generic Detail View" b +class ${1:MODEL_NAME}DetailView(DetailView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet listview "Generic List View" b +class ${1:MODEL_NAME}ListView(ListView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet stackedinline "Stacked Inline" b +class ${1}Inline(admin.StackedInline): + ''' + Stacked Inline View for ${1} + ''' + model = ${2:${1}} + min_num = ${3:3} + max_num = ${4:20} + extra = ${5:1} + raw_id_fields = (${6},) +endsnippet + +snippet tabularinline "Tabular Inline" b +class ${1}Inline(admin.TabularInline): + ''' + Tabular Inline View for ${1} + ''' + model = ${2:${1}} + min_num = ${3:3} + max_num = ${4:20} + extra = ${5:1} + raw_id_fields = (${6},) +endsnippet + +snippet templateview "Generic Template View" b +class ${1:CLASS_NAME}(TemplateView): + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet updateview "Generic Update View" b +class ${1:MODEL_NAME}UpdateView(UpdateView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet dispatch "Dispatch View method" b +def dispatch(self, request, *args, **kwargs): + return super(${1:CLASS_NAME}, self).dispatch(request, *args, **kwargs) +endsnippet + +snippet context "get_context_data view method" b +def get_context_data(self, **kwargs): + kwargs['extra_context'] = ${1:'New Value'} + return super(${2:CLASS_NAME}, self).get_context_data(**kwargs) +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/eruby.snippets b/sources_non_forked/vim-snippets/UltiSnips/eruby.snippets index b626cc4a..fe38c2fc 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/eruby.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/eruby.snippets @@ -27,11 +27,11 @@ def textmate_var(var, snip): endglobal -snippet % "<% ${0} %>" +snippet % "<% ${0} %>" i `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` endsnippet -snippet = "<%= ${0} %>" +snippet = "<%= ${0} %>" i `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet @@ -43,59 +43,59 @@ snippet fi "<%= Fixtures.identify(:symbol) %>" `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`Fixtures.identify(:${1:name})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`$0 endsnippet -snippet ft "form_tag" -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => '${5:update}'}${6:, {:${8:class} => '${9:form}'\}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +snippet ft "form_tag" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => '${2:update}'}${3:, ${4:${5:class} => '${6:form}'\}}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` $0 `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet -snippet ffs "form_for submit 2" +snippet ffs "form_for submit 2" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${1:f}.submit '${2:Submit}'${3:, :disable_with => '${4:$2ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f_fields_for (nff)" +snippet f. "f_fields_for (nff)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`f.fields_for :${1:attribute} do |${2:f}|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` $0 `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet -snippet f. "f.checkbox" +snippet f. "f.checkbox" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.check_box :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f.file_field" +snippet f. "f.file_field" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.file_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f.hidden_field" +snippet f. "f.hidden_field" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.hidden_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f.label" +snippet f. "f.label" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f.password_field" +snippet f. "f.password_field" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.password_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f.radio_button" +snippet f. "f.radio_button" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_button :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f.submit" +snippet f. "f.submit" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f.text_area" +snippet f. "f.text_area" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_area :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet f. "f.text_field" +snippet f. "f.text_field" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet ffe "form_for with errors" +snippet ffe "form_for with errors" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`error_messages_for :${1:model}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` @@ -103,17 +103,17 @@ snippet ffe "form_for with errors" `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet -snippet ff "form_for" +snippet ff "form_for" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` $0 `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet -snippet ist "image_submit_tag" +snippet ist "image_submit_tag" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_submit_tag("${1:agree.png}"${2:${3:, :id => "${4:${1/^(\w+)(\.\w*)?$/$1/}}"}${5:, :name => "${6:${1/^(\w+)(\.\w*)?$/$1/}}"}${7:, :class => "${8:${1/^(\w+)(\.\w*)?$/$1/}-button}"}${9:, :disabled => ${10:false}}})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet it "image_tag" +snippet it "image_tag" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_tag "$1${2:.png}"${3:${4:, :title => "${5:title}"}${6:, :class => "${7:class}"}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet @@ -121,47 +121,51 @@ snippet layout "layout" layout "${1:template_name}"${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}} endsnippet -snippet jit "javascript_include_tag" +snippet jit "javascript_include_tag" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`javascript_include_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet lia "link_to (action)" +snippet lt "link_to (name, dest)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", ${2:dest}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lia "link_to (action)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet liai "link_to (action, id)" +snippet liai "link_to (action, id)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:edit}", :id => ${3:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet lic "link_to (controller)" +snippet lic "link_to (controller)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet lica "link_to (controller, action)" +snippet lica "link_to (controller, action)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet licai "link_to (controller, action, id)" +snippet licai "link_to (controller, action, id)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:edit}", :id => ${4:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet linpp "link_to (nested path plural)" +snippet linpp "link_to (nested path plural)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${10:parent}_${11:child}_path(${12:@}${13:${10}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet linp "link_to (nested path)" +snippet linp "link_to (nested path)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet lipp "link_to (path plural)" +snippet lipp "link_to (path plural)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${4:model}s_path}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet lip "link_to (path)" +snippet lip "link_to (path)" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:model}_path(${13:@}${14:${12}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet lim "link_to model" +snippet lim "link_to model" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:model}.${2:name}, ${3:${4:$1}_path(${14:$1})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet @@ -213,11 +217,11 @@ snippet rps "render (partial,status) (rps)" render :partial => "${1:item}", :status => ${2:500} endsnippet -snippet slt "stylesheet_link_tag" +snippet slt "stylesheet_link_tag" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`stylesheet_link_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet st "submit_tag" +snippet st "submit_tag" w `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/go.snippets b/sources_non_forked/vim-snippets/UltiSnips/go.snippets index 780ee29b..b6891ff0 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/go.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/go.snippets @@ -45,25 +45,6 @@ type ${1:Interface} interface { } endsnippet -# statements -snippet for "For loop" b -for ${1:condition}${1/(.+)/ /}{ - ${0:${VISUAL}} -} -endsnippet - -snippet fori "Integer for loop" b -for ${1:i} := 0; $1 < ${2:N}; $1++ { - ${0:${VISUAL}} -} -endsnippet - -snippet forr "For range loop" b -for ${2:name} := range ${1:collection} { - ${0:${VISUAL}} -} -endsnippet - snippet if "If statement" b if ${1:condition}${1/(.+)/ /}{ ${0:${VISUAL}} @@ -76,22 +57,6 @@ case${0} } endsnippet -snippet select "Select statement" b -select { -case${0} -} -endsnippet - -snippet case "Case clause" b -case ${1:condition}: - ${0:${VISUAL}} -endsnippet - -snippet default "Default clause" b -default: - ${0:${VISUAL}} -endsnippet - # functions snippet /^main/ "Main function" r func main() { diff --git a/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets b/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets deleted file mode 100644 index 419edb4b..00000000 --- a/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets +++ /dev/null @@ -1,68 +0,0 @@ -priority -50 - -snippet if "if ... then ... else ..." -if ${1:condition} - then ${2:expression} - else ${3:expression} -endsnippet - -snippet case "case ... of ..." -case ${1:expression} of - ${2:pattern} -> ${3:expression} - ${4:pattern} -> ${5:expression} -endsnippet - -snippet :: "Type signature" -${1:name} :: ${2:Type} -> ${3:Type} -endsnippet - -snippet => "Type constraint" -(${1:Class} ${2:a}) => $2 -endsnippet - -snippet def "Function definition" -${1:name} :: ${2:Type} -> ${3:Type} -endsnippet - -snippet def[] "Function definition for list patterns" -${1:name} :: [${2:Type}] -> ${3:Type} -$1 [] = ${4:undefined} -$1 ${5:(x:xs)} = ${6:undefined} -endsnippet - -snippet = "Function clause" -${1:name} ${2:pattern} = ${3:undefined} -endsnippet - -snippet 2= "Function clause" -${1:name} ${2:pattern} = ${3:undefined} -$1 ${4:pattern} = ${5:undefined} -endsnippet - -snippet 3= "Function clause" -${1:name} ${2:pattern} = ${3:undefined} -$1 ${4:pattern} = ${5:undefined} -$1 ${6:pattern} = ${7:undefined} -endsnippet - -snippet | "Guard" -| ${1:predicate} = ${2:undefined} -endsnippet - -snippet \ "Lambda expression" -\\${1:pattern} -> ${2:expression} -endsnippet - -snippet [|] "List comprehension" -[${3:foo }$1 | ${1:x} <- ${2:xs} ] -endsnippet - -snippet let "let ... in ..." -let ${1:name} = ${2:expression} -in ${3:expression} -endsnippet - -snippet wh "where x = expression" -where - ${1:name} = ${2:expression} -endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/html.snippets b/sources_non_forked/vim-snippets/UltiSnips/html.snippets index fd1aca51..4e92a960 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/html.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/html.snippets @@ -127,7 +127,6 @@ endsnippet ############# snippet input "Input with Label" w - endsnippet snippet input "XHTML " w @@ -141,9 +140,7 @@ endsnippet snippet select "Select Box" w endsnippet @@ -162,25 +159,25 @@ endsnippet snippet body "" - $0 + ${0:${VISUAL}} endsnippet snippet div "
            " w
            - $0 + ${0:${VISUAL}}
            endsnippet snippet div. "
            with class" w - $0 + ${0:${VISUAL}}
            endsnippet snippet div# "
            with ID & class" w - $0 + ${0:${VISUAL}}
            endsnippet @@ -188,33 +185,39 @@ snippet form "XHTML
            " w - $0 - -

            + ${0:${VISUAL}}
            endsnippet snippet h1 "XHTML

            " w -

            $0

            +

            ${0:${VISUAL}}

            endsnippet snippet h2 "XHTML

            " w -

            $0

            +

            ${0:${VISUAL}}

            endsnippet snippet h3 "XHTML

            " w -

            $0

            +

            ${0:${VISUAL}}

            endsnippet snippet h4 "XHTML

            " w -

            $0

            +

            ${0:${VISUAL}}

            +endsnippet + +snippet h5 "XHTML
            " w +
            ${0:${VISUAL}}
            +endsnippet + +snippet h6 "XHTML
            " w +
            ${0:${VISUAL}}
            endsnippet snippet head "XHTML " ${1:`!p snip.rv = snip.basename or "Page Title"`} - $0 + ${0:${VISUAL}} endsnippet @@ -232,20 +235,19 @@ endsnippet snippet script "XHTML endsnippet snippet style "XHTML endsnippet snippet table "XHTML " w
            - - + ${0:${VISUAL}}
            ${5:Header}
            ${0:Data}
            endsnippet @@ -254,29 +256,29 @@ snippet a "Link" w endsnippet snippet p "paragraph" w -

            $0

            +

            ${0:${VISUAL}}

            endsnippet snippet li "list item" w -
          • $0
          • +
          • ${0:${VISUAL}}
          • endsnippet snippet ul "unordered list" w
              -$0 + ${0:${VISUAL}}
            endsnippet snippet td "table cell" w -$0 +${0:${VISUAL}} endsnippet snippet th "table header" w -$0 +${0:${VISUAL}} endsnippet snippet tr "table row" w -$0 +${0:${VISUAL}} endsnippet snippet title "XHTML " w @@ -286,7 +288,7 @@ endsnippet snippet fieldset "Fieldset" w <fieldset id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}" ${2:class="${3:}"}> <legend>$1</legend> - $0 + ${0:${VISUAL}} </fieldset> endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/htmldjango.snippets b/sources_non_forked/vim-snippets/UltiSnips/htmldjango.snippets index 5836a2f6..37fa85fd 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/htmldjango.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/htmldjango.snippets @@ -1,3 +1,299 @@ priority -50 -extends html, django +extends html + +# Generic Tags +snippet % "" bi +{% ${1} %}${2} +endsnippet + +snippet %% "" bi +{% ${1:tag_name} %} + ${2} +{% end$1 %} +endsnippet + +snippet { "" bi +{{ ${1} }}${2} +endsnippet + +# Template Tags + +snippet autoescape "" bi +{% autoescape ${1:off} %} + ${2} +{% endautoescape %} +endsnippet + +snippet block "" bi +{% block ${1} %} + ${2} +{% endblock $1 %} +endsnippet + +snippet # "" bi +{# ${1:comment} #} +endsnippet + +snippet comment "" bi +{% comment %} + ${1} +{% endcomment %} +endsnippet + +snippet cycle "" bi +{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +endsnippet + +snippet debug "" bi +{% debug %} +endsnippet + +snippet extends "" bi +{% extends "${1:base.html}" %} +endsnippet + +snippet filter "" bi +{% filter ${1} %} + ${2} +{% endfilter %} +endsnippet + +snippet firstof "" bi +{% firstof ${1} %} +endsnippet + +snippet for "" bi +{% for ${1} in ${2} %} + ${3} +{% endfor %} +endsnippet + +snippet empty "" bi +{% empty %} + ${1} +endsnippet + +snippet if "" bi +{% if ${1} %} + ${2} +{% endif %} +endsnippet + +snippet iif "" bi +{% if ${1} %}${2}{% endif %} +endsnippet + +snippet ielse "" bi +{% else %}${1} +endsnippet + +snippet else "" bi +{% else %} + ${1} +endsnippet + +snippet ielif "" bi +{% elif %}${1} +endsnippet + +snippet elif "" bi +{% elif %} + ${1} +endsnippet + +snippet ifchanged "" bi +{% ifchanged %}${1}{% endifchanged %} +endsnippet + +snippet ifequal "" bi +{% ifequal ${1} ${2} %} + ${3} +{% endifequal %} +endsnippet + +snippet ifnotequal "" bi +{% ifnotequal ${1} ${2} %} + ${3} +{% endifnotequal %} +endsnippet + +snippet include "" bi +{% include "${1}" %} +endsnippet + +snippet load "" bi +{% load ${1} %} +endsnippet + +snippet now "" bi +{% now "${1:jS F Y H:i}" %} +endsnippet + +snippet regroup "" bi +{% regroup ${1} by ${2} as ${3} %} +endsnippet + +snippet spaceless "" bi +{% spaceless %}${1}{% endspaceless %} +endsnippet + +snippet ssi "" bi +{% ssi ${1} %} +endsnippet + +snippet trans "" bi +{% trans "${1:string}" %} +endsnippet + +snippet url "" bi +{% url ${1} as ${2} %} +endsnippet + +snippet widthratio "" bi +{% widthratio ${1:this_value} ${2:max_value} ${3:100} %} +endsnippet + +snippet with "" bi +{% with ${1} as ${2} %} + ${VISUAL} +{% endwith %} +endsnippet + +snippet verbatim "" bi +{% verbatim %} + ${VISUAL} +{% endverbatim %} +endsnippet + +snippet super "" bi +{{ block.super }} +endsnippet + +snippet staticu "" bi +{{ STATIC_URL }} +endsnippet + +snippet static "" bi +{% static "${VISUAL}" %} +endsnippet + +snippet mediau "" bi +{{ MEDIA_URL }} +endsnippet + +snippet iblock "" bi +{% block ${1:blockname} %}${VISUAL}{% endblock $1 %} +endsnippet + +snippet csrf "" bi +{% csrf_token %} +endsnippet + +snippet blocktrans "" bi +{% blocktrans %} + ${VISUAL} +{% endblocktrans %} +endsnippet + +snippet lorem "" bi +{% lorem ${1} %} +endsnippet + +# Template Filters + +# Note: Since SnipMate can't determine which template filter you are +# expanding without the "|" character, these do not add the "|" +# character. These save a few keystrokes still. + +# Note: Template tags that take no arguments are not implemented. + +snippet add "" bi +add:"${1}" +endsnippet + +snippet center "" bi +center:"${1}" +endsnippet + +snippet cut "" bi +cut:"${1}" +endsnippet + +snippet date "" bi +date:"${1}" +endsnippet + +snippet default "" bi +default:"${1}" +endsnippet + +snippet defaultifnone "" bi +default_if_none:"${1}" +endsnippet + +snippet dictsort "" bi +dictsort:"${1}" +endsnippet + +snippet dictsortrev "" bi +dictsortreversed:"${1}" +endsnippet + +snippet divisibleby "" bi +divisibleby:"${1}" +endsnippet + +snippet floatformat "" bi +floatformat:"${1}" +endsnippet + +snippet getdigit "" bi +get_digit:"${1}" +endsnippet + +snippet join "" bi +join:"${1}" +endsnippet + +snippet lengthis "" bi +length_is:"${1}" +endsnippet + +snippet pluralize "" bi +pluralize:"${1}" +endsnippet + +snippet removetags "" bi +removetags:"${1}" +endsnippet + +snippet slice "" bi +slice:"${1}" +endsnippet + +snippet stringformat "" bi +stringformat:"${1}" +endsnippet + +snippet time "" bi +time:"${1}" +endsnippet + +snippet truncatewords "" bi +truncatewords:${1} +endsnippet + +snippet truncatewordshtml "" bi +truncatewords_html:${1} +endsnippet + +snippet urlizetrunc "" bi +urlizetrunc:${1} +endsnippet + +snippet wordwrap "" bi +wordwrap:${1} +endsnippet + +# vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/java.snippets b/sources_non_forked/vim-snippets/UltiSnips/java.snippets index e8eb77cc..54d026df 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/java.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/java.snippets @@ -21,7 +21,7 @@ def nl(snip): snip.rv += " " def getArgs(group): import re - word = re.compile('[a-zA-Z><.]+ \w+') + word = re.compile('[a-zA-Z0-9><.]+ \w+') return [i.split(" ") for i in word.findall(group) ] def camel(word): @@ -109,7 +109,7 @@ for i in args: snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" if len(args) > 0: snip.rv += "\n"` - public `!p snip.rv = snip.basename or "unknown"`($1) { `!p + public `!p snip.rv = snip.basename or "unknown"`($1) {`!p args = getArgs(t[1]) for i in args: snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] + ";" @@ -123,8 +123,8 @@ for i in args: snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\ \tthis." + i[1] + " = " + i[1] + ";\n\t}\n" - snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\ - \n\t\treturn " + i[1] + ";\n\t}\n" + snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\n\ + \treturn " + i[1] + ";\n\t}\n" ` } endsnippet @@ -138,7 +138,7 @@ for i in args: snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" if len(args) > 0: snip.rv += "\n"` - public `!p snip.rv = snip.basename or "unknown"`($1) { `!p + public `!p snip.rv = snip.basename or "unknown"`($1) {`!p args = getArgs(t[1]) for i in args: snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1]) @@ -266,7 +266,7 @@ for i in args: snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" if len(args) > 0: snip.rv += "\n"` -public `!p snip.rv = snip.basename or "unknown"`($1) { `!p +public `!p snip.rv = snip.basename or "unknown"`($1) {`!p args = getArgs(t[1]) for i in args: snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1]) @@ -326,11 +326,11 @@ snippet md "Method With javadoc" b * ${7:Short Description}`!p for i in getArgs(t[4]): snip.rv += "\n\t * @param " + i[1] + " usage..."` - * `!p + *`!p if "throws" in t[5]: snip.rv = "\n\t * @throws " + t[6] else: - snip.rv = ""` `!p + snip.rv = ""``!p if not "void" in t[2]: snip.rv = "\n\t * @return object" else: @@ -356,8 +356,7 @@ endsnippet snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) { this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`; -} - +}`!p snip.rv += "\n"` public $2 get$1() { return `!p snip.rv = mixedCase(t[1])`; } diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_angular.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript-angular.snippets similarity index 100% rename from sources_non_forked/vim-snippets/UltiSnips/javascript_angular.snippets rename to sources_non_forked/vim-snippets/UltiSnips/javascript-angular.snippets diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_ember.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript-ember.snippets similarity index 100% rename from sources_non_forked/vim-snippets/UltiSnips/javascript_ember.snippets rename to sources_non_forked/vim-snippets/UltiSnips/javascript-ember.snippets diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_jasmine.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript-jasmine.snippets similarity index 73% rename from sources_non_forked/vim-snippets/UltiSnips/javascript_jasmine.snippets rename to sources_non_forked/vim-snippets/UltiSnips/javascript-jasmine.snippets index e3f3ad70..77aec773 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/javascript_jasmine.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript-jasmine.snippets @@ -28,10 +28,40 @@ afterEach(function() { }); endsnippet +snippet befa "before all (js)" b +beforeAll(function() { + $0 +}); +endsnippet + +snippet afta "after all (js)" b +afterAll(function() { + $0 +}); +endsnippet + snippet any "any (js)" b jasmine.any($1) endsnippet +snippet anyt "anything (js)" b +jasmine.anything() +endsnippet + +snippet objc "object containing (js)" b +jasmine.objectContaining({ + ${VISUAL}$0 +}); +endsnippet + +snippet arrc "array containing (js)" b +jasmine.arrayContaining([${1:value1}]); +endsnippet + +snippet strm "string matching (js)" b +jasmine.stringMatching("${1:matcher}") +endsnippet + snippet ru "runs (js)" b runs(function() { $0 @@ -50,6 +80,14 @@ snippet ee "expect to equal (js)" b expect(${1:target}).toEqual(${2:value}); endsnippet +snippet el "expect to be less than (js)" b +expect(${1:target}).toBeLessThan(${2:value}); +endsnippet + +snippet eg "expect to be greater than (js)" b +expect(${1:target}).toBeGreaterThan(${2:value}); +endsnippet + snippet eb "expect to be (js)" b expect(${1:target}).toBe(${2:value}); endsnippet @@ -74,6 +112,10 @@ snippet ed "expect to be defined (js)" b expect(${1:target}).toBeDefined(); endsnippet +snippet eud "expect to be defined (js)" b +expect(${1:target}).toBeUndefined(); +endsnippet + snippet en "expect to be null (js)" b expect(${1:target}).toBeNull(); endsnippet @@ -98,6 +140,14 @@ snippet note "expect not to equal (js)" b expect(${1:target}).not.toEqual(${2:value}); endsnippet +snippet notl "expect to not be less than (js)" b +expect(${1:target}).not.toBeLessThan(${2:value}); +endsnippet + +snippet notg "expect to not be greater than (js)" b +expect(${1:target})..not.toBeGreaterThan(${2:value}); +endsnippet + snippet notm "expect not to match (js)" b expect(${1:target}).not.toMatch(${2:pattern}); endsnippet @@ -139,35 +189,19 @@ spyOn(${1:object}, '${2:method}')$0; endsnippet snippet sr "spy on and return (js)" b -spyOn(${1:object}, '${2:method}').andReturn(${3:arguments}); +spyOn(${1:object}, '${2:method}').and.returnValue(${3:arguments}); endsnippet snippet st "spy on and throw (js)" b -spyOn(${1:object}, '${2:method}').andThrow(${3:exception}); +spyOn(${1:object}, '${2:method}').and.throwError(${3:exception}); endsnippet snippet sct "spy on and call through (js)" b -spyOn(${1:object}, '${2:method}').andCallThrough(); +spyOn(${1:object}, '${2:method}').and.callThrough(); endsnippet snippet scf "spy on and call fake (js)" b -spyOn(${1:object}, '${2:method}').andCallFake(${3:function}); -endsnippet - -snippet esc "expect was called (js)" b -expect(${1:target}).wasCalled(); -endsnippet - -snippet escw "expect was called with (js)" b -expect(${1:target}).wasCalledWith(${2:arguments}); -endsnippet - -snippet notsc "expect was not called (js)" b -expect(${1:target}).wasNotCalled(); -endsnippet - -snippet noscw "expect was not called with (js)" b -expect(${1:target}).wasNotCalledWith(${2:arguments}); +spyOn(${1:object}, '${2:method}').and.callFake(${3:function}); endsnippet snippet ethbc "expect to have been called (js)" b diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_jsdoc.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript-jsdoc.snippets similarity index 100% rename from sources_non_forked/vim-snippets/UltiSnips/javascript_jsdoc.snippets rename to sources_non_forked/vim-snippets/UltiSnips/javascript-jsdoc.snippets diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript-node.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript-node.snippets new file mode 100644 index 00000000..7a14deeb --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript-node.snippets @@ -0,0 +1,65 @@ +priority -50 + +snippet #! "shebang" +#!/usr/bin/env node +endsnippet + +snippet vreq "assign a CommonJS-style module to a var" +var ${0:${1/(.+\/)*(\w+)(-|\b|$)(\..+$)?/\u$2/g}} = require('${1}'); +endsnippet + +snippet ex "module.exports" +module.exports = ${1}; +endsnippet + +snippet hcs "http.createServer" +http.createServer(${1}).listen(${2}); +endsnippet + +snippet ncs "net.createServer" +net.createServer(function(${1:socket}){ + ${1}.on('data', function(${3:data}){ + ${4} + }); + ${1}.on('end', function(){ + ${5} + }); +}).listen(${6:8124}); +endsnippet + +snippet pipe "pipe" +pipe(${1:stream})${2} +endsnippet + +# Express snippets + +snippet eget "express GET" +${1:app}.get('${2}', ${3}); +endsnippet + +snippet epost "express POST" +${1:app}.post('${2}', ${3}); +endsnippet + +snippet eput "express PUT" +${1:app}.put('${2}', ${3}); +endsnippet + +snippet edelete "express DELETE" +${1:app}.delete('${2}', ${3}); +endsnippet + +# process snippets + +snippet stdout "stdout" +process.stdout +endsnippet + +snippet stdin "stdin" +process.stdin +endsnippet + +snippet stderr "stderr" +process.stderr +endsnippet + diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript-openui5.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript-openui5.snippets new file mode 100644 index 00000000..5553c79a --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript-openui5.snippets @@ -0,0 +1,205 @@ +snippet sapmlabel + var ${1} = new sap.m.Label({ + design : ${2}, + text : ${3}, + visible : ${4}, + textAlign : ${5}, + textDirection : ${6}, + width : ${7}, + required : ${7} + }); + +snippet sapmtext + var ${1} = new sap.m.Text({ + text :${2}, + textDirection :${3}, + visible :${4}, + wrapping : ${5}, + textAlign : ${6}, + width :${7}, + maxLines :${8} + }); + +snippet sapmbutton + var ${1} = new sap.m.Button({ + text : ${2}, + type : ${3}, + width : ${4}, + enabled :${5}, + visible :${6}, + icon : ${7}, + iconFirst : ${8}, + activeIcon :${9}, + iconDensityAware : ${10}, + }); +snippet sapmflexbox + var ${1} = new sap.m.FlexBox({ + visible : ${2}, + height : ${3}, + width : ${4}, + displayInline :${5}, + direction :${6}, + fitContainer : ${7}, + renderType : ${8}, + justifyContent :${9}, + alignItems : ${10}, + items:[] + }); +snippet sapmhbox + var ${1} = new sap.m.HBox({ + visible : ${2}, + height : ${3}, + width : ${4}, + displayInline :${5}, + direction :${6}, + fitContainer : ${7}, + renderType : ${8}, + justifyContent :${9}, + alignItems : ${10}, + items:[] + }); + +snippet sapmvbox + var ${1} = new sap.m.VBox({ + visible : ${2}, + height : ${3}, + width : ${4}, + displayInline :${5}, + direction :${6}, + fitContainer : ${7}, + renderType : ${8}, + justifyContent :${9}, + alignItems : ${10}, + items:[] + }); + +snippet sapcomponent + sap.ui.controller("${1}", { + onInit: function(){ + }, + onAfterRendering: function() { + }, + onAfterRendering: function() { + }, + onExit: function() { + }, + }); + +snippet sapminput + var ${1} = new sap.m.Input({ + value :${2}, + width : ${3}, + enabled :${4}, + visible :${5}, + valueState :${6}, + name : ${7}, + placeholder : ${8}, + editable : ${9}, + type : ${10}, + maxLength :${11}, + valueStateText :${12}, + showValueStateMessage :${13}, + dateFormat :${14}, + showValueHelp :${15}, + showSuggestion :${16}, + valueHelpOnly :${17}, + filterSuggests :${18}, + maxSuggestionWidth :${19}, + startSuggestion : ${20}, + showTableSuggestionValueHelp : ${21}, + description : ${22}, + fieldWidth : ${23}, + valueLiveUpdate :${24}, + suggestionItems :[${25}], + suggestionColumns : [${26}], + suggestionRows : [${27}], + liveChange : ${28}, + valueHelpRequest :${29}, + suggest : ${30}, + suggestionItemSelected : ${31} + }); +snippet _sthis + var _self = this; + +snippet sapmresponsivepopup + var ${1} = new sap.m.ResponsivePopover({ + placement :${2} ,//sap.m.PlacementType (default: sap.m.PlacementType.Right) + showHeader :${3} ,//boolean (default: true) + title : ${4},//string + icon :${5} ,//sap.ui.core.URI + modal :${6} ,// boolean + offsetX :${7}, //int + offsetY :${8}, //int + contentWidth : ${9},//sap.ui.core.CSSSize + contentHeight :${10}, //sap.ui.core.CSSSize + horizontalScrolling :${11}, //boolean + verticalScrolling :${12}, //boolean + showCloseButton :${13}, //boolean (default: true) + //Aggregations + content :${14}, //sap.ui.core.Control[] + customHeader :${15}, //sap.m.IBar + subHeader : ${16}, //sap.m.IBar + beginButton :${17}, //sap.m.Button + endButton : ${18}, //sap.m.Button + //Associations + initialFocus : ${19}, //string | sap.ui.core.Control + //Events + beforeOpen :${20}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] + afterOpen : ${21}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] + beforeClose : ${22}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] + afterClose : ${23} //fnList + }); + +snippet sapicon + var ${1} = new sap.ui.core.Icon({ + src :${2} , //sap.ui.core.URI + size :${3} , //sap.ui.core.CSSSize + color :${4} , //sap.ui.core.CSSColor + hoverColor : ${5} , // sap.ui.core.CSSColor + activeColor :${6} , //sap.ui.core.CSSColor + width :${7} , //sap.ui.core.CSSSize + height : ${8} ,//sap.ui.core.CSSSize + backgroundColor :${8} , //sap.ui.core.CSSColor + hoverBackgroundColor :${9} , //sap.ui.core.CSSColor + activeBackgroundColor :${10} , //sap.ui.core.CSSColor + visible :${11} , //boolean (default: true) + decorative : ${12} ,//boolean (default: true) + }); +snippet extendVerticalL + sap.ui.layout.VerticalLayout.extend("${1}", { + metadata: { + properties: { + ${2} + }, + aggregations: { + ${3} + }, + events: { + ${4} + } + }, + init: function(){ + ${5} + }, + + renderer: "${6}" + }); +snippet extendHorizontalL + sap.ui.layout.HorizontalLayout.extend("${1}", { + metadata: { + properties: { + ${2} + }, + aggregations: { + ${3} + }, + events: { + ${4} + } + }, + init: function(){ + ${5} + }, + + renderer: "${6}" + }); diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets index 6c177bc1..4537baea 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets @@ -58,8 +58,14 @@ ${1:var }${2:function_name} = function $2(${3}) { }; endsnippet +snippet af "Anonymous Function" i +function($1) { + ${VISUAL}$0 +} +endsnippet + snippet iife "Immediately-Invoked Function Expression (iife)" -(function (${1:argument}) { +(function(${1:window}) { ${VISUAL}$0 }(${2:$1})); endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/json.snippets b/sources_non_forked/vim-snippets/UltiSnips/json.snippets index b0cad830..75edef9d 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/json.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/json.snippets @@ -4,7 +4,7 @@ snippet s "String" b "${1:key}": "${0:value}", endsnippet -snippet n "number" b +snippet n "Number" b "${1:key}": ${0:value}, endsnippet @@ -13,8 +13,39 @@ snippet a "Array" b ${VISUAL}$0 ], endsnippet + +snippet na "Named array" b +"${1:key}": [ + ${VISUAL}$0 +], +endsnippet + snippet o "Object" b { ${VISUAL}$0 }, endsnippet + +snippet no "Named object" b +"${1:key}": { + ${VISUAL}$0 +}, +endsnippet + +snippet null "Null" b +"${0:key}": null, +endsnippet + + +global !p +def compB(t, opts): + if t: + opts = [m[len(t):] for m in opts if m.startswith(t)] + if len(opts) == 1: + return opts[0] + return "(" + '|'.join(opts) + ')' +endglobal + +snippet b "Bool" b +"${1:key}": $2`!p snip.rv=compB(t[2], ['true', 'false'])`, +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/lua.snippets b/sources_non_forked/vim-snippets/UltiSnips/lua.snippets index bc59c60c..b6d0c1a3 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/lua.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/lua.snippets @@ -32,6 +32,65 @@ for ${1:i}=${2:first},${3:last}${4/^..*/(?0:,:)/}${4:step} do end endsnippet +snippet do "do block" +do + $0 +end +endsnippet + +snippet repeat "repeat loop" b +repeat + $1 +until $0 +endsnippet + +snippet while "while loop" b +while $1 do + $0 +end +endsnippet + +snippet if "if statement" b +if $1 then + $0 +end +endsnippet + +snippet ife "if/else statement" b +if $1 then + $2 +else + $0 +end +endsnippet + +snippet eif "if/elseif statement" b +if $1 then + $2 +elseif $3 then + $0 +end +endsnippet + +snippet eife "if/elseif/else statement" b +if $1 then + $2 +elseif $3 then + $4 +else + $0 +end +endsnippet + +snippet pcall "pcall statement" b +local ok, err = pcall(${1:your_function}) +if not ok then + handler(${2:ok, err}) +${3:else + success(${4:ok, err}) +}end +endsnippet + snippet local "local x = 1" local ${1:x} = ${0:1} endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets b/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets index 0720cbfc..add9f7f9 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets @@ -1,5 +1,27 @@ priority -50 +global !p +def create_table(snip): + # retrieving single line from current string and treat it like tabstops count + placeholders_string = snip.buffer[snip.line].strip().split("x",1) + rows_amount = int(placeholders_string[0]) + columns_amount = int(placeholders_string[1]) + + # erase current line + snip.buffer[snip.line] = '' + + # create anonymous snippet with expected content and number of tabstops + anon_snippet_title = ' | '.join(['$' + str(col) for col in range(1,columns_amount+1)]) + "\n" + anon_snippet_delimiter = ':-|' * (columns_amount-1) + ":-\n" + anon_snippet_body = "" + for row in range(1,rows_amount+1): + anon_snippet_body += ' | '.join(['$' + str(row*columns_amount+col) for col in range(1,columns_amount+1)]) + "\n" + anon_snippet_table = anon_snippet_title + anon_snippet_delimiter + anon_snippet_body + + # expand anonymous snippet + snip.expand_anon(anon_snippet_table) +endglobal + ########################### # Sections and Paragraphs # ########################### @@ -50,4 +72,21 @@ $1 $0 endsnippet +snippet refl "Reference Link" +[${1:${VISUAL:Text}}][${2:id}]$0 + +[$2]:${4:http://${3:www.url.com}} "${5:$4}" +endsnippet + +snippet fnt "Footnote" +[^${1:${VISUAL:Footnote}}]$0 + +[^$1]:${2:Text} +endsnippet + +post_jump "create_table(snip)" +snippet "tb(\d+x\d+)" "Customizable table" br +`!p snip.rv = match.group(1)` +endsnippet + # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/pandoc.snippets b/sources_non_forked/vim-snippets/UltiSnips/pandoc.snippets index ad165c56..ce858f0b 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/pandoc.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/pandoc.snippets @@ -4,7 +4,7 @@ extends markdown priority -49 snippet title "Title Header" b -% ${1:`!v Filename('', 'title')`} +% ${1:`!v vim_snippets#Filename('$1', 'title')`} % ${2:`!v g:snips_author`} % ${3:`!v strftime("%d %B %Y")`} diff --git a/sources_non_forked/vim-snippets/UltiSnips/php_laravel.snippets b/sources_non_forked/vim-snippets/UltiSnips/php-laravel.snippets similarity index 99% rename from sources_non_forked/vim-snippets/UltiSnips/php_laravel.snippets rename to sources_non_forked/vim-snippets/UltiSnips/php-laravel.snippets index 3ad26c63..7367a147 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/php_laravel.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/php-laravel.snippets @@ -36,6 +36,8 @@ endsnippet #service service provider snippet l_ssp "Laravel service provider for service" b +<?php + /*! * \namespace $1 * \class $2 @@ -62,6 +64,8 @@ endsnippet #repository service provider snippet l_rsp "Laravel service provider for repository" b +<?php + /*! * \namespace $2 * \class $3 @@ -100,6 +104,8 @@ endsnippet #model snippet l_md "Laravel simple model" b +<?php + /*! * \namespace $1 * \class $2 @@ -123,6 +129,8 @@ endsnippet #abstract repository snippet l_ar "Laravel abstract Repository" b +<?php + /*! * \namespace $1 * \class $2 @@ -189,6 +197,8 @@ endsnippet #repository snippet l_r "Laravel Repository" b +<?php + /*! * \namespace $1 * \class $3 @@ -207,6 +217,8 @@ endsnippet #service snippet l_s "Laravel Service" b +<?php + /*! * \namespace $1 * \class $2 @@ -233,6 +245,8 @@ endsnippet #facade snippet l_f "Laravel Facade" b +<?php + /*! * \namespace $1 * \class $2 diff --git a/sources_non_forked/vim-snippets/UltiSnips/php-phpspec.snippets b/sources_non_forked/vim-snippets/UltiSnips/php-phpspec.snippets new file mode 100644 index 00000000..08d84a05 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/php-phpspec.snippets @@ -0,0 +1,222 @@ +# Snippets for phpspec, to use add the following to your .vimrc +# `autocmd BufRead,BufNewFile,BufEnter *Spec.php UltiSnipsAddFiletypes php-phpspec` + +priority -50 + +snippet spec "class XYZSpec extends ObjectBehaviour" +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use PhpSpec\ObjectBehavior; +use Prophecy\Argument; + +/** + * @author `!v g:snips_author` + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends ObjectBehavior +{ + function it_${1}() + { + $0 + } +} +endsnippet + +snippet it "function it_does_something() { ... }" +function it_${1}() +{ + ${0:${VISUAL}} +} +endsnippet + +snippet let "function let() { ... }" +function let() +{ + ${0:${VISUAL}} +} +endsnippet + +snippet letgo "function letgo() { ... }" +function letgo() +{ + ${0:${VISUAL}} +} +endsnippet + +# Object construction +snippet cw "$this->beConstructedWith($arg)" +$this->beConstructedWith(${1}); +endsnippet + +snippet ct "$this->beConstructedThrough($methodName, [$arg])" +$this->beConstructedThrough(${1:'methodName'}, [${2:'$arg'}]); +endsnippet + +# Identity and comparison matchers +snippet sreturn "$this->XYZ()->shouldReturn('value')" +$this->${1:method}()->shouldReturn(${2:'value'}); +endsnippet + +snippet snreturn "$this->XYZ()->shouldNotReturn('value')" +$this->${1:method}()->shouldNotReturn(${2:'value'}); +endsnippet + +snippet sbe "$this->XYZ()->shouldBe('value')" +$this->${1:method}()->shouldBe(${2:'value'}); +endsnippet + +snippet snbe "$this->XYZ()->shouldNotBe('value')" +$this->${1:method}()->shouldNotBe(${2:'value'}); +endsnippet + +snippet sequal "$this->XYZ()->shouldEqual('value')" +$this->${1:method}()->shouldEqual(${2:'value'}); +endsnippet + +snippet snequal "$this->XYZ()->shouldNotEqual('value')" +$this->${1:method}()->shouldNotEqual(${2:'value'}); +endsnippet + +snippet sbequalto "$this->XYZ()->shouldBeEqualTo('value')" +$this->${1:method}()->shouldBeEqualTo(${2:'value'}); +endsnippet + +snippet snbequalto "$this->XYZ()->shouldNotBeEqualTo('value')" +$this->${1:method}()->shouldNotBeEqualTo(${2:'value'}); +endsnippet + +snippet sblike "$this->XYZ()->shouldBeLike('value')" +$this->${1:method}()->shouldBeLike(${2:'value'}); +endsnippet + +snippet snblike "$this->XYZ()->shouldNotBeLike('value')" +$this->${1:method}()->shouldNotBeLike(${2:'value'}); +endsnippet + +# Throw matcher +snippet sthrowm "$this->shouldThrow('\Exception')->duringXYZ($arg)" +$this->shouldThrow(${1:'\Exception'})->during${2:Method}(${3:'$arg'}); +endsnippet + +snippet sthrowi "$this->shouldThrow('\Exception')->duringInstantiation()" +$this->shouldThrow(${1:'\Exception'})->duringInstantiation(); +endsnippet + +# Type matchers +snippet stype "$this->shouldHaveType('Type')" +$this->shouldHaveType(${1}); +endsnippet + +snippet sntype "$this->shouldNotHaveType('Type')" +$this->shouldNotHaveType(${1}); +endsnippet + +snippet srinstance "$this->shouldReturnAnInstanceOf('Type')" +$this->shouldReturnAnInstanceOf(${1}); +endsnippet + +snippet snrinstance "$this->shouldNotReturnAnInstanceOf('Type')" +$this->shouldNotReturnAnInstanceOf(${1}); +endsnippet + +snippet sbinstance "$this->shouldBeAnInstanceOf('Type')" +$this->shouldBeAnInstanceOf(${1}); +endsnippet + +snippet snbinstance "$this->shouldNotBeAnInstanceOf('Type')" +$this->shouldNotBeAnInstanceOf(${1}); +endsnippet + +snippet simplement "$this->shouldImplement('Type')" +$this->shouldImplement(${1}); +endsnippet + +snippet snimplement "$this->shouldNotImplement('Type')" +$this->shouldNotImplement(${1}); +endsnippet + +# Object state matchers +snippet sbstate "$this->shouldBeXYZ()" +$this->shouldBe${1}(); +endsnippet + +snippet snbstate "$this->shouldNotBeXYZ()" +$this->shouldNotBe${1}(); +endsnippet + +# Count matchers +snippet scount "$this->XYZ()->shouldHaveCount(7)" +$this->${1:method}()->shouldHaveCount(${2:7}); +endsnippet + +snippet sncount "$this->XYZ()->shouldNotHaveCount(7)" +$this->${1:method}()->shouldNotHaveCount(${2:7}); +endsnippet + +# Scalar type matchers +snippet sbscalar "$this->XYZ()->shouldBeString|Array|Bool()" +$this->${1:method}()->shouldBe${2:String|Array|Bool}(); +endsnippet + +snippet snbscalar "$this->XYZ()->shouldNotBeString|Array|Bool()" +$this->${1:method}()->shouldNotBe${2:String|Array|Bool}(); +endsnippet + +# Contain matcher +snippet scontain "$this->XYZ()->shouldContain('value')" +$this->${1:method}()->shouldContain(${2:'value'}); +endsnippet + +snippet sncontain "$this->XYZ()->shouldNotContain('value')" +$this->${1:method}()->shouldNotContain(${2:'value'}); +endsnippet + +# Array matchers +snippet skey "$this->XYZ()->shouldHaveKey('key')" +$this->${1:method}()->shouldHaveKey(${2:'key'}); +endsnippet + +snippet snkey "$this->XYZ()->shouldNotHaveKey('key')" +$this->${1:method}()->shouldNotHaveKey(${2:'key'}); +endsnippet + +snippet skeyvalue "$this->XYZ()->shouldHaveKeyWithValue('key', 'value')" +$this->${1:method}()->shouldHaveKeyWithValue(${2:'key'}, ${3:'value'}); +endsnippet + +snippet snkeyvalue "$this->XYZ()->shouldNotHaveKeyWithValue('key', 'value')" +$this->${1:method}()->shouldNotHaveKeyWithValue(${2:'key'}, ${3:'value'}); +endsnippet + +# String matchers +snippet sstart "$this->XYZ()->shouldStartWith('string')" +$this->${1:method}()->shouldStartWith(${2:'string'}); +endsnippet + +snippet snstart "$this->XYZ()->shouldNotStartWith('string')" +$this->${1:method}()->shouldNotStartWith(${2:'string'}); +endsnippet + +snippet send "$this->XYZ()->shouldEndWith('string')" +$this->${1:method}()->shouldEndWith(${2:'string'}); +endsnippet + +snippet snend "$this->XYZ()->shouldNotEndWith('string')" +$this->${1:method}()->shouldNotEndWith(${2:'string'}); +endsnippet + +snippet smatch "$this->XYZ()->shouldMatch('/wizard/i')" +$this->${1:method}()->shouldMatch(${2:'/wizard/i'}); +endsnippet + +snippet snmatch "$this->XYZ()->shouldNotMatch('/wizard/i')" +$this->${1:method}()->shouldNotMatch(${2:'/wizard/i'}); +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/php_symfony2.snippets b/sources_non_forked/vim-snippets/UltiSnips/php-symfony2.snippets similarity index 84% rename from sources_non_forked/vim-snippets/UltiSnips/php_symfony2.snippets rename to sources_non_forked/vim-snippets/UltiSnips/php-symfony2.snippets index 520e366b..2b127ee9 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/php_symfony2.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/php-symfony2.snippets @@ -4,15 +4,17 @@ priority -50 snippet classn "Basic class with namespace snippet" b +<?php + namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `; /** - * ${1:@author `whoami`} + * ${1:@author `!v g:snips_author`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -26,9 +28,11 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet contr "Symfony2 controller" b +<?php + namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `; @@ -40,7 +44,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; /** - * ${1:@author `whoami`} + * ${1:@author `!v g:snips_author`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -49,6 +53,18 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() } endsnippet +snippet sfa "Symfony 2 Controller action" +/** +* @Route("/${1:route_name}", name="$1") +* @Template() +*/ +public function $1Action($2) +{ + $3 + return ${4:array();}$0 +} +endsnippet + snippet act "Symfony2 action" b /** * @Route("${3}", name="${4}") @@ -72,13 +88,15 @@ public function ${1}Action(${2}) ${6} return []; }`!p -abspath = os.path.abspath(path)` +relpath = os.path.relpath(path)` endsnippet snippet comm "Symfony2 command" b +<?php + namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `; @@ -90,7 +108,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** - * ${3:@author `whoami`} + * ${3:@author `!v g:snips_author`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -113,9 +131,11 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet subs "Symfony2 subscriber" b +<?php + namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `; @@ -123,7 +143,7 @@ if m: use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * ${1:@author `whoami`} + * ${1:@author `!v g:snips_author`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -144,9 +164,11 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet transf "Symfony2 form data transformer" b +<?php + namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `; @@ -155,7 +177,7 @@ use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; /** - * ${3:@author `whoami`} + * ${3:@author `!v g:snips_author`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -178,9 +200,11 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet ent "Symfony2 doctrine entity" b +<?php + namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `; @@ -188,7 +212,7 @@ if m: use Doctrine\ORM\Mapping as ORM; /** - * ${3:@author `whoami`} + * ${3:@author `!v g:snips_author`} * * @ORM\Entity() * @ORM\Table(name="`!p @@ -215,9 +239,11 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet form "Symfony2 form type" b +<?php + namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `; @@ -227,7 +253,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** - * ${2:@author `whoami`} + * ${2:@author `!v g:snips_author`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -259,9 +285,11 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet ev "Symfony2 event" b +<?php + namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `; @@ -269,7 +297,7 @@ if m: use Symfony\Component\EventDispatcher\Event; /** - * ${2:@author `whoami`} + * ${2:@author `!v g:snips_author`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() diff --git a/sources_non_forked/vim-snippets/UltiSnips/php.snippets b/sources_non_forked/vim-snippets/UltiSnips/php.snippets index 66abe5cf..c7344a59 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/php.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/php.snippets @@ -1,162 +1,67 @@ priority -50 +global !p +import vim + +# Set g:ultisnips_php_scalar_types to 1 if you'd like to enable PHP 7's scalar types for return values +def isPHPScalarTypesEnabled(): + isEnabled = vim.eval("get(g:, 'ultisnips_php_scalar_types', 0)") == "1" + return isEnabled or re.match('<\?php\s+declare\(strict_types=[01]\);', '\n'.join(vim.current.window.buffer)) +endglobal + ## Snippets from SnipMate, taken from ## https://github.com/scrooloose/snipmate-snippets.git -snippet array "array" -$${1:arrayName} = array('${2}' => ${3});${4} -endsnippet - -snippet def "def" -define('${1:VARIABLE_NAME}', ${2:'definition'});${3} -endsnippet - -snippet do "do" -do { - ${2:// code... } -} while (${1:/* condition */}); -endsnippet - -snippet doc_f "doc_f" -/** - * $2 - * @return ${4:void} - * @author ${5:`!v g:snips_author`} - **/ -${1:public }function ${2:someFunc}(${3}) -{${6} -} -endsnippet - -snippet doc_i "doc_i" -/** - * $1 - * @package ${2:default} - * @author ${3:`!v g:snips_author`} - **/ -interface ${1:someClass} -{${4} -} // END interface $1" -endsnippet - -snippet else "else" -else { - ${1:// code...} -} -endsnippet - -snippet for "for" -for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { - ${4:// code...} -} -endsnippet - -snippet foreachk "foreachk" -foreach ($${1:variable} as $${2:key} => $${3:value}) { - ${4:// code...} -} -endsnippet - -snippet get "get" -$_GET['${1}']${2} -endsnippet - -snippet if "if" -if (${1:/* condition */}) { - ${2:// code...} -} -endsnippet - -snippet elif "elseif" -elseif (${1:/* condition */}) { - ${2:// code...} -} -endsnippet - -snippet inc "inc" -include '${1:file}';${2} -endsnippet - -snippet log "log" -error_log(var_export(${1}, true));${2} -endsnippet - -snippet post "post" -$_POST['${1}']${2} -endsnippet - -snippet req "req1" -require_once '${1:file}';${2} -endsnippet - -snippet req1 "req1" -require_once '${1:file}';${2} -endsnippet - -snippet session "session" -$_SESSION['${1}']${2} -endsnippet - -snippet t "t" -$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} -endsnippet - -snippet var "var" -var_export(${1});${2} -endsnippet - -snippet getter "PHP Class Getter" b +snippet gm "PHP Class Getter" b /** * Getter for $1 * - * ${2:return string} + * @return ${2:string} */ -public function get${1/\w+\s*/\u$0/}() +public function get${1/\w+\s*/\u$0/}()`!p snip.rv = ': '+t[2] if isPHPScalarTypesEnabled() else ''` { - return $this->$1;$3 + return $this->$1; } endsnippet -snippet setter "PHP Class Setter" b +snippet sm "PHP Class Setter" b /** * Setter for $1 * - * @param ${2:string} $$1 + * @param ${2:string} $$1 * @return ${3:`!p snip.rv=snip.basename`} */ public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1) { - $this->$1 = $$1;$5 + $this->$1 = $$1; - ${6:return $this;} + ${5:return $this;} } -$0 endsnippet snippet gs "PHP Class Getter Setter" b /** * Getter for $1 * - * return ${2:string} + * @return ${2:string} */ -public function get${1/\w+\s*/\u$0/}() +public function get${1/\w+\s*/\u$0/}()`!p snip.rv = ': '+t[2] if isPHPScalarTypesEnabled() else ''` { - return $this->$1;$3 + return $this->$1; } /** * Setter for $1 * * @param $2 $$1 - * @return ${4:`!p snip.rv=snip.basename`} + * @return ${3:`!p snip.rv=snip.basename`} */ -public function set${1/\w+\s*/\u$0/}(${5:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1) +public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1) { - $this->$1 = $$1;$6 + $this->$1 = $$1; - ${7:return $this;} + ${5:return $this;} } -$0 endsnippet snippet pub "Public function" b @@ -245,31 +150,15 @@ function ${1:name}(${2:$param}) $0 endsnippet -snippet fore "Foreach loop" -foreach ($${1:variable} as $${3:value}) { - ${VISUAL}${4} -} -$0 -endsnippet - snippet new "New class instance" b $${1:variableName} = new ${2:${1/\w+\s*/\u$0/}}($3); $0 endsnippet -snippet ife "if else" -if (${1:/* condition */}) { - ${2:// code...} -} else { - ${3:// code...} -} -$0 -endsnippet - snippet ns "namespace declaration" b namespace ${1:`!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `}; @@ -279,8 +168,8 @@ snippet class "Class declaration template" b <?php namespace ${1:`!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `}; @@ -298,8 +187,8 @@ snippet interface "Interface declaration template" b <?php namespace ${1:`!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) if m: snip.rv = m.group().replace('/', '\\') `}; @@ -310,10 +199,28 @@ if m: */ interface $1 { - public function ${3:someFunction}();$4 + public function ${3:someFunction}();$4 } endsnippet +snippet trait "Trait declaration template" b +<?php + +namespace ${1:`!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`}; + +/** + * Trait ${1:`!p snip.rv=snip.basename`} + * @author ${2:`!v g:snips_author`} + */ +trait $1 +{ +} +endsnippet snippet construct "__construct()" b /** @@ -325,31 +232,29 @@ public function __construct(${1:$dependencies}) $0 endsnippet -snippet ve "Dumb debug helper in HTML" - echo '<pre>' . var_export($1, 1) . '</pre>';$0 -endsnippet +# PHPUnit snippets +snippet testcase "class XYZTest extends \PHPUnit_Framework_TestCase { ... }" +<?php -snippet pc "Dumb debug helper in cli" -var_export($1);$0 -endsnippet +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; -# Symfony 2 based snippets -snippet sfa "Symfony 2 Controller action" /** -* @Route("/${1:route_name}", name="$1") -* @Template() -*/ -public function $1Action($2) + * @author `!v g:snips_author` + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends \PHPUnit_Framework_TestCase { - $3 - return ${4:array();}$0 + public function test${1}() + { + ${0:${VISUAL}} + } } endsnippet -snippet inheritdoc "@inheritdoc docblock" -/** - * {@inheritdoc} - */ -endsnippet - # :vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/php_phpunit.snippets b/sources_non_forked/vim-snippets/UltiSnips/php_phpunit.snippets deleted file mode 100644 index e928bb1e..00000000 --- a/sources_non_forked/vim-snippets/UltiSnips/php_phpunit.snippets +++ /dev/null @@ -1,38 +0,0 @@ -# suggestion? report bugs? -# please go to https://github.com/chrisyue/vim-snippets/issues -priority -50 - -snippet test "phpunit test class" b -namespace `!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) -if m: - snip.rv = m.group().replace('/', '\\') -`; - -/** - * @author `whoami` - */ -class `!p -snip.rv = re.match(r'.*(?=\.)', fn).group() -` extends \PHPUnit_Framework_TestCase -{ - public function test${1}() - { - ${2} - } -} -endsnippet - -snippet exp "phpunit expects" i -expects($this->${1:once}()) - ->method('${2}') - ->with($this->equalTo(${3})${4}) - ->will($this->returnValue(${5})); -endsnippet - -snippet testcmt "phpunit comment with group" b -/** -* @group ${1} -*/ -endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/python.snippets b/sources_non_forked/vim-snippets/UltiSnips/python.snippets index 1c16529a..fa3ff8b9 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/python.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/python.snippets @@ -12,10 +12,16 @@ $0 endsnippet snippet ifmain "ifmain" b -if __name__ == '__main__': +if __name__ == `!p snip.rv = get_quoting_style(snip)`__main__`!p snip.rv = get_quoting_style(snip)`: ${1:${VISUAL:main()}} endsnippet +snippet with "with" b +with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}: + ${3:${VISUAL:pass}} +${0} +endsnippet + snippet for "for loop" b for ${1:item} in ${2:iterable}: ${3:${VISUAL:pass}} @@ -35,6 +41,8 @@ NORMAL = 0x1 DOXYGEN = 0x2 SPHINX = 0x3 GOOGLE = 0x4 +NUMPY = 0x5 +JEDI = 0x6 SINGLE_QUOTES = "'" DOUBLE_QUOTES = '"' @@ -69,7 +77,10 @@ def get_quoting_style(snip): return DOUBLE_QUOTES def triple_quotes(snip): - return get_quoting_style(snip) * 3 + style = snip.opt("g:ultisnips_python_triple_quoting_style") + if not style: + return get_quoting_style(snip) * 3 + return (SINGLE_QUOTES if style == 'single' else DOUBLE_QUOTES) * 3 def triple_quotes_handle_trailing(snip, quoting_style): """ @@ -105,6 +116,8 @@ def get_style(snip): if style == "doxygen": return DOXYGEN elif style == "sphinx": return SPHINX elif style == "google": return GOOGLE + elif style == "numpy": return NUMPY + elif style == "jedi": return JEDI else: return NORMAL @@ -117,12 +130,16 @@ def format_arg(arg, style): return ":%s: TODO" % arg elif style == GOOGLE: return "%s (TODO): TODO" % arg + elif style == JEDI: + return ":type %s: TODO" % arg + elif style == NUMPY: + return "%s : TODO" % arg def format_return(style): if style == DOXYGEN: return "@return: TODO" - elif style in (NORMAL, SPHINX): + elif style in (NORMAL, SPHINX, JEDI): return ":returns: TODO" elif style == GOOGLE: return "Returns: TODO" @@ -139,6 +156,8 @@ def write_docstring_args(args, snip): if style == GOOGLE: write_google_docstring_args(args, snip) + elif style == NUMPY: + write_numpy_docstring_args(args, snip) else: for arg in args: snip += format_arg(arg, style) @@ -165,6 +184,23 @@ def write_google_docstring_args(args, snip): snip.rv += '\n' + snip.mkline('', indent='') +def write_numpy_docstring_args(args, snip): + if args: + snip += "Parameters" + snip += "----------" + + kwargs = [arg for arg in args if arg.is_kwarg()] + args = [arg for arg in args if not arg.is_kwarg()] + + if args: + for arg in args: + snip += format_arg(arg, NUMPY) + if kwargs: + for kwarg in kwargs: + snip += format_arg(kwarg, NUMPY) + ', optional' + snip.rv += '\n' + snip.mkline('', indent='') + + def write_init_body(args, parents, snip): parents = [p.strip() for p in parents.split(",")] parents = [p for p in parents if p != 'object'] @@ -199,10 +235,19 @@ def write_function_docstring(t, snip): write_docstring_args(args, snip) style = get_style(snip) - snip += format_return(style) + + if style == NUMPY: + snip += 'Returns' + snip += '-------' + snip += 'TODO' + else: + snip += format_return(style) snip.rv += '\n' + snip.mkline('', indent='') snip += triple_quotes(snip) +def get_dir_and_file_name(snip): + return os.getcwd().split(os.sep)[-1] + '.' + snip.basename + endglobal ######################################## @@ -546,14 +591,14 @@ endsnippet snippet try "Try / Except" b try: ${1:${VISUAL:pass}} -except ${2:Exception}, ${3:e}: +except ${2:Exception} as ${3:e}: ${4:raise $3} endsnippet snippet trye "Try / Except / Else" b try: ${1:${VISUAL:pass}} -except ${2:Exception}, ${3:e}: +except ${2:Exception} as ${3:e}: ${4:raise $3} else: ${5:pass} @@ -562,7 +607,7 @@ endsnippet snippet tryf "Try / Except / Finally" b try: ${1:${VISUAL:pass}} -except ${2:Exception}, ${3:e}: +except ${2:Exception} as ${3:e}: ${4:raise $3} finally: ${5:pass} @@ -571,7 +616,7 @@ endsnippet snippet tryef "Try / Except / Else / Finally" b try: ${1:${VISUAL:pass}} -except${2: ${3:Exception}, ${4:e}}: +except${2: ${3:Exception} as ${4:e}}: ${5:raise} else: ${6:pass} @@ -580,21 +625,9 @@ finally: endsnippet -##################### +###################### # Assertions & Tests # -##################### - -snippet pdb "Set PDB breakpoint" b -import pdb; pdb.set_trace() -endsnippet - -snippet ipdb "Set IPDB breakpoint" b -import ipdb; ipdb.set_trace() -endsnippet - -snippet pudb "Set PUDB breakpoint" b -import pudb; pudb.set_trace() -endsnippet +###################### snippet ae "Assert equal" b self.assertEqual(${1:${VISUAL:first}},${2:second}) @@ -657,4 +690,18 @@ ${1:${VISUAL:doc}} `!p snip.rv = triple_quotes(snip)` endsnippet +snippet pmdoc "pocoo style module doc string" b +# -*- coding: utf-8 -*- +""" + `!p snip.rv = get_dir_and_file_name(snip)` + `!p snip.rv = '~' * len(get_dir_and_file_name(snip))` + + ${1:DESCRIPTION} + + :copyright: (c) `date +%Y` by ${2:YOUR_NAME}. + :license: ${3:LICENSE_NAME}, see LICENSE for more details. +""" +$0 +endsnippet + # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/r.snippets b/sources_non_forked/vim-snippets/UltiSnips/r.snippets index 10c818c0..02c4c259 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/r.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/r.snippets @@ -59,6 +59,7 @@ snippet eif "Else-If statement" else if (${1}) { ${0} } +endsnippet snippet el "Else statement" else { diff --git a/sources_non_forked/vim-snippets/UltiSnips/rails.snippets b/sources_non_forked/vim-snippets/UltiSnips/rails.snippets index 5c521795..e7b2757b 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/rails.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/rails.snippets @@ -15,7 +15,7 @@ t.boolean :${1:title} $0 endsnippet -snippet cla "Create controller class" +snippet clac "Create controller class" class ${1:Model}Controller < ApplicationController before_filter :find_${2:model} @@ -48,7 +48,7 @@ t.float :${1:title} $0 endsnippet -snippet cla "Create functional test class" +snippet clact "Create functional test class" require 'test_helper' class ${1:Model}ControllerTest < ActionController::TestCase @@ -133,7 +133,7 @@ class ${1:Model}sController < ApplicationController # PUT /${1/./\l$0/}s/1.xml def update respond_to do |wants| - if @${1/./\l$0/}.update_attributes(params[:${1/./\l$0/}]) + if @${1/./\l$0/}.update(params[:${1/./\l$0/}]) flash[:notice] = '${1:Model} was successfully updated.' wants.html { redirect_to(@${1/./\l$0/}) } wants.xml { head :ok } @@ -601,12 +601,6 @@ respond_to do |wants| end endsnippet -snippet resw "respond_with" -respond_with(${1:@${2:model}})${3: do |format| - format.${4:html} { $0 \} -end} -endsnippet - # FIXME snippet returning "returning do |variable| ... end" returning ${1:variable} do${2/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1: |)/}${2:v}${2/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/} @@ -799,10 +793,6 @@ snippet xput "xhr put" xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { $4 }$0 endsnippet -snippet finl "find(:last)" -find(:last${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) -endsnippet - snippet sweeper "Create sweeper class" class ${1:Model}Sweeper < ActionController::Caching::Sweeper observe ${1:Model} diff --git a/sources_non_forked/vim-snippets/UltiSnips/ruby.snippets b/sources_non_forked/vim-snippets/UltiSnips/ruby.snippets index b8a00922..b7124f83 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/ruby.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/ruby.snippets @@ -266,18 +266,6 @@ snippet "(\S+)\.Index" ".index do |item| ... end" r end endsnippet -snippet do "do |<key>| ... end" i -do |${1:args}| - $0 -end -endsnippet - -snippet Do "do ... end" i -do - $0 -end -endsnippet - snippet until "until <expression> ... end" until ${1:expression} $0 diff --git a/sources_non_forked/vim-snippets/UltiSnips/rust.snippets b/sources_non_forked/vim-snippets/UltiSnips/rust.snippets index 4a65d772..40e76055 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/rust.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/rust.snippets @@ -18,6 +18,12 @@ fn ${1:function_name}(${2})${3/..*/ -> /}${3} { } endsnippet +snippet pfn "A public function, optionally with arguments and return type." +pub fn ${1:function_name}(${2})${3/..*/ -> /}${3} { + ${VISUAL}${0} +} +endsnippet + snippet arg "Function Arguments" i ${1:a}: ${2:T}${3:, arg} endsnippet @@ -45,11 +51,11 @@ format!("${1}"${2/..*/, /}${2}); endsnippet snippet macro "macro_rules!" b -macro_rules! ${1:name} ( +macro_rules! ${1:name} { (${2:matcher}) => ( ${3} ) -) +} endsnippet snippet mod "A module" b @@ -82,7 +88,7 @@ pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} { impl $1 { pub fn new(${2}) -> $1 { - $1 { ${3} }; + $1 { ${3} } } } endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/scss.snippets b/sources_non_forked/vim-snippets/UltiSnips/scss.snippets deleted file mode 100644 index cab17c14..00000000 --- a/sources_non_forked/vim-snippets/UltiSnips/scss.snippets +++ /dev/null @@ -1,57 +0,0 @@ -extends css - -priority -50 - -snippet imp "@import '...';" b -@import '${1:file}'; -endsnippet - -snippet inc "@include mixin(...);" b -@include ${1:mixin}(${2}); -endsnippet - -snippet ext "@extend %placeholder;" b -@extend %${1:%placeholder}; -endsnippet - -snippet mixin "@mixin (...) { ... }" b -@mixin ${1:name}(${2}) { - ${VISUAL}$0 -} -endsnippet - -snippet fun "@function (...) { ... }" b -@function ${1:name}(${2}) { - ${VISUAL}$0 -} -endsnippet - -snippet if "@if (...) { ... }" b -@if ${1:condition} { - ${VISUAL}$0 -} -endsnippet - -snippet else "@else { ... }" b -@else ${1:condition} { - ${VISUAL}$0 -} -endsnippet - -snippet for "@for loop" b -@for ${1:$i} from ${2:1} through ${3:3} { - ${VISUAL}$0 -} -endsnippet - -snippet each "@each loop" b -@each ${1:$item} in ${2:item, item, item} { - ${VISUAL}$0 -} -endsnippet - -snippet while "@while loop" b -@while ${1:$i} ${2:>} ${3:0} { - ${VISUAL}$0 -} -endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/sh.snippets b/sources_non_forked/vim-snippets/UltiSnips/sh.snippets index 9cc45779..70181845 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/sh.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/sh.snippets @@ -33,6 +33,13 @@ snippet !env "#!/usr/bin/env (!env)" `!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n\n" ` endsnippet +snippet sbash "safe bash options" +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +`!p snip.rv ='\n\n' ` +endsnippet + snippet temp "Tempfile" ${1:TMPFILE}="$(mktemp -t ${2:`!p snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" diff --git a/sources_non_forked/vim-snippets/UltiSnips/supercollider.snippets b/sources_non_forked/vim-snippets/UltiSnips/supercollider.snippets new file mode 100644 index 00000000..b8538aa9 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/supercollider.snippets @@ -0,0 +1,10 @@ +snippet for +for (${1:1}, ${2:10}) {${3: |i}|} + $0 +} +endsnippet +snippet sdef +SynthDef(\\${1:synthName}, {${2: |${3:x}|} + ${0} +}).add; +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/twig.snippets b/sources_non_forked/vim-snippets/UltiSnips/twig.snippets deleted file mode 100644 index 156b981b..00000000 --- a/sources_non_forked/vim-snippets/UltiSnips/twig.snippets +++ /dev/null @@ -1,35 +0,0 @@ -priority -50 - -snippet bl "twig block" b -{% block ${1} %} -${2} -{% endblock $1 %} -endsnippet - -snippet js "twig javascripts" b -{% javascripts '${1}' %} - <script src="{{ asset_url }}"></script> -{% endjavascripts %} -endsnippet - -snippet css "twig stylesheets" b -{% stylesheets '${1}' %} - <link rel="stylesheet" href="{{ asset_url }}"> -{% endstylesheets %} -endsnippet - -snippet if "twig if" b -{% if ${1} %} -${2} -{% endif %} -endsnippet - -snippet for "twig for" b -{% for ${1} in ${2} %} -${3} -{% endfor %} -endsnippet - -snippet ext "twig extends" b -{% extends ${1} %} -endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/typescript.snippets b/sources_non_forked/vim-snippets/UltiSnips/typescript.snippets new file mode 100644 index 00000000..11072ddd --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/typescript.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends javascript diff --git a/sources_non_forked/vim-snippets/pythonx/vimsnippets.py b/sources_non_forked/vim-snippets/pythonx/vimsnippets.py index b00edb15..6a446a2a 100644 --- a/sources_non_forked/vim-snippets/pythonx/vimsnippets.py +++ b/sources_non_forked/vim-snippets/pythonx/vimsnippets.py @@ -1,5 +1,7 @@ """Helper methods used in UltiSnips snippets.""" +import string, vim + def complete(tab, opts): """ get options that start with tab @@ -18,3 +20,73 @@ def complete(tab, opts): if not len(opts): msg = "{0}" return msg.format("|".join(opts)) + +def _parse_comments(s): + """ Parses vim's comments option to extract comment format """ + i = iter(s.split(",")) + + rv = [] + try: + while True: + # get the flags and text of a comment part + flags, text = next(i).split(':', 1) + + if len(flags) == 0: + rv.append((text, text, text, "")) + # parse 3-part comment, but ignore those with O flag + elif 's' in flags and 'O' not in flags: + ctriple = ["TRIPLE"] + indent = "" + + if flags[-1] in string.digits: + indent = " " * int(flags[-1]) + ctriple.append(text) + + flags, text = next(i).split(':', 1) + assert flags[0] == 'm' + ctriple.append(text) + + flags, text = next(i).split(':', 1) + assert flags[0] == 'e' + ctriple.append(text) + ctriple.append(indent) + + rv.append(ctriple) + elif 'b' in flags: + if len(text) == 1: + rv.insert(0, ("SINGLE_CHAR", text, text, text, "")) + except StopIteration: + return rv + +def get_comment_format(): + """ Returns a 4-element tuple (first_line, middle_lines, end_line, indent) + representing the comment format for the current file. + + It first looks at the 'commentstring', if that ends with %s, it uses that. + Otherwise it parses '&comments' and prefers single character comment + markers if there are any. + """ + commentstring = vim.eval("&commentstring") + if commentstring.endswith("%s"): + c = commentstring[:-2] + return (c, c, c, "") + comments = _parse_comments(vim.eval("&comments")) + for c in comments: + if c[0] == "SINGLE_CHAR": + return c[1:] + return comments[0][1:] + + +def make_box(twidth, bwidth=None): + b, m, e, i = (s.strip() for s in get_comment_format()) + bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2 + sline = b + m + bwidth_inner * m[0] + 2 * m[0] + nspaces = (bwidth_inner - twidth) // 2 + mlines = i + m + " " + " " * nspaces + mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m + eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e + return sline, mlines, mlinee, eline + +def foldmarker(): + "Return a tuple of (open fold marker, close fold marker)" + return vim.eval("&foldmarker").split(",") diff --git a/sources_non_forked/vim-snippets/snippets/_.snippets b/sources_non_forked/vim-snippets/snippets/_.snippets index d7f51bea..0153a146 100644 --- a/sources_non_forked/vim-snippets/snippets/_.snippets +++ b/sources_non_forked/vim-snippets/snippets/_.snippets @@ -7,6 +7,8 @@ snippet date `strftime("%Y-%m-%d")` snippet ddate `strftime("%B %d, %Y")` +snippet diso + `strftime("%Y-%m-%dT%H:%M:%S")` snippet time `strftime("%H:%M")` snippet datetime diff --git a/sources_non_forked/vim-snippets/snippets/c.snippets b/sources_non_forked/vim-snippets/snippets/c.snippets index aa7ce847..f4745c25 100644 --- a/sources_non_forked/vim-snippets/snippets/c.snippets +++ b/sources_non_forked/vim-snippets/snippets/c.snippets @@ -25,7 +25,7 @@ snippet Inc snippet ndef #ifndef $1 #define ${1:SYMBOL} ${2:value} - #endif + #endif /* ifndef $1 */ # define snippet def #define @@ -98,6 +98,8 @@ snippet case case ${1:/* variable case */}: ${2} ${3:break;} +snippet ret + return ${0}; ## ## Loops # for @@ -146,6 +148,9 @@ snippet tds typedef struct ${2:_$1 }{ ${3:/* data */} } ${1:`vim_snippets#Filename('$1_t', 'name')`}; + +snippet enum + enum ${1:name} { ${0} }; # typedef enum snippet tde typedef enum { @@ -221,23 +226,3 @@ snippet getopt # This is kind of convenient snippet . [${1}] -# GPL -snippet gpl - /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - * - * Copyright (C) ${1:Author}, `strftime("%Y")` - */ - - ${0} diff --git a/sources_non_forked/vim-snippets/snippets/cmake.snippets b/sources_non_forked/vim-snippets/snippets/cmake.snippets index ef2256a4..3a0b920e 100644 --- a/sources_non_forked/vim-snippets/snippets/cmake.snippets +++ b/sources_non_forked/vim-snippets/snippets/cmake.snippets @@ -1,58 +1,83 @@ -snippet cmake - CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - PROJECT(${1:ProjectName}) +snippet init + cmake_minimum_required(version ${1:2.8.2}) + project(${2:ProjectName}) - FIND_PACKAGE(${2:LIBRARY}) + find_package(${3:library}) - INCLUDE_DIRECTORIES( - ${$2_INCLUDE_DIR} - ) + include_directories(${$3_INCLUDE_DIRS}) - ADD_SUBDIRECTORY(${0:src}) + add_subdirectory(${0:src}) - ADD_EXECUTABLE($1) + add_executable($2) - TARGET_LINK_LIBRARIES($1 - ${$2_LIBRARIES} - ) + target_link_libraries($2 ${$3_LIBRARIES}) + +snippet proj + project(${0:Name}) + +snippet min + cmake_minimum_required(version ${0:2.8.2}) snippet include - INCLUDE_DIRECTORIES( - ${${0:INCLUDE_DIR}} - ) + include_directories(${${0:include_dir}}) snippet find - FIND_PACKAGE(${0:LIBRARY}) + find_package(${1:library} ${0:REQUIRED}) snippet glob - FILE(GLOB ${1:SRCS} *.${0:cpp}) + file(glob ${1:srcs} *.${0:cpp}) snippet subdir - ADD_SUBDIRECTORY(${0:src}) + add_subdirectory(${0:src}) snippet lib - ADD_LIBRARY(${1:lib} ${2:STATIC} - ${${0:SRCS}} - ) + add_library(${1:lib} ${${0:srcs}}) snippet link - TARGET_LINK_LIBRARIES(${1:bin} - ${0:somelib} - ) + target_link_libraries(${1:bin} ${0:somelib}) snippet bin - ADD_EXECUTABLE(${1:bin}) + add_executable(${1:bin}) snippet set - SET(${1:var} ${0:val}) + set(${1:var} ${0:val}) snippet dep - ADD_DEPENDENCIES(${1:target} + add_dependencies(${1:target} ${0:dep} ) +snippet Ext_url + include(ExternalProject) + ExternalProject_Add(${1:googletest} + URL ${2:http://googletest.googlecode.com/files/gtest-1.7.0.zip} + URL_HASH SHA1=${3:f85f6d2481e2c6c4a18539e391aa4ea8ab0394af} + SOURCE_DIR "${4:${CMAKE_BINARY_DIR}/gtest-src}" + BINARY_DIR "${0:${CMAKE_BINARY_DIR}/gtest-build}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) + +snippet Ext_git + include(ExternalProject) + ExternalProject_Add(${1:googletest} + GIT_REPOSITORY ${2:https://github.com/google/googletest.git} + GIT_TAG ${3:master} + SOURCE_DIR "${4:${CMAKE_BINARY_DIR}/googletest-src}" + BINARY_DIR "${0:${CMAKE_BINARY_DIR}/googletest-build}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) + snippet props - SET_TARGET_PROPERTIES(${1:target} - ${2:PROPERTIES} ${3:COMPILE_FLAGS} + set_target_properties(${1:target} + ${2:properties} ${3:compile_flags} ${0:"-O3 -Wall -pedantic"} ) + +snippet test + add_test(${1:ATestName} ${0:testCommand --options}) diff --git a/sources_non_forked/vim-snippets/snippets/cpp.snippets b/sources_non_forked/vim-snippets/snippets/cpp.snippets index 632f76f9..42c37341 100644 --- a/sources_non_forked/vim-snippets/snippets/cpp.snippets +++ b/sources_non_forked/vim-snippets/snippets/cpp.snippets @@ -1,5 +1,13 @@ extends c +## +## Preprocessor +# #include <...> +snippet incc + #include <${1:iostream}> +snippet binc + #include <boost/${1:shared_ptr}.hpp> +## ## STL Collections # std::array snippet array @@ -98,6 +106,19 @@ snippet cout snippet cin std::cin >> ${1}; ## +## Casts +# static +snippet sca + static_cast<${1:unsigned}>(${2:expr})${3} +# dynamic +snippet dca + dynamic_cast<${1:unsigned}>(${2:expr})${3} +# reinterpret +snippet rca + reinterpret_cast<${1:unsigned}>(${2:expr})${3} +# const +snippet cca + const_cast<${1:unsigned}>(${2:expr})${3} ## Iteration # for i snippet fori @@ -125,9 +146,9 @@ snippet itera ## Lambdas # lamda (one line) snippet ld - [${1}](${2}){${3}} + [${1}](${2}){${3}}; # lambda (multi-line) snippet lld [${1}](${2}){ ${3} - } + }; diff --git a/sources_non_forked/vim-snippets/snippets/eelixir.snippets b/sources_non_forked/vim-snippets/snippets/eelixir.snippets index fd76d169..3d6e33d4 100644 --- a/sources_non_forked/vim-snippets/snippets/eelixir.snippets +++ b/sources_non_forked/vim-snippets/snippets/eelixir.snippets @@ -1,37 +1,31 @@ +extends html + snippet % <% ${0} %> - snippet = <%= ${0} %> - snippet end <% end %> - snippet for <%= for ${1:item} <- ${2:items} ${3:@conn} do %> ${0} <% end %> - snippet if <%= if ${1} do %> ${0} <% end %> - snippet ife <%= if ${1} do %> ${2} <%= else %> ${0} <% end %> - snippet ft <%= form_tag(${1:"/users"}, method: ${2::post}) %> ${0} </form> - snippet lin <%= link "${1:Submit}", to: ${2:"/users"}, method: ${3::delete} %> - snippet ff <%= form_for @changeset, ${1:"/users"}, fn f -> %> ${0} diff --git a/sources_non_forked/vim-snippets/snippets/elixir.snippets b/sources_non_forked/vim-snippets/snippets/elixir.snippets index 8ca37912..0a3efbdc 100644 --- a/sources_non_forked/vim-snippets/snippets/elixir.snippets +++ b/sources_non_forked/vim-snippets/snippets/elixir.snippets @@ -70,7 +70,7 @@ snippet defma ${0} end snippet defmo - defmodule ${1:module_name} do + defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do ${0} end snippet defp @@ -87,14 +87,12 @@ snippet doc """ snippet fn fn ${1:args} -> ${0} end -snippet fun - function do - ${0} - end snippet mdoc @moduledoc """ ${0} """ +snippet mdocf + @moduledoc false snippet rec receive do ${1} -> @@ -107,11 +105,21 @@ snippet imp snippet ali alias ${0:module_name} snippet test - test "${1:test_name}" do + test "${1:test name}" do ${0} end snippet testa test "${1:test_name}", %{${2:arg: arg}} do + ${0} + end +snippet des + describe "${1:test group subject}" do + ${0} + end +snippet exunit + defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do + use ExUnit.Case, async: true + ${0} end snippet try try .. rescue .. end @@ -123,3 +131,10 @@ snippet try try .. rescue .. end snippet pry require IEx; IEx.pry ${0} +snippet qu + quote do + ${1} + end +snippet beh + @behaviour ${1:Mix.Task} + ${0} diff --git a/sources_non_forked/vim-snippets/snippets/elm.snippets b/sources_non_forked/vim-snippets/snippets/elm.snippets new file mode 100644 index 00000000..6a15c83a --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/elm.snippets @@ -0,0 +1,50 @@ +snippet mod + module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` exposing (${1}) + ${0} +snippet imp + import ${0:List} +snippet impe + import ${1:List} exposing (${0:map}) +snippet fn + ${1:fn} : ${2:a} -> ${3:a} + $1 ${4} = + ${0} +snippet fn1 + ${1:fn} : ${2:a} -> ${3:a} + $1 ${4} = + ${0} +snippet fn2 + ${1:fn} : ${2:a} -> ${3:a} -> ${4:a} + $1 ${5} = + ${0} +snippet fn3 + ${1:fn} : ${2:a} -> ${3:a} -> ${4:a} -> ${5:a} + $1 ${6} = + ${0} +snippet fn0 + ${1:fn} : ${2:a} + $1 = + ${0} +snippet case + case ${1} of + ${2} -> + ${0} +snippet - + ${1} -> + ${0} +snippet let + let + ${1} = ${2} + in + ${0} +snippet if + if ${1} then + ${2} + else + ${0} +snippet ty + type ${1:Msg} + = ${0} +snippet tya + type alias ${1:Model} = + ${0} diff --git a/sources_non_forked/vim-snippets/snippets/erlang.snippets b/sources_non_forked/vim-snippets/snippets/erlang.snippets index 18f1c6de..5440d7c4 100644 --- a/sources_non_forked/vim-snippets/snippets/erlang.snippets +++ b/sources_non_forked/vim-snippets/snippets/erlang.snippets @@ -24,6 +24,10 @@ snippet incl # behavior directive snippet beh -behaviour(${1:behaviour}). +snippet ifd + -ifdef(${1:TEST}). + ${0} + -endif. # if expression snippet if if @@ -478,26 +482,57 @@ snippet gen_event %%%=================================================================== %%% Internal functions %%%=================================================================== +# EUnit snippets +snippet eunit + -module(${1:`vim_snippets#Filename('', 'my')`}). + -include_lib("eunit/include/eunit.hrl"). + + ${0} +snippet ieunit + -ifdef(TEST). + -include_lib("eunit/include/eunit.hrl"). + + ${0} + + -endif. +snippet as + ?assert(${0}) +snippet asn + ?assertNot(${0}) +snippet aseq + ?assertEqual(${1}, ${0}) +snippet asneq + ?assertNotEqual(${1}, ${0}) +snippet asmat + ?assertMatch(${1:Pattern}, ${0:Expression}) +snippet asnmat + ?assertNotMatch(${1:Pattern}, ${0:Expression}) +snippet aserr + ?assertError(${1:Pattern}, ${0:Expression}) +snippet asex + ?assertExit(${1:Pattern}, ${0:Expression}) +snippet asexc + ?assertException(${1:Class}, ${2:Pattern}, ${0:Expression}) # common_test test_SUITE snippet testsuite -module(${0:`vim_snippets#Filename('', 'my')`}). -include_lib("common_test/include/ct.hrl"). - + %% Test server callbacks -export([suite/0, all/0, groups/0, init_per_suite/1, end_per_suite/1, init_per_group/2, end_per_group/2, init_per_testcase/2, end_per_testcase/2]). - + %% Test cases -export([ ]). - + %%-------------------------------------------------------------------- %% COMMON TEST CALLBACK FUNCTIONS %%-------------------------------------------------------------------- - + %%-------------------------------------------------------------------- %% Function: suite() -> Info %% @@ -512,7 +547,7 @@ snippet testsuite %%-------------------------------------------------------------------- suite() -> [{timetrap,{minutes,10}}]. - + %%-------------------------------------------------------------------- %% Function: init_per_suite(Config0) -> %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} @@ -529,7 +564,7 @@ snippet testsuite %%-------------------------------------------------------------------- init_per_suite(Config) -> Config. - + %%-------------------------------------------------------------------- %% Function: end_per_suite(Config0) -> void() | {save_config,Config1} %% @@ -540,7 +575,7 @@ snippet testsuite %%-------------------------------------------------------------------- end_per_suite(_Config) -> ok. - + %%-------------------------------------------------------------------- %% Function: init_per_group(GroupName, Config0) -> %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} @@ -556,7 +591,7 @@ snippet testsuite %%-------------------------------------------------------------------- init_per_group(_GroupName, Config) -> Config. - + %%-------------------------------------------------------------------- %% Function: end_per_group(GroupName, Config0) -> %% void() | {save_config,Config1} @@ -570,7 +605,7 @@ snippet testsuite %%-------------------------------------------------------------------- end_per_group(_GroupName, _Config) -> ok. - + %%-------------------------------------------------------------------- %% Function: init_per_testcase(TestCase, Config0) -> %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} @@ -589,7 +624,7 @@ snippet testsuite %%-------------------------------------------------------------------- init_per_testcase(_TestCase, Config) -> Config. - + %%-------------------------------------------------------------------- %% Function: end_per_testcase(TestCase, Config0) -> %% void() | {save_config,Config1} | {fail,Reason} @@ -605,7 +640,7 @@ snippet testsuite %%-------------------------------------------------------------------- end_per_testcase(_TestCase, _Config) -> ok. - + %%-------------------------------------------------------------------- %% Function: groups() -> [Group] %% @@ -629,7 +664,7 @@ snippet testsuite %%-------------------------------------------------------------------- groups() -> []. - + %%-------------------------------------------------------------------- %% Function: all() -> GroupsAndTestCases | {skip,Reason} %% @@ -644,14 +679,14 @@ snippet testsuite %% Description: Returns the list of groups and test cases that %% are to be executed. %%-------------------------------------------------------------------- - all() -> + all() -> []. - - + + %%-------------------------------------------------------------------- %% TEST CASES %%-------------------------------------------------------------------- - + %%-------------------------------------------------------------------- %% Function: TestCase(Config0) -> %% ok | exit() | {skip,Reason} | {comment,Comment} | diff --git a/sources_non_forked/vim-snippets/snippets/eruby.snippets b/sources_non_forked/vim-snippets/snippets/eruby.snippets index 00696963..adad8cb0 100644 --- a/sources_non_forked/vim-snippets/snippets/eruby.snippets +++ b/sources_non_forked/vim-snippets/snippets/eruby.snippets @@ -22,23 +22,23 @@ snippet for ${0} <% end %> snippet rp - <%= render :partial => '${0:item}' %> + <%= render partial: '${0:item}' %> snippet rpl - <%= render :partial => '${1:item}', :locals => { :${2:name} => '${3:value}'${0} } %> + <%= render partial: '${1:item}', locals: { :${2:name} => '${3:value}'${0} } %> snippet rps - <%= render :partial => '${1:item}', :status => ${0:500} %> + <%= render partial: '${1:item}', status: ${0:500} %> snippet rpc - <%= render :partial => '${1:item}', :collection => ${0:items} %> + <%= render partial: '${1:item}', collection: ${0:items} %> snippet lia - <%= link_to '${1:link text...}', :action => '${0:index}' %> + <%= link_to '${1:link text...}', action: '${0:index}' %> snippet liai - <%= link_to '${1:link text...}', :action => '${2:edit}', :id => ${0:@item} %> + <%= link_to '${1:link text...}', action: '${2:edit}', id: ${0:@item} %> snippet lic - <%= link_to '${1:link text...}', :controller => '${0:items}' %> + <%= link_to '${1:link text...}', controller: '${0:items}' %> snippet lica - <%= link_to '${1:link text...}', :controller => '${2:items}', :action => '${0:index}' %> + <%= link_to '${1:link text...}', controller: '${2:items}', action: '${0:index}' %> snippet licai - <%= link_to '${1:link text...}', :controller => '${2:items}', :action => '${3:edit}', :id => ${0:@item} %> + <%= link_to '${1:link text...}', controller: '${2:items}', action: '${3:edit}', id: ${0:@item} %> snippet yield <%= yield ${1::content_symbol} %> snippet conf @@ -110,11 +110,11 @@ snippet ofcfs snippet ofs <%= options_for_select ${1:collection}, ${2:value_method} %> snippet rf - <%= render :file => "${1:file}"${0} %> + <%= render file: "${1:file}"${0} %> snippet rt - <%= render :template => "${1:file}"${0} %> + <%= render template: "${1:file}"${0} %> snippet slt - <%= stylesheet_link_tag ${1::all}, :cache => ${0:true} %> + <%= stylesheet_link_tag ${1::all}, cache: ${0:true} %> snippet sslt <%= stylesheet_link_tag "${0}" %> snippet if diff --git a/sources_non_forked/vim-snippets/snippets/go.snippets b/sources_non_forked/vim-snippets/snippets/go.snippets index af76e724..b2bdc9e0 100644 --- a/sources_non_forked/vim-snippets/snippets/go.snippets +++ b/sources_non_forked/vim-snippets/snippets/go.snippets @@ -53,26 +53,6 @@ snippet dfr ${0} } }() -# gpl -snippet gpl - /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - * - * Copyright (C) ${1:Author}, `strftime("%Y")` - */ - - ${0} # int snippet i int @@ -94,6 +74,12 @@ snippet if if ${1:/* condition */} { ${2} } +snippet ife + if ${1:/* condition */} { + ${2} + } else { + ${0} + } # else snippet snippet el else { @@ -128,18 +114,21 @@ snippet ie ${3} } ${0} -# for loop -snippet fo +# for int loop +snippet for + for ${1}{ + ${0} + } +# for int loop +snippet fori for ${2:i} := 0; $2 < ${1:count}; $2${3:++} { - ${4} + ${0} } - ${0} # for range loop -snippet fr - for ${1:k}, ${2:v} := range ${3} { - ${4} +snippet forr + for ${1:e} := range ${2:collection} { + ${0} } - ${0} # function simple snippet fun func ${1:funcName}(${2}) ${3:error} { @@ -182,6 +171,9 @@ snippet pn # print snippet pr fmt.Printf("%${1:s}\n", ${2:var}) +# println +snippet pl + fmt.Println("${1:s}") # range snippet rn range ${0} @@ -196,8 +188,6 @@ snippet sl select { case ${1:v1} := <-${2:chan1} ${3} - case ${4:v2} := <-${5:chan2} - ${6} default: ${0} } @@ -228,7 +218,7 @@ snippet t # goroutine named function snippet g go ${1:funcName}(${0}) -# goroutine anonymous function +# goroutine anonymous function snippet ga go func(${1} ${2:type}) { ${3:/* code */} diff --git a/sources_non_forked/vim-snippets/snippets/haskell.snippets b/sources_non_forked/vim-snippets/snippets/haskell.snippets index 633c9aaf..e4957e4c 100644 --- a/sources_non_forked/vim-snippets/snippets/haskell.snippets +++ b/sources_non_forked/vim-snippets/snippets/haskell.snippets @@ -2,11 +2,13 @@ snippet lang {-# LANGUAGE ${0:OverloadedStrings} #-} snippet haddock {-# OPTIONS_HADDOCK ${0:hide} #-} +snippet ghc + {-# OPTIONS_GHC ${0:-fno-warn-unused-imports} #-} snippet inline {-# INLINE ${0:name} #-} snippet info -- | - -- Module : ${1:Module.Namespace} + -- Module : ${1:`substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')`} -- Copyright : ${2:Author} ${3:2011-2012} -- License : ${4:BSD3} -- @@ -40,9 +42,12 @@ snippet class ${0} snippet module module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` ( - ) where - `expand('%') =~ 'Main' ? "\n\nmain = do\n print \"hello world\"" : ""` + ) where + `expand('%') =~ 'Main' ? "\nmain :: IO ()\nmain = undefined" : ""` +snippet main + main :: IO () + main = ${0:undefined} snippet const ${1:name} :: ${2:a} $1 = ${0:undefined} @@ -52,25 +57,21 @@ snippet fn snippet fn2 ${1:fn} :: ${2:a} -> ${3:a} -> ${4:a} $1 ${5} = ${0:undefined} +snippet fn3 + ${1:fn} :: ${2:a} -> ${3:a} -> ${4:a} -> ${5:a} + $1 ${6} = ${0:undefined} +snippet => "Type constraint" + (${1:Class} ${2:a}) => $2 snippet ap ${1:map} ${2:fn} ${0:list} -snippet do - do - -snippet λ - \\${1:x} -> ${0:expression} snippet \ \\${1:x} -> ${0:expression} snippet (\ (\\${1:x} -> ${0:expression}) snippet <- ${1:a} <- ${0:m a} -snippet ← - ${1:a} <- ${0:m a} snippet -> ${1:m a} -> ${0:a} -snippet → - ${1:m a} -> ${0:a} snippet tup (${1:a}, ${0:b}) snippet tup2 @@ -90,3 +91,25 @@ snippet let snippet where where ${1:fn} = ${0:undefined} +snippet spec + module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` (main, spec) where + + import Test.Hspec + import Test.QuickCheck + + main :: IO () + main = hspec spec + + spec :: Spec + spec = + describe "${1}" $ do + $0 +snippet desc + describe "${1}" $ do + $0 +snippet it + it "${1}" $ + $0 +snippet itp + it "${1}" $ property $ + $0 diff --git a/sources_non_forked/vim-snippets/snippets/html.snippets b/sources_non_forked/vim-snippets/snippets/html.snippets index 89438b41..5ae8e749 100644 --- a/sources_non_forked/vim-snippets/snippets/html.snippets +++ b/sources_non_forked/vim-snippets/snippets/html.snippets @@ -254,11 +254,11 @@ snippet colgroup+ col+${0} </colgroup> snippet command - <command type="command" label="${1}" icon="${0}" /> + <command type="command" label="${1}" icon="${0}"> snippet command:c - <command type="checkbox" label="${1}" icon="${0}" /> + <command type="checkbox" label="${1}" icon="${0}"> snippet command:r - <command type="radio" radiogroup="${1}" label="${2}" icon="${0}" /> + <command type="radio" radiogroup="${1}" label="${2}" icon="${0}"> snippet datagrid <datagrid> ${0} @@ -462,8 +462,8 @@ snippet html5 <!DOCTYPE html> <html> <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width"> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width" /> <title>${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:link} @@ -475,8 +475,8 @@ snippet html5l - - + + ${2:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`} ${3:link} @@ -550,8 +550,6 @@ snippet ins ${0} snippet kbd ${0} -snippet keygen - ${0} snippet label snippet label:i @@ -853,7 +851,7 @@ snippet tr+ td+${0} snippet track - { + ${0} + }); +snippet it "it" b + it('${1:}', () => { + ${0} + }); +snippet exp "expect" b + expect(${1:})${0}; +snippet expe "expect" b + expect(${1:}).to.equal(${0}); +snippet expd "expect" b + expect(${1:}).to.deep.equal(${0}); diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.d3.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.d3.snippets index a3f7fa7a..f5be9189 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.d3.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.d3.snippets @@ -16,8 +16,8 @@ snippet marginconvention var ${8:height} = ${9:500} - $1.top - $1.bottom; var ${10:svg} = d3.select("${11}").append("svg") - .attr("width", $6) - .attr("height", $8) + .attr("width", $6 + $1.left + $1.right) + .attr("height", $8 + $1.top + $1.bottom) .append("g") .attr("transform", "translate(" + $1.left + "," + $1.top + ")") snippet nest diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.es6.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.es6.snippets new file mode 100644 index 00000000..df059a15 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.es6.snippets @@ -0,0 +1,28 @@ +snippet const + const ${1} = ${0}; +snippet let + let ${1} = ${0}; +snippet im + import ${1} from '${0}'; +snippet cla + class ${1} { + ${0} + } +snippet clax + class ${1} extends ${2} { + ${0} + } +snippet => + (${1}) => { + ${0} + } +snippet af + (${1}) => { + ${0} + } +snippet sym + const ${1} = Symbol('${0}'); +snippet ed + export default ${0} +snippet ${ + ${${1}}${0} diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets index 1da78d09..2b5aefb4 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets @@ -5,7 +5,7 @@ snippet ex module.exports = ${1}; # require snippet re - var ${1} = require('${2:module_name}'); + ${1:var} ${2} = require('${3:module_name}'); # EventEmitter snippet on on('${1:event_name}', function(${2:stream}) { diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets index 4832815d..db04e545 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets @@ -11,7 +11,7 @@ snippet fun ${0} } # Anonymous Function -snippet f +snippet f "" w function(${1}) { ${0} } @@ -30,6 +30,11 @@ snippet (f (function(${1}) { ${0} }(${2})); +# Minify safe iife +snippet ;fe + ;(function(${1}) { + ${0} + }(${2})) # self-defining function snippet sdf var ${1:function_name} = function (${2:argument}) { @@ -80,6 +85,18 @@ snippet try } catch (${2:e}) { ${0:/* handle error */} } +# try finally +snippet tryf + try { + ${1} + } catch (${2:e}) { + ${0:/* handle error */} + } finally { + ${3:/* be executed regardless of the try / catch result*/} + } +# throw Error +snippet terr + throw new Error('${1:error message}') # return snippet ret return ${0:result}; @@ -88,12 +105,12 @@ snippet ret # for loop snippet for - for (var ${2:i} = 0, l = ${1:arr}.length; $2 < l; $2 ++) { + for (var ${2:i} = 0, l = ${1:arr}.length; $2 < l; $2++) { var ${3:v} = $1[$2];${0:} } # Reversed for loop snippet forr - for (var ${2:i} = ${1:arr}.length - 1; $2 >= 0; $2 --) { + for (var ${2:i} = ${1:arr}.length - 1; $2 >= 0; $2--) { var ${3:v} = $1[$2];${0:} } # While loop @@ -203,7 +220,6 @@ snippet @par @param {${1:type}} ${2:name} ${0:description} snippet @ret @return {${1:type}} ${0:description} - # JSON # JSON.parse @@ -243,6 +259,9 @@ snippet cl # console.debug snippet cd console.debug(${0}); +# console.error +snippet ce + console.error(${0}); # console.trace snippet ct console.trace(${0:label}); diff --git a/sources_non_forked/vim-snippets/snippets/jinja.snippets b/sources_non_forked/vim-snippets/snippets/jinja.snippets new file mode 100644 index 00000000..7d14ca83 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/jinja.snippets @@ -0,0 +1,142 @@ +# Generic tags + +extends html + +snippet % + {% ${1} %} +snippet %% + {% ${1:tag_name} %} + ${0} + {% end$1 %} +snippet { + {{ ${1} }} +# Template Tags + +snippet autoescape + {% autoescape ${1:off} %} + ${0} + {% endautoescape %} +snippet block + {% block ${1} %} + ${0} + {% endblock %} +snippet # + {# ${0:comment} #} +snippet comment + {% comment %} + ${0} + {% endcomment %} +snippet cycle + {% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +snippet debug + {% debug %} +snippet extends + {% extends "${0:base.html}" %} +snippet filter + {% filter ${1} %} + ${0} + {% endfilter %} +snippet firstof + {% firstof ${1} %} +snippet for + {% for ${1} in ${2} %} + ${0} + {% endfor %} +snippet empty + {% empty %} + ${0} +snippet if + {% if ${1} %} + ${0} + {% endif %} +snippet el + {% else %} + ${1} +snippet eif + {% elif ${1} %} + ${0} +snippet ifchanged + {% ifchanged %}${1}{% endifchanged %} +snippet ifequal + {% ifequal ${1} ${2} %} + ${0} + {% endifequal %} +snippet ifnotequal + {% ifnotequal ${1} ${2} %} + ${0} + {% endifnotequal %} +snippet include + {% include "${0}" %} +snippet load + {% load ${0} %} +snippet now + {% now "${0:jS F Y H:i}" %} +snippet regroup + {% regroup ${1} by ${2} as ${0} %} +snippet spaceless + {% spaceless %}${0}{% endspaceless %} +snippet ssi + {% ssi ${0} %} +snippet trans + {% trans "${0:string}" %} +snippet url + {% url ${1} as ${0} %} +snippet widthratio + {% widthratio ${1:this_value} ${2:max_value} ${0:100} %} +snippet with + {% with ${1} as ${2} %} + ${0} + {% endwith %} + +# Template Filters + +# Note: Since SnipMate can't determine which template filter you are +# expanding without the "|" character, these do not add the "|" +# character. These save a few keystrokes still. + +# Note: Template tags that take no arguments are not implemented. + +snippet add + add:"${0}" +snippet center + center:"${0}" +snippet cut + cut:"${0}" +snippet date + date:"${0}" +snippet default + default:"${0}" +snippet defaultifnone + default_if_none:"${0}" +snippet dictsort + dictsort:"${0}" +snippet dictsortrev + dictsortreversed:"${0}" +snippet divisibleby + divisibleby:"${0}" +snippet floatformat + floatformat:"${0}" +snippet getdigit + get_digit:"${0}" +snippet join + join:"${0}" +snippet lengthis + length_is:"${0}" +snippet pluralize + pluralize:"${0}" +snippet removetags + removetags:"${0}" +snippet slice + slice:"${0}" +snippet stringformat + stringformat:"${0}" +snippet time + time:"${0}" +snippet truncatewords + truncatewords:${0} +snippet truncatewordshtml + truncatewords_html:${0} +snippet urlizetrunc + urlizetrunc:${0} +snippet wordwrap + wordwrap:${0} diff --git a/sources_non_forked/vim-snippets/snippets/make.snippets b/sources_non_forked/vim-snippets/snippets/make.snippets index 8367b8fe..332d6fc9 100644 --- a/sources_non_forked/vim-snippets/snippets/make.snippets +++ b/sources_non_forked/vim-snippets/snippets/make.snippets @@ -25,7 +25,26 @@ snippet add snippet print print-%: ; @echo $*=$($*) # ifeq -snippet ifeq +snippet if ifeq (${1:cond0}, ${2:cond1}) ${0} endif +# ifeq ... else ... endif +snippet ife + ifeq (${1:cond0}, ${2:cond1}) + ${3} + else + ${0} + endif +# else ... +snippet el + else + ${0} +# .DEFAULT_GOAL := target +snippet default + .DEFAULT_GOAL := ${1} +# help target for self-documented Makefile +snippet help + help: ## Prints help for targets with comments + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $\$1, $\$2}' + ${0} diff --git a/sources_non_forked/vim-snippets/snippets/mustache.snippets b/sources_non_forked/vim-snippets/snippets/mustache.snippets new file mode 100644 index 00000000..8296afcb --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/mustache.snippets @@ -0,0 +1,18 @@ +# if {{#value}} ... {{/value}} +snippet if + {{#${1:value}}} + ${0} + {{/$1}} +# if not {{^value}} ... {{/value}} +snippet ifn + {{^${1:value}}} + ${0} + {{/$1}} +# if else {{#value}} ... {{/value}} {{^value}} ... {{/value}} +snippet ife + {{#${1:value}}} + ${2} + {{/$1}} + {{^$1}} + ${3} + {{/$1}} diff --git a/sources_non_forked/vim-snippets/snippets/perl6.snippets b/sources_non_forked/vim-snippets/snippets/perl6.snippets new file mode 100644 index 00000000..21ddf5bd --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/perl6.snippets @@ -0,0 +1,116 @@ +# shebang +snippet #! + #!/usr/bin/env perl6 + +# Hash Pointer +snippet . + => +# Function +snippet sub + sub ${1:function_name}(${2:Str $var}) { + ${3} + } +snippet mul + multi ${1:function_name}(${2:Str $var}) { + ${3} + } +# Conditional +snippet if + if ${1} { + ${2} + } +# Conditional if..else +snippet ife + if ${1} { + ${2} + } + else { + ${3} + } +snippet eif + elsif ${1) { + ${2} + } +# Conditional One-line +snippet xif + ${1:expression} if ${2:condition}; +# Unless conditional +snippet unless + unless ${1} { + ${2} + } +# Unless conditional One-line +snippet xunless + ${1:expression} unless ${2:condition}; +# Ternary conditional +snippet tc + ${1:condition} ?? ${2:value-if-true} !! ${3:value-if-false}; +# given - when (perl6 switch) +snippet switch + given ${1:$var} { + when ${2:condition} { + ${3:# code block ...} + } + ${4} + default { + ${5} + } + } +# 'loop' - C's for. +snippet loop + loop (my ${1:$i} = 0; $$1 < ${2:count}; $$1++) { + ${3} + } +# for loop +snippet for + for ${1:@array} -> ${2:$variable} { + ${3} + } +# While Loop +snippet wh + while ${1} { + ${2} + } +# Repeat while and repean until +snippet rp + repeat { + ${1} + } ${2:while|until} ${3}; +# classes .. +snippet cl + ${1:my} class ${2:ClassName} ${3:is|does Parent|Role}{ + ${4} + } +snippet has + has ${1:Type} ${2:$!identifier}; +snippet mth + method ${1:method_name}(${2:$attr}) { + ${3} + } +snippet pmth + method ${1:!}${2:method_name}(${3:$attr}) { + ${4} + } +snippet smth + submethod ${1:submethod_name}(${2:$attr}) { + ${3} + } +# Tests +snippet test + use v6; + use Test; + ${1:use lib 'lib';} + + plan ${2:$num-tests}; + +# IO +snippet slurp + my ${1:$var} = "${2:filename}".IO.slurp; +snippet rfile + for "${1:filename}".IO.lines -> $line { + ${2} + } +snippet open + my $fh = open "${1:filename}", ${2::r|:w|:a}; + ${3:# actions}; + $fh.close; diff --git a/sources_non_forked/vim-snippets/snippets/php.snippets b/sources_non_forked/vim-snippets/snippets/php.snippets index b200463a..06448590 100644 --- a/sources_non_forked/vim-snippets/snippets/php.snippets +++ b/sources_non_forked/vim-snippets/snippets/php.snippets @@ -2,6 +2,8 @@ snippet ${8:$1} = $$1; + return $this; } -# getter method -snippet gm +snippet gm "PHP Class Getter Setter" /** * Gets the value of ${1:foo} * - * @return ${2:$1} + * @return ${2:string} */ - ${3:public} function get${4:$2}() + ${3:public} function get${4:$1}() { return $this->${5:$1}; } @@ -81,13 +79,14 @@ snippet $s #getter snippet $g ${1:$foo}->get${0:Bar}(); - # Tertiary conditional snippet =?: $${1:foo} = ${2:true} ? ${3:a} : ${0}; snippet ?: ${1:true} ? ${2:a} : ${0} - +snippet t "$retVal = (condition) ? a : b" + $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b}; +# Predefined variables snippet C $_COOKIE['${1:variable}'] snippet E @@ -104,7 +103,12 @@ snippet S $_SERVER['${1:variable}'] snippet SS $_SESSION['${1:variable}'] - +snippet get "get" + $_GET['${1}'] +snippet post "post" + $_POST['${1}'] +snippet session "session" + $_SESSION['${1}'] # the following are old ones snippet inc include '${1:file}'; @@ -205,7 +209,19 @@ snippet doc_h * @copyright ${4:$2}, `strftime('%d %B, %Y')` * @package ${0:default} */ - +snippet doc_i "interface someClass {}" + /** + * $1 + * @package ${2:default} + * @author ${3:`!v g:snips_author`} + **/ + interface ${1:someClass} + {${4} + } +snippet inheritdoc "@inheritdoc docblock" + /** + * {@inheritdoc} + */ # Interface snippet interface /** @@ -218,6 +234,18 @@ snippet interface { ${0} } +# Trait +snippet trait + /** + * ${2:undocumented class} + * + * @package ${3:default} + * @author ${4:`g:snips_author`} + */ + trait ${1:`vim_snippets#Filename()`} + { + ${0} + } # class ... snippet class /** @@ -242,55 +270,54 @@ snippet nc ${0} } # define(...) -snippet def - define('${1}'${2}); +snippet def "define('VARIABLE_NAME', 'definition')" + define('${1:VARIABLE_NAME}', ${2:'definition'}); # defined(...) snippet def? ${1}defined('${2}') -snippet wh +snippet wh "while (condition) { ... }" while (${1:/* condition */}) { ${0} } -# do ... while -snippet do +snippet do "do { ... } while (condition)" do { ${0} - } while (${1:/* condition */}); -snippet if - if (${1:/* condition */}) { + } while (${1}); +snippet if "if (condition) { ... }" + if (${1}) { ${0} } -snippet ifn - if (!${1:/* condition */}) { +snippet ifn "if (!condition) { ... }" + if (!${1}) { ${2} } -snippet ifil - +snippet ifil " ... " + ${0} -snippet ife - if (${1:/* condition */}) { +snippet ife "if (cond) { ... } else { ... }" + if (${1}) { ${2} } else { ${3} } ${0} -snippet ifeil - - ${2:} +snippet ifeil " ... ... " + + ${2} - ${3:} + ${3} ${0} -snippet el +snippet el "else { ... }" else { ${0} } -snippet eif - elseif (${1:/* condition */}) { +snippet eif "elseif(condition) { ... }" + elseif (${1}) { ${0} } -snippet switch +snippet switch "switch($var) { case 'xyz': ... default: .... }" switch ($${1:variable}) { case '${2:value}': ${3} @@ -300,34 +327,33 @@ snippet switch ${4} break; } -snippet case +snippet case "case 'value': ... break" case '${1:value}': ${2} break; -snippet for +snippet for "for ($i = 0; $i < $count; $i++) { ... }" for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { ${0} } -snippet foreach +snippet foreach "foreach ($var as $value) { .. }" foreach ($${1:variable} as $${2:value}) { ${0} } -snippet foreachil +snippet foreachil " ... " - ${0:} + ${0} -snippet foreachk +snippet foreachk "foreach ($var as $key => $value) { .. }" foreach ($${1:variable} as $${2:key} => $${3:value}) { ${0} } -snippet foreachkil +snippet foreachkil " $value): ?> ... " $${3:value}): ?> ${0:} -# $... = array (...) -snippet array +snippet array "$... = array(...)" $${1:arrayName} = array('${2}' => ${3}); -snippet try +snippet try "try { ... } catch (Exception $e) { ... }" try { ${0} } catch (${1:Exception} $e) { @@ -357,14 +383,22 @@ snippet http_redirect header ("HTTP/1.1 301 Moved Permanently"); header ("Location: ".URL); exit(); +snippet log "error_log(var_export($var, true));" + error_log(var_export(${1}, true)); +snippet var "var_export($var)" + var_export(${1}); +snippet ve "Dumb debug helper in HTML" + echo '
            ' . var_export(${1}, 1) . '
            '; +snippet pc "Dumb debug helper in cli" + var_export($1);$0 # Getters & Setters -snippet gs +snippet gs "PHP Class Getter Setter" /** * Gets the value of ${1:foo} * - * @return ${2:$1} + * @return ${2:string} */ - public function get${3:$2}() + public function get${3:$1}() { return $this->${4:$1}; } @@ -413,14 +447,12 @@ snippet aw array_walk($${1:foo}, function(&$${2:v}, $${3:k}) { $$2 = ${0}; }); - # static var assign once snippet static_var static $${1} = null; if (is_null($$1)){ $$1 = ${2}; } - snippet CSVWriter assertEquals()" $this->assertEquals(${1:expected}, ${2:actual}); - -snippet asne +snippet asne "$this->assertNotEquals()" $this->assertNotEquals(${1:expected}, ${2:actual}); - -snippet asf - $this->assertFalse(${1:Something}); - -snippet ast - $this->assertTrue(${1:Something}); - -snippet asfex - $this->assertFileExists(${1:path/to/file}); - -snippet asfnex - $this->assertFileNotExists(${1:path/to/file}); - -snippet ascon - $this->assertContains(${1:Search Value}, ${2:Array or Iterator}); - -snippet ashk - $this->assertArrayHasKey(${1:key}, ${2:array}); - -snippet asnhk - this->assertArrayNotHasKey(${1:value}, ${2:array}); - -snippet ascha - $this->assertClassHasAttribute('${1:Attribute Name}', '${2:ClassName}'); - -snippet asi +snippet asf "$this->assertFalse()" + $this->assertFalse(${1}); +snippet ast "$this->assertTrue()" + $this->assertTrue(${1}); +snippet asfex "$this->assertFileExists()" + $this->assertFileExists(${1:'path/to/file'}); +snippet asfnex "$this->assertFileNotExists()" + $this->assertFileNotExists(${1:'path/to/file'}); +snippet ascon "$this->assertContains()" + $this->assertContains(${1:$needle}, ${2:$haystack}); +snippet ashk "$this->assertArrayHasKey()" + $this->assertArrayHasKey(${1:$key}, ${2:$array}); +snippet asnhk "$this->assertArrayNotHasKey()" + this->assertArrayNotHasKey(${1:$key}, ${2:$array}); +snippet ascha "$this->assertClassHasAttribute()" + $this->assertClassHasAttribute(${1:$attributeName}, '${2:$className}'); +snippet asi "$this->assertInstanceOf(...)" $this->assertInstanceOf(${1:expected}, ${2:actual}); - -snippet tc - public function test${1:name_of_the_test}() +snippet test "public function testXYZ() { ... }" + public function test${1}() { - ${0:code} + ${0} } - +snippet setup "protected function setUp() { ... }" + protected function setUp() + { + ${0} + } +snippet teardown "protected function tearDown() { ... }" + protected function tearDown() + { + ${0} + } +snippet exp "phpunit expects" + expects($this->${1:once}()) + ->method('${2}') + ->with($this->equalTo(${3})${4}) + ->will($this->returnValue(${5})); +snippet testcmt "phpunit comment with group" + /** + * @group ${1} + */ +snippet fail "$this->fail()" + $this->fail(${1}); +snippet marki "$this->markTestIncomplete()" + $this->markTestIncomplete(${1}); +snippet marks "$this->markTestSkipped()" + $this->markTestSkipped(${1}); +# end of phpunit snippets +snippet te "throw new Exception()" + throw new ${1:Exception}("${2:Error Processing Request}"); +snippet fpc "file_put_contents" b + file_put_contents(${1:file}, ${2:content}${3:, FILE_APPEND});$0 +snippet sr "str_replace" + str_replace(${1:search}, ${2:replace}, ${3:subject})$0 +snippet ia "in_array" + in_array(${1:needle}, ${2:haystack})$0 +snippet is "isset" + isset(${1:var})$0 +snippet isa "isset array" + isset($${1:array}[${2:key}])$0 +snippet in "is_null" + is_null($${1:var})$0 +snippet fe "file_exists" + file_exists(${1:file})$0 +snippet id "is_dir" + is_dir(${1:path})$0 diff --git a/sources_non_forked/vim-snippets/snippets/puppet.snippets b/sources_non_forked/vim-snippets/snippets/puppet.snippets index 8b0a4109..9e9ceeb2 100644 --- a/sources_non_forked/vim-snippets/snippets/puppet.snippets +++ b/sources_non_forked/vim-snippets/snippets/puppet.snippets @@ -221,7 +221,7 @@ snippet package snippet yumrepo yumrepo { "${1:repo name}": - Descr => "${2:$1}", + descr => "${2:$1}", enabled => ${0:1}, } diff --git a/sources_non_forked/vim-snippets/snippets/python.snippets b/sources_non_forked/vim-snippets/snippets/python.snippets index ea5f2c98..0f68acbd 100644 --- a/sources_non_forked/vim-snippets/snippets/python.snippets +++ b/sources_non_forked/vim-snippets/snippets/python.snippets @@ -1,6 +1,9 @@ snippet #! #!/usr/bin/env python # -*- coding: utf-8 -*- +snippet #!3 + #!/usr/bin/env python3 + # -*- coding: utf-8 -*- snippet imp import ${0:module} snippet uni @@ -125,28 +128,43 @@ snippet _ __${1:init}__ # python debugger (pdb) snippet pdb - import pdb; pdb.set_trace() + import pdb + pdb.set_trace() +# bpython debugger (bpdb) +snippet bpdb + import bpdb + bpdb.set_trace() # ipython debugger (ipdb) snippet ipdb - import ipdb; ipdb.set_trace() + import ipdb + ipdb.set_trace() # embed ipython itself snippet iem - import IPython; IPython.embed() + import IPython + IPython.embed() # ipython debugger (pdbbb) snippet pdbbb - import pdbpp; pdbpp.set_trace() + import pdbpp + pdbpp.set_trace() # remote python debugger (rpdb) snippet rpdb - import rpdb; rpdb.set_trace() + import rpdb + rpdb.set_trace() # ptpython snippet ptpython from ptpython.repl import embed embed(globals(), locals(), vi_mode=${1:False}, history_filename=${2:None}) # python console debugger (pudb) snippet pudb - import pudb; pudb.set_trace() + import pudb + pudb.set_trace() +# pdb in nosetests +snippet nosetrace + from nose.tools import set_trace + set_trace() snippet pprint - import pprint; pprint.pprint(${1}) + import pprint + pprint.pprint(${1}) snippet " """${0:doc} """ diff --git a/sources_non_forked/vim-snippets/snippets/rails.snippets b/sources_non_forked/vim-snippets/snippets/rails.snippets index 6018621d..e8342222 100644 --- a/sources_non_forked/vim-snippets/snippets/rails.snippets +++ b/sources_non_forked/vim-snippets/snippets/rails.snippets @@ -348,7 +348,7 @@ snippet mct ${0} end snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end - class ${1:class_name} < ActiveRecord::Migration + class `substitute( substitute(vim_snippets#Filename(), '^\d\+_', '',''), '\(_\|^\)\(.\)', '\u\2', 'g')` < ActiveRecord::Migration def up ${0} end @@ -357,7 +357,7 @@ snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. en end end snippet migration class .. < ActiveRecord::Migration .. def change .. end - class ${1:class_name} < ActiveRecord::Migration + class `substitute( substitute(vim_snippets#Filename(), '^\d\+_', '',''), '\(_\|^\)\(.\)', '\u\2', 'g')` < ActiveRecord::Migration def change ${0} end diff --git a/sources_non_forked/vim-snippets/snippets/rst.snippets b/sources_non_forked/vim-snippets/snippets/rst.snippets index f4d99d7a..b1852458 100644 --- a/sources_non_forked/vim-snippets/snippets/rst.snippets +++ b/sources_non_forked/vim-snippets/snippets/rst.snippets @@ -56,11 +56,40 @@ snippet err: snippet cau: .. caution:: ${0:Watch out!} -#Spinx only +#Sphinx only snippet sid: .. sidebar:: ${1:Title} ${0} +snippet tod: + .. todo:: + ${0} +snippet lis: + .. list-table:: ${0:Title} + :header-rows: 1 + :stub-columns: 1 + + * - x1,y1 + - x2,y1 + - x3,y1 + * - x1,y2 + - x2,y2 + - x3,y2 + * - x1,y3 + - x2,y3 + - x3,y3 + +snippet toc: + .. toctree:: + :maxdepth: 2 + + ${0} +snippet dow: + :download:`${0:text} <${1:path}>` +snippet ref: + :ref:`${0:text} <${1:path}>` +snippet doc: + :doc:`${0:text} <${1:path}>` # CJK optimize, CJK has no space between charaters snippet *c \ *${1:Emphasis}*\ ${0} diff --git a/sources_non_forked/vim-snippets/snippets/ruby.snippets b/sources_non_forked/vim-snippets/snippets/ruby.snippets index 6b9d85d7..772f4644 100644 --- a/sources_non_forked/vim-snippets/snippets/ruby.snippets +++ b/sources_non_forked/vim-snippets/snippets/ruby.snippets @@ -1,12 +1,9 @@ -# encoding for Ruby 1.9 snippet enc # encoding: utf-8 - -# #!/usr/bin/env ruby +snippet frozen + # frozen_string_literal: true snippet #! #!/usr/bin/env ruby - # encoding: utf-8 - # New Block snippet =b =begin rdoc @@ -29,15 +26,12 @@ snippet beg ${0} rescue ${1:Exception} => ${2:e} end - snippet req require require '${1}' snippet reqr require_relative '${1}' snippet # # => -snippet end - __END__ snippet case case ${1:object} when ${2:condition} @@ -115,7 +109,7 @@ snippet cla class .. end class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} ${0} end -snippet cla class .. initialize .. end +snippet clai class .. initialize .. end class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} def initialize(${2:args}) ${0} @@ -731,3 +725,7 @@ snippet iiexp it { is_expected.to ${0} } snippet iiexpn it { is_expected.not_to ${0} } +snippet agg + aggregate_failures '${1:message}' do + ${0} + end diff --git a/sources_non_forked/vim-snippets/snippets/rust.snippets b/sources_non_forked/vim-snippets/snippets/rust.snippets index c273f537..20532f73 100644 --- a/sources_non_forked/vim-snippets/snippets/rust.snippets +++ b/sources_non_forked/vim-snippets/snippets/rust.snippets @@ -7,6 +7,10 @@ snippet fn "Function definition" fn ${1:function_name}(${2})${3} { ${0} } +snippet pfn "Function definition" + pub fn ${1:function_name}(${2})${3} { + ${0} + } snippet test "Unit test function" #[test] fn ${1:test_function_name}() { @@ -21,16 +25,20 @@ snippet bench "Bench function" b } snippet new "Constructor function" pub fn new(${2}) -> ${1:Name} { - $1 { ${3} }; + $1 { ${3} } } snippet main "Main function" pub fn main() { ${0} } -snippet let "let variable declaration" - let ${1:name}${2:: ${3:type}} = ${4}; -snippet letm "let mut variable declaration" - let mut ${1:name}${2:: ${3:type}} = ${4}; +snippet let "let variable declaration with type inference" + let ${1} = ${2}; +snippet lett "let variable declaration with explicit type annotation" + let ${1}: ${2} = ${3}; +snippet letm "let mut variable declaration with type inference" + let mut ${1} = ${2}; +snippet lettm "let mut variable declaration with explicit type annotation" + let mut ${1}: ${2} = ${3}; snippet pln "println!" println!("${1}"); snippet pln, "println! with format param" @@ -106,7 +114,7 @@ snippet loop "loop {}" b loop { ${0} } -snippet while "while loop" +snippet wh "while loop" while ${1:condition} { ${0} } @@ -135,7 +143,7 @@ snippet stn "Struct with new constructor" impl $1 { pub fn new(${2}) -> $1 { - $1 { ${3} }; + $1 { ${3} } } } snippet type "Type alias" diff --git a/sources_non_forked/vim-snippets/snippets/sass.snippets b/sources_non_forked/vim-snippets/snippets/sass.snippets new file mode 100644 index 00000000..7207360c --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/sass.snippets @@ -0,0 +1,36 @@ +extends css + +snippet $ + $${1:variable}: ${0:value} +snippet imp + @import '${0}' +snippet mix + @mixin ${1:name}(${2}) + ${0} +snippet inc + @include ${1:mixin}(${2}) +snippet ext + @extend ${0} +snippet fun + @function ${1:name}(${2:args}) + ${0} +snippet if + @if ${1:condition} + ${0} +snippet ife + @if ${1:condition} + ${2} + @else + ${0} +snippet eif + @else if ${1:condition} + ${0} +snippet for + @for ${1:$i} from ${2:1} through ${3:3} + ${0} +snippet each + @each ${1:$item} in ${2:items} + ${0} +snippet while + @while ${1:$i} ${2:>} ${3:0} + ${0} diff --git a/sources_non_forked/vim-snippets/snippets/scss.snippets b/sources_non_forked/vim-snippets/snippets/scss.snippets index 9a208cab..998a1200 100644 --- a/sources_non_forked/vim-snippets/snippets/scss.snippets +++ b/sources_non_forked/vim-snippets/snippets/scss.snippets @@ -1,3 +1,5 @@ +extends css + snippet $ $${1:variable}: ${0:value}; snippet imp @@ -8,7 +10,7 @@ snippet mix } snippet inc @include ${1:mixin}(${2}); -snippet ex +snippet ext @extend ${0}; snippet fun @function ${1:name}(${2:args}) { diff --git a/sources_non_forked/vim-snippets/snippets/sh.snippets b/sources_non_forked/vim-snippets/snippets/sh.snippets index 4d2c62b8..e470a2ab 100644 --- a/sources_non_forked/vim-snippets/snippets/sh.snippets +++ b/sources_non_forked/vim-snippets/snippets/sh.snippets @@ -5,6 +5,11 @@ snippet #! snippet bash #!/usr/bin/env bash +snippet sbash + #!/usr/bin/env bash + set -euo pipefail + IFS=$'\n\t' + snippet if if [[ ${1:condition} ]]; then ${0:#statements} diff --git a/sources_non_forked/vim-snippets/snippets/simplemvcf.snippets b/sources_non_forked/vim-snippets/snippets/simplemvcf.snippets new file mode 100644 index 00000000..2ef6a653 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/simplemvcf.snippets @@ -0,0 +1,122 @@ +snippet sm_controller + db->select('SELECT * FROM '.$table.' WHERE ${3:where}', $data); + } + + public function getRows($where) + { + return $this->db->select('SELECT * FROM '.$table.'); + } + + public function insert($data) + { + $this->db->insert($table, $data); + } + + public function update($data, $where) + { + $this->db->update($table ,$data, $where); + } + + public function delete($where) + { + $this->db->delete($table, $where); + } + } +snippet sm_render + View::render('${1:view}', $${2:array}); +snippet sm_render_template + View::renderTemplate('${1:part}', $${2:array}); + +# database +snippet sm_db_select + $this->db->select(${1:sql}, ${2:where}); + +snippet sm_db_insert + $this->db->insert(${1:table}, ${2:data}); + +snippet sm_db_update + $this->db->update(${1:table}, ${2:data}, ${3:where}); + +snippet sm_db_delete + $this->db->delete(${1:table}, ${2:where}); + +snippet sm_db_truncate + $this->db->delete(${1:table}); + +#session +snippet sm_session_set + Session::set(${1:key}, ${2:value}); + +snippet sm_session_get + Session::get(${1:key}); + +snippet sm_session_pull + Session::pull(${1:key}); + +snippet sm_session_id + Session::id(); + +snippet sm_session_destroy + Session::set(${1:key}); + +snippet sm_session_display + Session::display(); + +#url +snippet sm_url_redirect + Url:redirect('${1:path}'); + +snippet sm_url_previous + Url:previous(); + +snippet sm_url_templatepath + Url:templatePath(); + +snippet sm_url_autolink + Url:autolink('${1:string}'); diff --git a/sources_non_forked/vim-snippets/snippets/slim.snippets b/sources_non_forked/vim-snippets/snippets/slim.snippets index 8eeb4a53..885ca8d7 100644 --- a/sources_non_forked/vim-snippets/snippets/slim.snippets +++ b/sources_non_forked/vim-snippets/snippets/slim.snippets @@ -1,3 +1,16 @@ +snippet pry + - binding.pry +snippet renp + = render partial: '${0}' +# Forms +# ===== +snippet fieldset + fieldset + legend ${1} +snippet css + link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" +snippet script + script src="${1:script.js}" type="text/javascript" # Some useful Unicode entities # ============================ # Non-Breaking Space @@ -48,17 +61,3 @@ snippet backspace # ⎋ snippet esc ⎋ - -# Forms -# ===== -snippet fieldset - fieldset - legend ${1} - -# Assets -# ====== -snippet css - link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" - -snippet script - script src="${1:script.js}" type="text/javascript" diff --git a/sources_non_forked/vim-snippets/snippets/stylus.snippets b/sources_non_forked/vim-snippets/snippets/stylus.snippets index d03d1781..205f8479 100644 --- a/sources_non_forked/vim-snippets/snippets/stylus.snippets +++ b/sources_non_forked/vim-snippets/snippets/stylus.snippets @@ -1,993 +1,993 @@ snippet ! - !important + !important snippet bdi:m+ - -moz-border-image url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch} + -moz-border-image url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch} snippet bdi:m - -moz-border-image ${0} + -moz-border-image ${0} snippet bdrz:m - -moz-border-radius ${0} + -moz-border-radius ${0} snippet bxsh:m+ - -moz-box-shadow ${1:0} ${2:0} ${3:0} ${0} + -moz-box-shadow ${1:0} ${2:0} ${3:0} ${0} snippet bxsh:m - -moz-box-shadow ${0} + -moz-box-shadow ${0} snippet bdi:w+ - -webkit-border-image url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch} + -webkit-border-image url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch} snippet bdi:w - -webkit-border-image ${0} + -webkit-border-image ${0} snippet bdrz:w - -webkit-border-radius ${0} + -webkit-border-radius ${0} snippet bxsh:w+ - -webkit-box-shadow ${1:0} ${2:0} ${3:0} ${0} + -webkit-box-shadow ${1:0} ${2:0} ${3:0} ${0} snippet bxsh:w - -webkit-box-shadow ${0} + -webkit-box-shadow ${0} snippet @f - @font-face ${0} + @font-face ${0} snippet @i - @import '${0}' + @import '${0}' snippet @r - @require '${0}' + @require '${0}' snippet @m - @media ${1:screen} + @media ${1:screen} snippet @msmw - @media screen and (min-width: ${0}px) + @media screen and (min-width: ${0}px) snippet @ext - @extend .${1} - ${0} + @extend .${1} + ${0} snippet bg+ - background ${1} url(${2}) ${3:0} ${4:0} ${0:no-repeat} + background ${1} url(${2}) ${3:0} ${4:0} ${0:no-repeat} snippet bga - background-attachment ${0} + background-attachment ${0} snippet bga:f - background-attachment fixed + background-attachment fixed snippet bga:s - background-attachment scroll + background-attachment scroll snippet bgbk - background-break ${0} + background-break ${0} snippet bgbk:bb - background-break bounding-box + background-break bounding-box snippet bgbk:c - background-break continuous + background-break continuous snippet bgbk:eb - background-break each-box + background-break each-box snippet bgcp - background-clip ${0} + background-clip ${0} snippet bgcp:bb - background-clip border-box + background-clip border-box snippet bgcp:cb - background-clip content-box + background-clip content-box snippet bgcp:nc - background-clip no-clip + background-clip no-clip snippet bgcp:pb - background-clip padding-box + background-clip padding-box snippet bgc - background-color ${0} + background-color ${0} snippet bgc:t - background-color transparent + background-color transparent snippet bgi - background-image url(${0}) + background-image url(${0}) snippet bgi:n - background-image none + background-image none snippet bgo - background-origin ${0} + background-origin ${0} snippet bgo:bb - background-origin border-box + background-origin border-box snippet bgo:cb - background-origin content-box + background-origin content-box snippet bgo:pb - background-origin padding-box + background-origin padding-box snippet bgpx - background-position-x ${0} + background-position-x ${0} snippet bgpy - background-position-y ${0} + background-position-y ${0} snippet bgp - background-position ${1:0} ${0:0} + background-position ${1:0} ${0:0} snippet bgr - background-repeat ${0} + background-repeat ${0} snippet bgr:n - background-repeat no-repeat + background-repeat no-repeat snippet bgr:x - background-repeat repeat-x + background-repeat repeat-x snippet bgr:y - background-repeat repeat-y + background-repeat repeat-y snippet bgr:r - background-repeat repeat + background-repeat repeat snippet bgz - background-size ${0} + background-size ${0} snippet bgz:a - background-size auto + background-size auto snippet bgz:ct - background-size contain + background-size contain snippet bgz:cv - background-size cover + background-size cover snippet bg - background ${0} + background ${0} snippet bg:ie - filter progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${1}',sizingMethod='${0:crop}') + filter progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${1}',sizingMethod='${0:crop}') snippet bg:n - background none + background none snippet bd+ - border ${1:1px} ${2:solid} ${0} + border ${1:1px} ${2:solid} ${0} snippet bdb+ - border-bottom ${1:1px} ${2:solid} ${0} + border-bottom ${1:1px} ${2:solid} ${0} snippet bdbc - border-bottom-color ${0} + border-bottom-color ${0} snippet bdbi - border-bottom-image url(${0}) + border-bottom-image url(${0}) snippet bdbi:n - border-bottom-image none + border-bottom-image none snippet bdbli - border-bottom-left-image url(${0}) + border-bottom-left-image url(${0}) snippet bdbli:c - border-bottom-left-image continue + border-bottom-left-image continue snippet bdbli:n - border-bottom-left-image none + border-bottom-left-image none snippet bdblrz - border-bottom-left-radius ${0} + border-bottom-left-radius ${0} snippet bdbri - border-bottom-right-image url(${0}) + border-bottom-right-image url(${0}) snippet bdbri:c - border-bottom-right-image continue + border-bottom-right-image continue snippet bdbri:n - border-bottom-right-image none + border-bottom-right-image none snippet bdbrrz - border-bottom-right-radius ${0} + border-bottom-right-radius ${0} snippet bdbs - border-bottom-style ${0} + border-bottom-style ${0} snippet bdbs:n - border-bottom-style none + border-bottom-style none snippet bdbw - border-bottom-width ${0} + border-bottom-width ${0} snippet bdb - border-bottom ${0} + border-bottom ${0} snippet bdb:n - border-bottom none + border-bottom none snippet bdbk - border-break ${0} + border-break ${0} snippet bdbk:c - border-break close + border-break close snippet bdcl - border-collapse ${0} + border-collapse ${0} snippet bdcl:c - border-collapse collapse + border-collapse collapse snippet bdcl:s - border-collapse separate + border-collapse separate snippet bdc - border-color ${0} + border-color ${0} snippet bdci - border-corner-image url(${0}) + border-corner-image url(${0}) snippet bdci:c - border-corner-image continue + border-corner-image continue snippet bdci:n - border-corner-image none + border-corner-image none snippet bdf - border-fit ${0} + border-fit ${0} snippet bdf:c - border-fit clip + border-fit clip snippet bdf:of - border-fit overwrite + border-fit overwrite snippet bdf:ow - border-fit overwrite + border-fit overwrite snippet bdf:r - border-fit repeat + border-fit repeat snippet bdf:sc - border-fit scale + border-fit scale snippet bdf:sp - border-fit space + border-fit space snippet bdf:st - border-fit stretch + border-fit stretch snippet bdi - border-image url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch} + border-image url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch} snippet bdi:n - border-image none + border-image none snippet bdl+ - border-left ${1:1px} ${2:solid} ${0} + border-left ${1:1px} ${2:solid} ${0} snippet bdlc - border-left-color ${0} + border-left-color ${0} snippet bdli - border-left-image url(${0}) + border-left-image url(${0}) snippet bdli:n - border-left-image none + border-left-image none snippet bdls - border-left-style ${0} + border-left-style ${0} snippet bdls:n - border-left-style none + border-left-style none snippet bdlw - border-left-width ${0} + border-left-width ${0} snippet bdl - border-left ${0} + border-left ${0} snippet bdl:n - border-left none + border-left none snippet bdlt - border-length ${0} + border-length ${0} snippet bdlt:a - border-length auto + border-length auto snippet bdrz - border-radius ${0} + border-radius ${0} snippet bdr+ - border-right ${1:1px} ${2:solid} ${0} + border-right ${1:1px} ${2:solid} ${0} snippet bdrc - border-right-color ${0} + border-right-color ${0} snippet bdri - border-right-image url(${0}) + border-right-image url(${0}) snippet bdri:n - border-right-image none + border-right-image none snippet bdrs - border-right-style ${0} + border-right-style ${0} snippet bdrs:n - border-right-style none + border-right-style none snippet bdrw - border-right-width ${0} + border-right-width ${0} snippet bdr - border-right ${0} + border-right ${0} snippet bdr:n - border-right none + border-right none snippet bdsp - border-spacing ${0} + border-spacing ${0} snippet bds - border-style ${0} + border-style ${0} snippet bds:ds - border-style dashed + border-style dashed snippet bds:dtds - border-style dot-dash + border-style dot-dash snippet bds:dtdtds - border-style dot-dot-dash + border-style dot-dot-dash snippet bds:dt - border-style dotted + border-style dotted snippet bds:db - border-style double + border-style double snippet bds:g - border-style groove + border-style groove snippet bds:h - border-style hidden + border-style hidden snippet bds:i - border-style inset + border-style inset snippet bds:n - border-style none + border-style none snippet bds:o - border-style outset + border-style outset snippet bds:r - border-style ridge + border-style ridge snippet bds:s - border-style solid + border-style solid snippet bds:w - border-style wave + border-style wave snippet bdt+ - border-top ${1:1px} ${2:solid} ${0} + border-top ${1:1px} ${2:solid} ${0} snippet bdtc - border-top-color ${0} + border-top-color ${0} snippet bdti - border-top-image url(${0}) + border-top-image url(${0}) snippet bdti:n - border-top-image none + border-top-image none snippet bdtli - border-top-left-image url(${0}) + border-top-left-image url(${0}) snippet bdtli:c - border-corner-image continue + border-corner-image continue snippet bdtli:n - border-corner-image none + border-corner-image none snippet bdtlrz - border-top-left-radius ${0} + border-top-left-radius ${0} snippet bdtri - border-top-right-image url(${0}) + border-top-right-image url(${0}) snippet bdtri:c - border-top-right-image continue + border-top-right-image continue snippet bdtri:n - border-top-right-image none + border-top-right-image none snippet bdtrrz - border-top-right-radius ${0} + border-top-right-radius ${0} snippet bdts - border-top-style ${0} + border-top-style ${0} snippet bdts:n - border-top-style none + border-top-style none snippet bdtw - border-top-width ${0} + border-top-width ${0} snippet bdt - border-top ${0} + border-top ${0} snippet bdt:n - border-top none + border-top none snippet bdw - border-width ${0} + border-width ${0} snippet bd - border ${0} + border ${0} snippet bd:n - border none + border none snippet b - bottom ${0} + bottom ${0} snippet b:a - bottom auto + bottom auto snippet bxsh+ - box-shadow ${1:0} ${2:0} ${3:0} ${0} + box-shadow ${1:0} ${2:0} ${3:0} ${0} snippet bxsh - box-shadow ${0} + box-shadow ${0} snippet bxsh:n - box-shadow none + box-shadow none snippet bxz - box-sizing ${0} + box-sizing ${0} snippet bxz:bb - box-sizing border-box + box-sizing border-box snippet bxz:cb - box-sizing content-box + box-sizing content-box snippet cps - caption-side ${0} + caption-side ${0} snippet cps:b - caption-side bottom + caption-side bottom snippet cps:t - caption-side top + caption-side top snippet cl - clear ${0} + clear ${0} snippet cl:b - clear both + clear both snippet cl:l - clear left + clear left snippet cl:n - clear none + clear none snippet cl:r - clear right + clear right snippet cp - clip ${0} + clip ${0} snippet cp:a - clip auto + clip auto snippet cp:r - clip rect(${1:0} ${2:0} ${3:0} ${0:0}) + clip rect(${1:0} ${2:0} ${3:0} ${0:0}) snippet c - color ${0} + color ${0} snippet ct - content ${0} + content ${0} snippet ct:a - content attr(${0}) + content attr(${0}) snippet ct:cq - content close-quote + content close-quote snippet ct:c - content counter(${0}) + content counter(${0}) snippet ct:cs - content counters(${0}) + content counters(${0}) snippet ct:ncq - content no-close-quote + content no-close-quote snippet ct:noq - content no-open-quote + content no-open-quote snippet ct:n - content normal + content normal snippet ct:oq - content open-quote + content open-quote snippet coi - counter-increment ${0} + counter-increment ${0} snippet cor - counter-reset ${0} + counter-reset ${0} snippet cur - cursor ${0} + cursor ${0} snippet cur:a - cursor auto + cursor auto snippet cur:c - cursor crosshair + cursor crosshair snippet cur:d - cursor default + cursor default snippet cur:ha - cursor hand + cursor hand snippet cur:he - cursor help + cursor help snippet cur:m - cursor move + cursor move snippet cur:p - cursor pointer + cursor pointer snippet cur:t - cursor text + cursor text snippet d - display ${0} + display ${0} snippet d:mib - display -moz-inline-box + display -moz-inline-box snippet d:mis - display -moz-inline-stack + display -moz-inline-stack snippet d:b - display block + display block snippet d:cp - display compact + display compact snippet d:ib - display inline-block + display inline-block snippet d:itb - display inline-table + display inline-table snippet d:i - display inline + display inline snippet d:li - display list-item + display list-item snippet d:n - display none + display none snippet d:ri - display run-in + display run-in snippet d:tbcp - display table-caption + display table-caption snippet d:tbc - display table-cell + display table-cell snippet d:tbclg - display table-column-group + display table-column-group snippet d:tbcl - display table-column + display table-column snippet d:tbfg - display table-footer-group + display table-footer-group snippet d:tbhg - display table-header-group + display table-header-group snippet d:tbrg - display table-row-group + display table-row-group snippet d:tbr - display table-row + display table-row snippet d:tb - display table + display table snippet ec - empty-cells ${0} + empty-cells ${0} snippet ec:h - empty-cells hide + empty-cells hide snippet ec:s - empty-cells show + empty-cells show snippet exp - expression() + expression() snippet fl - float ${0} + float ${0} snippet fl:l - float left + float left snippet fl:n - float none + float none snippet fl:r - float right + float right snippet f+ - font ${1:1em} ${2:Arial},${0:sans-serif} + font ${1:1em} ${2:Arial},${0:sans-serif} snippet fef - font-effect ${0} + font-effect ${0} snippet fef:eb - font-effect emboss + font-effect emboss snippet fef:eg - font-effect engrave + font-effect engrave snippet fef:n - font-effect none + font-effect none snippet fef:o - font-effect outline + font-effect outline snippet femp - font-emphasize-position ${0} + font-emphasize-position ${0} snippet femp:a - font-emphasize-position after + font-emphasize-position after snippet femp:b - font-emphasize-position before + font-emphasize-position before snippet fems - font-emphasize-style ${0} + font-emphasize-style ${0} snippet fems:ac - font-emphasize-style accent + font-emphasize-style accent snippet fems:c - font-emphasize-style circle + font-emphasize-style circle snippet fems:ds - font-emphasize-style disc + font-emphasize-style disc snippet fems:dt - font-emphasize-style dot + font-emphasize-style dot snippet fems:n - font-emphasize-style none + font-emphasize-style none snippet fem - font-emphasize ${0} + font-emphasize ${0} snippet ff - font-family ${0} + font-family ${0} snippet ff:c - font-family ${0:'Monotype Corsiva','Comic Sans MS'},cursive + font-family ${0:'Monotype Corsiva','Comic Sans MS'},cursive snippet ff:f - font-family ${0:Capitals,Impact},fantasy + font-family ${0:Capitals,Impact},fantasy snippet ff:m - font-family ${0:Monaco,'Courier New'},monospace + font-family ${0:Monaco,'Courier New'},monospace snippet ff:ss - font-family ${0:Helvetica,Arial},sans-serif + font-family ${0:Helvetica,Arial},sans-serif snippet ff:s - font-family ${0:Georgia,'Times New Roman'},serif + font-family ${0:Georgia,'Times New Roman'},serif snippet fza - font-size-adjust ${0} + font-size-adjust ${0} snippet fza:n - font-size-adjust none + font-size-adjust none snippet fz - font-size ${0} + font-size ${0} snippet fsm - font-smooth ${0} + font-smooth ${0} snippet fsm:aw - font-smooth always + font-smooth always snippet fsm:a - font-smooth auto + font-smooth auto snippet fsm:n - font-smooth never + font-smooth never snippet fst - font-stretch ${0} + font-stretch ${0} snippet fst:c - font-stretch condensed + font-stretch condensed snippet fst:e - font-stretch expanded + font-stretch expanded snippet fst:ec - font-stretch extra-condensed + font-stretch extra-condensed snippet fst:ee - font-stretch extra-expanded + font-stretch extra-expanded snippet fst:n - font-stretch normal + font-stretch normal snippet fst:sc - font-stretch semi-condensed + font-stretch semi-condensed snippet fst:se - font-stretch semi-expanded + font-stretch semi-expanded snippet fst:uc - font-stretch ultra-condensed + font-stretch ultra-condensed snippet fst:ue - font-stretch ultra-expanded + font-stretch ultra-expanded snippet fs - font-style ${0} + font-style ${0} snippet fs:i - font-style italic + font-style italic snippet fs:n - font-style normal + font-style normal snippet fs:o - font-style oblique + font-style oblique snippet fv - font-variant ${0} + font-variant ${0} snippet fv:n - font-variant normal + font-variant normal snippet fv:sc - font-variant small-caps + font-variant small-caps snippet fw - font-weight ${0} + font-weight ${0} snippet fw:b - font-weight bold + font-weight bold snippet fw:br - font-weight bolder + font-weight bolder snippet fw:lr - font-weight lighter + font-weight lighter snippet fw:n - font-weight normal + font-weight normal snippet f - font ${0} + font ${0} snippet h - height ${0} + height ${0} snippet h:a - height auto + height auto snippet l - left ${0} + left ${0} snippet l:a - left auto + left auto snippet lts - letter-spacing ${0} + letter-spacing ${0} snippet lh - line-height ${0} + line-height ${0} snippet lisi - list-style-image url(${0}) + list-style-image url(${0}) snippet lisi:n - list-style-image none + list-style-image none snippet lisp - list-style-position ${0} + list-style-position ${0} snippet lisp:i - list-style-position inside + list-style-position inside snippet lisp:o - list-style-position outside + list-style-position outside snippet list - list-style-type ${0} + list-style-type ${0} snippet list:c - list-style-type circle + list-style-type circle snippet list:dclz - list-style-type decimal-leading-zero + list-style-type decimal-leading-zero snippet list:dc - list-style-type decimal + list-style-type decimal snippet list:d - list-style-type disc + list-style-type disc snippet list:lr - list-style-type lower-roman + list-style-type lower-roman snippet list:n - list-style-type none + list-style-type none snippet list:s - list-style-type square + list-style-type square snippet list:ur - list-style-type upper-roman + list-style-type upper-roman snippet lis - list-style ${0} + list-style ${0} snippet lis:n - list-style none + list-style none snippet mb - margin-bottom ${0} + margin-bottom ${0} snippet mb:a - margin-bottom auto + margin-bottom auto snippet ml - margin-left ${0} + margin-left ${0} snippet ml:a - margin-left auto + margin-left auto snippet mr - margin-right ${0} + margin-right ${0} snippet mr:a - margin-right auto + margin-right auto snippet mt - margin-top ${0} + margin-top ${0} snippet mt:a - margin-top auto + margin-top auto snippet m - margin ${0} + margin ${0} snippet m:4 - margin ${1:0} ${2:0} ${3:0} ${0:0} + margin ${1:0} ${2:0} ${3:0} ${0:0} snippet m:3 - margin ${1:0} ${2:0} ${0:0} + margin ${1:0} ${2:0} ${0:0} snippet m:2 - margin ${1:0} ${0:0} + margin ${1:0} ${0:0} snippet m:0 - margin 0 + margin 0 snippet m:a - margin auto + margin auto snippet mah - max-height ${0} + max-height ${0} snippet mah:n - max-height none + max-height none snippet maw - max-width ${0} + max-width ${0} snippet maw:n - max-width none + max-width none snippet mih - min-height ${0} + min-height ${0} snippet miw - min-width ${0} + min-width ${0} snippet op - opacity ${0} + opacity ${0} snippet op:ie - filter progid:DXImageTransform.Microsoft.Alpha(Opacity=${0:100}) + filter progid:DXImageTransform.Microsoft.Alpha(Opacity=${0:100}) snippet op:ms - -ms-filter 'progid:DXImageTransform.Microsoft.Alpha(Opacity=${0:100})' + -ms-filter 'progid:DXImageTransform.Microsoft.Alpha(Opacity=${0:100})' snippet orp - orphans ${0} + orphans ${0} snippet o+ - outline ${1:1px} ${2:solid} ${0} + outline ${1:1px} ${2:solid} ${0} snippet oc - outline-color ${0} + outline-color ${0} snippet oc:i - outline-color invert + outline-color invert snippet oo - outline-offset ${0} + outline-offset ${0} snippet os - outline-style ${0} + outline-style ${0} snippet ow - outline-width ${0} + outline-width ${0} snippet o - outline ${0} + outline ${0} snippet o:n - outline none + outline none snippet ovs - overflow-style ${0} + overflow-style ${0} snippet ovs:a - overflow-style auto + overflow-style auto snippet ovs:mq - overflow-style marquee + overflow-style marquee snippet ovs:mv - overflow-style move + overflow-style move snippet ovs:p - overflow-style panner + overflow-style panner snippet ovs:s - overflow-style scrollbar + overflow-style scrollbar snippet ovx - overflow-x ${0} + overflow-x ${0} snippet ovx:a - overflow-x auto + overflow-x auto snippet ovx:h - overflow-x hidden + overflow-x hidden snippet ovx:s - overflow-x scroll + overflow-x scroll snippet ovx:v - overflow-x visible + overflow-x visible snippet ovy - overflow-y ${0} + overflow-y ${0} snippet ovy:a - overflow-y auto + overflow-y auto snippet ovy:h - overflow-y hidden + overflow-y hidden snippet ovy:s - overflow-y scroll + overflow-y scroll snippet ovy:v - overflow-y visible + overflow-y visible snippet ov - overflow ${0} + overflow ${0} snippet ov:a - overflow auto + overflow auto snippet ov:h - overflow hidden + overflow hidden snippet ov:s - overflow scroll + overflow scroll snippet ov:v - overflow visible + overflow visible snippet pb - padding-bottom ${0} + padding-bottom ${0} snippet pl - padding-left ${0} + padding-left ${0} snippet pr - padding-right ${0} + padding-right ${0} snippet pt - padding-top ${0} + padding-top ${0} snippet p - padding ${0} + padding ${0} snippet p:4 - padding ${1:0} ${2:0} ${3:0} ${0:0} + padding ${1:0} ${2:0} ${3:0} ${0:0} snippet p:3 - padding ${1:0} ${2:0} ${0:0} + padding ${1:0} ${2:0} ${0:0} snippet p:2 - padding ${1:0} ${0:0} + padding ${1:0} ${0:0} snippet p:0 - padding 0 + padding 0 snippet pgba - page-break-after ${0} + page-break-after ${0} snippet pgba:aw - page-break-after always + page-break-after always snippet pgba:a - page-break-after auto + page-break-after auto snippet pgba:l - page-break-after left + page-break-after left snippet pgba:r - page-break-after right + page-break-after right snippet pgbb - page-break-before ${0} + page-break-before ${0} snippet pgbb:aw - page-break-before always + page-break-before always snippet pgbb:a - page-break-before auto + page-break-before auto snippet pgbb:l - page-break-before left + page-break-before left snippet pgbb:r - page-break-before right + page-break-before right snippet pgbi - page-break-inside ${0} + page-break-inside ${0} snippet pgbi:a - page-break-inside auto + page-break-inside auto snippet pgbi:av - page-break-inside avoid + page-break-inside avoid snippet pos - position ${0} + position ${0} snippet pos:a - position absolute + position absolute snippet pos:f - position fixed + position fixed snippet pos:r - position relative + position relative snippet pos:s - position static + position static snippet q - quotes ${0} + quotes ${0} snippet q:en - quotes '\201C' '\201D' '\2018' '\2019' + quotes '\201C' '\201D' '\2018' '\2019' snippet q:n - quotes none + quotes none snippet q:ru - quotes '\00AB' '\00BB' '\201E' '\201C' + quotes '\00AB' '\00BB' '\201E' '\201C' snippet rz - resize ${0} + resize ${0} snippet rz:b - resize both + resize both snippet rz:h - resize horizontal + resize horizontal snippet rz:n - resize none + resize none snippet rz:v - resize vertical + resize vertical snippet r - right ${0} + right ${0} snippet r:a - right auto + right auto snippet tbl - table-layout ${0} + table-layout ${0} snippet tbl:a - table-layout auto + table-layout auto snippet tbl:f - table-layout fixed + table-layout fixed snippet tal - text-align-last ${0} + text-align-last ${0} snippet tal:a - text-align-last auto + text-align-last auto snippet tal:c - text-align-last center + text-align-last center snippet tal:l - text-align-last left + text-align-last left snippet tal:r - text-align-last right + text-align-last right snippet ta - text-align ${0} + text-align ${0} snippet ta:c - text-align center + text-align center snippet ta:l - text-align left + text-align left snippet ta:r - text-align right + text-align right snippet td - text-decoration ${0} + text-decoration ${0} snippet td:l - text-decoration line-through + text-decoration line-through snippet td:n - text-decoration none + text-decoration none snippet td:o - text-decoration overline + text-decoration overline snippet td:u - text-decoration underline + text-decoration underline snippet te - text-emphasis ${0} + text-emphasis ${0} snippet te:ac - text-emphasis accent + text-emphasis accent snippet te:a - text-emphasis after + text-emphasis after snippet te:b - text-emphasis before + text-emphasis before snippet te:c - text-emphasis circle + text-emphasis circle snippet te:ds - text-emphasis disc + text-emphasis disc snippet te:dt - text-emphasis dot + text-emphasis dot snippet te:n - text-emphasis none + text-emphasis none snippet th - text-height ${0} + text-height ${0} snippet th:a - text-height auto + text-height auto snippet th:f - text-height font-size + text-height font-size snippet th:m - text-height max-size + text-height max-size snippet th:t - text-height text-size + text-height text-size snippet ti - text-indent ${0} + text-indent ${0} snippet ti:- - text-indent -9999px + text-indent -9999px snippet tj - text-justify ${0} + text-justify ${0} snippet tj:a - text-justify auto + text-justify auto snippet tj:d - text-justify distribute + text-justify distribute snippet tj:ic - text-justify inter-cluster + text-justify inter-cluster snippet tj:ii - text-justify inter-ideograph + text-justify inter-ideograph snippet tj:iw - text-justify inter-word + text-justify inter-word snippet tj:k - text-justify kashida + text-justify kashida snippet tj:t - text-justify tibetan + text-justify tibetan snippet to+ - text-outline ${1:0} ${2:0} ${0} + text-outline ${1:0} ${2:0} ${0} snippet to - text-outline ${0} + text-outline ${0} snippet to:n - text-outline none + text-outline none snippet tr - text-replace ${0} + text-replace ${0} snippet tr:n - text-replace none + text-replace none snippet tsh+ - text-shadow ${1:0} ${2:0} ${3:0} ${0} + text-shadow ${1:0} ${2:0} ${3:0} ${0} snippet tsh - text-shadow ${0} + text-shadow ${0} snippet tsh:n - text-shadow none + text-shadow none snippet tt - text-transform ${0} + text-transform ${0} snippet tt:c - text-transform capitalize + text-transform capitalize snippet tt:l - text-transform lowercase + text-transform lowercase snippet tt:n - text-transform none + text-transform none snippet tt:u - text-transform uppercase + text-transform uppercase snippet tw - text-wrap ${0} + text-wrap ${0} snippet tw:no - text-wrap none + text-wrap none snippet tw:n - text-wrap normal + text-wrap normal snippet tw:s - text-wrap suppress + text-wrap suppress snippet tw:u - text-wrap unrestricted + text-wrap unrestricted snippet t - top ${0} + top ${0} snippet t:a - top auto + top auto snippet va - vertical-align ${0} + vertical-align ${0} snippet va:bl - vertical-align baseline + vertical-align baseline snippet va:b - vertical-align bottom + vertical-align bottom snippet va:m - vertical-align middle + vertical-align middle snippet va:sub - vertical-align sub + vertical-align sub snippet va:sup - vertical-align super + vertical-align super snippet va:tb - vertical-align text-bottom + vertical-align text-bottom snippet va:tt - vertical-align text-top + vertical-align text-top snippet va:t - vertical-align top + vertical-align top snippet v - visibility ${0} + visibility ${0} snippet v:c - visibility collapse + visibility collapse snippet v:h - visibility hidden + visibility hidden snippet v:v - visibility visible + visibility visible snippet whsc - white-space-collapse ${0} + white-space-collapse ${0} snippet whsc:ba - white-space-collapse break-all + white-space-collapse break-all snippet whsc:bs - white-space-collapse break-strict + white-space-collapse break-strict snippet whsc:k - white-space-collapse keep-all + white-space-collapse keep-all snippet whsc:l - white-space-collapse loose + white-space-collapse loose snippet whsc:n - white-space-collapse normal + white-space-collapse normal snippet whs - white-space ${0} + white-space ${0} snippet whs:n - white-space normal + white-space normal snippet whs:nw - white-space nowrap + white-space nowrap snippet whs:pl - white-space pre-line + white-space pre-line snippet whs:pw - white-space pre-wrap + white-space pre-wrap snippet whs:p - white-space pre + white-space pre snippet wid - widows ${0} + widows ${0} snippet w - width ${0} + width ${0} snippet w:a - width auto + width auto snippet wob - word-break ${0} + word-break ${0} snippet wob:ba - word-break break-all + word-break break-all snippet wob:bs - word-break break-strict + word-break break-strict snippet wob:k - word-break keep-all + word-break keep-all snippet wob:l - word-break loose + word-break loose snippet wob:n - word-break normal + word-break normal snippet wos - word-spacing ${0} + word-spacing ${0} snippet wow - word-wrap ${0} + word-wrap ${0} snippet wow:no - word-wrap none + word-wrap none snippet wow:n - word-wrap normal + word-wrap normal snippet wow:s - word-wrap suppress + word-wrap suppress snippet wow:u - word-wrap unrestricted + word-wrap unrestricted snippet z - z-index ${0} + z-index ${0} snippet z:a - z-index auto + z-index auto snippet zoo - zoom 1 + zoom 1 snippet :h - :hover + :hover snippet :fc - :first-child + :first-child snippet :lc - :last-child + :last-child snippet :nc - :nth-child(${0}) + :nth-child(${0}) snippet :nlc - :nth-last-child(${0}) + :nth-last-child(${0}) snippet :oc - :only-child + :only-child snippet :a - :after + :after snippet :b - :before + :before snippet ::a - ::after + ::after snippet ::b - ::before + ::before snippet if - if ${0} + if ${0} snippet mix - ${1}(${0}) + ${1}(${0}) snippet for - for ${1:i} in ${0} + for ${1:i} in ${0} snippet keyf - @keyframes ${0} + @keyframes ${0} diff --git a/sources_non_forked/vim-snippets/snippets/supercollider.snippets b/sources_non_forked/vim-snippets/snippets/supercollider.snippets new file mode 100644 index 00000000..afaefb69 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/supercollider.snippets @@ -0,0 +1,22 @@ +snippet b + ( + ${0} + ) +snippet if + if (${1}) { + ${0} + } +snippet ife + if (${1}) { + ${2} + } { + ${0} + } +snippet for + for (${1:1}, ${2:10}) { |i| + ${0} + } +snippet sdef + SynthDef(\\${1:synthName}, {${2} + ${0} + }).add; diff --git a/sources_non_forked/vim-snippets/snippets/systemverilog.snippets b/sources_non_forked/vim-snippets/snippets/systemverilog.snippets index 86d664f6..70a9d2d3 100644 --- a/sources_non_forked/vim-snippets/snippets/systemverilog.snippets +++ b/sources_non_forked/vim-snippets/snippets/systemverilog.snippets @@ -1,37 +1,6 @@ -# if statement -snippet if - if (${1}) begin - ${0} - end -# If/else statements -snippet ife - if (${1}) begin - ${2} - end - else begin - ${1} - end -# Else if statement -snippet eif - else if (${1}) begin - ${0} - end -#Else statement -snippet el - else begin - ${0} - end -# While statement -snippet wh - while (${1}) begin - ${0} - end -# Repeat Loop -snippet rep - repeat (${1}) begin - ${0} - end -# Foreach Loopo +extends verilog + +# Foreach Loop snippet fe foreach (${1}) begin ${0} @@ -41,24 +10,6 @@ snippet dowh do begin ${0} end while (${1}); -# Case statement -snippet case - case (${1}) - {$2}: begin - ${0} - end - default: begin - end - endcase -# CaseZ statement -snippet casez -casez (${1}) - {$2}: begin - ${0} - end - default: begin - end - endcase # Combinational always block snippet alc always_comb begin ${1:: statement_label} @@ -74,11 +25,6 @@ snippet all always_latch begin ${1:: statement_label} ${0} end $1 -# Module block -snippet mod - module ${1:module_name} (${2}); - ${0} - endmodule : $1 # Class snippet cl class ${1:class_name}; diff --git a/sources_non_forked/vim-snippets/snippets/tex.snippets b/sources_non_forked/vim-snippets/snippets/tex.snippets index 0727cb45..68ac5d05 100644 --- a/sources_non_forked/vim-snippets/snippets/tex.snippets +++ b/sources_non_forked/vim-snippets/snippets/tex.snippets @@ -16,57 +16,57 @@ snippet dmo \DeclareMathOperator # \begin{}...\end{} snippet begin \begin{} ... \end{} block \begin{${1:env}} - ${0} + ${0:${VISUAL}} \end{$1} # Tabular snippet tab tabular (or arbitrary) environment \begin{${1:tabular}}{${2:c}} - ${0} + ${0:${VISUAL}} \end{$1} snippet thm thm (or arbitrary) environment with optional argument \begin[${1:author}]{${2:thm}} - ${0} + ${0:${VISUAL}} \end{$2} snippet center center environment \begin{center} - ${0} + ${0:${VISUAL}} \end{center} # Align(ed) snippet ali align(ed) environment \begin{align${1:ed}} \label{eq:${2}} - ${0} + ${0:${VISUAL}} \end{align$1} # Gather(ed) snippet gat gather(ed) environment \begin{gather${1:ed}} - ${0} + ${0:${VISUAL}} \end{gather$1} # Equation snippet eq equation environment \begin{equation} - ${0} + ${0:${VISUAL}} \end{equation} # Equation snippet eql Labeled equation environment \begin{equation} \label{eq:${2}} - ${0} + ${0:${VISUAL}} \end{equation} # Equation snippet eq* unnumbered equation environment \begin{equation*} - ${0} + ${0:${VISUAL}} \end{equation*} # Unnumbered Equation snippet \ unnumbered equation: \[ ... \] \[ - ${0} + ${0:${VISUAL}} \] # Equation array snippet eqnarray eqnarray environment \begin{eqnarray} - ${0} + ${0:${VISUAL}} \end{eqnarray} # Label snippet lab \label @@ -76,13 +76,21 @@ snippet enum enumerate environment \begin{enumerate} \item ${0} \end{enumerate} +snippet enuma enumerate environment + \begin{enumerate}[(a)] + \item ${0} + \end{enumerate} +snippet enumi enumerate environment + \begin{enumerate}[(i)] + \item ${0} + \end{enumerate} # Itemize snippet itemize itemize environment \begin{itemize} \item ${0} \end{itemize} snippet item \item - \item ${1} + \item ${1:${VISUAL}} # Description snippet desc description environment \begin{description} @@ -95,18 +103,18 @@ snippet ]i \item (recursive) # Matrix snippet mat smart matrix environment \begin{${1:p/b/v/V/B/small}matrix} - ${0} + ${0:${VISUAL}} \end{$1matrix} # Cases snippet cas cases environment \begin{cases} ${1:equation}, &\text{ if }${2:case}\\ - ${0} + ${0:${VISUAL}} \end{cases} # Split snippet spl split environment \begin{split} - ${0} + ${0:${VISUAL}} \end{split} # Part snippet part document \part @@ -195,32 +203,32 @@ snippet fcite \footcite[]{} \footcite[${1}]{${2}}${0} #Formating text: italic, bold, underline, small capital, emphase .. snippet it italic text - \textit{${0:text}} + \textit{${0:${VISUAL:text}}} snippet bf bold face text - \textbf{${0:text}} + \textbf{${0:${VISUAL:text}}} snippet under underline text - \underline{${0:text}} + \underline{${0:${VISUAL:text}}} snippet emp emphasize text - \emph{${0:text}} + \emph{${0:${VISUAL:text}}} snippet sc small caps text - \textsc{${0:text}} + \textsc{${0:${VISUAL:text}}} #Choosing font snippet sf sans serife text - \textsf{${0:text}} + \textsf{${0:${VISUAL:text}}} snippet rm roman font text - \textrm{${0:text}} + \textrm{${0:${VISUAL:text}}} snippet tt typewriter (monospace) text - \texttt{${0:text}} + \texttt{${0:${VISUAL:text}}} #Math font snippet mf mathfrak - \mathfrak{${0:text}} + \mathfrak{${0:${VISUAL:text}}} snippet mc mathcal - \mathcal{${0:text}} + \mathcal{${0:${VISUAL:text}}} snippet ms mathscr - \mathscr{${0:text}} + \mathscr{${0:${VISUAL:text}}} #misc snippet ft \footnote - \footnote{${0:text}} + \footnote{${0:${VISUAL:text}}} snippet fig figure environment (includegraphics) \begin{figure} \begin{center} @@ -249,22 +257,22 @@ snippet frac \frac{}{} snippet sum \sum^{}_{} \sum^{${1:n}}_{${2:i=1}} ${0} snippet lim \lim_{} - \lim_{${1:x \to +\infty}} ${0} + \lim_{${1:n \to \infty}} ${0} snippet frame frame environment \begin{frame}[${1:t}]{${2:title}} - ${0} + ${0:${VISUAL}} \end{frame} snippet block block environment \begin{block}{${1:title}} - ${0} + ${0:${VISUAL}} \end{block} snippet alert alertblock environment \begin{alertblock}{${1:title}} - ${0} + ${0:${VISUAL}} \end{alertblock} snippet example exampleblock environment \begin{exampleblock}{${1:title}} - ${0} + ${0:${VISUAL}} \end{exampleblock} snippet col2 two-column environment \begin{columns} @@ -275,7 +283,11 @@ snippet col2 two-column environment ${0} \end{column} \end{columns} +snippet \{ \{ \} + \\{ ${0} \\} #delimiter +snippet lr left right + \left${1} ${0} \right$1 snippet lr( left( right) \left( ${0} \right) snippet lr| left| right| @@ -286,11 +298,10 @@ snippet lr[ left[ right] \left[ ${0} \right] snippet lra langle rangle \langle ${0} \rangle - # Code listings snippet lst \begin{listing}[language=${1:language}] - ${0} + ${0:${VISUAL}} \end{listing} snippet lsi \lstinline|${1}| ${0} diff --git a/sources_non_forked/vim-snippets/snippets/twig.snippets b/sources_non_forked/vim-snippets/snippets/twig.snippets new file mode 100644 index 00000000..47997c3b --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/twig.snippets @@ -0,0 +1,34 @@ +snippet bl "{% block xyz %} .. {% endblock xyz %}" + {% block ${1} %} + ${2} + {% endblock $1 %} +snippet js "{% javascripts 'xyz' %} .. {% endjavascripts %}" + {% javascripts '${1}' %} + + {% endjavascripts %} +snippet css "{% stylesheets 'xyz' %} .. {% endstylesheets %}" + {% stylesheets '${1}' %} + + {% endstylesheets %} +snippet if "{% if %} .. {% endif %}" + {% if ${1} %} + ${2} + {% endif %} +snippet ife "{% if %} .. {% else %} .. {% endif %}" + {% if ${1} %} + ${2} + {% else %} + ${0} + {% endif %} +snippet el "{% else %}" + {% else %} + ${0} +snippet eif "{% elseif %}" + {% elseif ${1} %} + ${0} +snippet for "{% for x in y %} .. {% endfor %}" + {% for ${1} in ${2} %} + ${3} + {% endfor %} +snippet ext "{% extends xyz %}" + {% extends ${1} %} diff --git a/sources_non_forked/vim-snippets/snippets/verilog.snippets b/sources_non_forked/vim-snippets/snippets/verilog.snippets new file mode 100644 index 00000000..5cd80f39 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/verilog.snippets @@ -0,0 +1,63 @@ +# if statement +snippet if + if (${1}) begin + ${0} + end +# If/else statements +snippet ife + if (${1}) begin + ${2} + end + else begin + ${1} + end +# Else if statement +snippet eif + else if (${1}) begin + ${0} + end +#Else statement +snippet el + else begin + ${0} + end +# While statement +snippet wh + while (${1}) begin + ${0} + end +# Repeat Loop +snippet rep + repeat (${1}) begin + ${0} + end +# Case statement +snippet case + case (${1:/* variable */}) + ${2:/* value */}: begin + ${3} + end + default: begin + ${4} + end + endcase +# CaseZ statement +snippet casez + casez (${1:/* variable */}) + ${2:/* value */}: begin + ${3} + end + default: begin + ${4} + end + endcase +# Always block +snippet al + always @(${1:/* sensitive list */}) begin + ${0} + end +# Module block +snippet mod + module ${1:module_name} (${2}); + ${0} + endmodule diff --git a/sources_non_forked/vim-snippets/snippets/vhdl.snippets b/sources_non_forked/vim-snippets/snippets/vhdl.snippets new file mode 100644 index 00000000..f13f5bf9 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/vhdl.snippets @@ -0,0 +1,127 @@ +# +## Libraries + +snippet lib + library ${1} + use ${1}.${2} + +# Standard Libraries +snippet libs + library IEEE; + use IEEE.std_logic_1164.ALL; + use IEEE.numeric_std.ALL; + +# Xilinx Library +snippet libx + library UNISIM; + use UNISIM.VCOMPONENTS.ALL; + +## Entity Declaration +snippet ent + entity ${1:`vim_snippets#Filename()`} is + generic ( + ${2} + ); + port ( + ${3} + ); + end entity $1; + +## Architecture +snippet arc + architecture ${1:behav} of ${2:`vim_snippets#Filename()`} is + + ${3} + + begin + + + end $1; + +## Declarations +# std_logic +snippet st + signal ${1} : std_logic; +# std_logic_vector +snippet sv + signal ${1} : std_logic_vector (${2} downto 0); +# std_logic in +snippet ist + ${1} : in std_logic; +# std_logic_vector in +snippet isv + ${1} : in std_logic_vector (${2} downto 0); +# std_logic out +snippet ost + ${1} : out std_logic; +# std_logic_vector out +snippet osv + ${1} : out std_logic_vector (${2} downto 0); +# unsigned +snippet un + signal ${1} : unsigned (${2} downto 0); +## Process Statements +# process +snippet pr + process (${1}) + begin + ${2} + end process; +# process with clock +snippet prc + process (${1:clk}) + begin + if rising_edge ($1) then + ${2} + end if; + end process; +# process all +snippet pra + process (${1:all}) + begin + ${2} + end process; +## Control Statements +# if +snippet if + if ${1} then + ${2} + end if; +# if +snippet ife + if ${1} then + ${2} + else + ${3} + end if; +# else +snippet el + else + ${1} +# if +snippet eif + elsif ${1} then + ${2} +# case +snippet ca + case ${1} is + ${2} + end case; +# when +snippet wh + when ${1} => + ${2} +# for +snippet for + for ${1:i} in ${2} ${3:to} ${4} loop + ${5} + end loop; +# while +snippet wh + while ${1} loop + ${2} + end loop; +## Misc +# others +snippet oth + (others => '${1:0}'); diff --git a/sources_non_forked/vim-snippets/snippets/xml.snippets b/sources_non_forked/vim-snippets/snippets/xml.snippets new file mode 100644 index 00000000..0ab346ba --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/xml.snippets @@ -0,0 +1,12 @@ +# xml declaration +snippet xml + +# tag +snippet t + <${1:}> + ${2} + +# inline tag +snippet ti + <${1:}>${2} + diff --git a/sources_non_forked/vim-snippets/tests.sh b/sources_non_forked/vim-snippets/tests.sh index 5b93b6ba..07f0ff31 100644 --- a/sources_non_forked/vim-snippets/tests.sh +++ b/sources_non_forked/vim-snippets/tests.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash -SPACED=$(grep -REn '^ .+' --include '*.snippets' snippets); +SPACED=$(grep -REn '^ .+' --include '*.snippets' snippets) if [[ $? -ne 1 ]]; then - echo These snippet lines are indented with spaces:; - echo; - echo "$SPACED"; - echo; + echo These snippet lines are indented with spaces: + echo + echo "$SPACED" + echo echo Tests failed! - exit 1; + exit 1 fi echo Tests passed! -exit 0; +exit 0 diff --git a/sources_non_forked/vim-surround/plugin/surround.vim b/sources_non_forked/vim-surround/plugin/surround.vim index 82b016ed..46f32529 100644 --- a/sources_non_forked/vim-surround/plugin/surround.vim +++ b/sources_non_forked/vim-surround/plugin/surround.vim @@ -92,7 +92,7 @@ function! s:process(string) let m = matchstr(a:string,nr2char(i).'.\{-\}\ze'.nr2char(i)) if m != '' let m = substitute(strpart(m,1),'\r.*','','') - let repl_{i} = input(substitute(m,':\s*$','','').': ') + let repl_{i} = input(match(m,'\w\+$') >= 0 ? m.': ' : m) endif endfor let s = "" @@ -164,7 +164,7 @@ function! s:wrap(string,char,type,removed,special) elseif newchar ==# ':' let before = ':' let after = '' - elseif newchar =~# "[tT\<,]" + elseif newchar =~# "[tT\<]" let dounmapp = 0 let dounmapb = 0 if !maparg(">","c") @@ -200,7 +200,7 @@ function! s:wrap(string,char,type,removed,special) let before = '<'.tag.attributes.'>' let after = '' endif - if newchar == "\" || newchar == "," + if newchar == "\" if type ==# "v" || type ==# "V" let before .= "\n\t" endif @@ -386,7 +386,7 @@ function! s:dosurround(...) " {{{1 let strcount = (scount == 1 ? "" : scount) if char == '/' exe 'norm! '.strcount.'[/d'.strcount.']/' - elseif char =~# '[[:punct:]]' && char !~# '[][(){}<>"''`]' + elseif char =~# '[[:punct:][:space:]]' && char !~# '[][(){}<>"''`]' exe 'norm! T'.char if getline('.')[col('.')-1] == char exe 'norm! l' @@ -416,7 +416,7 @@ function! s:dosurround(...) " {{{1 norm! "_x call setreg('"','/**/',"c") let keeper = substitute(substitute(keeper,'^/\*\s\=','',''),'\s\=\*$','','') - elseif char =~# '[[:punct:]]' && char !~# '[][(){}<>]' + elseif char =~# '[[:punct:][:space:]]' && char !~# '[][(){}<>]' exe 'norm! F'.char exe 'norm! df'.char else diff --git a/sources_non_forked/vim-yankstack/.gitignore b/sources_non_forked/vim-yankstack/.gitignore new file mode 100644 index 00000000..655a3682 --- /dev/null +++ b/sources_non_forked/vim-yankstack/.gitignore @@ -0,0 +1,2 @@ +.rvmrc +doc/tags diff --git a/sources_non_forked/vim-yankstack/Gemfile b/sources_non_forked/vim-yankstack/Gemfile new file mode 100644 index 00000000..f2e1aba5 --- /dev/null +++ b/sources_non_forked/vim-yankstack/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem "vimbot", :git => "git@github.com:maxbrunsfeld/vimbot.git" +gem "rspec" diff --git a/sources_non_forked/vim-yankstack/Gemfile.lock b/sources_non_forked/vim-yankstack/Gemfile.lock new file mode 100644 index 00000000..c17e2f41 --- /dev/null +++ b/sources_non_forked/vim-yankstack/Gemfile.lock @@ -0,0 +1,25 @@ +GIT + remote: git@github.com:maxbrunsfeld/vimbot.git + revision: 489cb3283a89d3e7891d9d9765188179c764317b + specs: + vimbot (0.0.1) + +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.1.3) + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.8.0) + +PLATFORMS + ruby + +DEPENDENCIES + rspec + vimbot! diff --git a/sources_non_forked/vim-yankstack/README.md b/sources_non_forked/vim-yankstack/README.md new file mode 100644 index 00000000..2fcfc769 --- /dev/null +++ b/sources_non_forked/vim-yankstack/README.md @@ -0,0 +1,134 @@ +yankstack.vim +============= + +Author: Max Brunsfeld + +[Yankstack.vim](https://github.com/maxbrunsfeld/vim-yankstack) is a +lightweight implementation of the Emacs 'kill ring' for Vim. It allows you to +yank and delete things without worrying about losing the text that you yanked +previously. It effectively turns your default register into a stack, and lets +you cycle through the items in the stack after doing a paste. + +This plugin is intended to be a simpler alternative to the +[yankring](https://github.com/chrismetcalf/vim-yankring) plugin. It has a fairly +complete [test suite](https://github.com/maxbrunsfeld/vim-yankstack/blob/master/spec/yankstack/yankstack_spec.rb) +based on [rspec](https://www.relishapp.com/rspec) +and [vimbot](https://github.com/maxbrunsfeld/vimbot). + +## Installation ## + +I recommend loading your plugins with +[vundle](https://github.com/gmarik/vundle) or +[pathogen](https://github.com/tpope/vim-pathogen). + +## Key Mappings ## + +By default, yankstack adds only 2 key bindings, in normal and visual modes: + +- ```meta-p``` - cycle *backward* through your history of yanks +- ```meta-shift-p``` - cycle *forwards* through your history of yanks + +After pasting some text using ```p``` or ```P```, you can cycle through your +yank history using these commands. Typing either of these keys *without* pasting first +will do a normal paste (the same as typing `p`). This also works in insert mode. + +### the 'meta' key + +If you're using MacVim, and you want to use +this plugin's default key bindings (or any bindings involving the `option` +key), you must ```:set macmeta```. On Linux, you may have issues with the meta key if your terminal is running in 7bit mode. +Instructions for dealing with this can be found on the [wiki](https://github.com/maxbrunsfeld/vim-yankstack/wiki/Linux-terminal-configurations-for-correct-meta-key-handling) + +## Commands ## + +You can see the contents of the yank-stack using the ```:Yanks``` command. +Its output is similar to the ```:registers``` command. + +## Configuration ## + +Yankstack defines two plugin mappings that you can map to keys of your choosing. +The same mappings work in normal and insert modes. + +- ```yankstack_substitute_older_paste``` - cycle backwards through your history of yanks +- ```yankstack_substitute_newer_paste``` - cycle forwards through your history of yanks + +For example, if you wanted to define some mappings based on your 'leader' key, +you could do this: + +``` +nmap p yankstack_substitute_older_paste +nmap P yankstack_substitute_newer_paste +``` + +Also, if you want to load yankstack without the default key mappings, just +``` let g:yankstack_map_keys = 0 ``` +in your .vimrc file. + +## Compatibility ## + +Yankstack works by mapping the yank and paste keys to functions that do some +book-keeping before calling through to the normal yank/paste keys. You may want +to define your own mappings of the yank and paste keys. For example, I like to +map the ```Y``` key to ```y$```, so that it behaves the same as ```D``` and +```C```. The yankstack mappings need to happen **before** you define any such +mappings of your own. To achieve this, just call ```yankstack#setup()``` in +your vimrc, before defining your mappings: + +``` +call yankstack#setup() +nmap Y y$ +" other mappings involving y, d, c, etc +``` + +You can also prevent certain keys from being remapped by setting the `g:yankstack_yank_keys` +to the keys of your choosing. For example, if you only want Yankstack to remap `y` and `d`: + +``` +let g:yankstack_yank_keys = ['y', 'd'] +``` + +## Contributing, Feedback ## + +I'd enjoy hearing anybody's feedback on yankstack, and welcome any contribution. +Check it out on [github](https://github.com/maxbrunsfeld/vim-yankstack)! + +## Changelog ## + + +### 1.0.6 (2014-08-04) + - Allow customization of the list of keys to be remapped. + +### 1.0.5 (2012-07-19) + - Fix bug where on certain versions of vim, the first time you tried + to cycle through your yanks after doing a normal paste, an extra + paste was created. + +### 1.0.4 (2012-07-01) + - Make it so that yankstack-cycling keys cause a normal paste if they are + used without pasting first. Fix stack-cycling in insert-mode. + +### 1.0.3 (2012-05-04): + - Fix bug when overwriting text in select mode. This was causing + problems for snipMate users. + +### 1.0.2 (2012-4-20): + - Add test coverage using rspec and [vimbot](https://github.com/maxbrunsfeld/vimbot)! + - Perfect the behavior of the yankstack when pasting over text in visual + mode + - Fix bug where 's' and 'S' didn't push to the yankstack + +### 1.0.1 (2012-2-11): + - Change default key bindings, update readme, add link to github page. + +### 1.0.1 (2011-12-08): + - Fix bug when displaying empty yanks. + +### 1.0.0 (2011-12-04): + - Remove unnecessary dependency on the undotree() function. Plugin should + now work on any recent version of vim. + +## License ## +Copyright (c) Max Brunsfeld. Distributed under the same terms as Vim itself. +See the vim license. + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-yankstack/autoload/yankstack.vim b/sources_non_forked/vim-yankstack/autoload/yankstack.vim new file mode 100644 index 00000000..8feb49e8 --- /dev/null +++ b/sources_non_forked/vim-yankstack/autoload/yankstack.vim @@ -0,0 +1,197 @@ +" yankstack.vim - keep track of your history of yanked/killed text +" +" Maintainer: Max Brunsfeld +" Version: 1.0.6 +" Todo: +" + +let s:yankstack_tail = [] +let g:yankstack_size = 30 +let s:last_paste = { 'changedtick': -1, 'key': '', 'mode': 'n', 'count': 1, 'register': '' } + +if !exists('g:yankstack_yank_keys') + let g:yankstack_yank_keys = ['c', 'C', 'd', 'D', 's', 'S', 'x', 'X', 'y', 'Y'] +endif + +function! s:yank_with_key(key) + call s:before_yank() + return a:key +endfunction + +function! s:paste_with_key(key, mode, register, count) + return s:paste_from_yankstack(a:key, a:mode, a:register, a:count, 1) +endfunction + +function! s:paste_from_yankstack(key, mode, register, count, is_new) + let keys = a:count . a:key + let keys = (a:register == s:default_register()) ? keys : ('"' . a:register . keys) + let s:last_paste = { 'key': a:key, 'mode': a:mode, 'register': a:register, 'count': a:count, 'changedtick': -1 } + call feedkeys("\yankstack_after_paste", "m") + + if a:mode == 'n' + exec 'normal!' keys + elseif a:mode == 'v' + if a:is_new + call s:before_yank() + call feedkeys("\yankstack_substitute_older_paste", "t") + exec 'normal! gv' . keys + else + let head = s:get_yankstack_head() + exec 'normal! gv' . keys + call s:set_yankstack_head(head) + endif + + " In insert mode, this function's return value is used in an + " expression mapping. In other modes, it is called for its + " side effects only. + elseif a:mode == 'i' + return keys + endif + + silent! call repeat#setreg(a:register) + silent! call repeat#set(a:key, a:count) +endfunction + +function! s:substitute_paste(offset, current_mode) + if s:last_change_was_paste() + silent undo + call s:yankstack_rotate(a:offset) + return s:paste_from_yankstack(s:last_paste.key, s:last_paste.mode, s:last_paste.register, s:last_paste.count, 0) + else + return s:paste_from_yankstack(s:default_paste_key(a:current_mode), a:current_mode, v:register, '', 1) + endif +endfunction + +function! s:before_yank() + let head = s:get_yankstack_head() + if !empty(head.text) && (empty(s:yankstack_tail) || (head != s:yankstack_tail[0])) + call insert(s:yankstack_tail, head) + let s:yankstack_tail = s:yankstack_tail[: g:yankstack_size-1] + endif +endfunction + +function! s:yankstack_rotate(offset) + if empty(s:yankstack_tail) | return | endif + let offset_left = a:offset + while offset_left != 0 + let head = s:get_yankstack_head() + if offset_left > 0 + let entry = remove(s:yankstack_tail, 0) + call add(s:yankstack_tail, head) + let offset_left -= 1 + elseif offset_left < 0 + let entry = remove(s:yankstack_tail, -1) + call insert(s:yankstack_tail, head) + let offset_left += 1 + endif + call s:set_yankstack_head(entry) + endwhile +endfunction + +function! s:get_yankstack_head() + let reg = s:default_register() + return { 'text': getreg(reg), 'type': getregtype(reg) } +endfunction + +function! s:set_yankstack_head(entry) + let reg = s:default_register() + call setreg(reg, a:entry.text, a:entry.type) +endfunction + +function! s:after_paste() + let s:last_paste.changedtick = b:changedtick +endfunction + +function! s:last_change_was_paste() + return b:changedtick == s:last_paste.changedtick +endfunction + +function! s:default_register() + let clipboard_flags = split(&clipboard, ',') + if index(clipboard_flags, 'unnamedplus') >= 0 + return "+" + elseif index(clipboard_flags, 'unnamed') >= 0 + return "*" + else + return "\"" + endif +endfunction + +function! s:default_paste_key(mode) + if a:mode == 'i' + return "\u\" . s:default_register() + else + return "p" + endif +endfunction + +function! g:Yankstack() + return [s:get_yankstack_head()] + s:yankstack_tail +endfunction + +command! -nargs=0 Yanks call s:show_yanks() +function! s:show_yanks() + echohl WarningMsg | echo "--- Yanks ---" | echohl None + let i = 0 + for yank in g:Yankstack() + call s:show_yank(yank, i) + let i += 1 + endfor +endfunction + +function! s:show_yank(yank, index) + let index = printf("%-4d", a:index) + let lines = split(a:yank.text, '\n') + let line = empty(lines) ? '' : lines[0] + let line = substitute(line, '\t', repeat(' ', &tabstop), 'g') + if len(line) > 80 || len(lines) > 1 + let line = line[: 80] . '…' + endif + + echohl Directory | echo index + echohl None | echon line + echohl None +endfunction + +function! yankstack#setup() + if exists('g:yankstack_did_setup') | return | endif + let g:yankstack_did_setup = 1 + + let paste_keys = ['p', 'P', 'gp', 'gP'] + let word_characters = split("qwertyuiopasdfghjklzxcvbnm1234567890_", '\zs') + + for key in g:yankstack_yank_keys + exec 'nnoremap ' key 'yank_with_key("' . key . '")' + exec 'xnoremap ' key 'yank_with_key("' . key . '")' + endfor + + for key in paste_keys + exec 'nnoremap ' key ':call paste_with_key("' . key . '", "n", v:register, v:count1)' + exec 'xnoremap ' key ':call paste_with_key("' . key . '", "v", v:register, v:count1)' + endfor + + for key in word_characters + exec 'smap ' key 'yank_with_key("' . key . '")' + endfor +endfunction + +nnoremap yankstack_substitute_older_paste :call substitute_paste(v:count1, 'n') +nnoremap yankstack_substitute_newer_paste :call substitute_paste(-v:count1, 'n') +xnoremap yankstack_substitute_older_paste :call substitute_paste(v:count1, 'v') +xnoremap yankstack_substitute_newer_paste :call substitute_paste(-v:count1, 'v') +inoremap yankstack_substitute_older_paste =substitute_paste(v:count1, 'i') +inoremap yankstack_substitute_newer_paste =substitute_paste(-v:count1, 'i') + +nnoremap yankstack_after_paste :call after_paste() +xnoremap yankstack_after_paste :call after_paste() +inoremap yankstack_after_paste :call after_paste() + +if !exists('g:yankstack_map_keys') || g:yankstack_map_keys + nmap yankstack_substitute_older_paste + xmap yankstack_substitute_older_paste + imap yankstack_substitute_older_paste + nmap yankstack_substitute_newer_paste + xmap yankstack_substitute_newer_paste + imap yankstack_substitute_newer_paste +endif + diff --git a/sources_non_forked/vim-yankstack/doc/yankstack.txt b/sources_non_forked/vim-yankstack/doc/yankstack.txt new file mode 100644 index 00000000..2a7dee5f --- /dev/null +++ b/sources_non_forked/vim-yankstack/doc/yankstack.txt @@ -0,0 +1,124 @@ +*yankstack.txt* Plugin for storing and cycling through yanked text strings. + +Author: Max Brunsfeld + +|yankstack-introduction| Introduction +|yankstack-installation| Installation +|yankstack-initialization| Initialization +|yankstack-commands| Commands +|yankstack-configuration| Configuration +|yankstack-changelog| Changelog + +INTRODUCTION *yankstack-introduction* + +[Yankstack.vim](https://github.com/maxbrunsfeld/vim-yankstack) is a +lightweight implementation of the Emacs 'kill ring' for Vim. It allows you to +yank and delete things without worrying about losing the text that you yanked +previously. It effectively turns your default register into a stack, and lets +you cycle through the items in the stack after doing a paste. + +This plugin is intended to be a simpler alternative to the {Yankring} plugin +(https://github.com/chrismetcalf/vim-yankring). + +INSTALLATION *yankstack-installation* + +I recommend loading your plugins with {Pathogen} +(https://github.com/tpope/vim-pathogen), so you can just clone this repo into +your "bundle" directory. + +KEY MAPPINGS *yankstack-mappings* + +By default, yankstack adds only 2 key mappings, in normal and visual modes: + +Mapping Action ~ +meta-p cycle backward through your history of yanks +meta-shift-p cycle forwards through your history of yanks + +After pasting some text using |p| or |P|, you can cycle through your +yank history using these commands. + +Typing either of these keys without pasting first will do a normal paste +(the same as typing `p`). This also works in insert mode. + +A note about the meta key - if you're using MacVim, and you want to use +this plugin's default key bindings (or any bindings involving the `option` +key), you must :set |macmeta|. + +COMMANDS *yankstack-commands* + +You can see the contents of the yank-stack using the :Yanks command. +Its output is similar to the |registers| command. > + + :Yanks (lists the contents of the yank-stack) + +CONFIGURATION *yankstack-configuration* + +If you want to load yankstack without defining any of the default key +mappings, just add > + + let g:yankstack_map_keys = 0 + +to your |.vimrc| file. + +Yankstack defines three plugin mappings that you can map to keys of your +choosing. The same mappings work in normal and insert modes. + +Mapping Name Action ~ +yankstack_substitute_older_paste cycle BACKWARDs through your history of yanks +yankstack_substitute_newer_paste cycle FORWARDS through your history of yanks + +For example, if you wanted to define some mappings based on your |leader| key, you could do this: > + + nmap p yankstack_substitute_older_paste + nmap P yankstack_substitute_newer_paste + + +COMPATIBILITY *yankstack-compatibility* + +Yankstack works by mapping the yank and paste keys to functions that do some +book-keeping before calling through to the normal yank/paste keys. You may +want to define your own mappings of the yank and paste keys. For example, I +like to map the |Y| key to "y$", so that it behaves the same as |D| and |C|. +The yankstack mappings need to happen **BEFORE** you define any such +mappings of your own. To achieve this, just call 'yankstack#setup()'in your +|vimrc|, before defining your mappings: > + + call yankstack#setup() + nmap Y y$ + +CHANGELOG *yankstack-changelog* + +1.0.5 (2012-07-19) + - Fix bug where on certain versions of vim, the first time you tried + to cycle through your yanks after doing a normal paste, an extra + paste was created. + +1.0.4 (2012-07-01) + - Make it so that yankstack-cycling keys cause a normal paste if they are + used without pasting first. Fix stack-cycling in insert-mode. + +1.0.3 (2012-05-04): + - Fix bug when overwriting text in select mode. This was causing + problems for snipMate users. + +1.0.2 (2012-4-20): + - Add test coverage using rspec and [vimbot](https://github.com/maxbrunsfeld/vimbot)! + - Perfect the behavior of the yankstack when pasting over text in visual + mode + - Fix bug where 's' and 'S' didn't push to the yankstack + +1.0.1 (2012-02-11): + - Change default key bindings, update readme, add link to github page. + +1.0.1 (2011-12-08): + - Fix bug when displaying empty yanks. + +1.0 (2011-12-04): + - Remove unnecessary dependency on the undotree() function. Plugin should + now work on any recent version of vim. + + *yankstack-license* +Copyright (c) Max Brunsfeld. Distributed under the same terms as Vim itself. +See |license|. + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-yankstack/plugin/yankstack.vim b/sources_non_forked/vim-yankstack/plugin/yankstack.vim new file mode 100644 index 00000000..a5ad03b7 --- /dev/null +++ b/sources_non_forked/vim-yankstack/plugin/yankstack.vim @@ -0,0 +1 @@ +call yankstack#setup() diff --git a/sources_non_forked/vim-yankstack/spec/fixtures/repeat.vim b/sources_non_forked/vim-yankstack/spec/fixtures/repeat.vim new file mode 100644 index 00000000..e8fe7237 --- /dev/null +++ b/sources_non_forked/vim-yankstack/spec/fixtures/repeat.vim @@ -0,0 +1,115 @@ +" repeat.vim - Let the repeat command repeat plugin maps +" Maintainer: Tim Pope +" Version: 1.1 +" GetLatestVimScripts: 2136 1 :AutoInstall: repeat.vim + +" Installation: +" Place in either ~/.vim/plugin/repeat.vim (to load at start up) or +" ~/.vim/autoload/repeat.vim (to load automatically as needed). +" +" License: +" Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. +" See :help license +" +" Developers: +" Basic usage is as follows: +" +" silent! call repeat#set("\MappingToRepeatCommand",3) +" +" The first argument is the mapping that will be invoked when the |.| key is +" pressed. Typically, it will be the same as the mapping the user invoked. +" This sequence will be stuffed into the input queue literally. Thus you must +" encode special keys by prefixing them with a backslash inside double quotes. +" +" The second argument is the default count. This is the number that will be +" prefixed to the mapping if no explicit numeric argument was given. The +" value of the v:count variable is usually correct and it will be used if the +" second parameter is omitted. If your mapping doesn't accept a numeric +" argument and you never want to receive one, pass a value of -1. +" +" Make sure to call the repeat#set function _after_ making changes to the +" file. +" +" For mappings that use a register and want the same register used on +" repetition, use: +" +" silent! call repeat#setreg("\MappingToRepeatCommand", v:register) +" +" This function can (and probably needs to be) called before making changes to +" the file (as those typically clear v:register). Therefore, the call sequence +" in your mapping will look like this: +" +" nnoremap MyMap +" \ :execute 'silent! call repeat#setreg("\Plug>MyMap", v:register)' +" \ call MyFunction(v:register, ...) +" \ silent! call repeat#set("\Plug>MyMap") + +if exists("g:loaded_repeat") || &cp || v:version < 700 + finish +endif +let g:loaded_repeat = 1 + +let g:repeat_tick = -1 +let g:repeat_reg = ['', ''] + +" Special function to avoid spurious repeats in a related, naturally repeating +" mapping when your repeatable mapping doesn't increase b:changedtick. +function! repeat#invalidate() + let g:repeat_tick = -1 +endfunction + +function! repeat#set(sequence,...) + let g:repeat_sequence = a:sequence + let g:repeat_count = a:0 ? a:1 : v:count + let g:repeat_tick = b:changedtick +endfunction + +function! repeat#setreg(sequence,register) + let g:repeat_reg = [a:sequence, a:register] +endfunction + +function! repeat#run(count) + if g:repeat_tick == b:changedtick + let r = '' + if g:repeat_reg[0] ==# g:repeat_sequence && !empty(g:repeat_reg[1]) + if g:repeat_reg[1] ==# '=' + " This causes a re-evaluation of the expression on repeat, which + " is what we want. + let r = '"=' . getreg('=', 1) . "\" + else + let r = '"' . g:repeat_reg[1] + endif + endif + + let c = g:repeat_count + let s = g:repeat_sequence + let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : '')) + call feedkeys(r . cnt, 'n') + call feedkeys(s) + else + call feedkeys((a:count ? a:count : '') . '.', 'n') + endif +endfunction + +function! repeat#wrap(command,count) + let preserve = (g:repeat_tick == b:changedtick) + exe 'norm! '.(a:count ? a:count : '').a:command . (&foldopen =~# 'undo' ? 'zv' : '') + if preserve + let g:repeat_tick = b:changedtick + endif +endfunction + +nnoremap . :call repeat#run(v:count) +nnoremap u :call repeat#wrap('u',v:count) +if maparg('U','n') ==# '' + nnoremap U :call repeat#wrap('U',v:count) +endif +nnoremap :call repeat#wrap("\C-R>",v:count) + +augroup repeatPlugin + autocmd! + autocmd BufLeave,BufWritePre,BufReadPre * let g:repeat_tick = (g:repeat_tick == b:changedtick || g:repeat_tick == 0) ? 0 : -1 + autocmd BufEnter,BufWritePost * if g:repeat_tick == 0|let g:repeat_tick = b:changedtick|endif +augroup END + +" vim:set ft=vim et sw=4 sts=4: diff --git a/sources_non_forked/vim-yankstack/spec/spec_helper.rb b/sources_non_forked/vim-yankstack/spec/spec_helper.rb new file mode 100644 index 00000000..8fa4b47f --- /dev/null +++ b/sources_non_forked/vim-yankstack/spec/spec_helper.rb @@ -0,0 +1,9 @@ +require "vimbot" + +PLUGIN_ROOT = File.expand_path("../..", __FILE__) +VIM_REPEAT_PATH = File.expand_path("spec/fixtures/repeat.vim", PLUGIN_ROOT) + +RSpec.configure do |c| + c.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:' +end + diff --git a/sources_non_forked/vim-yankstack/spec/yankstack/yankstack_spec.rb b/sources_non_forked/vim-yankstack/spec/yankstack/yankstack_spec.rb new file mode 100644 index 00000000..327fb5fc --- /dev/null +++ b/sources_non_forked/vim-yankstack/spec/yankstack/yankstack_spec.rb @@ -0,0 +1,343 @@ +require "spec_helper" + +describe "Yankstack" do + let(:vim) { Vimbot::Driver.new } + + before(:all) do + vim.start + + vim.set "visualbell" + vim.set "noerrorbells" + vim.set "macmeta" + + vim.set "runtimepath+=#{PLUGIN_ROOT}" + vim.runtime "plugin/yankstack.vim" + + vim.source VIM_REPEAT_PATH + end + + after(:all) { vim.stop } + before(:each) { vim.clear_buffer } + + shared_examples "yanking and pasting" do + let(:yank_keys) { "yw" } + + before do + vim.insert "first_line", "second_line", "third_line", "fourth_line" + vim.normal "gg" + vim.normal yank_keys, 'j', yank_keys, 'j', yank_keys, 'j', yank_keys + end + + it "pushes every yanked string to the :Yanks stack" do + yank_entries[0].should match /0\s+fourth_line/ + yank_entries[1].should match /1\s+third_line/ + yank_entries[2].should match /2\s+second_line/ + yank_entries[3].should match /3\s+first_line/ + end + + describe "yanking with different keys" do + before do + vim.normal "A", "", "line to delete", "", "^" + end + + keys_that_change_register = [ + 'cc', 'C', + 'dd', 'D', + 's', 'S', + 'x', 'X', + 'yy', 'Y' + ] + + keys_that_change_register.each do |key| + it "pushes to the stack when deleting text with '#{key}'" do + vim.normal key + yank_entries[1].should match /1\s+fourth_line/ + end + end + + it "pushes to the stack when overwriting text in select mode" do + vim.type "V" + vim.type "", "this overwrites the last line" + yank_entries[0].should include "line to delete" + yank_entries[1].should include "fourth_line" + end + end + + context "in normal mode" do + before { vim.normal "o", "" } + + describe "pasting a string with 'p'" do + before { vim.normal "p" } + + it "pastes the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + + describe "pressing the repeat key with '.'" do + it "pastes again" do + pending unless File.exists?(VIM_REPEAT_PATH) + + vim.type "." + vim.line.should == "fourth_linefourth_line" + end + end + + describe "typing the 'cycle paste' key" do + before { vim.normal "" } + + it "replaces the pasted string with the previously yanked text" do + vim.line.should == "third_line" + end + + it "rotates the previously yanked text to the top of the yank stack" do + yank_entries[0].should include 'third_line' + yank_entries[1].should include 'second_line' + yank_entries[2].should include 'first_line' + yank_entries[-1].should include 'fourth_line' + end + + it "rotates through the yanks when pressed multiple times" do + vim.normal "" + vim.line.should == "second_line" + vim.normal "" + vim.line.should == "first_line" + + vim.normal "" + vim.line.should == "second_line" + vim.normal "" + vim.line.should == "third_line" + vim.normal "" + vim.line.should == "fourth_line" + end + end + end + + describe "typing the `substitute_older_paste` key without pasting first" do + before { vim.type "" } + + it "pastes the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + + describe "typing the 'cycle paste' key" do + before { vim.normal "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line.should == "third_line" + end + end + end + + describe "typing the `substitute_newer_paste` key without pasting first" do + before { vim.type "" } + + it "pastes the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + + describe "typing the 'cycle paste' key" do + before { vim.normal "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line.should == "third_line" + end + end + end + + it "allows pasting from a non-default register" do + reg = 'a' + vim.normal "gg" + vim.normal %("#{reg}y$) + vim.normal "G" + + vim.normal %("#{reg}p) + vim.line.should == "first_line" + end + + it "allows pasting with a count" do + vim.normal "3p" + vim.line_number.should == 5 + vim.line.should == "fourth_line" * 3 + end + end + + context "in visual mode, with text highlighted" do + before do + vim.normal "A", "line to overwrite" + vim.normal "V" + end + + describe "pasting a string with 'p'" do + before do + vim.type "p" + end + + it "overwrites the selection with the most recently yanked string" do + vim.line.should == "fourth_line" + end + + it "moves the the overwritten text to the bottom of the stack" do + yank_entries[0].should include "fourth_line" + yank_entries[1].should include "third_line" + yank_entries[2].should include "second_line" + yank_entries[-1].should include "line to overwrite" + end + + describe "typing the 'cycle older paste' key" do + before { vim.normal "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line.should == "third_line" + end + + it "moves the previously yanked text to the top of the stack" do + yank_entries[0].should include "third_line" + yank_entries[1].should include "second_line" + yank_entries[2].should include "first_line" + yank_entries[-2].should include "line to overwrite" + yank_entries[-1].should include "fourth_line" + end + + describe "typing the 'cycle newer paste' key" do + before { vim.normal "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line.should == "fourth_line" + end + + it "moves the previously yanked text to the top of the stack" do + yank_entries[0].should include "fourth_line" + yank_entries[1].should include "third_line" + yank_entries[2].should include "second_line" + yank_entries[3].should include "first_line" + yank_entries[-1].should include "line to overwrite" + end + end + end + end + + describe "typing the `substitute_older_paste` key without pasting first" do + before { vim.type "" } + + it "overwrites the selection with the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + end + + describe "typing the `substitute_newer_paste` key without pasting first" do + before { vim.type "" } + + it "overwrites the selection with the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + end + + it "allows pasting with a count" do + vim.type "3p" + + vim.line_number.should == 5 + vim.line.should == "fourth_line" + + vim.normal 'j' + vim.line_number.should == 6 + vim.line.should == "fourth_line" + + vim.normal 'j' + vim.line_number.should == 7 + vim.line.should == "fourth_line" + end + end + + context "in insert mode" do + before do + vim.normal "A", "()", "" + vim.type "" + end + + describe "typing the `substitute_older_paste` after a character-wise yank" do + it "pastes the most recently yanked text after the cursor" do + vim.line_number.should == 5 + vim.line.should == "(fourth_line)" + end + + it "stays in insert mode, with the cursor at the end of the pasted text" do + vim.should be_in_insert_mode + vim.column_number.should == "(fourth_line".length + 1 + end + + describe "typing the `substitute_older_paste` key again" do + before { vim.type "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line_number.should == 5 + vim.line.should == "(third_line)" + end + + it "stays in insert mode, with the cursor at the end of the pasted text" do + vim.should be_in_insert_mode + vim.column_number.should == "(third_line".length+1 + end + + it "rotates the previously yanked text to the top of the yank stack" do + yank_entries[0].should include 'third_line' + yank_entries[1].should include 'second_line' + yank_entries[2].should include 'first_line' + yank_entries[-1].should include 'fourth_line' + end + + it "rotates through the yanks when pressed multiple times" do + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(second_line)" + + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(first_line)" + + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(second_line)" + + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(third_line)" + + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(fourth_line)" + end + end + end + + describe "typing `substitute_older_paste` after a line-wise yank" do + let(:yank_keys) { "yy" } + + xit "pastes and puts the cursor after the pasted text" do + vim.line_number.should == 6 + vim.line.should == ")" + vim.type "" + vim.line.should == "(fourth_line" + end + end + end + end + + describe "when using the normal default register" do + it_has_behavior "yanking and pasting" + end + + describe "when using the system clipboard as the default register" do + before { vim.set "clipboard", "unnamed" } + it_has_behavior "yanking and pasting" + end + + def yank_entries + @yank_entries ||= vim.command("Yanks").split("\n")[1..-1] + end +end + diff --git a/temp_dirs/undodir/.gitignore b/temp_dirs/undodir/.gitignore new file mode 100644 index 00000000..47e856eb --- /dev/null +++ b/temp_dirs/undodir/.gitignore @@ -0,0 +1,2 @@ +# http://stackoverflow.com/a/932982 +!.gitignore diff --git a/temp_dirs/undodir/README.md b/temp_dirs/undodir/README.md new file mode 100644 index 00000000..37f6debe --- /dev/null +++ b/temp_dirs/undodir/README.md @@ -0,0 +1 @@ +Undo dir for VIM diff --git a/update_plugins.py b/update_plugins.py index bdea53d8..07116c96 100644 --- a/update_plugins.py +++ b/update_plugins.py @@ -1,3 +1,11 @@ +try: + import concurrent.futures as futures +except ImportError: + try: + import futures + except ImportError: + futures = None + import zipfile import shutil import tempfile @@ -11,10 +19,10 @@ PLUGINS = """ ack.vim https://github.com/mileszs/ack.vim ag.vim https://github.com/rking/ag.vim bufexplorer https://github.com/corntrace/bufexplorer -ctrlp.vim https://github.com/kien/ctrlp.vim +ctrlp.vim https://github.com/ctrlpvim/ctrlp.vim mayansmoke https://github.com/vim-scripts/mayansmoke nerdtree https://github.com/scrooloose/nerdtree -nginx.vim https://github.com/vim-scripts/nginx.vim +nginx-vim-syntax https://github.com/evanmiller/nginx-vim-syntax open_file_under_cursor.vim https://github.com/amix/open_file_under_cursor.vim snipmate-snippets https://github.com/scrooloose/snipmate-snippets tlib https://github.com/vim-scripts/tlib @@ -32,7 +40,6 @@ vim-surround https://github.com/tpope/vim-surround vim-expand-region https://github.com/terryma/vim-expand-region vim-multiple-cursors https://github.com/terryma/vim-multiple-cursors vim-fugitive https://github.com/tpope/vim-fugitive -vim-airline https://github.com/bling/vim-airline goyo.vim https://github.com/junegunn/goyo.vim vim-zenroom2 https://github.com/amix/vim-zenroom2 syntastic https://github.com/scrooloose/syntastic @@ -41,6 +48,10 @@ vim-commentary https://github.com/tpope/vim-commentary vim-go https://github.com/fatih/vim-go vim-gitgutter https://github.com/airblade/vim-gitgutter gruvbox https://github.com/morhetz/gruvbox +vim-flake8 https://github.com/nvie/vim-flake8 +vim-pug https://github.com/digitaltoad/vim-pug +vim-yankstack https://github.com/maxbrunsfeld/vim-yankstack +lightline.vim https://github.com/itchyny/lightline.vim """.strip() GITHUB_ZIP = '%s/archive/master.zip' @@ -74,14 +85,21 @@ def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir): print('Updated {0}'.format(plugin_name)) +def update(plugin): + name, github_url = plugin.split(' ') + zip_path = GITHUB_ZIP % github_url + download_extract_replace(name, zip_path, + temp_directory, SOURCE_DIR) + + if __name__ == '__main__': temp_directory = tempfile.mkdtemp() try: - for line in PLUGINS.splitlines(): - name, github_url = line.split(' ') - zip_path = GITHUB_ZIP % github_url - download_extract_replace(name, zip_path, - temp_directory, SOURCE_DIR) + if futures: + with futures.ThreadPoolExecutor(16) as executor: + executor.map(update, PLUGINS.splitlines()) + else: + [update(x) for x in PLUGINS.splitlines()] finally: shutil.rmtree(temp_directory) diff --git a/vimrcs/basic.vim b/vimrcs/basic.vim index bfe89f43..837469f7 100644 --- a/vimrcs/basic.vim +++ b/vimrcs/basic.vim @@ -84,9 +84,9 @@ set wildmenu " Ignore compiled files set wildignore=*.o,*~,*.pyc if has("win16") || has("win32") - set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store -else set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store endif "Always show current position @@ -102,11 +102,6 @@ set hid set backspace=eol,start,indent set whichwrap+=<,>,h,l -" In many terminal emulators the mouse works just fine, thus enable it. -if has('mouse') - set mouse=a -endif - " Ignore case when searching set ignorecase @@ -204,17 +199,13 @@ set wrap "Wrap lines """""""""""""""""""""""""""""" " Visual mode pressing * or # searches for the current selection " Super useful! From an idea by Michael Naumann -vnoremap * :call VisualSelection('f', '') -vnoremap # :call VisualSelection('b', '') +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Moving around, tabs, windows and buffers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Treat long lines as break lines (useful when moving around in them) -map j gj -map k gk - " Map to / (search) and Ctrl- to ? (backwards search) map / map ? @@ -229,11 +220,14 @@ map h map l " Close the current buffer -map bd :Bclose +map bd :Bclose:tabclosegT " Close all the buffers map ba :bufdo bd +map l :bnext +map h :bprevious + " Useful mappings for managing tabs map tn :tabnew map to :tabonly @@ -262,12 +256,7 @@ catch endtry " Return to last edit position when opening files (You want this!) -" autocmd BufReadPost * -" \ if line("'\"") > 0 && line("'\"") <= line("$") | -" \ exe "normal! g`\"" | -" \ endif -" Remember info about open buffers on close -" set viminfo^=% +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif """""""""""""""""""""""""""""" @@ -277,7 +266,7 @@ endtry set laststatus=2 " Format the status line -set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l +set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -286,7 +275,7 @@ set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ " Remap VIM 0 to first non-blank character map 0 ^ -" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac +" Move a line of text using ALT+[jk] or Command+[jk] on mac nmap mz:m+`z nmap mz:m-2`z vmap :m'>+`mzgv`yo`z @@ -386,14 +375,10 @@ function! VisualSelection(direction, extra_filter) range let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") - if a:direction == 'b' - execute "normal ?" . l:pattern . "^M" - elseif a:direction == 'gv' + if a:direction == 'gv' call CmdLine("Ag \"" . l:pattern . "\" " ) elseif a:direction == 'replace' call CmdLine("%s" . '/'. l:pattern . '/') - elseif a:direction == 'f' - execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern @@ -431,6 +416,6 @@ function! BufcloseCloseIt() endfunction " Make VIM remember position in file after reopen -if has("autocmd") - au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif -endif +" if has("autocmd") +" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif +"endif diff --git a/vimrcs/extended.vim b/vimrcs/extended.vim index 255a31cf..499959a2 100644 --- a/vimrcs/extended.vim +++ b/vimrcs/extended.vim @@ -10,21 +10,17 @@ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Set font according to system if has("mac") || has("macunix") - set gfn=Source\ Code\ Pro:h15,Menlo:h15 + set gfn=Hack:h14,Source\ Code\ Pro:h15,Menlo:h15 elseif has("win16") || has("win32") - set gfn=Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11 + set gfn=Hack:h14,Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11 +elseif has("gui_gtk2") + set gfn=Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11 elseif has("linux") - set gfn=Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11 + set gfn=Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11 elseif has("unix") set gfn=Monospace\ 11 endif -" Open MacVim in fullscreen mode -if has("gui_macvim") - set fuoptions=maxvert,maxhorz - au GUIEnter * set fullscreen -endif - " Disable scrollbars (real hackers don't use scrollbars for navigation!) set guioptions-=r set guioptions-=R @@ -32,13 +28,8 @@ set guioptions-=l set guioptions-=L " Colorscheme -if has("gui_running") - set background=dark - colorscheme peaksea -else - colorscheme desert - let g:colors_name="desert" -endif +set background=dark +colorscheme peaksea """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -103,7 +94,6 @@ inoremap $3 {}i inoremap $4 {o}O inoremap $q ''i inoremap $e ""i -inoremap $t <>i """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/vimrcs/filetypes.vim b/vimrcs/filetypes.vim index f6a58f6b..8c4eb9db 100644 --- a/vimrcs/filetypes.vim +++ b/vimrcs/filetypes.vim @@ -12,11 +12,14 @@ au FileType python map F :set foldmethod=indent au FileType python inoremap $r return au FileType python inoremap $i import au FileType python inoremap $p print -au FileType python inoremap $f #--- PH ----------------------------------------------FP2xi +au FileType python inoremap $f #--- a au FileType python map 1 /class au FileType python map 2 /def au FileType python map C ?class au FileType python map D ?def +au FileType python set cindent +au FileType python set cinkeys-=0# +au FileType python set indentkeys-=0# """""""""""""""""""""""""""""" @@ -30,7 +33,7 @@ au FileType javascript imap $log();hi au FileType javascript imap alert();hi au FileType javascript inoremap $r return -au FileType javascript inoremap $f //--- PH ----------------------------------------------FP2xi +au FileType javascript inoremap $f //--- PHFP2xi function! JavaScriptFold() setl foldmethod=syntax @@ -54,3 +57,11 @@ endfunction au FileType coffee call CoffeeScriptFold() au FileType gitcommit call setpos('.', [0, 1, 1, 0]) + + +"""""""""""""""""""""""""""""" +" => Shell section +"""""""""""""""""""""""""""""" +if exists('$TMUX') + set term=screen-256color +endif diff --git a/vimrcs/plugins_config.vim b/vimrcs/plugins_config.vim index bbff26f5..44d761cb 100644 --- a/vimrcs/plugins_config.vim +++ b/vimrcs/plugins_config.vim @@ -1,5 +1,5 @@ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Important: +" Important: " This requries that you install https://github.com/amix/vimrc ! " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -30,13 +30,10 @@ map f :MRU """""""""""""""""""""""""""""" -" => YankRing +" => YankStack """""""""""""""""""""""""""""" -if has("win16") || has("win32") - " Don't do anything -else - let g:yankring_history_dir = '~/.vim_runtime/temp_dirs/' -endif +nmap yankstack_substitute_older_paste +nmap yankstack_substitute_newer_paste """""""""""""""""""""""""""""" @@ -81,7 +78,7 @@ let NERDTreeShowHidden=0 let NERDTreeIgnore = ['\.pyc$', '__pycache__'] let g:NERDTreeWinSize=35 map nn :NERDTreeToggle -map nb :NERDTreeFromBookmark +map nb :NERDTreeFromBookmark map nf :NERDTreeFind @@ -100,9 +97,32 @@ au FileType mako vmap Si S"i${ _(2f"a) } """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => vim-airline config (force color) +" => lightline """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let g:airline_theme="luna" +let g:lightline = { + \ 'colorscheme': 'wombat', + \ } + +let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ ['mode', 'paste'], + \ ['fugitive', 'readonly', 'filename', 'modified'] ], + \ 'right': [ [ 'lineinfo' ], ['percent'] ] + \ }, + \ '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': ' ' } + \ } """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Vimroom @@ -113,20 +133,33 @@ let g:goyo_margin_bottom = 2 nnoremap z :Goyo +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Vim-go +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +let g:go_fmt_command = "goimports" + + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Syntastic (syntax checker) """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Python let g:syntastic_python_checkers=['pyflakes'] + +" Javascript let g:syntastic_javascript_checkers = ['jshint'] +" Go +let g:syntastic_auto_loc_list = 1 +let g:syntastic_go_checkers = ['go', 'golint', 'errcheck'] + " Custom CoffeeScript SyntasticCheck func! SyntasticCheckCoffeescript() let l:filename = substitute(expand("%:p"), '\(\w\+\)\.coffee', '.coffee.\1.js', '') - execute "e " . l:filename + execute "tabedit " . l:filename execute "SyntasticCheck" execute "Errors" endfunc -nnoremap l :call SyntasticCheckCoffeescript() +nnoremap c :call SyntasticCheckCoffeescript() """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""