commit 6d4398077d5b221a9734ff90899c6a5f19ee004c Author: wangzheng Date: Sun Oct 14 21:43:54 2018 +0800 myset diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..55273366 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +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_plugins/ +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 new file mode 100644 index 00000000..adc63d24 --- /dev/null +++ b/README.md @@ -0,0 +1,330 @@ +![VIM](https://dnp4pehkvoo6n.cloudfront.net/43c5af597bd5c1a64eb1829f011c208f/as/Ultimate%20Vimrc.svg) + +# The Ultimate vimrc + +Over the last 10 years, I have used and tweaked Vim. This configuration is the ultimate vimrc (or at least my version of it). + +There are two versions: + +* **The 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 good basic setup +* **The Awesome**: Includes a ton of useful plugins, color schemes, and configurations + +I would, of course, recommend using the awesome version. + + +## How to install the Awesome version? +### Install for your own user only +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 from your terminal: + + git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime + sh ~/.vim_runtime/install_awesome_vimrc.sh + +### Install for multiple users +To install for multiple users, the repository needs to be cloned to a location accessible for all the intended users. + + git clone --depth=1 https://github.com/amix/vimrc.git /opt/vim_runtime + sh ~/.vim_runtime/install_awesome_parameterized.sh /opt/vim_runtime user0 user1 user2 + # to install for all users with home directories + sh ~/.vim_runtime/install_awesome_parameterized.sh /opt/vim_runtime --all + +Naturally, `/opt/vim_runtime` can be any directory, as long as all the users specified have read access. + +## Fonts + +I recommend using [IBM Plex Mono font](https://github.com/IBM/plex) (it's an open-source and awesome font that can make your code beautiful). The Awesome vimrc is already setup to try to use it. + +Some other fonts that Awesome will try to use: + +* [Hack](http://sourcefoundry.org/hack/) +* [Source Code Pro](https://adobe-fonts.github.io/source-code-pro/) + +## How to install the Basic version? + +The basic version is just one file and no plugins. Just copy [basic.vim](https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim) and paste it into your vimrc. + +The basic version is useful to install on remote servers where you don't need many plugins, and you don't do many edits. + + git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime + sh ~/.vim_runtime/install_basic_vimrc.sh + + +## How to install on Windows? + +Use [gitforwindows](http://gitforwindows.org/) 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? + +Just do a git rebase! + + cd ~/.vim_runtime + git pull --rebase + + +## Some screenshots + +Colors when editing a Python file: + +![Screenshot 1](https://dnp4pehkvoo6n.cloudfront.net/07583008e4da885801657e8781777844/as/Python%20editing.png) + +Opening recently opened files with the [mru.vim](https://github.com/vim-scripts/mru.vim) plugin: + +![Screenshot 2](https://dnp4pehkvoo6n.cloudfront.net/1d49a88f9bd5d013c025bb1e1272a7d8/as/MRU%20plugin.png) + +[NERD Tree](https://github.com/scrooloose/nerdtree) plugin in a terminal window: +![Screenshot 3](https://dnp4pehkvoo6n.cloudfront.net/ae719203166585d64728f28398f4b1b7/as/Terminal%20usage.png) + +Distraction free mode using [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2): +![Screenshot 4](https://dnp4pehkvoo6n.cloudfront.net/f0dcc4c9739148c56cbf8285a910ac41/as/Zen%20mode.png) + + +## Included Plugins + +I recommend reading the docs of these plugins to understand them better. Each plugin provides a much better Vim experience! + +* [ack.vim](https://github.com/mileszs/ack.vim): Vim plugin for `the_silver_searcher` (ag) or ack -- a wicked fast grep +* [bufexplorer.zip](https://github.com/vim-scripts/bufexplorer.zip): Quickly and easily switch between buffers. This plugin can be opened with `` +* [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim): Fuzzy file, buffer, mru and tag finder. It's mapped to `` +* [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2): +* [lightline.vim](https://github.com/itchyny/lightline.vim): A light and configurable statusline/tabline for Vim +* [NERD Tree](https://github.com/scrooloose/nerdtree): A tree explorer plugin for vim +* [mru.vim](https://github.com/vim-scripts/mru.vim): Plugin to manage Most Recently Used (MRU) files. 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` +* [pathogen.vim](https://github.com/tpope/vim-pathogen): Manage your vim runtimepath +* [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 +* [ale](https://github.com/w0rp/ale): Syntax and lint checking for vim (async) +* [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. +* [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-fugitive](https://github.com/tpope/vim-fugitive): A Git wrapper so awesome, it should be illegal +* [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 +* [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-yankstack](https://github.com/maxbrunsfeld/vim-yankstack): Maintains a history of previous yanks, changes and deletes +* [vim-zenroom2](https://github.com/amix/vim-zenroom2) Remove all clutter and focus only on the essential. Similar to iA Writer or Write Room + + +## Included color schemes + +* [peaksea](https://github.com/vim-scripts/peaksea): The default +* [vim-colors-solarized](https://github.com/altercation/vim-colors-solarized) +* [vim-irblack](https://github.com/wgibbs/vim-irblack) +* [mayansmoke](https://github.com/vim-scripts/mayansmoke) +* [vim-pyte](https://github.com/therubymug/vim-pyte) + + +## Included modes + +* [vim-coffee-script](https://github.com/kchmck/vim-coffee-script) +* [vim-less](https://github.com/groenewege/vim-less) +* [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-go](https://github.com/fatih/vim-go) + + +## How to include your own stuff? + +After you have installed the setup, you can create **~/.vim_runtime/my_configs.vim** to fill in any configurations that are important for you. For instance, my **my_configs.vim** looks like this: + + ~/.vim_runtime (master)> cat my_configs.vim + map ct :cd ~/Desktop/Todoist/todoist + map cw :cd ~/Desktop/Wedoist/wedoist + +You can also install your plugins, for instance, via pathogen you can install [vim-rails](https://github.com/tpope/vim-rails): + + cd ~/.vim_runtime + git clone git://github.com/tpope/vim-rails.git my_plugins/vim-rails + + +## Key Mappings + +The [leader](http://learnvimscriptthehardway.stevelosh.com/chapters/06.html#leader) is `,`, so whenever you see `` it means `,`. + + +### Plugin related mappings + +Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) to see and manage the current buffers (`o`): + + map o :BufExplorer + +Open [MRU.vim](https://github.com/vim-scripts/mru.vim) to see the recently open files (`f`): + + map f :MRU + +Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin to quickly find a file or a buffer (`j` or `f`): + + let g:ctrlp_map = '' + +[NERD Tree](https://github.com/scrooloose/nerdtree) mappings: + + 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. (`z`) + + map z :Goyo + + +### Normal mode mappings + +Fast saving of a buffer (`w`): + + nmap w :w! + +Map `` to `/` (search) and `+` to `?` (backwards search): + + map / + map ? + map :noh + +Disable highlights when you press ``: + + map :noh + +Smart way to move between windows (`j` etc.): + + map j + map k + map h + map l + +Closing of the current buffer(s) (`bd` and (`ba`)): + + " Close current buffer + map bd :Bclose + + " Close all buffers + map ba :1,1000 bd! + +Useful mappings for managing tabs: + + map tn :tabnew + map to :tabonly + map tc :tabclose + map tm :tabmove + + " Opens a new tab with the current buffer's path + " Super useful when editing files in the same directory + map te :tabedit =expand("%:p:h")/ + +Switch [CWD](http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file) to the directory of the open buffer: + + map cd :cd %:p:h:pwd + +Open `ack.vim` for fast search: + + map g :Ack + +Quickly open a buffer for scripbble: + + map q :e ~/buffer + +Toggle paste mode on and off: + + map pp :setlocal paste! + + +### Visual mode mappings + +Visual mode pressing `*` or `#` searches for the current selection: + + vnoremap * :call VisualSelection('f') + vnoremap # :call VisualSelection('b') + +When you press gv you `Ack.vim` after the selected text: + + vnoremap gv :call VisualSelection('gv', '') + +When you press `r` you can search and replace the selected text: + + vnoremap r :call VisualSelection('replace') + +Surround the visual selection in parenthesis/brackets/etc.: + + vnoremap $1 `>a)` + vnoremap $2 `>a]` + vnoremap $3 `>a}` + vnoremap $$ `>a"` + vnoremap $q `>a'` + vnoremap $e `>a"` + + +### Insert mode mappings + +Quickly insert parenthesis/brackets/etc.: + + inoremap $1 ()i + inoremap $2 []i + inoremap $3 {}i + inoremap $4 {o}O + inoremap $q ''i + inoremap $e ""i + inoremap $t <>i + +Insert the current date and time (useful for timestamps): + + iab xdate =strftime("%d/%m/%y %H:%M:%S") + + +### Command line mappings + +$q is super useful when browsing on the command line. It deletes everything until the last slash: + + cno $q eDeleteTillSlash() + +Bash like keys for the command line: + + cnoremap + cnoremap + cnoremap + + cnoremap + cnoremap + +Write the file as sudo (works only on Unix). Super useful when you open a file and you don't have permissions to save your changes. [Vim tip](http://vim.wikia.com/wiki/Su-write): + + :W + + +### Spell checking +Pressing `ss` will toggle spell checking: + + map ss :setlocal spell! + +Shortcuts using `` instead of special characters: + + map sn ]s + map sp [s + map sa zg + map s? z= + + +### Cope +Query `:help cope` if you are unsure what cope is. It's super useful! + +When you search with `Ack.vim`, display your results in cope by doing: +`cc` + +To go to the next search result do: +`n` + +To go to the previous search results do: +`p` + +Cope mappings: + + map cc :botright cope + map co ggVGy:tabnew:set syntax=qfpgg + map n :cn + map p :cp + + +## How to uninstall +Just do following: +* Remove `~/.vim_runtime` +* Remove any lines that reference `.vim_runtime` in your `~/.vimrc` diff --git a/autoload/pathogen.vim b/autoload/pathogen.vim new file mode 100755 index 00000000..a13ae08f --- /dev/null +++ b/autoload/pathogen.vim @@ -0,0 +1,347 @@ +" pathogen.vim - path option manipulation +" Maintainer: Tim Pope +" Version: 2.3 + +" Install in ~/.vim/autoload (or ~\vimfiles\autoload). +" +" For management of individually installed plugins in ~/.vim/bundle (or +" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your +" .vimrc is the only other setup necessary. +" +" The API is documented inline below. + +if exists("g:loaded_pathogen") || &cp + finish +endif +let g:loaded_pathogen = 1 + +" Point of entry for basic default usage. Give a relative path to invoke +" pathogen#interpose() (defaults to "bundle/{}"), or an absolute path to invoke +" pathogen#surround(). Curly braces are expanded with pathogen#expand(): +" "bundle/{}" finds all subdirectories inside "bundle" inside all directories +" in the runtime path. +function! pathogen#infect(...) abort + for path in a:0 ? filter(reverse(copy(a:000)), 'type(v:val) == type("")') : ['bundle/{}'] + if path =~# '^\%({\=[$~\\/]\|{\=\w:[\\/]\).*[{}*]' + call pathogen#surround(path) + elseif path =~# '^\%([$~\\/]\|\w:[\\/]\)' + call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') + call pathogen#surround(path . '/{}') + elseif path =~# '[{}*]' + call pathogen#interpose(path) + else + call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') + call pathogen#interpose(path . '/{}') + endif + endfor + call pathogen#cycle_filetype() + if pathogen#is_disabled($MYVIMRC) + return 'finish' + endif + return '' +endfunction + +" Split a path into a list. +function! pathogen#split(path) abort + if type(a:path) == type([]) | return a:path | endif + if empty(a:path) | return [] | endif + let split = split(a:path,'\\\@]','\\&','') + endif +endfunction + +" Like findfile(), but hardcoded to use the runtimepath. +function! pathogen#runtime_findfile(file,count) abort "{{{1 + let rtp = pathogen#join(1,pathogen#split(&rtp)) + let file = findfile(a:file,rtp,a:count) + if file ==# '' + return '' + else + return fnamemodify(file,':p') + endif +endfunction + +" Section: Deprecated + +function! s:warn(msg) abort + echohl WarningMsg + echomsg a:msg + echohl NONE +endfunction + +" Prepend all subdirectories of path to the rtp, and append all 'after' +" directories in those subdirectories. Deprecated. +function! pathogen#runtime_prepend_subdirectories(path) abort + call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#infect('.string(a:path.'/{}').')') + return pathogen#surround(a:path . pathogen#slash() . '{}') +endfunction + +function! pathogen#incubate(...) abort + let name = a:0 ? a:1 : 'bundle/{}' + call s:warn('Change pathogen#incubate('.(a:0 ? string(a:1) : '').') to pathogen#infect('.string(name).')') + return pathogen#interpose(name) +endfunction + +" Deprecated alias for pathogen#interpose(). +function! pathogen#runtime_append_all_bundles(...) abort + if a:0 + call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#infect('.string(a:1.'/{}').')') + else + call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#infect()') + endif + return pathogen#interpose(a:0 ? a:1 . '/{}' : 'bundle/{}') +endfunction + +if exists(':Vedit') + finish +endif + +let s:vopen_warning = 0 + +function! s:find(count,cmd,file,lcd) + let rtp = pathogen#join(1,pathogen#split(&runtimepath)) + let file = pathogen#runtime_findfile(a:file,a:count) + if file ==# '' + return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'" + endif + if !s:vopen_warning + let s:vopen_warning = 1 + let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE' + else + let warning = '' + endif + if a:lcd + let path = file[0:-strlen(a:file)-2] + execute 'lcd `=path`' + return a:cmd.' '.pathogen#fnameescape(a:file) . warning + else + return a:cmd.' '.pathogen#fnameescape(file) . warning + endif +endfunction + +function! s:Findcomplete(A,L,P) + let sep = pathogen#slash() + let cheats = { + \'a': 'autoload', + \'d': 'doc', + \'f': 'ftplugin', + \'i': 'indent', + \'p': 'plugin', + \'s': 'syntax'} + if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0]) + let request = cheats[a:A[0]].a:A[1:-1] + else + let request = a:A + endif + let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*' + let found = {} + for path in pathogen#split(&runtimepath) + let path = expand(path, ':p') + let matches = split(glob(path.sep.pattern),"\n") + call map(matches,'isdirectory(v:val) ? v:val.sep : v:val') + call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]') + for match in matches + let found[match] = 1 + endfor + endfor + return sort(keys(found)) +endfunction + +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(,'edit',,0) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',,0) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',,1) + +" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=': diff --git a/install_awesome_parameterized.sh b/install_awesome_parameterized.sh new file mode 100755 index 00000000..d83f6dc6 --- /dev/null +++ b/install_awesome_parameterized.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +echo 'Installing Awesome Vim from '$1 +cd $1 + +VIMRC="set runtimepath+=$1 + +source $1/vimrcs/basic.vim +source $1/vimrcs/filetypes.vim +source $1/vimrcs/plugins_config.vim +source $1/vimrcs/extended.vim + +try +source $1/my_configs.vim +catch +endtry" + +if [ $2 == "--all" ]; then + USERS=($(ls -l /home | awk '{if(NR>1)print $9}')) + for user in ${USERS[*]}; do + homepath=$(eval echo "~$user") + IFS='' + echo $VIMRC > ${homepath}/.vimrc + unset IFS + echo "Installed the Ultimate Vim configuration for user $user successfully! Enjoy :-)" + done + echo "Installed the Ultimate Vim configuration successfully! Enjoy :-)" + exit 0 +else + SELECTED_USERS=(${@:2}) + echo "Selected users: ${SELECTED_USERS[@]}" + for user in ${SELECTED_USERS[@]}; do + homepath=$(eval echo "~$user") + IFS='' + echo $VIMRC > ${homepath}/.vimrc + unset IFS + echo "Installed the Ultimate Vim configuration for user $user successfully! Enjoy :-)" + done + exit 0 +fi diff --git a/install_awesome_vimrc.sh b/install_awesome_vimrc.sh new file mode 100644 index 00000000..6b94e519 --- /dev/null +++ b/install_awesome_vimrc.sh @@ -0,0 +1,18 @@ +#!/bin/sh +set -e + +cd ~/.vim_runtime + +echo 'set runtimepath+=~/.vim_runtime + +source ~/.vim_runtime/vimrcs/basic.vim +source ~/.vim_runtime/vimrcs/filetypes.vim +source ~/.vim_runtime/vimrcs/plugins_config.vim +source ~/.vim_runtime/vimrcs/extended.vim + +try +source ~/.vim_runtime/my_configs.vim +catch +endtry' > ~/.vimrc + +echo "Installed the Ultimate Vim configuration successfully! Enjoy :-)" diff --git a/install_basic_vimrc.sh b/install_basic_vimrc.sh new file mode 100644 index 00000000..6b3142d1 --- /dev/null +++ b/install_basic_vimrc.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e + +cd ~/.vim_runtime +cat ~/.vim_runtime/vimrcs/basic.vim > ~/.vimrc +echo "Installed the Basic Vim configuration successfully! Enjoy :-)" diff --git a/sources_forked/peaksea/colors/peaksea.vim b/sources_forked/peaksea/colors/peaksea.vim new file mode 100644 index 00000000..06924bc1 --- /dev/null +++ b/sources_forked/peaksea/colors/peaksea.vim @@ -0,0 +1,606 @@ +" Vim color file --- psc (peak sea color) "Lite version" +" Maintainer: Pan, Shi Zhu +" URL: http://vim.sourceforge.net/scripts/script.php?script_id=760 +" Last Change: 5 Feb 2010 +" Version: 3.4 +" +" Comments and e-mails are welcomed, thanks. +" +" The peaksea color is simply a colorscheme with the default settings of +" the original ps_color. Lite version means there's no custom settings +" and fancy features such as integration with reloaded.vim +" +" The full version of ps_color.vim will be maintained until Vim 8. +" By then there will be only the lite version: peaksea.vim +" +" Note: Please set the background option in your .vimrc and/or .gvimrc +" +" It is much better *not* to set 'background' option inside +" a colorscheme file. because ":set background" improperly +" may cause colorscheme be sourced twice +" +" Color Scheme Overview: +" :ru syntax/hitest.vim +" +" Relevant Help: +" :h highlight-groups +" :h psc-cterm-color-table +" +" Colors Order: +" #rrggbb +" + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let g:colors_name = "peaksea" + +" I don't want to abuse folding, but here folding is used to avoid confusion. +if &background=='light' + " for background=light {{{2 + " LIGHT COLOR DEFINE START + + hi Normal guifg=#000000 guibg=#e0e0e0 gui=NONE + hi Search guifg=White guibg=DarkRed gui=NONE + hi Visual guifg=NONE guibg=#a6caf0 gui=NONE + hi Cursor guifg=#f0f0f0 guibg=#008000 gui=NONE + " The idea of CursorIM is pretty good, however, the feature is still buggy + " in the current version (Vim 7.0). + " The following line will be kept commented until the bug fixed. + " + " hi CursorIM guifg=#f0f0f0 guibg=#800080 + hi Special guifg=#907000 guibg=NONE gui=NONE + hi Comment guifg=#606000 guibg=NONE gui=NONE + hi Number guifg=#907000 guibg=NONE gui=NONE + hi Constant guifg=#007068 guibg=NONE gui=NONE + hi StatusLine guifg=fg guibg=#a6caf0 gui=NONE + hi LineNr guifg=#686868 guibg=NONE gui=NONE + hi Question guifg=fg guibg=#d0d090 gui=NONE + hi PreProc guifg=#009030 guibg=NONE gui=NONE + hi Statement guifg=#2060a8 guibg=NONE gui=NONE + hi Type guifg=#0850a0 guibg=NONE gui=NONE + hi Todo guifg=#800000 guibg=#e0e090 gui=NONE + " NOTE THIS IS IN THE WARM SECTION + hi Error guifg=#c03000 guibg=NONE gui=NONE + hi Identifier guifg=#a030a0 guibg=NONE gui=NONE + hi ModeMsg guifg=fg guibg=#b0b0e0 gui=NONE + hi VisualNOS guifg=fg guibg=#b0b0e0 gui=NONE + hi SpecialKey guifg=#1050a0 guibg=NONE gui=NONE + hi NonText guifg=#002090 guibg=#d0d0d0 gui=NONE + hi Directory guifg=#a030a0 guibg=NONE gui=NONE + hi ErrorMsg guifg=fg guibg=#f0b090 gui=NONE + hi MoreMsg guifg=#489000 guibg=NONE gui=NONE + hi Title guifg=#a030a0 guibg=NONE gui=NONE + 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=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 + hi DiffText guifg=NONE guibg=#c0e080 gui=NONE + hi SignColumn guifg=fg guibg=#90e090 gui=NONE + + hi IncSearch guifg=White guibg=DarkRed gui=NONE + hi StatusLineNC guifg=fg guibg=#c0c0c0 gui=NONE + hi VertSplit guifg=fg guibg=#c0c0c0 gui=NONE + hi Underlined guifg=#6a5acd guibg=NONE gui=underline + hi Ignore guifg=bg guibg=NONE + " NOTE THIS IS IN THE WARM SECTION + if v:version >= 700 + if has('spell') + hi SpellBad guifg=NONE guibg=NONE guisp=#c03000 + hi SpellCap guifg=NONE guibg=NONE guisp=#2060a8 + hi SpellRare guifg=NONE guibg=NONE guisp=#a030a0 + hi SpellLocal guifg=NONE guibg=NONE guisp=#007068 + endif + hi Pmenu guifg=fg guibg=#e0b0e0 + hi PmenuSel guifg=#f0f0f0 guibg=#806060 gui=NONE + hi PmenuSbar guifg=fg guibg=#c0c0c0 gui=NONE + hi PmenuThumb guifg=fg guibg=#c0e080 gui=NONE + hi TabLine guifg=fg guibg=#c0c0c0 gui=NONE + hi TabLineFill guifg=fg guibg=#c0c0c0 gui=NONE + hi TabLineSel guifg=fg guibg=NONE gui=NONE + hi CursorColumn guifg=NONE guibg=#f0b090 + hi CursorLine guifg=NONE guibg=NONE gui=underline + hi MatchParen guifg=NONE guibg=#c0e080 + endif + + " LIGHT COLOR DEFINE END + + " Vim 7 added stuffs + if v:version >= 700 + hi Ignore gui=NONE + + " the gui=undercurl guisp could only support in Vim 7 + if has('spell') + hi SpellBad gui=undercurl + hi SpellCap gui=undercurl + hi SpellRare gui=undercurl + hi SpellLocal gui=undercurl + endif + hi TabLine gui=underline + hi TabLineFill gui=underline + hi CursorLine gui=underline + endif + + " For reversed stuffs, clear the reversed prop and set the bold prop again + hi IncSearch gui=bold + hi StatusLine gui=bold + hi StatusLineNC gui=bold + hi VertSplit gui=bold + hi Visual gui=bold + + " Enable the bold property + hi Question gui=bold + hi DiffText gui=bold + hi Statement gui=bold + hi Type gui=bold + hi MoreMsg gui=bold + hi ModeMsg gui=bold + hi NonText gui=bold + hi Title gui=bold + hi DiffDelete gui=bold + hi TabLineSel gui=bold + + " gui define for background=light end here + + " generally, a dumb terminal is dark, we assume the light terminal has 256 + " color support. + if &t_Co==8 || &t_Co==16 + set t_Co=256 + endif + if &t_Co==256 + " 256color light terminal support here + + hi Normal ctermfg=16 ctermbg=254 cterm=NONE + " Comment/Uncomment the following line to disable/enable transparency + "hi Normal ctermfg=16 ctermbg=NONE cterm=NONE + hi Search ctermfg=White ctermbg=DarkRed cterm=NONE + hi Visual ctermfg=NONE ctermbg=153 cterm=NONE + hi Cursor ctermfg=255 ctermbg=28 cterm=NONE + " hi CursorIM ctermfg=255 ctermbg=90 + hi Special ctermfg=94 ctermbg=NONE cterm=NONE + hi Comment ctermfg=58 ctermbg=NONE cterm=NONE + hi Number ctermfg=94 ctermbg=NONE cterm=NONE + hi Constant ctermfg=23 ctermbg=NONE cterm=NONE + hi StatusLine ctermfg=fg ctermbg=153 cterm=NONE + hi LineNr ctermfg=242 ctermbg=NONE cterm=NONE + hi Question ctermfg=fg ctermbg=186 cterm=NONE + hi PreProc ctermfg=29 ctermbg=NONE cterm=NONE + hi Statement ctermfg=25 ctermbg=NONE cterm=NONE + hi Type ctermfg=25 ctermbg=NONE cterm=NONE + hi Todo ctermfg=88 ctermbg=186 cterm=NONE + " NOTE THIS IS IN THE WARM SECTION + hi Error ctermfg=130 ctermbg=NONE cterm=NONE + hi Identifier ctermfg=133 ctermbg=NONE cterm=NONE + hi ModeMsg ctermfg=fg ctermbg=146 cterm=NONE + hi VisualNOS ctermfg=fg ctermbg=146 cterm=NONE + hi SpecialKey ctermfg=25 ctermbg=NONE cterm=NONE + hi NonText ctermfg=18 ctermbg=252 cterm=NONE + " Comment/Uncomment the following line to disable/enable transparency + "hi NonText ctermfg=18 ctermbg=NONE cterm=NONE + hi Directory ctermfg=133 ctermbg=NONE cterm=NONE + hi ErrorMsg ctermfg=fg ctermbg=216 cterm=NONE + hi MoreMsg ctermfg=64 ctermbg=NONE cterm=NONE + hi Title ctermfg=133 ctermbg=NONE cterm=NONE + 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=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 + hi DiffText ctermfg=NONE ctermbg=150 cterm=NONE + hi SignColumn ctermfg=fg ctermbg=114 cterm=NONE + + hi IncSearch ctermfg=White ctermbg=DarkRed cterm=NONE + hi StatusLineNC ctermfg=fg ctermbg=250 cterm=NONE + hi VertSplit ctermfg=fg ctermbg=250 cterm=NONE + hi Underlined ctermfg=62 ctermbg=NONE cterm=underline + hi Ignore ctermfg=bg ctermbg=NONE + " NOTE THIS IS IN THE WARM SECTION + if v:version >= 700 + if has('spell') + if 0 + " ctermsp is not supported in Vim7, we ignore it. + hi SpellBad cterm=undercurl ctermbg=NONE ctermfg=130 + hi SpellCap cterm=undercurl ctermbg=NONE ctermfg=25 + hi SpellRare cterm=undercurl ctermbg=NONE ctermfg=133 + hi SpellLocal cterm=undercurl ctermbg=NONE ctermfg=23 + else + hi SpellBad cterm=undercurl ctermbg=NONE ctermfg=NONE + hi SpellCap cterm=undercurl ctermbg=NONE ctermfg=NONE + hi SpellRare cterm=undercurl ctermbg=NONE ctermfg=NONE + hi SpellLocal cterm=undercurl ctermbg=NONE ctermfg=NONE + endif + endif + hi Pmenu ctermfg=fg ctermbg=182 + hi PmenuSel ctermfg=255 ctermbg=95 cterm=NONE + hi PmenuSbar ctermfg=fg ctermbg=250 cterm=NONE + hi PmenuThumb ctermfg=fg ctermbg=150 cterm=NONE + hi TabLine ctermfg=fg ctermbg=250 cterm=NONE + hi TabLineFill ctermfg=fg ctermbg=250 cterm=NONE + hi TabLineSel ctermfg=fg ctermbg=NONE cterm=NONE + hi CursorColumn ctermfg=NONE ctermbg=216 + hi CursorLine ctermfg=NONE ctermbg=NONE cterm=underline + hi MatchParen ctermfg=NONE ctermbg=150 + endif + + hi TabLine cterm=underline + hi TabLineFill cterm=underline + hi CursorLine cterm=underline + + " For reversed stuffs, clear the reversed prop and set the bold prop again + hi IncSearch cterm=bold + hi StatusLine cterm=bold + hi StatusLineNC cterm=bold + hi VertSplit cterm=bold + hi Visual cterm=bold + + hi NonText cterm=bold + hi Question cterm=bold + hi Title cterm=bold + hi DiffDelete cterm=bold + hi DiffText cterm=bold + hi Statement cterm=bold + hi Type cterm=bold + hi MoreMsg cterm=bold + hi ModeMsg cterm=bold + hi TabLineSel cterm=bold + + "hi lCursor ctermfg=bg ctermbg=fg cterm=NONE + endif " t_Co==256 + " }}}2 +elseif &background=='dark' + " for background=dark {{{2 + " DARK COLOR DEFINE START + + hi Normal guifg=#d0d0d0 guibg=#202020 gui=NONE + hi Comment guifg=#d0d090 guibg=NONE gui=NONE + hi Constant guifg=#80c0e0 guibg=NONE gui=NONE + hi Number guifg=#e0c060 guibg=NONE gui=NONE + hi Identifier guifg=#f0c0f0 guibg=NONE gui=NONE + hi Statement guifg=#c0d8f8 guibg=NONE gui=NONE + hi PreProc guifg=#60f080 guibg=NONE gui=NONE + hi Type guifg=#b0d0f0 guibg=NONE gui=NONE + hi Special guifg=#e0c060 guibg=NONE gui=NONE + hi Error guifg=#f08060 guibg=NONE gui=NONE + hi Todo guifg=#800000 guibg=#d0d090 gui=NONE + hi Search guifg=White guibg=DarkRed gui=NONE + hi Visual guifg=#000000 guibg=#a6caf0 gui=NONE + hi Cursor guifg=#000000 guibg=#00f000 gui=NONE + " NOTE THIS IS IN THE COOL SECTION + " hi CursorIM guifg=#000000 guibg=#f000f0 gui=NONE + hi StatusLine guifg=#000000 guibg=#a6caf0 gui=NONE + hi LineNr guifg=#b0b0b0 guibg=NONE gui=NONE + hi Question guifg=#000000 guibg=#d0d090 gui=NONE + hi ModeMsg guifg=fg guibg=#000080 gui=NONE + hi VisualNOS guifg=fg guibg=#000080 gui=NONE + hi SpecialKey guifg=#b0d0f0 guibg=NONE gui=NONE + hi NonText guifg=#202020 guibg=#202020 gui=NONE + hi Directory guifg=#80c0e0 guibg=NONE gui=NONE + hi ErrorMsg guifg=#d0d090 guibg=#800000 gui=NONE + hi MoreMsg guifg=#c0e080 guibg=NONE gui=NONE + hi Title guifg=#f0c0f0 guibg=NONE gui=NONE + 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=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 + hi DiffText guifg=#000000 guibg=#c0e080 gui=NONE + hi SignColumn guifg=#e0e0e0 guibg=#202020 gui=NONE + hi IncSearch guifg=White guibg=DarkRed gui=NONE + hi StatusLineNC guifg=#000000 guibg=#c0c0c0 gui=NONE + hi VertSplit guifg=#000000 guibg=#c0c0c0 gui=NONE + hi Underlined guifg=#80a0ff guibg=NONE gui=underline + hi Ignore guifg=#000000 guibg=NONE + " NOTE THIS IS IN THE COOL SECTION + if v:version >= 700 + if has('spell') + " the guisp= could only support in Vim 7 + hi SpellBad guifg=NONE guibg=NONE guisp=#f08060 + hi SpellCap guifg=NONE guibg=NONE guisp=#6080f0 + hi SpellRare guifg=NONE guibg=NONE guisp=#f0c0f0 + hi SpellLocal guifg=NONE guibg=NONE guisp=#c0d8f8 + endif + + hi Pmenu guifg=#dddddd guibg=#444444 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE + hi PmenuSel guifg=#000000 guibg=#ffffff gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE + + hi TabLine guifg=fg guibg=#008000 gui=NONE + hi TabLineFill guifg=fg guibg=#008000 gui=NONE + hi TabLineSel guifg=fg guibg=NONE gui=NONE + hi CursorColumn guifg=NONE guibg=#800000 gui=NONE + hi CursorLine guifg=NONE guibg=NONE gui=underline + hi MatchParen guifg=NONE guibg=#800080 + endif + + " DARK COLOR DEFINE END + + " Vim 7 added stuffs + if v:version >= 700 + hi Ignore gui=NONE + + " the gui=undercurl could only support in Vim 7 + if has('spell') + hi SpellBad gui=undercurl + hi SpellCap gui=undercurl + hi SpellRare gui=undercurl + hi SpellLocal gui=undercurl + endif + hi TabLine gui=underline + hi TabLineFill gui=underline + hi Underlined gui=underline + hi CursorLine gui=underline + endif + + " gui define for background=dark end here + + if &t_Co==8 || &t_Co==16 + " for 8-color and 16-color term + hi Normal ctermfg=LightGrey ctermbg=Black + hi Special ctermfg=Yellow ctermbg=bg + hi Comment ctermfg=DarkYellow ctermbg=bg + hi Constant ctermfg=Blue ctermbg=bg + hi Number ctermfg=Yellow ctermbg=bg + hi LineNr ctermfg=DarkGrey ctermbg=bg + hi PreProc ctermfg=Green ctermbg=bg + hi Statement ctermfg=Cyan ctermbg=bg + hi Type ctermfg=Cyan ctermbg=bg + hi Error ctermfg=Red ctermbg=bg + hi Identifier ctermfg=Magenta ctermbg=bg + hi SpecialKey ctermfg=Cyan ctermbg=bg + hi NonText ctermfg=Blue ctermbg=bg + hi Directory ctermfg=Blue ctermbg=bg + hi MoreMsg ctermfg=Green ctermbg=bg + hi Title ctermfg=Magenta ctermbg=bg + hi WarningMsg ctermfg=Red ctermbg=bg + hi DiffDelete ctermfg=Blue ctermbg=bg + + hi Search ctermfg=NONE ctermbg=DarkRed + hi Visual ctermfg=Black ctermbg=DarkCyan + hi Cursor ctermfg=Black ctermbg=Green + hi StatusLine ctermfg=Black ctermbg=DarkCyan + hi Question ctermfg=Black ctermbg=DarkYellow + hi Todo ctermfg=DarkRed ctermbg=DarkYellow + hi Folded 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 + hi WildMenu ctermfg=Black ctermbg=DarkYellow + hi SignColumn ctermfg=White ctermbg=DarkGreen + hi DiffText ctermfg=Black ctermbg=DarkYellow + + if v:version >= 700 + if has('spell') + hi SpellBad ctermfg=NONE ctermbg=DarkRed + hi SpellCap ctermfg=NONE ctermbg=DarkBlue + hi SpellRare ctermfg=NONE ctermbg=DarkMagenta + hi SpellLocal ctermfg=NONE ctermbg=DarkGreen + endif + + hi Pmenu ctermfg=White ctermbg=DarkGrey + hi PmenuSel ctermfg=Black ctermbg=White + + hi TabLine ctermfg=fg ctermbg=Black cterm=underline + hi TabLineFill ctermfg=fg ctermbg=Black cterm=underline + hi CursorColumn ctermfg=NONE ctermbg=DarkRed + + hi TabLineSel ctermfg=fg ctermbg=bg + hi CursorLine ctermfg=NONE ctermbg=bg cterm=underline + + hi MatchParen ctermfg=NONE ctermbg=DarkMagenta + endif + if &t_Co==8 + " 8 colour terminal support, this assumes 16 colour is available through + " setting the 'bold' attribute, will get bright foreground colour. + " However, the bright background color is not available for 8-color terms. + " + " You can manually set t_Co=16 in your .vimrc to see if your terminal + " supports 16 colours, + hi DiffText cterm=none + hi Visual cterm=none + hi Cursor cterm=none + hi Comment cterm=none + hi Todo cterm=none + hi StatusLine cterm=none + hi Question cterm=none + hi DiffChange cterm=none + hi ModeMsg cterm=none + hi VisualNOS cterm=none + hi ErrorMsg cterm=none + hi WildMenu cterm=none + hi DiffAdd cterm=none + hi Folded cterm=none + hi DiffDelete cterm=none + hi Normal cterm=none + hi PmenuThumb cterm=none + hi Search cterm=bold + hi Special cterm=bold + hi Constant cterm=bold + hi Number cterm=bold + hi LineNr cterm=bold + hi PreProc cterm=bold + hi Statement cterm=bold + hi Type cterm=bold + hi Error cterm=bold + hi Identifier cterm=bold + hi SpecialKey cterm=bold + hi NonText cterm=bold + hi MoreMsg cterm=bold + hi Title cterm=bold + hi WarningMsg cterm=bold + hi FoldColumn cterm=bold + hi SignColumn cterm=bold + hi Directory cterm=bold + hi DiffDelete cterm=bold + else + " Background > 7 is only available with 16 or more colors + + hi WarningMsg cterm=none + hi Search cterm=none + hi Visual cterm=none + hi Cursor cterm=none + hi Special cterm=none + hi Comment cterm=none + hi Constant cterm=none + hi Number cterm=none + hi LineNr cterm=none + hi PreProc cterm=none + hi Todo cterm=none + hi Error cterm=none + hi Identifier cterm=none + hi Folded cterm=none + hi SpecialKey cterm=none + hi Directory cterm=none + hi ErrorMsg cterm=none + hi Normal cterm=none + hi PmenuThumb cterm=none + hi WildMenu cterm=none + hi FoldColumn cterm=none + hi SignColumn cterm=none + hi DiffAdd cterm=none + hi DiffChange cterm=none + hi Question cterm=none + hi StatusLine cterm=none + hi DiffText cterm=none + hi IncSearch cterm=reverse + hi StatusLineNC cterm=reverse + hi VertSplit cterm=reverse + + " Well, well, bold font with color 0-7 is not possible. + " So, the Question, StatusLine, DiffText cannot act as expected. + + hi Statement cterm=none + hi Type cterm=none + hi MoreMsg cterm=none + hi ModeMsg cterm=none + hi NonText cterm=none + hi Title cterm=none + hi VisualNOS cterm=none + hi DiffDelete cterm=none + hi TabLineSel cterm=none + + endif + elseif &t_Co==256 + " 256color dark terminal support here + hi Normal ctermfg=252 ctermbg=234 cterm=NONE + " Comment/Uncomment the following line to disable/enable transparency + "hi Normal ctermfg=252 ctermbg=NONE cterm=NONE + hi Comment ctermfg=186 ctermbg=NONE cterm=NONE + hi Constant ctermfg=110 ctermbg=NONE cterm=NONE + hi Number ctermfg=179 ctermbg=NONE cterm=NONE + hi Identifier ctermfg=219 ctermbg=NONE cterm=NONE + hi Statement ctermfg=153 ctermbg=NONE cterm=NONE + hi PreProc ctermfg=84 ctermbg=NONE cterm=NONE + hi Type ctermfg=153 ctermbg=NONE cterm=NONE + hi Special ctermfg=179 ctermbg=NONE cterm=NONE + hi Error ctermfg=209 ctermbg=NONE cterm=NONE + hi Todo ctermfg=88 ctermbg=186 cterm=NONE + hi Search ctermfg=White ctermbg=DarkRed cterm=NONE + hi Visual ctermfg=16 ctermbg=153 cterm=NONE + hi Cursor ctermfg=16 ctermbg=46 cterm=NONE + " NOTE THIS IS IN THE COOL SECTION + " hi CursorIM ctermfg=16 ctermbg=201 cterm=NONE + hi StatusLine ctermfg=16 ctermbg=153 cterm=NONE + hi LineNr ctermfg=249 ctermbg=NONE cterm=NONE + hi Question ctermfg=16 ctermbg=186 cterm=NONE + hi ModeMsg ctermfg=fg ctermbg=18 cterm=NONE + hi VisualNOS ctermfg=fg ctermbg=18 cterm=NONE + hi SpecialKey ctermfg=153 ctermbg=NONE cterm=NONE + hi NonText ctermfg=69 ctermbg=233 cterm=NONE + " Comment/Uncomment the following line to disable/enable transparency + "hi NonText ctermfg=69 ctermbg=NONE cterm=NONE + hi Directory ctermfg=110 ctermbg=NONE cterm=NONE + hi ErrorMsg ctermfg=186 ctermbg=88 cterm=NONE + hi MoreMsg ctermfg=150 ctermbg=NONE cterm=NONE + hi Title ctermfg=219 ctermbg=NONE cterm=NONE + 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=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 + hi DiffText ctermfg=16 ctermbg=150 cterm=NONE + hi SignColumn ctermfg=254 ctermbg=28 cterm=NONE + hi IncSearch ctermfg=White ctermbg=DarkRed cterm=NONE + hi StatusLineNC ctermfg=16 ctermbg=250 cterm=NONE + hi VertSplit ctermfg=16 ctermbg=250 cterm=NONE + hi Underlined ctermfg=111 ctermbg=NONE cterm=underline + hi Ignore ctermfg=16 ctermbg=NONE + " NOTE THIS IS IN THE COOL SECTION + if v:version >= 700 + if has('spell') + " the ctermsp= is not supported in Vim 7 we simply ignored + if 0 + hi SpellBad cterm=undercurl ctermbg=NONE ctermfg=209 + hi SpellCap cterm=undercurl ctermbg=NONE ctermfg=69 + hi SpellRare cterm=undercurl ctermbg=NONE ctermfg=219 + hi SpellLocal cterm=undercurl ctermbg=NONE ctermfg=153 + else + hi SpellBad cterm=undercurl ctermbg=NONE ctermfg=NONE + hi SpellCap cterm=undercurl ctermbg=NONE ctermfg=NONE + hi SpellRare cterm=undercurl ctermbg=NONE ctermfg=NONE + hi SpellLocal cterm=undercurl ctermbg=NONE ctermfg=NONE + endif + endif + + hi Pmenu ctermfg=White ctermbg=DarkGrey + hi PmenuSel ctermfg=Black ctermbg=White cterm=NONE + + hi TabLine ctermfg=fg ctermbg=Black cterm=NONE + hi TabLineFill ctermfg=fg ctermbg=Black cterm=NONE + hi TabLineSel ctermfg=fg ctermbg=NONE cterm=NONE + + hi CursorColumn ctermfg=NONE ctermbg=88 cterm=NONE + hi CursorLine ctermfg=NONE ctermbg=NONE cterm=underline + hi MatchParen ctermfg=NONE ctermbg=90 + hi TabLine cterm=underline + hi TabLineFill cterm=underline + hi Underlined cterm=underline + hi CursorLine cterm=underline + endif + + endif " t_Co + + " }}}2 +endif + +" Links: +" +" COLOR LINKS DEFINE START + +hi link String Constant +" Character must be different from strings because in many languages +" (especially C, C++) a 'char' variable is scalar while 'string' is pointer, +" mistaken a 'char' for a 'string' will cause disaster! +hi link Character Number +hi link SpecialChar LineNr +hi link Tag Identifier +hi link cCppOut LineNr +" The following are not standard hi links, +" these are used by DrChip +hi link Warning MoreMsg +hi link Notice Constant +" these are used by Calendar +hi link CalToday PreProc +" these are used by TagList +hi link MyTagListTagName IncSearch +hi link MyTagListTagScope Constant + +hi TabLineFill guifg=#9098a0 guibg=#111111 +hi TabLine guifg=black guibg=#888888 +hi TabLineSel guifg=white guibg=#202020 gui=bold + +" COLOR LINKS DEFINE END + +" vim:et:nosta:sw=2:ts=8: +" vim600:fdm=marker:fdl=1: diff --git a/sources_forked/set_tabline/plugin/set_tabline.vim b/sources_forked/set_tabline/plugin/set_tabline.vim new file mode 100644 index 00000000..5d53e829 --- /dev/null +++ b/sources_forked/set_tabline/plugin/set_tabline.vim @@ -0,0 +1,30 @@ +function! CustomizedTabLine() + let s = '' + let t = tabpagenr() + let i = 1 + while i <= tabpagenr('$') + let buflist = tabpagebuflist(i) + let winnr = tabpagewinnr(i) + let s .= '%' . i . 'T' + let s .= (i == t ? '%1*' : '%2*') + let s .= ' ' + let s .= i . ':' + let s .= '%*' + let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#') + let file = bufname(buflist[winnr - 1]) + let file = fnamemodify(file, ':p:t') + if file == '' + let file = '[No Name]' + endif + let s .= file + let s .= ' ' + let i = i + 1 + endwhile + let s .= '%T%#TabLineFill#%=' + let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X') + return s +endfunction + +" Always show the tablilne +set stal=2 +set tabline=%!CustomizedTabLine() diff --git a/sources_forked/vim-irblack-forked/README b/sources_forked/vim-irblack-forked/README new file mode 100644 index 00000000..089fe730 --- /dev/null +++ b/sources_forked/vim-irblack-forked/README @@ -0,0 +1,11 @@ +This is a version of Infinite Red's vim theme (http://blog.infinitered.com/entries/show/8) packaged to work with Tim Pope's pathogen plugin (http://www.vim.org/scripts/script.php?script_id=2332). + +To use it (assuming you're using pathogen): + +- go to your bundle directory (.vim/bundle or .vimbundles) and clone the repo: + + git clone git@github.com:wgibbs/vim-irblack.git + +- edit your .vimrc and add: + + :colorscheme ir_black diff --git a/sources_forked/vim-irblack-forked/colors/ir_black.vim b/sources_forked/vim-irblack-forked/colors/ir_black.vim new file mode 100644 index 00000000..b06b12e2 --- /dev/null +++ b/sources_forked/vim-irblack-forked/colors/ir_black.vim @@ -0,0 +1,220 @@ +" ir_black color scheme +" More at: http://blog.infinitered.com/entries/show/8 + + +" ******************************************************************************** +" Standard colors used in all ir_black themes: +" Note, x:x:x are RGB values +" +" normal: #f6f3e8 +" +" string: #A8FF60 168:255:96 +" string inner (punc, code, etc): #00A0A0 0:160:160 +" number: #FF73FD 255:115:253 +" comments: #7C7C7C 124:124:124 +" keywords: #96CBFE 150:203:254 +" operators: white +" class: #FFFFB6 255:255:182 +" method declaration name: #FFD2A7 255:210:167 +" regular expression: #E9C062 233:192:98 +" regexp alternate: #FF8000 255:128:0 +" regexp alternate 2: #B18A3D 177:138:61 +" variable: #C6C5FE 198:197:254 +" +" Misc colors: +" red color (used for whatever): #FF6C60 255:108:96 +" light red: #FFB6B0 255:182:176 +" +" brown: #E18964 good for special +" +" lightpurpleish: #FFCCFF +" +" Interface colors: +" background color: black +" cursor (where underscore is used): #FFA560 255:165:96 +" cursor (where block is used): white +" visual selection: #1D1E2C +" current line: #151515 21:21:21 +" search selection: #07281C 7:40:28 +" line number: #3D3D3D 61:61:61 + + +" ******************************************************************************** +" The following are the preferred 16 colors for your terminal +" Colors Bright Colors +" Black #4E4E4E #7C7C7C +" Red #FF6C60 #FFB6B0 +" Green #A8FF60 #CEFFAB +" Yellow #FFFFB6 #FFFFCB +" Blue #96CBFE #FFFFCB +" Magenta #FF73FD #FF9CFE +" Cyan #C6C5FE #DFDFFE +" White #EEEEEE #FFFFFF + + +" ******************************************************************************** +set background=dark +hi clear + +if exists("syntax_on") + syntax reset +endif + +let colors_name = "ir_black" + + +"hi Example guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE + +" General colors +hi Normal guifg=#f6f3e8 guibg=black gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE +hi NonText guifg=#070707 guibg=black gui=NONE ctermfg=black ctermbg=NONE cterm=NONE + +hi Cursor guifg=black guibg=white gui=NONE ctermfg=black ctermbg=white cterm=reverse +hi LineNr guifg=#3D3D3D guibg=black gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE + +hi VertSplit guifg=#202020 guibg=#202020 gui=NONE ctermfg=darkgray ctermbg=darkgray cterm=NONE +hi StatusLine guifg=#CCCCCC guibg=#202020 gui=None ctermfg=white ctermbg=darkgray cterm=NONE +hi StatusLineNC guifg=black guibg=#202020 gui=NONE ctermfg=blue ctermbg=darkgray cterm=NONE + +hi Folded guifg=#a0a8b0 guibg=#384048 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE +hi Title guifg=#f6f3e8 guibg=NONE gui=bold ctermfg=NONE ctermbg=NONE cterm=NONE +hi Visual guifg=NONE guibg=DarkBlue gui=NONE ctermfg=NONE ctermbg=darkgray cterm=NONE + +hi SpecialKey guifg=#808080 guibg=#343434 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE + +hi WildMenu guifg=white guibg=DarkRed gui=NONE ctermfg=white ctermbg=DarkRed cterm=NONE +hi PmenuSbar guifg=black guibg=white gui=NONE ctermfg=black ctermbg=white cterm=NONE +"hi Ignore guifg=gray guibg=black gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE + +hi Error guifg=NONE guibg=red gui=undercurl ctermfg=white ctermbg=red cterm=NONE guisp=#FF6C60 " undercurl color +hi ErrorMsg guifg=white guibg=#FF6C60 gui=BOLD ctermfg=white ctermbg=red cterm=NONE +hi WarningMsg guifg=white guibg=#FF6C60 gui=BOLD ctermfg=white ctermbg=red cterm=NONE + +" Message displayed in lower left, such as --INSERT-- +hi ModeMsg guifg=black guibg=#C6C5FE gui=BOLD ctermfg=black ctermbg=cyan cterm=BOLD + +if version >= 700 " Vim 7.x specific colors + hi CursorLine guifg=NONE guibg=#121212 gui=NONE ctermfg=NONE ctermbg=NONE cterm=BOLD + hi CursorColumn guifg=NONE guibg=#121212 gui=NONE ctermfg=NONE ctermbg=NONE cterm=BOLD + hi MatchParen guifg=#f6f3e8 guibg=#857b6f gui=BOLD ctermfg=white ctermbg=darkgray cterm=NONE + hi Pmenu guifg=#f6f3e8 guibg=#444444 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE + hi PmenuSel guifg=#000000 guibg=#cae682 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE + hi Search guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE +endif + +" Syntax highlighting +hi Comment guifg=#7C7C7C guibg=NONE gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE +hi String guifg=#A8FF60 guibg=NONE gui=NONE ctermfg=green ctermbg=NONE cterm=NONE +hi Number guifg=#FF73FD guibg=NONE gui=NONE ctermfg=magenta ctermbg=NONE cterm=NONE + +hi Keyword guifg=#96CBFE guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE +hi PreProc guifg=#96CBFE guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE +hi Conditional guifg=#6699CC guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE " if else end + +hi Todo guifg=#8f8f8f guibg=NONE gui=NONE ctermfg=red ctermbg=NONE cterm=NONE +hi Constant guifg=#99CC99 guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE + +hi Identifier guifg=#C6C5FE guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE +hi Function guifg=#FFD2A7 guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE +hi Type guifg=#FFFFB6 guibg=NONE gui=NONE ctermfg=yellow ctermbg=NONE cterm=NONE +hi Statement guifg=#6699CC guibg=NONE gui=NONE ctermfg=lightblue ctermbg=NONE cterm=NONE + +hi Special guifg=#E18964 guibg=NONE gui=NONE ctermfg=white ctermbg=NONE cterm=NONE +hi Delimiter guifg=#00A0A0 guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE +hi Operator guifg=#6699CC guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE + +hi link Character Constant +hi link Boolean Constant +hi link Float Number +hi link Repeat Statement +hi link Label Statement +hi link Exception Statement +hi link Include PreProc +hi link Define PreProc +hi link Macro PreProc +hi link PreCondit PreProc +hi link StorageClass Type +hi link Structure Type +hi link Typedef Type +hi link Tag Special +hi link SpecialChar Special +hi link SpecialComment Special +hi link Debug Special + + +" Special for Ruby +hi rubyRegexp guifg=#B18A3D guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE +hi rubyRegexpDelimiter guifg=#FF8000 guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE +hi rubyEscape guifg=white guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE +hi rubyInterpolationDelimiter guifg=#00A0A0 guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE +hi rubyControl guifg=#6699CC guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE "and break, etc +"hi rubyGlobalVariable guifg=#FFCCFF guibg=NONE gui=NONE ctermfg=lightblue ctermbg=NONE cterm=NONE "yield +hi rubyStringDelimiter guifg=#336633 guibg=NONE gui=NONE ctermfg=lightgreen ctermbg=NONE cterm=NONE +"rubyInclude +"rubySharpBang +"rubyAccess +"rubyPredefinedVariable +"rubyBoolean +"rubyClassVariable +"rubyBeginEnd +"rubyRepeatModifier +"hi link rubyArrayDelimiter Special " [ , , ] +"rubyCurlyBlock { , , } + +hi link rubyClass Keyword +hi link rubyModule Keyword +hi link rubyKeyword Keyword +hi link rubyOperator Operator +hi link rubyIdentifier Identifier +hi link rubyInstanceVariable Identifier +hi link rubyGlobalVariable Identifier +hi link rubyClassVariable Identifier +hi link rubyConstant Type + + +" Special for Java +" hi link javaClassDecl Type +hi link javaScopeDecl Identifier +hi link javaCommentTitle javaDocSeeTag +hi link javaDocTags javaDocSeeTag +hi link javaDocParam javaDocSeeTag +hi link javaDocSeeTagParam javaDocSeeTag + +hi javaDocSeeTag guifg=#CCCCCC guibg=NONE gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE +hi javaDocSeeTag guifg=#CCCCCC guibg=NONE gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE +"hi javaClassDecl guifg=#CCFFCC guibg=NONE gui=NONE ctermfg=white ctermbg=NONE cterm=NONE + + +" Special for XML +hi link xmlTag Keyword +hi link xmlTagName Conditional +hi link xmlEndTag Identifier + + +" Special for HTML +hi link htmlTag Keyword +hi link htmlTagName Conditional +hi link htmlEndTag Identifier + + +" Special for Javascript +hi link javaScriptNumber Number + + +" Special for Python +"hi link pythonEscape Keyword + + +" Special for CSharp +hi link csXmlTag Keyword + + +" Amix customizations + +" Tab line +hi TabLineFill guifg=#000000 guibg=#000000 gui=NONE +hi TabLine guifg=black guibg=#888888 gui=NONE +hi TabLineSel guifg=white guibg=#000000 gui=bold + +" Search higlights +hi Search guifg=White guibg=DarkRed gui=NONE diff --git a/sources_forked/vim-peepopen/README b/sources_forked/vim-peepopen/README new file mode 100644 index 00000000..e69de29b diff --git a/sources_forked/vim-peepopen/README.md b/sources_forked/vim-peepopen/README.md new file mode 100644 index 00000000..290acee8 --- /dev/null +++ b/sources_forked/vim-peepopen/README.md @@ -0,0 +1,38 @@ +vim-peepopen +============= + +A plugin for the Vim text editor. PeepOpen provides fuzzy search of filenames and paths in a programming project. + +Installation +------------ + +Get the PeepOpen.app and open it at least once to approve the Mac OS X security dialog. + +Standard: + +Copy `peepopen.vim` to your `~/.vim/plugin` directory. + +With Tim Pope's [Pathogen](http://github.com/tpope/vim-pathogen): + +Copy the entire `vim-peepopen` plugin directory to your `~/.vim/bundle` directory. + +Usage +----- + +`p` opens the current project directory with the PeepOpen application. + +Use the [vim-rooter](https://github.com/airblade/vim-rooter) plugin for automatic assignment of the current working directory for projects stored in Git. + +(Leader is mapped to '\' by default) + +### Options +Automatically quit PeepOpen when Vim exits. + +`let p:peepopen_quit = 1` + +Credits +------- + +- Initial Vim Plugin by [Andrew Stewart](http://www.airbladesoftware.com/). +- Some plugin boilerplate from [Rein Henrichs](http://reinh.com/). + diff --git a/sources_forked/vim-peepopen/plugin/peepopen.vim b/sources_forked/vim-peepopen/plugin/peepopen.vim new file mode 100644 index 00000000..eadb413e --- /dev/null +++ b/sources_forked/vim-peepopen/plugin/peepopen.vim @@ -0,0 +1,57 @@ +" plugin/peepopen.vim +" Author: Geoffrey Grosenbach +" License: MIT License + +" Install this file as plugin/peepopen.vim. + +" If you prefer Command-T, use this snippet in your .gvimrc: + +" if has("gui_macvim") +" macmenu &File.New\ Tab key= +" map PeepOpen +" end + +" ============================================================================ + +" Exit quickly when: +" - this plugin was already loaded (or disabled) +" - when 'compatible' is set +if &cp || exists("g:peepopen_loaded") && g:peepopen_loaded + finish +endif +let g:peepopen_loaded = 1 +let s:save_cpo = &cpo +set cpo&vim + +if !exists('g:peepopen_quit') + let g:peepopen_quit = 0 +endif + +function s:LaunchPeepOpenViaVim() + silent exe "!open -a PeepOpen " . shellescape(getcwd()) + redraw! +endfunction + +function s:QuitPeepOpenViaVim() + silent exe '!ps ax | grep PeepOpen | grep -v grep | awk "{ print $1 }" | xargs kill -QUIT' +endfunction + +command! PeepOpen :call LaunchPeepOpenViaVim() +command! PeepQuit :call QuitPeepOpenViaVim() + +if has('autocmd') && exists('g:peepopen_quit') && g:peepopen_quit + au VimLeave * :call QuitPeepOpenViaVim() +endif + +noremap ${2} diff --git a/sources_non_forked/snipmate-snippets/html/script/inline_script.snippet b/sources_non_forked/snipmate-snippets/html/script/inline_script.snippet new file mode 100644 index 00000000..35e078b3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/script/inline_script.snippet @@ -0,0 +1,5 @@ + diff --git a/sources_non_forked/snipmate-snippets/html/select.snippet b/sources_non_forked/snipmate-snippets/html/select.snippet new file mode 100644 index 00000000..252e3f77 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/select.snippet @@ -0,0 +1,3 @@ + diff --git a/sources_non_forked/snipmate-snippets/html/skel/basic.snippet b/sources_non_forked/snipmate-snippets/html/skel/basic.snippet new file mode 100644 index 00000000..61ec2444 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/skel/basic.snippet @@ -0,0 +1,13 @@ + + + + + ${1:Page Title} + + + + + ${2} + + diff --git a/sources_non_forked/snipmate-snippets/html/skel/basic_with_meta.snippet b/sources_non_forked/snipmate-snippets/html/skel/basic_with_meta.snippet new file mode 100644 index 00000000..b6de9f8d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/skel/basic_with_meta.snippet @@ -0,0 +1,15 @@ + + + + + ${1:Page Title} + + + + + + + ${2} + + diff --git a/sources_non_forked/snipmate-snippets/html/style.snippet b/sources_non_forked/snipmate-snippets/html/style.snippet new file mode 100644 index 00000000..26ae0fe9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/style.snippet @@ -0,0 +1,3 @@ + diff --git a/sources_non_forked/snipmate-snippets/html/t.snippet b/sources_non_forked/snipmate-snippets/html/t.snippet new file mode 100644 index 00000000..ef504276 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/t.snippet @@ -0,0 +1,3 @@ +<${1:div}${2}> + ${3} +${4} diff --git a/sources_non_forked/snipmate-snippets/html/table/basic.snippet b/sources_non_forked/snipmate-snippets/html/table/basic.snippet new file mode 100644 index 00000000..2100d13d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/table/basic.snippet @@ -0,0 +1,3 @@ + + ${2} +
diff --git a/sources_non_forked/snipmate-snippets/html/table/hardcore.snippet b/sources_non_forked/snipmate-snippets/html/table/hardcore.snippet new file mode 100644 index 00000000..35fa01ae --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/table/hardcore.snippet @@ -0,0 +1,9 @@ ++>> + + <++> + + + + + + diff --git a/sources_non_forked/snipmate-snippets/html/textarea.snippet b/sources_non_forked/snipmate-snippets/html/textarea.snippet new file mode 100644 index 00000000..0b3fb84b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/html/textarea.snippet @@ -0,0 +1 @@ + diff --git a/sources_non_forked/snipmate-snippets/java/class/basic+constructor+main.snippet b/sources_non_forked/snipmate-snippets/java/class/basic+constructor+main.snippet new file mode 100644 index 00000000..3bd770e2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/class/basic+constructor+main.snippet @@ -0,0 +1,17 @@ +/** + * class $2 + * @author ${4:`g:snips_author`} + */ +${1:public} class ${2:`Snippet_JavaClassNameFromFilename()`}${3} { + + /** + * Constructor for $2 + */ + public $2(${4}) { + ${5} + } + + public static void main(String args[]) { + } + +} diff --git a/sources_non_forked/snipmate-snippets/java/class/basic+constructor.snippet b/sources_non_forked/snipmate-snippets/java/class/basic+constructor.snippet new file mode 100644 index 00000000..05eabefa --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/class/basic+constructor.snippet @@ -0,0 +1,14 @@ +/** + * class $2 + * @author ${4:`g:snips_author`} + */ +${1:public} class ${2:`Snippet_JavaClassNameFromFilename()`}${3} { + + /** + * Constructor for $2 + */ + public $2(${5}){ + ${6} + } + +} diff --git a/sources_non_forked/snipmate-snippets/java/class/basic.snippet b/sources_non_forked/snipmate-snippets/java/class/basic.snippet new file mode 100644 index 00000000..05eabefa --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/class/basic.snippet @@ -0,0 +1,14 @@ +/** + * class $2 + * @author ${4:`g:snips_author`} + */ +${1:public} class ${2:`Snippet_JavaClassNameFromFilename()`}${3} { + + /** + * Constructor for $2 + */ + public $2(${5}){ + ${6} + } + +} diff --git a/sources_non_forked/snipmate-snippets/java/for.snippet b/sources_non_forked/snipmate-snippets/java/for.snippet new file mode 100644 index 00000000..70a41086 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/for.snippet @@ -0,0 +1,3 @@ +for(${1:int i=0}; ${2:condition}; ${3:i++}){ + ${4} +} diff --git a/sources_non_forked/snipmate-snippets/java/gs.snippet b/sources_non_forked/snipmate-snippets/java/gs.snippet new file mode 100644 index 00000000..954a9a09 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/gs.snippet @@ -0,0 +1,9 @@ +//getter for $3 +public ${2:variable_type} get${1:VariableName}() { + return ${3:variableName}; +} + +//setter for $3 +public void set$1($2 $3) { + this.$3 = $3; +}${4} diff --git a/sources_non_forked/snipmate-snippets/java/if.snippet b/sources_non_forked/snipmate-snippets/java/if.snippet new file mode 100644 index 00000000..b9d1c5c3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/if.snippet @@ -0,0 +1,3 @@ +if(${1}){ + ${2} +} diff --git a/sources_non_forked/snipmate-snippets/java/ife.snippet b/sources_non_forked/snipmate-snippets/java/ife.snippet new file mode 100644 index 00000000..a7e43d09 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/ife.snippet @@ -0,0 +1,4 @@ +if(${1}){ + ${2} +}else{ +} diff --git a/sources_non_forked/snipmate-snippets/java/log.snippet b/sources_non_forked/snipmate-snippets/java/log.snippet new file mode 100644 index 00000000..abb7c7d6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/log.snippet @@ -0,0 +1 @@ +System.${1:out}.println(${2}); diff --git a/sources_non_forked/snipmate-snippets/java/m.snippet b/sources_non_forked/snipmate-snippets/java/m.snippet new file mode 100644 index 00000000..67bf3fb0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/java/m.snippet @@ -0,0 +1,8 @@ +/** + * ${7:Method Description} + * ${5} + * @return ${6} + */ +${1:public} ${2:void} ${3:methodName}(${4}) { + ${8} +} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/add.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/add.snippet new file mode 100644 index 00000000..3bf9756d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/add.snippet @@ -0,0 +1 @@ +${1:obj}.add('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/addClass.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/addClass.snippet new file mode 100644 index 00000000..68007744 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/addClass.snippet @@ -0,0 +1 @@ +${1:obj}.addClass('${2:class name}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/after.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/after.snippet new file mode 100644 index 00000000..34d1956d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/after.snippet @@ -0,0 +1 @@ +${1:obj}.after('${2:Some text and bold!}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajax.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajax.snippet new file mode 100644 index 00000000..5453a257 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajax.snippet @@ -0,0 +1,18 @@ +$.ajax({ + url: "${1:mydomain.com/url}", + type: "${2:POST}", + dataType: "${3:xml/html/script/json}", + data: $.param( $("${4:Element or Expression}") ), + + complete: function() { + ${5://called when complete} + }, + + success: function() { + ${6://called when successful} + }, + + error: function() { + ${7://called when there is an error} + }, +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxerror.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxerror.snippet new file mode 100644 index 00000000..0f8ccdaf --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxerror.snippet @@ -0,0 +1,4 @@ +.ajaxError(function(${1:request, settings}) { + ${2://stuff to do when an AJAX call returns an error}; +}); +${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxget.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxget.snippet new file mode 100644 index 00000000..1489859a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxget.snippet @@ -0,0 +1,3 @@ +$.get('${1:/test/ajax-test.xml}', function(xml){ + ${2:alert( ("title",xml).text() ) //optional stuff to do after get;} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxgetif.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxgetif.snippet new file mode 100644 index 00000000..0f4d1ef0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxgetif.snippet @@ -0,0 +1,3 @@ +$.getIfModified('${1:/test/test.cgi}', function(data){ + ${2:alert( "Data loaded: " + data ) //optional stuff to do after get;} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxpost.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxpost.snippet new file mode 100644 index 00000000..f62bf102 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxpost.snippet @@ -0,0 +1,5 @@ +$.post('<+/path/to/file.cgi+>',{ + <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+>}, + function(){ + <+//stuff to do after event occurs;+> +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsend.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsend.snippet new file mode 100644 index 00000000..4b74cd98 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsend.snippet @@ -0,0 +1,4 @@ +.ajaxSend(function(${1:request, settings}) { + ${2://stuff to do when an AJAX call returns an error}; +}); +${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsetup.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsetup.snippet new file mode 100644 index 00000000..c5b4ad02 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsetup.snippet @@ -0,0 +1,18 @@ +$.ajaxSetup({ + url: "${1:mydomain.com/url}", + type: "${2:POST}", + dataType: "${3:xml/html/script/json}", + data: $.param( $("${4:Element or Expression}") ), + + complete: function() { + ${5://called when complete} + }, + + success: function() { + ${6://called when successful} + }, + + error: function() { + ${7://called when there is an error} + }, +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxstart.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxstart.snippet new file mode 100644 index 00000000..3caafd58 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxstart.snippet @@ -0,0 +1,4 @@ +$.ajaxStart(function() { + ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; +}); +${2} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxstop.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxstop.snippet new file mode 100644 index 00000000..6088a9f5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxstop.snippet @@ -0,0 +1,4 @@ +$.ajaxStop(function() { + ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; +}); +${2} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsuccess.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsuccess.snippet new file mode 100644 index 00000000..ba2247dc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ajaxsuccess.snippet @@ -0,0 +1,4 @@ +$.ajaxSuccess(function() { + ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; +}); +${2} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/animate.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/animate.snippet new file mode 100644 index 00000000..19135327 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/animate.snippet @@ -0,0 +1 @@ +${1:obj}.animate({${2:param1: value1, param2: value2}}, ${3:speed})${4} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/append.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/append.snippet new file mode 100644 index 00000000..bc4ff4d3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/append.snippet @@ -0,0 +1 @@ +${1:obj}.append('${2:Some text and bold!}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/appendTo.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/appendTo.snippet new file mode 100644 index 00000000..97883710 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/appendTo.snippet @@ -0,0 +1 @@ +${1:obj}.appendTo('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/attr.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/attr.snippet new file mode 100644 index 00000000..fb7e2f42 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/attr.snippet @@ -0,0 +1 @@ +${1:obj}.attr('${2:attribute}', '${3:value}')${4} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/attrm.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/attrm.snippet new file mode 100644 index 00000000..15685512 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/attrm.snippet @@ -0,0 +1 @@ +${1:obj}.attr({'${2:attr1}': '${3:value1}', '${4:attr2}': '${5:value2}'})${6} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/before.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/before.snippet new file mode 100644 index 00000000..e12c4aed --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/before.snippet @@ -0,0 +1 @@ +${1:obj}.before('${2:Some text and bold!}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/bind.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/bind.snippet new file mode 100644 index 00000000..dda284d9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/bind.snippet @@ -0,0 +1,3 @@ +${1:obj}.bind('${2:event name}', function(${3:event}) { + ${4:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/blur.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/blur.snippet new file mode 100644 index 00000000..674623db --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/blur.snippet @@ -0,0 +1,3 @@ +${1:obj}.blur(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/change.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/change.snippet new file mode 100644 index 00000000..184f8a99 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/change.snippet @@ -0,0 +1,3 @@ +${1:obj}.change(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/children.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/children.snippet new file mode 100644 index 00000000..2db688b1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/children.snippet @@ -0,0 +1 @@ +${1:obj}.children('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/click.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/click.snippet new file mode 100644 index 00000000..d17a047e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/click.snippet @@ -0,0 +1,3 @@ +${1:obj}.click(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/clone.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/clone.snippet new file mode 100644 index 00000000..83b0b421 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/clone.snippet @@ -0,0 +1 @@ +${1:obj}.clone()${2} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/contains.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/contains.snippet new file mode 100644 index 00000000..2a073948 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/contains.snippet @@ -0,0 +1 @@ +${1:obj}.contains('${2:text to find}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/css.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/css.snippet new file mode 100644 index 00000000..408199eb --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/css.snippet @@ -0,0 +1 @@ +${1:obj}.css('${2:attribute}', '${3:value}')${4} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/cssm.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/cssm.snippet new file mode 100644 index 00000000..7eebe1e4 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/cssm.snippet @@ -0,0 +1 @@ +${1:obj}.css({${2:attribute1}: '${3:value1}', ${4:attribute2}: '${5:value2}'})${6} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/dblclick.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/dblclick.snippet new file mode 100644 index 00000000..4b2d6b2a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/dblclick.snippet @@ -0,0 +1,3 @@ +${1:obj}.dblclick(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/each.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/each.snippet new file mode 100644 index 00000000..05beed2e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/each.snippet @@ -0,0 +1,3 @@ +${1:obj}.each(function(index) { + ${2:this.innerHTML = this + " is the element, " + index + " is the position";} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/el.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/el.snippet new file mode 100644 index 00000000..d2065238 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/el.snippet @@ -0,0 +1 @@ +$('${1}')${2:} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/eltrim.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/eltrim.snippet new file mode 100644 index 00000000..9cc0d692 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/eltrim.snippet @@ -0,0 +1 @@ +$.trim('${1:string}')${2} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/end.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/end.snippet new file mode 100644 index 00000000..293102c4 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/end.snippet @@ -0,0 +1 @@ +${1:obj}.end()${2} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/error.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/error.snippet new file mode 100644 index 00000000..23b0e650 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/error.snippet @@ -0,0 +1,3 @@ +${1:obj}.error(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/fadein.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/fadein.snippet new file mode 100644 index 00000000..549d8464 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/fadein.snippet @@ -0,0 +1 @@ +${1:obj}.fadeIn('${2:slow/400/fast}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/fadeinc.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/fadeinc.snippet new file mode 100644 index 00000000..9090853e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/fadeinc.snippet @@ -0,0 +1,3 @@ +${1:obj}.fadeIn('slow/400/fast', function() { + ${2://Stuff to do *after* the animation takes place}; +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/fadeout.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/fadeout.snippet new file mode 100644 index 00000000..24d6c763 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/fadeout.snippet @@ -0,0 +1 @@ +${1:obj}.fadeOut('${2:slow/400/fast}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/fadeoutc.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/fadeoutc.snippet new file mode 100644 index 00000000..76d54571 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/fadeoutc.snippet @@ -0,0 +1,3 @@ +${1:obj}.fadeOut('slow/400/fast', function() { + ${2://Stuff to do *after* the animation takes place}; +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/fadeto.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/fadeto.snippet new file mode 100644 index 00000000..b0e584aa --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/fadeto.snippet @@ -0,0 +1 @@ +${1:obj}.fadeTo('${2:slow/400/fast}', ${3:0.5})${4} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/fadetoc.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/fadetoc.snippet new file mode 100644 index 00000000..17243b4c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/fadetoc.snippet @@ -0,0 +1,3 @@ +${1:obj}.fadeTo('slow/400/fast', ${2:0.5}, function() { + ${3://Stuff to do *after* the animation takes place}; +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/filter.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/filter.snippet new file mode 100644 index 00000000..d33fdf2b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/filter.snippet @@ -0,0 +1 @@ +${1:obj}.filter('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/find.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/find.snippet new file mode 100644 index 00000000..1791e912 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/find.snippet @@ -0,0 +1 @@ +${1:obj}.find('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/focus.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/focus.snippet new file mode 100644 index 00000000..3b1b5719 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/focus.snippet @@ -0,0 +1,3 @@ +${1:obj}.focus(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/get.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/get.snippet new file mode 100644 index 00000000..4374c183 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/get.snippet @@ -0,0 +1 @@ +${1:obj}.get(${2:element index})${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/getjson.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/getjson.snippet new file mode 100644 index 00000000..518d676d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/getjson.snippet @@ -0,0 +1,5 @@ +$.getJSON('<+/path/to/file.cgi+>',{ + <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+>}, + function(json){ + <+//stuff to do after event occurs;+> +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/getscript.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/getscript.snippet new file mode 100644 index 00000000..0b62d90b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/getscript.snippet @@ -0,0 +1,3 @@ +$.getScript('${1:somescript.js}', function(){ + ${2://optional stuff to do after getScript;} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/height.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/height.snippet new file mode 100644 index 00000000..1515d5c6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/height.snippet @@ -0,0 +1 @@ +${1:obj}.height(${2:integer})${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/hide.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/hide.snippet new file mode 100644 index 00000000..c8071cbc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/hide.snippet @@ -0,0 +1 @@ +${1:obj}.hide('${2:slow/400/fast}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/hidec.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/hidec.snippet new file mode 100644 index 00000000..62f2280a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/hidec.snippet @@ -0,0 +1,3 @@ +${1:obj}.hide('${2:slow/400/fast}', function() { + ${3://Stuff to do *after* the animation takes place} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/hover.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/hover.snippet new file mode 100644 index 00000000..d8468c1a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/hover.snippet @@ -0,0 +1,5 @@ +${1:obj}.hover(function() { + ${2:// Stuff to do when the mouse enters the element;} +}, function() { + ${3:// Stuff to do when the mouse leaves the element;} +});${4} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/html.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/html.snippet new file mode 100644 index 00000000..0c5a25e1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/html.snippet @@ -0,0 +1 @@ +${1:obj}.html('${2:Some text and bold!}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/insertAfter.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/insertAfter.snippet new file mode 100644 index 00000000..66c389eb --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/insertAfter.snippet @@ -0,0 +1 @@ +${1:obj}.insertAfter('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/insertBefore.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/insertBefore.snippet new file mode 100644 index 00000000..e7090d4d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/insertBefore.snippet @@ -0,0 +1 @@ +${1:obj}.insertBefore('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/is.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/is.snippet new file mode 100644 index 00000000..28eefb02 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/is.snippet @@ -0,0 +1 @@ +${1:obj}.is('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/load.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/load.snippet new file mode 100644 index 00000000..1f09fbc9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/load.snippet @@ -0,0 +1,3 @@ +${1:obj}.load(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/loadf.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/loadf.snippet new file mode 100644 index 00000000..2e7d9c8b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/loadf.snippet @@ -0,0 +1,3 @@ +<+obj+>.load('<+/path/to/file.htm+>', { <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+> }, function() { + <+// Stuff to do after the page is loaded+> +}); \ No newline at end of file diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/loadif.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/loadif.snippet new file mode 100644 index 00000000..fe45d05a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/loadif.snippet @@ -0,0 +1,3 @@ +<+obj+>.loadIfModified('<+/path/to/file.htm+>', { <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+> }, function() { + <+// Stuff to do after the page is loaded+> +}); \ No newline at end of file diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/mdown.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/mdown.snippet new file mode 100644 index 00000000..3be70e1b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/mdown.snippet @@ -0,0 +1,3 @@ +${1:obj}.mousedown(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/mmove.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/mmove.snippet new file mode 100644 index 00000000..eb7ac052 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/mmove.snippet @@ -0,0 +1,3 @@ +${1:obj}.mousemove(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/mout.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/mout.snippet new file mode 100644 index 00000000..f2142756 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/mout.snippet @@ -0,0 +1,3 @@ +${1:obj}.mouseout(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/mover.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/mover.snippet new file mode 100644 index 00000000..f1eb19cc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/mover.snippet @@ -0,0 +1,3 @@ +${1:obj}.mouseover(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/mup.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/mup.snippet new file mode 100644 index 00000000..04fb36a3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/mup.snippet @@ -0,0 +1,3 @@ +${1:obj}.mouseup(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/next.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/next.snippet new file mode 100644 index 00000000..b6a65281 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/next.snippet @@ -0,0 +1 @@ +${1:obj}.next('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/not.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/not.snippet new file mode 100644 index 00000000..c6a217f6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/not.snippet @@ -0,0 +1 @@ +${1:obj}.not('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/one.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/one.snippet new file mode 100644 index 00000000..cacdbfb5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/one.snippet @@ -0,0 +1,3 @@ +${1:obj}.one('${2:event name}', function(${3:event}) { + ${4:// Act on the event once} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/parent.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/parent.snippet new file mode 100644 index 00000000..0490f05a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/parent.snippet @@ -0,0 +1 @@ +${1:obj}.parent('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/parents.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/parents.snippet new file mode 100644 index 00000000..fb0bd131 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/parents.snippet @@ -0,0 +1 @@ +${1:obj}.parents('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/prepend.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/prepend.snippet new file mode 100644 index 00000000..bc41d48f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/prepend.snippet @@ -0,0 +1 @@ +${1:obj}.prepend('${2:Some text and bold!}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/prependto.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/prependto.snippet new file mode 100644 index 00000000..e4406957 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/prependto.snippet @@ -0,0 +1 @@ +${1:obj}.prependTo('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/prev.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/prev.snippet new file mode 100644 index 00000000..b7aba645 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/prev.snippet @@ -0,0 +1 @@ +${1:obj}.prev('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/ready.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/ready.snippet new file mode 100644 index 00000000..d0005318 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/ready.snippet @@ -0,0 +1,3 @@ +$(document).ready(function() { + ${1:// Stuff to do as soon as the DOM is ready;} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/remove.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/remove.snippet new file mode 100644 index 00000000..4c976a17 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/remove.snippet @@ -0,0 +1 @@ +${1:obj}.remove()${2} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/removeattr.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/removeattr.snippet new file mode 100644 index 00000000..267d584a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/removeattr.snippet @@ -0,0 +1 @@ +${1:obj}.removeAttr('${2:attribute name}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/removeclass.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/removeclass.snippet new file mode 100644 index 00000000..f5538030 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/removeclass.snippet @@ -0,0 +1 @@ +${1:obj}.removeClass('${2:class name}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/reset.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/reset.snippet new file mode 100644 index 00000000..777af958 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/reset.snippet @@ -0,0 +1,3 @@ +${1:obj}.reset(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/resize.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/resize.snippet new file mode 100644 index 00000000..b46ac0a0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/resize.snippet @@ -0,0 +1,3 @@ +${1:obj}.resize(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/scroll.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/scroll.snippet new file mode 100644 index 00000000..7a512442 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/scroll.snippet @@ -0,0 +1,3 @@ +${1:obj}.scroll(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/sdown.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/sdown.snippet new file mode 100644 index 00000000..b39840e9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/sdown.snippet @@ -0,0 +1 @@ +${1:obj}.slideDown('${2:slow/400/fast}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/sdownc.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/sdownc.snippet new file mode 100644 index 00000000..3404b783 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/sdownc.snippet @@ -0,0 +1,3 @@ +${1:obj}.slideDown('${2:slow/400/fast}', function() { + ${3://Stuff to do *after* the animation takes place}; +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/sdupc.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/sdupc.snippet new file mode 100644 index 00000000..873c6657 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/sdupc.snippet @@ -0,0 +1,3 @@ +${1:obj}.slideUp('${2:slow/400/fast}', function() { + ${3://Stuff to do *after* the animation takes place}; +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/select.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/select.snippet new file mode 100644 index 00000000..986437ed --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/select.snippet @@ -0,0 +1,3 @@ +${1:obj}.select(function() { + ${2:// Act on the event} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/show.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/show.snippet new file mode 100644 index 00000000..31819b1e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/show.snippet @@ -0,0 +1 @@ +${1:obj}.show('${2:slow/400/fast}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/showc.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/showc.snippet new file mode 100644 index 00000000..6dc5bacc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/showc.snippet @@ -0,0 +1,3 @@ +${1:obj}.show('${2:slow/400/fast}', function() { + ${3://Stuff to do *after* the animation takes place} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/sib.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/sib.snippet new file mode 100644 index 00000000..014f1f79 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/sib.snippet @@ -0,0 +1 @@ +${1:obj}.siblings('${2:selector expression}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/size.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/size.snippet new file mode 100644 index 00000000..1ba15439 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/size.snippet @@ -0,0 +1 @@ +${1:obj}.size()${2} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/stoggle.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/stoggle.snippet new file mode 100644 index 00000000..daba37d2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/stoggle.snippet @@ -0,0 +1 @@ +${1:obj}.slideToggle('${2:slow/400/fast}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/submit.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/submit.snippet new file mode 100644 index 00000000..ae98d83e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/submit.snippet @@ -0,0 +1,3 @@ +${1:obj}.submit(function() { + ${2:// Act on the event once} +}); diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/sup.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/sup.snippet new file mode 100644 index 00000000..d844a68e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/sup.snippet @@ -0,0 +1 @@ +${1:obj}.slideUp('${2:slow/400/fast}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/text.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/text.snippet new file mode 100644 index 00000000..5f667c07 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/text.snippet @@ -0,0 +1 @@ +${1:obj}.text(${2:'some text'})${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/this.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/this.snippet new file mode 100644 index 00000000..b3cee8d3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/this.snippet @@ -0,0 +1 @@ +$(this)${1} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/tog.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/tog.snippet new file mode 100644 index 00000000..54f5f17a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/tog.snippet @@ -0,0 +1,6 @@ +${1:obj}.toggle(function() { + ${2:// Stuff to do every *odd* time the element is clicked;} +}, function() { + ${3:// Stuff to do every *even* time the element is clicked;} +}); +${4} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/togclass.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/togclass.snippet new file mode 100644 index 00000000..023a4b7d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/togclass.snippet @@ -0,0 +1 @@ +${1:obj}.toggleClass('${2:class name}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/togsh.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/togsh.snippet new file mode 100644 index 00000000..265a62d0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/togsh.snippet @@ -0,0 +1 @@ +${1:obj}.toggle('${2:slow/400/fast}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/trig.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/trig.snippet new file mode 100644 index 00000000..f7105e08 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/trig.snippet @@ -0,0 +1 @@ +${1:obj}.trigger('${2:event name}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/unbind.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/unbind.snippet new file mode 100644 index 00000000..0fe423d5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/unbind.snippet @@ -0,0 +1 @@ +${1:obj}.unbind('${2:event name}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/val.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/val.snippet new file mode 100644 index 00000000..cafe0b0b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/val.snippet @@ -0,0 +1 @@ +${1:obj}.val('${2:text}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/width.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/width.snippet new file mode 100644 index 00000000..415631c6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/width.snippet @@ -0,0 +1 @@ +${1:obj}.width(${2:integer})${3} diff --git a/sources_non_forked/snipmate-snippets/javascript-jquery/wrap.snippet b/sources_non_forked/snipmate-snippets/javascript-jquery/wrap.snippet new file mode 100644 index 00000000..55df53ff --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript-jquery/wrap.snippet @@ -0,0 +1 @@ +${1:obj}.wrap('${2:<div class="extra-wrapper"></div>}')${3} diff --git a/sources_non_forked/snipmate-snippets/javascript/anon.snippet b/sources_non_forked/snipmate-snippets/javascript/anon.snippet new file mode 100644 index 00000000..d486c430 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/anon.snippet @@ -0,0 +1 @@ +function(${1}) { ${2} }; diff --git a/sources_non_forked/snipmate-snippets/javascript/for.snippet b/sources_non_forked/snipmate-snippets/javascript/for.snippet new file mode 100644 index 00000000..3933153f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/for.snippet @@ -0,0 +1,3 @@ +for (var <+i+>=0; <+i+> < <+<+Things+>.length+>; <+i+>++) { +<+<+Things+>[<+i+>]+> +}; diff --git a/sources_non_forked/snipmate-snippets/javascript/fun.snippet b/sources_non_forked/snipmate-snippets/javascript/fun.snippet new file mode 100644 index 00000000..064b9593 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/fun.snippet @@ -0,0 +1,3 @@ +function ${1:function_name} (${2:argument}) { + ${3:// body} +} diff --git a/sources_non_forked/snipmate-snippets/javascript/if.snippet b/sources_non_forked/snipmate-snippets/javascript/if.snippet new file mode 100644 index 00000000..931b9f17 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/if.snippet @@ -0,0 +1 @@ +if (${1:true}) { ${2} }; diff --git a/sources_non_forked/snipmate-snippets/javascript/ife.snippet b/sources_non_forked/snipmate-snippets/javascript/ife.snippet new file mode 100644 index 00000000..6b172d07 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/ife.snippet @@ -0,0 +1,4 @@ +if (${1:true}) { + ${2} +} else { +}; diff --git a/sources_non_forked/snipmate-snippets/javascript/log.snippet b/sources_non_forked/snipmate-snippets/javascript/log.snippet new file mode 100644 index 00000000..b4cf84fe --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/log.snippet @@ -0,0 +1 @@ +console.log(${1}); diff --git a/sources_non_forked/snipmate-snippets/javascript/met.snippet b/sources_non_forked/snipmate-snippets/javascript/met.snippet new file mode 100644 index 00000000..1c30d617 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/met.snippet @@ -0,0 +1,3 @@ +${1:method_name}: function(${2:attribute}){ + ${3} +}${4:, } diff --git a/sources_non_forked/snipmate-snippets/javascript/proto.snippet b/sources_non_forked/snipmate-snippets/javascript/proto.snippet new file mode 100644 index 00000000..37cd6d49 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/proto.snippet @@ -0,0 +1,3 @@ +${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) { + ${4:// body} +}; diff --git a/sources_non_forked/snipmate-snippets/javascript/timeout.snippet b/sources_non_forked/snipmate-snippets/javascript/timeout.snippet new file mode 100644 index 00000000..6ea2842c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/javascript/timeout.snippet @@ -0,0 +1 @@ +setTimeout(function() { ${1} }, ${2:10}); diff --git a/sources_non_forked/snipmate-snippets/objc/I.snippet b/sources_non_forked/snipmate-snippets/objc/I.snippet new file mode 100644 index 00000000..0032f65f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/I.snippet @@ -0,0 +1,6 @@ ++ (void) initialize +{ + [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys: + ${1}@"value", @"key", + nil]]; +} diff --git a/sources_non_forked/snipmate-snippets/objc/Imp.snippet b/sources_non_forked/snipmate-snippets/objc/Imp.snippet new file mode 100644 index 00000000..91724d3f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/Imp.snippet @@ -0,0 +1 @@ +#import "${1:`Filename()`.h}"${2} diff --git a/sources_non_forked/snipmate-snippets/objc/alloc.snippet b/sources_non_forked/snipmate-snippets/objc/alloc.snippet new file mode 100644 index 00000000..e4d15993 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/alloc.snippet @@ -0,0 +1 @@ +[[${1:foo} alloc] init]${2};${3} diff --git a/sources_non_forked/snipmate-snippets/objc/array.snippet b/sources_non_forked/snipmate-snippets/objc/array.snippet new file mode 100644 index 00000000..45d3ef01 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/array.snippet @@ -0,0 +1 @@ +NSMutableArray *${1:array} = [NSMutable array];${2} diff --git a/sources_non_forked/snipmate-snippets/objc/bez.snippet b/sources_non_forked/snipmate-snippets/objc/bez.snippet new file mode 100644 index 00000000..493aff69 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/bez.snippet @@ -0,0 +1 @@ +NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2} diff --git a/sources_non_forked/snipmate-snippets/objc/cat.snippet b/sources_non_forked/snipmate-snippets/objc/cat.snippet new file mode 100644 index 00000000..fd57aae3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/cat.snippet @@ -0,0 +1,6 @@ +@interface ${1:NSObject} (${2:Category}) +@end + +@implementation $1 ($2) +${3} +@end diff --git a/sources_non_forked/snipmate-snippets/objc/cati.snippet b/sources_non_forked/snipmate-snippets/objc/cati.snippet new file mode 100644 index 00000000..d2852600 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/cati.snippet @@ -0,0 +1,3 @@ +@interface ${1:NSObject} (${2:Category}) +${3} +@end diff --git a/sources_non_forked/snipmate-snippets/objc/cli.snippet b/sources_non_forked/snipmate-snippets/objc/cli.snippet new file mode 100644 index 00000000..fa896224 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/cli.snippet @@ -0,0 +1,5 @@ +@interface ${1:ClassName} : ${2:NSObject} +{${3} +} +${4} +@end diff --git a/sources_non_forked/snipmate-snippets/objc/dict.snippet b/sources_non_forked/snipmate-snippets/objc/dict.snippet new file mode 100644 index 00000000..8b2d7e90 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/dict.snippet @@ -0,0 +1 @@ +NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2} diff --git a/sources_non_forked/snipmate-snippets/objc/forarray.snippet b/sources_non_forked/snipmate-snippets/objc/forarray.snippet new file mode 100644 index 00000000..d32215d0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/forarray.snippet @@ -0,0 +1,7 @@ +unsigned int ${1:object}Count = [${2:array} count]; + +for (unsigned int index = 0; index < $1Count; index++) +{ + ${3:id} $1 = [$2 $1AtIndex:index]; + ${4} +} diff --git a/sources_non_forked/snipmate-snippets/objc/log.snippet b/sources_non_forked/snipmate-snippets/objc/log.snippet new file mode 100644 index 00000000..69f9c067 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/log.snippet @@ -0,0 +1 @@ +NSLog(@"${1}"${2});${3} diff --git a/sources_non_forked/snipmate-snippets/objc/m/class method.snippet b/sources_non_forked/snipmate-snippets/objc/m/class method.snippet new file mode 100644 index 00000000..191ee160 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/m/class method.snippet @@ -0,0 +1,4 @@ ++ (${1:id}) ${2:method} +{${3} + return nil; +} diff --git a/sources_non_forked/snipmate-snippets/objc/m/method.snippet b/sources_non_forked/snipmate-snippets/objc/m/method.snippet new file mode 100644 index 00000000..9f7390e2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/m/method.snippet @@ -0,0 +1,4 @@ +- (${1:id}) ${2:method} +{${3} + ${4:return nil;} +} diff --git a/sources_non_forked/snipmate-snippets/objc/objacc.snippet b/sources_non_forked/snipmate-snippets/objc/objacc.snippet new file mode 100644 index 00000000..840ebfd0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/objacc.snippet @@ -0,0 +1,11 @@ +- (${1:id})${2:thing} +{ + return $2; +} + +- (void) set$2:($1) +{ + $1 old$2 = $2; + $2 = [aValue retain]; + [old$2 release]; +} diff --git a/sources_non_forked/snipmate-snippets/objc/objc.snippet b/sources_non_forked/snipmate-snippets/objc/objc.snippet new file mode 100644 index 00000000..d6671487 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/objc.snippet @@ -0,0 +1,14 @@ +@interface ${1:`Filename('', 'object')`} : ${2:NSObject} +{ +} +@end + +@implementation $1 +- (id) init +{ + if (self = [super init]) + {${3} + } + return self +} +@end diff --git a/sources_non_forked/snipmate-snippets/objc/prop.snippet b/sources_non_forked/snipmate-snippets/objc/prop.snippet new file mode 100644 index 00000000..d77495a6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/prop.snippet @@ -0,0 +1 @@ +@property (${1:retain}) ${2:NSSomeClass} *${3:$2};${4} diff --git a/sources_non_forked/snipmate-snippets/objc/rel.snippet b/sources_non_forked/snipmate-snippets/objc/rel.snippet new file mode 100644 index 00000000..5dea04dd --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/rel.snippet @@ -0,0 +1 @@ +[${1:foo} release];${2} diff --git a/sources_non_forked/snipmate-snippets/objc/ret.snippet b/sources_non_forked/snipmate-snippets/objc/ret.snippet new file mode 100644 index 00000000..ee8eba46 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/ret.snippet @@ -0,0 +1 @@ +[${1:foo} retain];${2} diff --git a/sources_non_forked/snipmate-snippets/objc/sel.snippet b/sources_non_forked/snipmate-snippets/objc/sel.snippet new file mode 100644 index 00000000..4d4996d1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/sel.snippet @@ -0,0 +1 @@ +@selector(${1:method}:)${2} diff --git a/sources_non_forked/snipmate-snippets/objc/sm.snippet b/sources_non_forked/snipmate-snippets/objc/sm.snippet new file mode 100644 index 00000000..af139a90 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/sm.snippet @@ -0,0 +1,5 @@ +- (${1:id}) ${2:method}:(${3:id})${4:anArgument} +{ + $1 res = [super $2:$4];${5} + return res; +} diff --git a/sources_non_forked/snipmate-snippets/objc/syn.snippet b/sources_non_forked/snipmate-snippets/objc/syn.snippet new file mode 100644 index 00000000..eef7581c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/objc/syn.snippet @@ -0,0 +1 @@ +@synthesize ${1:NSSomeClass};${2} diff --git a/sources_non_forked/snipmate-snippets/php/array.snippet b/sources_non_forked/snipmate-snippets/php/array.snippet new file mode 100644 index 00000000..922542e0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/array.snippet @@ -0,0 +1 @@ +$${1:arrayName} = array('${2}' => ${3});${4} diff --git a/sources_non_forked/snipmate-snippets/php/case.snippet b/sources_non_forked/snipmate-snippets/php/case.snippet new file mode 100644 index 00000000..8f9e4daf --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/case.snippet @@ -0,0 +1,3 @@ +case '${1:value}': + ${2:// code...} + break;${3} diff --git a/sources_non_forked/snipmate-snippets/php/class.snippet b/sources_non_forked/snipmate-snippets/php/class.snippet new file mode 100644 index 00000000..4929a955 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/class.snippet @@ -0,0 +1,11 @@ +/** + * ${1} + */ +class ${2:ClassName} +{ + ${3} + function ${4:__construct}(${5:argument}) + { + ${6:// code...} + } +} diff --git a/sources_non_forked/snipmate-snippets/php/classe.snippet b/sources_non_forked/snipmate-snippets/php/classe.snippet new file mode 100644 index 00000000..2f2b0bc3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/classe.snippet @@ -0,0 +1,12 @@ +/** + * ${1} + */ +class ${2:ClassName} extends ${3:AnotherClass} +{ + ${4} + function ${5:__construct}(${6:argument}) + { + ${7:// code...} + } +} + diff --git a/sources_non_forked/snipmate-snippets/php/def.snippet b/sources_non_forked/snipmate-snippets/php/def.snippet new file mode 100644 index 00000000..df0f5ebd --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/def.snippet @@ -0,0 +1 @@ +define('${1}'${2});${3} diff --git a/sources_non_forked/snipmate-snippets/php/defd.snippet b/sources_non_forked/snipmate-snippets/php/defd.snippet new file mode 100644 index 00000000..6758cdad --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/defd.snippet @@ -0,0 +1 @@ +${1}defined('${2}')${3} diff --git a/sources_non_forked/snipmate-snippets/php/do.snippet b/sources_non_forked/snipmate-snippets/php/do.snippet new file mode 100644 index 00000000..e7dd5b06 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/do.snippet @@ -0,0 +1,3 @@ +do { + ${2:// code... } +} while (${1:/* condition */});" diff --git a/sources_non_forked/snipmate-snippets/php/doc_cp.snippet b/sources_non_forked/snipmate-snippets/php/doc_cp.snippet new file mode 100644 index 00000000..d6d1b3fc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/doc_cp.snippet @@ -0,0 +1,6 @@ +/** + * ${1:undocumented class} + * + * @package ${2:default} + * @author ${3:`g:snips_author`} + **/${4} diff --git a/sources_non_forked/snipmate-snippets/php/doc_f.snippet b/sources_non_forked/snipmate-snippets/php/doc_f.snippet new file mode 100644 index 00000000..a9adbb07 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/doc_f.snippet @@ -0,0 +1,8 @@ +/** + * $2 + * @return ${4:void} + * @author ${5:`g:snips_author`} + **/ +${1:public }function ${2:someFunc}(${3}) +{${6} +} diff --git a/sources_non_forked/snipmate-snippets/php/doc_h.snippet b/sources_non_forked/snipmate-snippets/php/doc_h.snippet new file mode 100644 index 00000000..a0c12e01 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/doc_h.snippet @@ -0,0 +1,10 @@ +/** + * ${1} + * + * @author ${2:`g:snips_author`} + * @version ${3:$Id$} + * @copyright ${4:$2}, `strftime('%d %B, %Y')` + * @package ${5:default} + **/ +/** + * Define DocBlock *// diff --git a/sources_non_forked/snipmate-snippets/php/doc_i.snippet b/sources_non_forked/snipmate-snippets/php/doc_i.snippet new file mode 100644 index 00000000..e62eab72 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/doc_i.snippet @@ -0,0 +1,8 @@ +/** + * $1 + * @package ${2:default} + * @author ${3:`g:snips_author`} + **/ +interface ${1:someClass} +{${4} +} // END interface $1" diff --git a/sources_non_forked/snipmate-snippets/php/ec.snippet b/sources_non_forked/snipmate-snippets/php/ec.snippet new file mode 100644 index 00000000..489d759b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/ec.snippet @@ -0,0 +1 @@ +echo "${1:string}"${2}; diff --git a/sources_non_forked/snipmate-snippets/php/else.snippet b/sources_non_forked/snipmate-snippets/php/else.snippet new file mode 100644 index 00000000..b910e982 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/else.snippet @@ -0,0 +1,3 @@ +else { + ${1:// code...} +} diff --git a/sources_non_forked/snipmate-snippets/php/elseif.snippet b/sources_non_forked/snipmate-snippets/php/elseif.snippet new file mode 100644 index 00000000..a57dec80 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/elseif.snippet @@ -0,0 +1,3 @@ +elseif (${1:/* condition */}) { + ${2:// code...} +} diff --git a/sources_non_forked/snipmate-snippets/php/for.snippet b/sources_non_forked/snipmate-snippets/php/for.snippet new file mode 100644 index 00000000..e9bc52aa --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/for.snippet @@ -0,0 +1,3 @@ +for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { + ${4:// code...} +} diff --git a/sources_non_forked/snipmate-snippets/php/foreach.snippet b/sources_non_forked/snipmate-snippets/php/foreach.snippet new file mode 100644 index 00000000..5fe47e5b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/foreach.snippet @@ -0,0 +1,3 @@ +foreach ($${1:variable} as $${2:key}){ + ${3:// code...} +} diff --git a/sources_non_forked/snipmate-snippets/php/foreachk.snippet b/sources_non_forked/snipmate-snippets/php/foreachk.snippet new file mode 100644 index 00000000..f78d57ae --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/foreachk.snippet @@ -0,0 +1,3 @@ +foreach ($${1:variable} as $${2:key} => $${3:value}){ + ${4:// code...} +} diff --git a/sources_non_forked/snipmate-snippets/php/fun.snippet b/sources_non_forked/snipmate-snippets/php/fun.snippet new file mode 100644 index 00000000..0f5d3534 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/fun.snippet @@ -0,0 +1,4 @@ +${1:public }function ${2:FunctionName}(${3}) +{ + ${4:// code...} +} diff --git a/sources_non_forked/snipmate-snippets/php/get.snippet b/sources_non_forked/snipmate-snippets/php/get.snippet new file mode 100644 index 00000000..af32e0a5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/get.snippet @@ -0,0 +1 @@ +$_GET['${1}']${2} diff --git a/sources_non_forked/snipmate-snippets/php/globals.snippet b/sources_non_forked/snipmate-snippets/php/globals.snippet new file mode 100644 index 00000000..6f5b04f3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/globals.snippet @@ -0,0 +1 @@ +$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5} diff --git a/sources_non_forked/snipmate-snippets/php/if.snippet b/sources_non_forked/snipmate-snippets/php/if.snippet new file mode 100644 index 00000000..69ac0bd6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/if.snippet @@ -0,0 +1,3 @@ +if (${1:/* condition */}) { + ${2:// code...} +} diff --git a/sources_non_forked/snipmate-snippets/php/ife.snippet b/sources_non_forked/snipmate-snippets/php/ife.snippet new file mode 100644 index 00000000..b8621c1b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/ife.snippet @@ -0,0 +1,4 @@ +if (${1:/* condition */}) { + ${2:// code...} +} else { +} diff --git a/sources_non_forked/snipmate-snippets/php/inc.snippet b/sources_non_forked/snipmate-snippets/php/inc.snippet new file mode 100644 index 00000000..8df3966c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/inc.snippet @@ -0,0 +1 @@ +include '${1:file}';${2} diff --git a/sources_non_forked/snipmate-snippets/php/inc1.snippet b/sources_non_forked/snipmate-snippets/php/inc1.snippet new file mode 100644 index 00000000..ba262818 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/inc1.snippet @@ -0,0 +1 @@ +include_once '${1:file}';${2} diff --git a/sources_non_forked/snipmate-snippets/php/log.snippet b/sources_non_forked/snipmate-snippets/php/log.snippet new file mode 100644 index 00000000..2b8dcc4b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/log.snippet @@ -0,0 +1 @@ +error_log(var_export(${1}, true));${2} diff --git a/sources_non_forked/snipmate-snippets/php/php.snippet b/sources_non_forked/snipmate-snippets/php/php.snippet new file mode 100644 index 00000000..ed2ed1ce --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/php.snippet @@ -0,0 +1,3 @@ + diff --git a/sources_non_forked/snipmate-snippets/php/post.snippet b/sources_non_forked/snipmate-snippets/php/post.snippet new file mode 100644 index 00000000..2de7aa5f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/post.snippet @@ -0,0 +1 @@ +$_POST['${1}']${2} diff --git a/sources_non_forked/snipmate-snippets/php/req.snippet b/sources_non_forked/snipmate-snippets/php/req.snippet new file mode 100644 index 00000000..c03ea36f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/req.snippet @@ -0,0 +1 @@ +require '${1:file}';${2} diff --git a/sources_non_forked/snipmate-snippets/php/req1.snippet b/sources_non_forked/snipmate-snippets/php/req1.snippet new file mode 100644 index 00000000..e909c3bc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/req1.snippet @@ -0,0 +1 @@ +require_once '${1:file}';${2} diff --git a/sources_non_forked/snipmate-snippets/php/request.snippet b/sources_non_forked/snipmate-snippets/php/request.snippet new file mode 100644 index 00000000..9a839b1b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/request.snippet @@ -0,0 +1 @@ +$_REQUEST['${1}']${2} diff --git a/sources_non_forked/snipmate-snippets/php/session.snippet b/sources_non_forked/snipmate-snippets/php/session.snippet new file mode 100644 index 00000000..5e3e11b9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/session.snippet @@ -0,0 +1 @@ +$_SESSION['${1}']${2} diff --git a/sources_non_forked/snipmate-snippets/php/switch.snippet b/sources_non_forked/snipmate-snippets/php/switch.snippet new file mode 100644 index 00000000..7fc47c63 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/switch.snippet @@ -0,0 +1,9 @@ +switch ($${1:variable}) { + case '${2:value}': + ${3:// code...} + break; + ${5} + default: + ${4:// code...} + break; +} diff --git a/sources_non_forked/snipmate-snippets/php/t.snippet b/sources_non_forked/snipmate-snippets/php/t.snippet new file mode 100644 index 00000000..e8deae52 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/t.snippet @@ -0,0 +1 @@ +$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} diff --git a/sources_non_forked/snipmate-snippets/php/try.snippet b/sources_non_forked/snipmate-snippets/php/try.snippet new file mode 100644 index 00000000..66a7f651 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/try.snippet @@ -0,0 +1,6 @@ +try { + ${1:// code...} +} catch (${2:Exception} $e) { + ${3:// code...} +} + diff --git a/sources_non_forked/snipmate-snippets/php/var.snippet b/sources_non_forked/snipmate-snippets/php/var.snippet new file mode 100644 index 00000000..1f8cd08e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/var.snippet @@ -0,0 +1 @@ +var_export(${1});${2} diff --git a/sources_non_forked/snipmate-snippets/php/wh.snippet b/sources_non_forked/snipmate-snippets/php/wh.snippet new file mode 100644 index 00000000..36ae0ffc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/php/wh.snippet @@ -0,0 +1,3 @@ +while (${1:/* condition */}) { + ${2:// code...} +} diff --git a/sources_non_forked/snipmate-snippets/po/msg.snippet b/sources_non_forked/snipmate-snippets/po/msg.snippet new file mode 100644 index 00000000..2ad6638a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/po/msg.snippet @@ -0,0 +1,2 @@ +msgid "${1}" +msgstr "${2}"${3} diff --git a/sources_non_forked/snipmate-snippets/python/class.snippet b/sources_non_forked/snipmate-snippets/python/class.snippet new file mode 100644 index 00000000..d9e2b8e8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/class.snippet @@ -0,0 +1,2 @@ +class ${1:``Snippet_PythonClassNameFromFilename()``}(${2:data}): +${3} diff --git a/sources_non_forked/snipmate-snippets/python/def.snippet b/sources_non_forked/snipmate-snippets/python/def.snippet new file mode 100644 index 00000000..c7cc9d38 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/def.snippet @@ -0,0 +1,2 @@ +def ${1:name}(${2:data}): +${3} diff --git a/sources_non_forked/snipmate-snippets/python/for.snippet b/sources_non_forked/snipmate-snippets/python/for.snippet new file mode 100644 index 00000000..fb69c05f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/for.snippet @@ -0,0 +1,3 @@ +for ${1:var} in ${2:type}: +${3:pass} +${4} diff --git a/sources_non_forked/snipmate-snippets/python/from.snippet b/sources_non_forked/snipmate-snippets/python/from.snippet new file mode 100644 index 00000000..98d0d825 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/from.snippet @@ -0,0 +1,2 @@ +from ${1:module} import ${2:name} +${3} diff --git a/sources_non_forked/snipmate-snippets/python/get.snippet b/sources_non_forked/snipmate-snippets/python/get.snippet new file mode 100644 index 00000000..bc0bf63d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/get.snippet @@ -0,0 +1,3 @@ +def get_${1:name}(self): +return self._$1 +${2} diff --git a/sources_non_forked/snipmate-snippets/python/ifmain.snippet b/sources_non_forked/snipmate-snippets/python/ifmain.snippet new file mode 100644 index 00000000..f6e7a262 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/ifmain.snippet @@ -0,0 +1,2 @@ +if __name__ == '__main__': +${1} diff --git a/sources_non_forked/snipmate-snippets/python/import.snippet b/sources_non_forked/snipmate-snippets/python/import.snippet new file mode 100644 index 00000000..58c9acdc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/import.snippet @@ -0,0 +1,2 @@ +import ${1:module} +${2} diff --git a/sources_non_forked/snipmate-snippets/python/init.snippet b/sources_non_forked/snipmate-snippets/python/init.snippet new file mode 100644 index 00000000..c1a4f0fa --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/init.snippet @@ -0,0 +1,2 @@ +def __init__(self, ${1:args}): +${2} diff --git a/sources_non_forked/snipmate-snippets/python/set.snippet b/sources_non_forked/snipmate-snippets/python/set.snippet new file mode 100644 index 00000000..6ab0b5aa --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/set.snippet @@ -0,0 +1 @@ +def set_${1:name}(self, ${2:value}): diff --git a/sources_non_forked/snipmate-snippets/python/try.snippet b/sources_non_forked/snipmate-snippets/python/try.snippet new file mode 100644 index 00000000..fd5f6e59 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/python/try.snippet @@ -0,0 +1,4 @@ +try: +${1} +except ${2:Exception} +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-factorygirl/fac.snippet b/sources_non_forked/snipmate-snippets/ruby-factorygirl/fac.snippet new file mode 100644 index 00000000..05cc3e8e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-factorygirl/fac.snippet @@ -0,0 +1 @@ +Factory(:${1}, ${2})${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-factorygirl/facb.snippet b/sources_non_forked/snipmate-snippets/ruby-factorygirl/facb.snippet new file mode 100644 index 00000000..299c0335 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-factorygirl/facb.snippet @@ -0,0 +1 @@ +Factory.build(:${1}, ${2})${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-factorygirl/facd.snippet b/sources_non_forked/snipmate-snippets/ruby-factorygirl/facd.snippet new file mode 100644 index 00000000..41d1503c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-factorygirl/facd.snippet @@ -0,0 +1,4 @@ +Factory.define(:${1:model}) do |${2:f}| + ${3} +end +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-factorygirl/facn.snippet b/sources_non_forked/snipmate-snippets/ruby-factorygirl/facn.snippet new file mode 100644 index 00000000..7232308c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-factorygirl/facn.snippet @@ -0,0 +1 @@ +Factory.next(:${1:sequence-name})${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-factorygirl/facs.snippet b/sources_non_forked/snipmate-snippets/ruby-factorygirl/facs.snippet new file mode 100644 index 00000000..13fd5b9d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-factorygirl/facs.snippet @@ -0,0 +1,4 @@ +Factory.sequence :${1:sequence-name} do |${2:m}| + ${3} +end +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/art.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/art.snippet new file mode 100644 index 00000000..a5a7d34e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/art.snippet @@ -0,0 +1 @@ +assert_redirected_to ${1::action => "${2:index}"} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/artnp.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/artnp.snippet new file mode 100644 index 00000000..2c9bfef0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/artnp.snippet @@ -0,0 +1 @@ +assert_redirected_to <+<+parent+>_<+child+>_path(<+@<+parent+>+>, <+@<+child+>+>)+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/artnpp.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/artnpp.snippet new file mode 100644 index 00000000..becd79b5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/artnpp.snippet @@ -0,0 +1 @@ +assert_redirected_to <+<+parent+>_<+child+>_path(<+@<+parent+>+>)+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/artp.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/artp.snippet new file mode 100644 index 00000000..55b9204a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/artp.snippet @@ -0,0 +1 @@ +assert_redirected_to <+<+model+>_path(<+@<+model+>+>)+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/artpp.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/artpp.snippet new file mode 100644 index 00000000..1d1d203d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/artpp.snippet @@ -0,0 +1 @@ +assert_redirected_to <+<+model+>s_path+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/asd.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/asd.snippet new file mode 100644 index 00000000..35ab7301 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/asd.snippet @@ -0,0 +1,3 @@ +assert_difference "${1:Model}.${2:count}", $1 do + ${3} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/asnd.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/asnd.snippet new file mode 100644 index 00000000..c5124e04 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/asnd.snippet @@ -0,0 +1,3 @@ +assert_no_difference "${1:Model}.${2:count}" do + ${3} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/asre.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/asre.snippet new file mode 100644 index 00000000..d0ac6b26 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/asre.snippet @@ -0,0 +1 @@ +assert_response :${1:success}, @response.body${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/asrj.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/asrj.snippet new file mode 100644 index 00000000..6ee13f2d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/asrj.snippet @@ -0,0 +1 @@ +assert_rjs :<+replace+>, <+"<+dom id+>"+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ass.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ass.snippet new file mode 100644 index 00000000..4cc696f6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ass.snippet @@ -0,0 +1 @@ +assert_select '<+path+>'<+, :<+text+> => <+'<+inner_html+>'+>+> <+do<++>+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/bf.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/bf.snippet new file mode 100644 index 00000000..ad25cc90 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/bf.snippet @@ -0,0 +1 @@ +before_filter :${1:method} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/bt.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/bt.snippet new file mode 100644 index 00000000..b28e1e62 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/bt.snippet @@ -0,0 +1 @@ +belongs_to :${1:association} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/crw.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/crw.snippet new file mode 100644 index 00000000..3b1ab619 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/crw.snippet @@ -0,0 +1 @@ +cattr_accessor :${1:attr_names} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/defcreate.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/defcreate.snippet new file mode 100644 index 00000000..e878d3a6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/defcreate.snippet @@ -0,0 +1,14 @@ +def create + @${1:model_class_name} = ${2:ModelClassName}.new(params[:$1]) + + respond_to do |wants| + if @$1.save + flash[:notice] = '$2 was successfully created.' + wants.html { redirect_to(@$1) } + wants.xml { render :xml => @$1, :status => :created, :location => @$1 } + else + wants.html { render :action => "new" } + wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity } + end + end +end${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/defdestroy.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/defdestroy.snippet new file mode 100644 index 00000000..9c340808 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/defdestroy.snippet @@ -0,0 +1,9 @@ +def destroy + @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) + @$1.destroy + + respond_to do |wants| + wants.html { redirect_to($1s_url) } + wants.xml { head :ok } + end +end${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/defedit.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/defedit.snippet new file mode 100644 index 00000000..0e80dcb8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/defedit.snippet @@ -0,0 +1,3 @@ +def edit + @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/defindex.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/defindex.snippet new file mode 100644 index 00000000..aa776f9a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/defindex.snippet @@ -0,0 +1,8 @@ +def index + @${1:model_class_name} = ${2:ModelClassName}.all + + respond_to do |wants| + wants.html # index.html.erb + wants.xml { render :xml => @$1s } + end +end${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/defnew.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/defnew.snippet new file mode 100644 index 00000000..0a4762b9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/defnew.snippet @@ -0,0 +1,8 @@ +def new + @${1:model_class_name} = ${2:ModelClassName}.new + + respond_to do |wants| + wants.html # new.html.erb + wants.xml { render :xml => @$1 } + end +end${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/defshow.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/defshow.snippet new file mode 100644 index 00000000..ba745d52 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/defshow.snippet @@ -0,0 +1,8 @@ +def show + @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) + + respond_to do |wants| + wants.html # show.html.erb + wants.xml { render :xml => @$1 } + end +end${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/defupdate.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/defupdate.snippet new file mode 100644 index 00000000..0556895c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/defupdate.snippet @@ -0,0 +1,14 @@ +def update + @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) + + respond_to do |wants| + if @$1.update_attributes(params[:$1]) + flash[:notice] = '$2 was successfully updated.' + wants.html { redirect_to(@$1) } + wants.xml { head :ok } + else + wants.html { render :action => "edit" } + wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity } + end + end +end${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/fina.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/fina.snippet new file mode 100644 index 00000000..af5ec413 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/fina.snippet @@ -0,0 +1 @@ +find(:all<+, :conditions => ['<+<+field+> = ?+>', <+true+>]+>) diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/finf.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/finf.snippet new file mode 100644 index 00000000..24ba2da3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/finf.snippet @@ -0,0 +1 @@ +find(:first<+, :conditions => ['<+<+field+> = ?+>', <+true+>]+>) diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/fini.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/fini.snippet new file mode 100644 index 00000000..96d68a5f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/fini.snippet @@ -0,0 +1 @@ +find(<+id+>) diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/finl.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/finl.snippet new file mode 100644 index 00000000..7ee6efec --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/finl.snippet @@ -0,0 +1 @@ +find(:last<+, :conditions => ['<+<+field+> = ?+>', <+true+>]+>) diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/flash.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/flash.snippet new file mode 100644 index 00000000..2a069307 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/flash.snippet @@ -0,0 +1 @@ +flash[:${1:notice}] = "${2}" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/habtm.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/habtm.snippet new file mode 100644 index 00000000..1b27396a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/habtm.snippet @@ -0,0 +1 @@ +has_and_belongs_to_many :${1:object}, :join_table => "${2:table_name}", :foreign_key => "${3}_id"${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/hm.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/hm.snippet new file mode 100644 index 00000000..9204df56 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/hm.snippet @@ -0,0 +1 @@ +has_many :${1:object} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/hmd.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/hmd.snippet new file mode 100644 index 00000000..6aadd73b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/hmd.snippet @@ -0,0 +1 @@ +has_many :<+object+>s<+, :class_name => "<+object+>", :foreign_key => "<+reference+>_id"+>, :dependent => :destroy<++> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/hmt.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/hmt.snippet new file mode 100644 index 00000000..4128e037 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/hmt.snippet @@ -0,0 +1 @@ +has_many :${1:object}, :through => :${2:object} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ho.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ho.snippet new file mode 100644 index 00000000..77e14e7a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ho.snippet @@ -0,0 +1 @@ +has_one :${1:object} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/i18.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/i18.snippet new file mode 100644 index 00000000..2a30fae0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/i18.snippet @@ -0,0 +1 @@ +I18n.t('${1:type.key}')${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ist.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ist.snippet new file mode 100644 index 00000000..d97d4829 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ist.snippet @@ -0,0 +1 @@ +<%= image_submit_tag("<+agree.png+>"<+<+, :id => "<+id+>"+><+, :name => "<+name+>"+><+, :class => "<+class+>"+><+, :disabled => <+false+>+>+>) %> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/log.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/log.snippet new file mode 100644 index 00000000..53360dd5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/log.snippet @@ -0,0 +1 @@ +RAILS_DEFAULT_LOGGER.${1:debug} ${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/logd.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/logd.snippet new file mode 100644 index 00000000..36236a31 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/logd.snippet @@ -0,0 +1 @@ +logger.debug { "${1:message}" }${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/loge.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/loge.snippet new file mode 100644 index 00000000..4417ad2e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/loge.snippet @@ -0,0 +1 @@ +logger.error { "${1:message}" }${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/logf.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/logf.snippet new file mode 100644 index 00000000..1bd419c8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/logf.snippet @@ -0,0 +1 @@ +logger.fatal { "${1:message}" }${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/logi.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/logi.snippet new file mode 100644 index 00000000..bf508dc1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/logi.snippet @@ -0,0 +1 @@ +logger.info { "${1:message}" }${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/logw.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/logw.snippet new file mode 100644 index 00000000..447f6886 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/logw.snippet @@ -0,0 +1 @@ +logger.warn { "${1:message}" }${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mac.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mac.snippet new file mode 100644 index 00000000..548d4af0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mac.snippet @@ -0,0 +1 @@ +add_column :${1:table}, :${2:column}, :${3:type} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mapc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mapc.snippet new file mode 100644 index 00000000..b14ec4ca --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mapc.snippet @@ -0,0 +1 @@ +${1:map}.${2:connect} '${3:controller/:action/:id}' diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mapca.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mapca.snippet new file mode 100644 index 00000000..9292ffe9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mapca.snippet @@ -0,0 +1 @@ +${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}"${5} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mapr.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mapr.snippet new file mode 100644 index 00000000..424805b7 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mapr.snippet @@ -0,0 +1 @@ +${1:map}.resource :${2:resource} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/maprs.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/maprs.snippet new file mode 100644 index 00000000..a18c4df3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/maprs.snippet @@ -0,0 +1 @@ +${1:map}.resources :${2:resource} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mapwo.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mapwo.snippet new file mode 100644 index 00000000..b3cf7911 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mapwo.snippet @@ -0,0 +1,3 @@ +${1:map}.with_options :${2:controller} => '${3:thing}' do |$3| + ${4} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mbs.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mbs.snippet new file mode 100644 index 00000000..a3b34bb3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mbs.snippet @@ -0,0 +1 @@ +before_save :${1:method} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mcc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mcc.snippet new file mode 100644 index 00000000..74dc7af0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mcc.snippet @@ -0,0 +1 @@ +change_column :${1:table}, :${2:column}, :${3:type} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mccc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mccc.snippet new file mode 100644 index 00000000..2915a37f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mccc.snippet @@ -0,0 +1 @@ +t.column :${1:title}, :${2:string} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mcht.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mcht.snippet new file mode 100644 index 00000000..a71b4731 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mcht.snippet @@ -0,0 +1,3 @@ +change_table :${1:table_name} do |t| + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mcol.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mcol.snippet new file mode 100644 index 00000000..8a5bd1ff --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mcol.snippet @@ -0,0 +1 @@ +remove_column :${1:table}, :${2:column} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mct.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mct.snippet new file mode 100644 index 00000000..8dbe1eab --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mct.snippet @@ -0,0 +1,3 @@ +create_table :${1:table_name} do |t| + t.column :${2:name}, :${3:type} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/migration.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/migration.snippet new file mode 100644 index 00000000..9f54e0b9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/migration.snippet @@ -0,0 +1,8 @@ +class ${1:`Snippet_MigrationNameFromFilename()`} < ActiveRecord::Migration + def self.up + ${2} + end + + def self.down + end +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mp.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mp.snippet new file mode 100644 index 00000000..1264a595 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mp.snippet @@ -0,0 +1 @@ +map(&:${1:id}) diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mrc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mrc.snippet new file mode 100644 index 00000000..aaeba258 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mrc.snippet @@ -0,0 +1 @@ +remove_column :${1:column} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mrmc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mrmc.snippet new file mode 100644 index 00000000..8a5bd1ff --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mrmc.snippet @@ -0,0 +1 @@ +remove_column :${1:table}, :${2:column} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mrnc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mrnc.snippet new file mode 100644 index 00000000..6e167210 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mrnc.snippet @@ -0,0 +1 @@ +rename_column :${1:table}, :${2:old}, :${3:new} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/mrw.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/mrw.snippet new file mode 100644 index 00000000..9ef0f8fe --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/mrw.snippet @@ -0,0 +1 @@ +mattr_accessor :${1:attr_names} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/nc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/nc.snippet new file mode 100644 index 00000000..cfc42ca4 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/nc.snippet @@ -0,0 +1 @@ +named_scope :<+name+><+, :joins => :<+table+>+>, :conditions => <+['<+<+field+> = ?+>', <+true+>]+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ncl.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ncl.snippet new file mode 100644 index 00000000..c420ef2f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ncl.snippet @@ -0,0 +1 @@ +named_scope :<+name+>, lambda { |<+param+>| { :conditions => <+['<+<+field+> = ?+>', <+param+>]+> } } diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/pa.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/pa.snippet new file mode 100644 index 00000000..14fa54fb --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/pa.snippet @@ -0,0 +1 @@ +params[:${1:id}]${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ra.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ra.snippet new file mode 100644 index 00000000..56a9bbf6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ra.snippet @@ -0,0 +1 @@ +render :action => "${1:action}" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ral.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ral.snippet new file mode 100644 index 00000000..0a0b202d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ral.snippet @@ -0,0 +1 @@ +render :action => "${1:action}", :layout => "${2:layoutname}" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rest.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rest.snippet new file mode 100644 index 00000000..7938f9d6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rest.snippet @@ -0,0 +1,3 @@ +respond_to do |wants| + wants.${1:html} <+{ <++> }+> +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rf.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rf.snippet new file mode 100644 index 00000000..76fcdb1d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rf.snippet @@ -0,0 +1 @@ +render :file => "${1:filepath}" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rfu.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rfu.snippet new file mode 100644 index 00000000..c0bb72bf --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rfu.snippet @@ -0,0 +1 @@ +render :file => "${1:filepath}", :use_full_path => ${2:false} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ri.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ri.snippet new file mode 100644 index 00000000..17a04048 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ri.snippet @@ -0,0 +1 @@ +render :inline => "<+<%= 'hello' %>+>" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ril.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ril.snippet new file mode 100644 index 00000000..b1801aa4 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ril.snippet @@ -0,0 +1 @@ +render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"${4} } diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rit.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rit.snippet new file mode 100644 index 00000000..b3cd8343 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rit.snippet @@ -0,0 +1 @@ +render :inline => "${1:<%= 'hello' %>}", :type => ${2::rxml} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rjson.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rjson.snippet new file mode 100644 index 00000000..fece1fcc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rjson.snippet @@ -0,0 +1 @@ +render :json => ${1:text to render} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rl.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rl.snippet new file mode 100644 index 00000000..53e8340a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rl.snippet @@ -0,0 +1 @@ +render :layout => "${1:layoutname}" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rn.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rn.snippet new file mode 100644 index 00000000..6c6b0fec --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rn.snippet @@ -0,0 +1 @@ +render :nothing => ${1:true} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rns.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rns.snippet new file mode 100644 index 00000000..d1a581f8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rns.snippet @@ -0,0 +1 @@ +render :nothing => ${1:true}, :status => ${2:401} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rp.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rp.snippet new file mode 100644 index 00000000..0c5daa25 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rp.snippet @@ -0,0 +1 @@ +render :partial => "${1:item}" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rpc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rpc.snippet new file mode 100644 index 00000000..570644b5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rpc.snippet @@ -0,0 +1 @@ +render :partial => "<+item+>", :collection => <+@<+item+>s+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rpl.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rpl.snippet new file mode 100644 index 00000000..6981fbc3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rpl.snippet @@ -0,0 +1 @@ +render :partial => "<+item+>", :locals => { :<+item+> => <+@<+item+>+><++> } diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rpo.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rpo.snippet new file mode 100644 index 00000000..bab9da96 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rpo.snippet @@ -0,0 +1 @@ +render :partial => "<+item+>", :object => <+@<+item+>+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rps.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rps.snippet new file mode 100644 index 00000000..aef4c494 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rps.snippet @@ -0,0 +1 @@ +render :partial => "${1:item}", :status => ${2:500} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rt.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rt.snippet new file mode 100644 index 00000000..c464879c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rt.snippet @@ -0,0 +1 @@ +render :text => "${1:text to render}" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rtl.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rtl.snippet new file mode 100644 index 00000000..fc78bf14 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rtl.snippet @@ -0,0 +1 @@ +render :text => "${1:text to render}", :layout => "${2:layoutname}" diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rtlt.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rtlt.snippet new file mode 100644 index 00000000..69618be0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rtlt.snippet @@ -0,0 +1 @@ +render :text => "${1:text to render}", :layout => ${2:true} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rts.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rts.snippet new file mode 100644 index 00000000..04fe409d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rts.snippet @@ -0,0 +1 @@ +render :text => "${1:text to render}", :status => ${2:401} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ru.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ru.snippet new file mode 100644 index 00000000..3a2d1ed0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ru.snippet @@ -0,0 +1,3 @@ +render :update do |${1:page}| + $1.${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/rxml.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/rxml.snippet new file mode 100644 index 00000000..e4e721a0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/rxml.snippet @@ -0,0 +1 @@ +render :xml => ${1:text to render} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/sha1.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/sha1.snippet new file mode 100644 index 00000000..19847471 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/sha1.snippet @@ -0,0 +1 @@ +Digest::SHA1.hexdigest(${1:string}) diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/sweeper.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/sweeper.snippet new file mode 100644 index 00000000..659aeb0d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/sweeper.snippet @@ -0,0 +1,15 @@ +class ${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper + observe $1 + + def after_save(${2:model_class_name}) + expire_cache($2) + end + + def after_destroy($2) + expire_cache($2) + end + + def expire_cache($2) + expire_page + end +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcb.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcb.snippet new file mode 100644 index 00000000..021740df --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcb.snippet @@ -0,0 +1,2 @@ +t.boolean :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcbi.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcbi.snippet new file mode 100644 index 00000000..3e6d3c9c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcbi.snippet @@ -0,0 +1,2 @@ +t.binary :<+title+><+, :limit => <+2+>.megabytes+> +<++> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcd.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcd.snippet new file mode 100644 index 00000000..0932f2c1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcd.snippet @@ -0,0 +1,2 @@ +t.decimal :<+title+><+<+, :precision => <+10+>+><+, :scale => <+2+>+>+> +<++> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcda.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcda.snippet new file mode 100644 index 00000000..b716e8b0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcda.snippet @@ -0,0 +1,2 @@ +t.date :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcdt.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcdt.snippet new file mode 100644 index 00000000..d060532e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcdt.snippet @@ -0,0 +1,2 @@ +t.datetime :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcf.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcf.snippet new file mode 100644 index 00000000..f09f7904 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcf.snippet @@ -0,0 +1,2 @@ +t.float :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tch.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tch.snippet new file mode 100644 index 00000000..bcce7271 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tch.snippet @@ -0,0 +1,2 @@ +t.change :<+name+><+, :<+string+><+, :<+limit+> => <+80+>+>+> +<++> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tci.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tci.snippet new file mode 100644 index 00000000..7cb011ca --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tci.snippet @@ -0,0 +1,2 @@ +t.integer :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcl.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcl.snippet new file mode 100644 index 00000000..ffa359f5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcl.snippet @@ -0,0 +1,2 @@ +t.integer :lock_version, :null => false, :default => 0 +${1} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcr.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcr.snippet new file mode 100644 index 00000000..2b421dd7 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcr.snippet @@ -0,0 +1,2 @@ +t.references :<+taggable+><+, :polymorphic => <+{ :default => '<+Photo+>' }+>+> +<++> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcs.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcs.snippet new file mode 100644 index 00000000..a7b8473b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcs.snippet @@ -0,0 +1,2 @@ +t.string :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tct.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tct.snippet new file mode 100644 index 00000000..f28518f4 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tct.snippet @@ -0,0 +1,2 @@ +t.text :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcti.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcti.snippet new file mode 100644 index 00000000..0006c819 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcti.snippet @@ -0,0 +1,2 @@ +t.time :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tcts.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tcts.snippet new file mode 100644 index 00000000..e46e844c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tcts.snippet @@ -0,0 +1,2 @@ +t.timestamp :${1:title} +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tctss.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tctss.snippet new file mode 100644 index 00000000..f009ee62 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tctss.snippet @@ -0,0 +1,2 @@ +t.timestamps +${1} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/trc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/trc.snippet new file mode 100644 index 00000000..2d6250ab --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/trc.snippet @@ -0,0 +1 @@ +t.remove :${1:column} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tre.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tre.snippet new file mode 100644 index 00000000..8f70788c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tre.snippet @@ -0,0 +1,2 @@ +t.rename :<+old_column_name+>, :<+new_column_name+> +<++> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/tref.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/tref.snippet new file mode 100644 index 00000000..12867868 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/tref.snippet @@ -0,0 +1 @@ +t.references :${1:model} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/va.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/va.snippet new file mode 100644 index 00000000..064bb7b2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/va.snippet @@ -0,0 +1 @@ +validates_associated :${1:attribute} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/vao.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/vao.snippet new file mode 100644 index 00000000..4c6c98b6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/vao.snippet @@ -0,0 +1 @@ +validates_acceptance_of :${1:terms} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/vc.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/vc.snippet new file mode 100644 index 00000000..0aa1a75d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/vc.snippet @@ -0,0 +1 @@ +validates_confirmation_of :${1:attribute} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/ve.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/ve.snippet new file mode 100644 index 00000000..b6a4c4d5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/ve.snippet @@ -0,0 +1 @@ +validates_exclusion_of :${1:attribute}, :in => ${2:%w( mov avi )} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/vf.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/vf.snippet new file mode 100644 index 00000000..adc142c7 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/vf.snippet @@ -0,0 +1 @@ +validates_format_of :${1:attribute}, :with => /${2:regex}/ diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/vi.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/vi.snippet new file mode 100644 index 00000000..8ba16d2e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/vi.snippet @@ -0,0 +1 @@ +validates_inclusion_of :${1:attribute}, :in => %w(${2: mov avi }) diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/vl.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/vl.snippet new file mode 100644 index 00000000..71d802bd --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/vl.snippet @@ -0,0 +1 @@ +validates_length_of :${1:attribute}, :within => ${2:3}..${3:20} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/vn.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/vn.snippet new file mode 100644 index 00000000..34bfaa72 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/vn.snippet @@ -0,0 +1 @@ +validates_numericality_of :${1:attribute} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/vpo.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/vpo.snippet new file mode 100644 index 00000000..c8fdff9c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/vpo.snippet @@ -0,0 +1 @@ +validates_presence_of :${1:attribute} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/vu.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/vu.snippet new file mode 100644 index 00000000..0c06e655 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/vu.snippet @@ -0,0 +1 @@ +validates_uniqueness_of :${1:attribute} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/wants.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/wants.snippet new file mode 100644 index 00000000..909c8d59 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/wants.snippet @@ -0,0 +1 @@ +wants.<+js|xml|html+> <+{ <++> }+> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/xdelete.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/xdelete.snippet new file mode 100644 index 00000000..41184e9e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/xdelete.snippet @@ -0,0 +1 @@ +xhr :delete, :${1:destroy}, :id => ${2:1}${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/xget.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/xget.snippet new file mode 100644 index 00000000..1ae7834e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/xget.snippet @@ -0,0 +1 @@ +xhr :get, :<+show+><+, :id => <+1+>+><++> diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/xpost.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/xpost.snippet new file mode 100644 index 00000000..3681a95f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/xpost.snippet @@ -0,0 +1 @@ +xhr :post, :${1:create}, :${2:object} => { ${3} } diff --git a/sources_non_forked/snipmate-snippets/ruby-rails/xput.snippet b/sources_non_forked/snipmate-snippets/ruby-rails/xput.snippet new file mode 100644 index 00000000..f046f2ea --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rails/xput.snippet @@ -0,0 +1 @@ +xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }${5} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/aft.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/aft.snippet new file mode 100644 index 00000000..528f1b30 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/aft.snippet @@ -0,0 +1,3 @@ +after(${1::each}) do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/annot.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/annot.snippet new file mode 100644 index 00000000..7199170c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/annot.snippet @@ -0,0 +1 @@ +any_number_of_times diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/anr.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/anr.snippet new file mode 100644 index 00000000..573addd5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/anr.snippet @@ -0,0 +1 @@ +and_return(${1:value}) diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/anra.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/anra.snippet new file mode 100644 index 00000000..ab03deb4 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/anra.snippet @@ -0,0 +1 @@ +and_raise(${1:exception}) diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/anrb.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/anrb.snippet new file mode 100644 index 00000000..e313a512 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/anrb.snippet @@ -0,0 +1 @@ +and_return { ${1} } diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/ant.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/ant.snippet new file mode 100644 index 00000000..d230e92c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/ant.snippet @@ -0,0 +1 @@ +and_throw(${1:sym}) diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/any.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/any.snippet new file mode 100644 index 00000000..34c08d69 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/any.snippet @@ -0,0 +1 @@ +and_yield(${1:values}) diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/atl.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/atl.snippet new file mode 100644 index 00000000..b95128bb --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/atl.snippet @@ -0,0 +1 @@ +at_least(${1:n}).times diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/atm.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/atm.snippet new file mode 100644 index 00000000..fa5c6060 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/atm.snippet @@ -0,0 +1 @@ +at_most(${1:n}).times diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/bef.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/bef.snippet new file mode 100644 index 00000000..f96608c5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/bef.snippet @@ -0,0 +1,3 @@ +before(${1::each}) do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/conn.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/conn.snippet new file mode 100644 index 00000000..4bd9d239 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/conn.snippet @@ -0,0 +1 @@ +controller_name :${1:controller} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/des.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/des.snippet new file mode 100644 index 00000000..44c75845 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/des.snippet @@ -0,0 +1,3 @@ +describe "${1:subject}" do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/desc.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/desc.snippet new file mode 100644 index 00000000..6311aa1d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/desc.snippet @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe ${1:`Snippet_RubyClassNameFromFilename()`} do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/desrc.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/desrc.snippet new file mode 100644 index 00000000..a9c8ac2b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/desrc.snippet @@ -0,0 +1,3 @@ +describe ${1:controller}, "${2:GET|POST|PUT|DELETE} ${3:/some/path}${4}" do + ${5} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/dest.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/dest.snippet new file mode 100644 index 00000000..b3b3e01a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/dest.snippet @@ -0,0 +1,3 @@ +describe ${1:Type} do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/dests.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/dests.snippet new file mode 100644 index 00000000..89e9372c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/dests.snippet @@ -0,0 +1,3 @@ +describe ${1:Type}, "${2:description}" do + ${3} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/ex.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/ex.snippet new file mode 100644 index 00000000..2e5a4a01 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/ex.snippet @@ -0,0 +1 @@ +exactly(${1:n}).times diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/isbl.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/isbl.snippet new file mode 100644 index 00000000..728223f0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/isbl.snippet @@ -0,0 +1 @@ +it_should_behave_like '${1:do something}' diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/it.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/it.snippet new file mode 100644 index 00000000..8af38db4 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/it.snippet @@ -0,0 +1,3 @@ +it "${1}" do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/its.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/its.snippet new file mode 100644 index 00000000..963f4041 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/its.snippet @@ -0,0 +1 @@ +it "should ${1:do something}" do${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/mat.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/mat.snippet new file mode 100644 index 00000000..2f047710 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/mat.snippet @@ -0,0 +1,24 @@ +class ${1:ReverseTo} + def initialize(${2:param}) + @$2 = $2 + end + + def matches?(actual) + @actual = actual + # Satisfy expectation here. Return false or raise an error if it's not met. + ${3:@actual.reverse.should == @$2} + true + end + + def failure_message + "expected #{@actual.inspect} to ${4} #{@$2.inspect}, but it didn't" + end + + def negative_failure_message + "expected #{@actual.inspect} not to ${5} #{@$2.inspect}, but it did" + end +end + +def ${6:reverse_to}(${7:expected}) + ${8}.new($7) +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/mm.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/mm.snippet new file mode 100644 index 00000000..b10aa1d5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/mm.snippet @@ -0,0 +1 @@ +mock_model(${1:model})${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/moc.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/moc.snippet new file mode 100644 index 00000000..4ff954f1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/moc.snippet @@ -0,0 +1,2 @@ +${1:var} = mock("${2:mock_name}"${3:, :null_object => true}) +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/mocw.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/mocw.snippet new file mode 100644 index 00000000..09f93e07 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/mocw.snippet @@ -0,0 +1,3 @@ +Spec::Runner.configure do |config| + config.mock_with :${1:mocha|flexmock|rr} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/on.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/on.snippet new file mode 100644 index 00000000..b2d1a776 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/on.snippet @@ -0,0 +1 @@ +once diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/resh.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/resh.snippet new file mode 100644 index 00000000..91cd5b06 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/resh.snippet @@ -0,0 +1 @@ +require File.dirname(__FILE__) + '/../spec_helper' diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/sef.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/sef.snippet new file mode 100644 index 00000000..89d34116 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/sef.snippet @@ -0,0 +1,3 @@ +shared_examples_for "${1:do something}" do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/sh.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/sh.snippet new file mode 100644 index 00000000..67530e9d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/sh.snippet @@ -0,0 +1,2 @@ +${1:target}.should == ${2:value} +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shb.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shb.snippet new file mode 100644 index 00000000..b909d9c0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shb.snippet @@ -0,0 +1,2 @@ +${1:target}.should be(${2:result}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shbc.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shbc.snippet new file mode 100644 index 00000000..9080a3c2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shbc.snippet @@ -0,0 +1,2 @@ +${1:target}.should be_close(${2:result}, ${3:tolerance}) +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shbio.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shbio.snippet new file mode 100644 index 00000000..98a73893 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shbio.snippet @@ -0,0 +1,2 @@ +${1:target}.should be_instance_of(${2:class}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shbko.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shbko.snippet new file mode 100644 index 00000000..74bf8520 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shbko.snippet @@ -0,0 +1,2 @@ +${1:target}.should be_a_kind_of(${2:class}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shbr.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shbr.snippet new file mode 100644 index 00000000..887ef800 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shbr.snippet @@ -0,0 +1,2 @@ +response.should be_redirect +${1} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shbs.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shbs.snippet new file mode 100644 index 00000000..602074b5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shbs.snippet @@ -0,0 +1,2 @@ +response.should be_success +${1} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shc.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shc.snippet new file mode 100644 index 00000000..16206fa1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shc.snippet @@ -0,0 +1,3 @@ +lambda do + ${1} +end.should change(${2:target}, :${3:method}).from(${4:old_value}).to(${5:new_value}).by(${6:change}) diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shdm.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shdm.snippet new file mode 100644 index 00000000..e82d82e7 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shdm.snippet @@ -0,0 +1,2 @@ +${1:target}.should match(/${2:regexp}/) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/she.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/she.snippet new file mode 100644 index 00000000..f896a26e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/she.snippet @@ -0,0 +1,2 @@ +${1:target}.should eql(${2:value}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/sheq.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/sheq.snippet new file mode 100644 index 00000000..e3c389e6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/sheq.snippet @@ -0,0 +1,2 @@ +${1:target}.should equal(${2:value}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shh.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shh.snippet new file mode 100644 index 00000000..93189cb8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shh.snippet @@ -0,0 +1,2 @@ +${1:target}.should have(${2:num}).${3:things} +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shhal.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shhal.snippet new file mode 100644 index 00000000..dabe237a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shhal.snippet @@ -0,0 +1,2 @@ +${1:target}.should have_at_least(${2:num}).${3:things} +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shham.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shham.snippet new file mode 100644 index 00000000..7072add1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shham.snippet @@ -0,0 +1,2 @@ +${1:target}.should have_at_most(${2:num}).${3:things} +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shhr.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shhr.snippet new file mode 100644 index 00000000..b8a8997f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shhr.snippet @@ -0,0 +1,2 @@ +${1:target}.should have(${2:n}).records +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shn.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shn.snippet new file mode 100644 index 00000000..b19cbb67 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shn.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not == ${2:value} +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnb.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnb.snippet new file mode 100644 index 00000000..a34d62e5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnb.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not be(${2:result}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnbc.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbc.snippet new file mode 100644 index 00000000..55ac6d3a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbc.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not be_close(${2:result}, ${3:tolerance}) +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnbio.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbio.snippet new file mode 100644 index 00000000..b6f15267 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbio.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not be_instance_of(${2:klass}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnbko.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbko.snippet new file mode 100644 index 00000000..0b0cfc7f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbko.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not be_a_kind_of(${2:klass}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnbr.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbr.snippet new file mode 100644 index 00000000..25519b08 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbr.snippet @@ -0,0 +1,2 @@ +response.should_not be_redirect +${1} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnbs.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbs.snippet new file mode 100644 index 00000000..7d35ab20 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnbs.snippet @@ -0,0 +1,2 @@ +response.should_not be_success +${1} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnc.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnc.snippet new file mode 100644 index 00000000..7baead27 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnc.snippet @@ -0,0 +1,3 @@ +lambda do + ${1} +end.should_not change(${2:target}, :${3:method}) diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shne.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shne.snippet new file mode 100644 index 00000000..68a7451c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shne.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not eql(${2:value}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shneq.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shneq.snippet new file mode 100644 index 00000000..da4f59b9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shneq.snippet @@ -0,0 +1,2 @@ + ${1:target}.should_not equal(${2:value}) + ${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnm.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnm.snippet new file mode 100644 index 00000000..ee7b6043 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnm.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not match(/${2:regexp}/) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnp.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnp.snippet new file mode 100644 index 00000000..9f1298b7 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnp.snippet @@ -0,0 +1 @@ +${1:target}.should_not be_${2:predicate} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnr.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnr.snippet new file mode 100644 index 00000000..98c0fc08 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnr.snippet @@ -0,0 +1,2 @@ +${1:mock}.should_not_receive(:${2:message})${3} +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnre.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnre.snippet new file mode 100644 index 00000000..fbf9604e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnre.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not raise_error(${2:error}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnredt.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnredt.snippet new file mode 100644 index 00000000..2afb69cc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnredt.snippet @@ -0,0 +1,2 @@ +response.should_not redirect_to(${1:url}) +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnrt.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnrt.snippet new file mode 100644 index 00000000..c2c5f2cb --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnrt.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not respond_to(:${2:sym}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shns.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shns.snippet new file mode 100644 index 00000000..b73a71c8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shns.snippet @@ -0,0 +1,2 @@ +${1:target}.should_not satisfy { |${2:obj}| ${3} } +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shnt.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shnt.snippet new file mode 100644 index 00000000..0353376b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shnt.snippet @@ -0,0 +1,2 @@ +lambda { ${1} }.should_not throw_symbol(:${2:symbol}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shp.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shp.snippet new file mode 100644 index 00000000..9267b612 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shp.snippet @@ -0,0 +1 @@ +${1:target}.should be_${2:predicate} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shr.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shr.snippet new file mode 100644 index 00000000..4effa2c1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shr.snippet @@ -0,0 +1,2 @@ +${1:mock}.should_receive(:${2:message})${3} +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shre.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shre.snippet new file mode 100644 index 00000000..420bbe80 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shre.snippet @@ -0,0 +1,2 @@ +${1:target}.should raise_error(${2:error}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shredt.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shredt.snippet new file mode 100644 index 00000000..979c1d6e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shredt.snippet @@ -0,0 +1,2 @@ +response.should redirect_to(${1:url}) +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shrt.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shrt.snippet new file mode 100644 index 00000000..a796ebd2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shrt.snippet @@ -0,0 +1,2 @@ +${1:target}.should respond_to(:${2:sym}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shs.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shs.snippet new file mode 100644 index 00000000..08eb9419 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shs.snippet @@ -0,0 +1,2 @@ +${1:target}.should satisfy { |${2:obj}| ${3} } +${4} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/sht.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/sht.snippet new file mode 100644 index 00000000..86f55fa3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/sht.snippet @@ -0,0 +1,2 @@ +${1:target}.should throw_symble(:${2:symbol}) +${3} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/shtemp.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/shtemp.snippet new file mode 100644 index 00000000..9b08c10e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/shtemp.snippet @@ -0,0 +1,2 @@ +response.should render_template(:${1:template}) +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/tw.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/tw.snippet new file mode 100644 index 00000000..6ebb6d4a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/tw.snippet @@ -0,0 +1 @@ +twice diff --git a/sources_non_forked/snipmate-snippets/ruby-rspec/wia.snippet b/sources_non_forked/snipmate-snippets/ruby-rspec/wia.snippet new file mode 100644 index 00000000..21eda197 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-rspec/wia.snippet @@ -0,0 +1,2 @@ +with(${1:args}) +${2} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/context.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/context.snippet new file mode 100644 index 00000000..0e5a7fd2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/context.snippet @@ -0,0 +1,5 @@ +context "${1:context}" do + + ${2} + +end diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/samao.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/samao.snippet new file mode 100644 index 00000000..cfd4e59f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/samao.snippet @@ -0,0 +1 @@ +should_allow_mass_assignment_of :${1:field} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/savf.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/savf.snippet new file mode 100644 index 00000000..39cfd6f1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/savf.snippet @@ -0,0 +1 @@ +should_allow_values_for :${1:field}, "${2:value}" diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/sbt.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/sbt.snippet new file mode 100644 index 00000000..90d25c84 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/sbt.snippet @@ -0,0 +1 @@ +should_belong_to :${1:association} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/selal.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/selal.snippet new file mode 100644 index 00000000..2fc48b4a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/selal.snippet @@ -0,0 +1 @@ +should_ensure_length_at_least :${1:field}, ${2:min_length} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/seli.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/seli.snippet new file mode 100644 index 00000000..8bc2bf87 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/seli.snippet @@ -0,0 +1 @@ +should_ensure_length_is :${1:field}, ${2:length} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/selir.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/selir.snippet new file mode 100644 index 00000000..1f0bdc98 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/selir.snippet @@ -0,0 +1 @@ +should_ensure_length_in_range :${1:field}, ${2:start}..${3:end} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/setup.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/setup.snippet new file mode 100644 index 00000000..68b895c1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/setup.snippet @@ -0,0 +1,3 @@ +setup do + ${1} +end diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/sevir.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/sevir.snippet new file mode 100644 index 00000000..195f7484 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/sevir.snippet @@ -0,0 +1 @@ +should_ensure_value_in_range :${1:field}, ${2:start}..${3:end} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/shabtm.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/shabtm.snippet new file mode 100644 index 00000000..03c70e24 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/shabtm.snippet @@ -0,0 +1 @@ +should_have_and_belong_to_many :${1:association} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/shcm.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/shcm.snippet new file mode 100644 index 00000000..6948aea9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/shcm.snippet @@ -0,0 +1 @@ +should_have_class_methods :${1:method} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/shdc.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/shdc.snippet new file mode 100644 index 00000000..d841d650 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/shdc.snippet @@ -0,0 +1 @@ +should_have_db_columns :${1:field} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/shi.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/shi.snippet new file mode 100644 index 00000000..d6d2b389 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/shi.snippet @@ -0,0 +1 @@ +should_have_indices :${1:field} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/shim.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/shim.snippet new file mode 100644 index 00000000..1f442528 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/shim.snippet @@ -0,0 +1 @@ +should_have_instance_methods :${1:method} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/shm.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/shm.snippet new file mode 100644 index 00000000..8c98c17e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/shm.snippet @@ -0,0 +1 @@ +should_have_many :${1:association} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/sho.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/sho.snippet new file mode 100644 index 00000000..a652b4f5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/sho.snippet @@ -0,0 +1 @@ +should_have_one :${1:association} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/shroa.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/shroa.snippet new file mode 100644 index 00000000..022015df --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/shroa.snippet @@ -0,0 +1 @@ +should_have_read_only_attributes :${1:field} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/snamao.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/snamao.snippet new file mode 100644 index 00000000..236190b5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/snamao.snippet @@ -0,0 +1 @@ +should_not_allow_mass_assignment_of :${1:field} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/snavf.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/snavf.snippet new file mode 100644 index 00000000..029c5bab --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/snavf.snippet @@ -0,0 +1 @@ +should_not_allow_values_for :${1:field}, "${2:value}" diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/svao.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/svao.snippet new file mode 100644 index 00000000..8eccb887 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/svao.snippet @@ -0,0 +1 @@ +should_validate_acceptance_of :${1:field} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/svno.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/svno.snippet new file mode 100644 index 00000000..a90c1cab --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/svno.snippet @@ -0,0 +1 @@ +should_validate_numericality_of :${1:field} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/svpo.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/svpo.snippet new file mode 100644 index 00000000..13598f86 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/svpo.snippet @@ -0,0 +1 @@ +should_validate_presence_of :${1:field} diff --git a/sources_non_forked/snipmate-snippets/ruby-shoulda/svuo.snippet b/sources_non_forked/snipmate-snippets/ruby-shoulda/svuo.snippet new file mode 100644 index 00000000..6e26912d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby-shoulda/svuo.snippet @@ -0,0 +1 @@ +should_validate_uniqueness_of :${1:field}, :scoped_to => ${2:arrayofnames} diff --git a/sources_non_forked/snipmate-snippets/ruby/Md.snippet b/sources_non_forked/snipmate-snippets/ruby/Md.snippet new file mode 100644 index 00000000..1c2c9f10 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/Md.snippet @@ -0,0 +1 @@ +File.open(${1:dump_path}, "wb") { |${2:file}| Marshal.dump(${3:obj}, ${4:$2}) } diff --git a/sources_non_forked/snipmate-snippets/ruby/Ml.snippet b/sources_non_forked/snipmate-snippets/ruby/Ml.snippet new file mode 100644 index 00000000..33c3200c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/Ml.snippet @@ -0,0 +1 @@ +File.open(${1:dump_path}, "rb") { |${2:file}| Marshal.load(${3:$2}) } diff --git a/sources_non_forked/snipmate-snippets/ruby/Pn.snippet b/sources_non_forked/snipmate-snippets/ruby/Pn.snippet new file mode 100644 index 00000000..e2136913 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/Pn.snippet @@ -0,0 +1 @@ +PStore.new(${1}) diff --git a/sources_non_forked/snipmate-snippets/ruby/Yd.snippet b/sources_non_forked/snipmate-snippets/ruby/Yd.snippet new file mode 100644 index 00000000..e667a081 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/Yd.snippet @@ -0,0 +1 @@ +File.open(${1:path_to_yml}, "w") { |${2:file}| YAML.dump(${3:obj}, ${4:$2}) } diff --git a/sources_non_forked/snipmate-snippets/ruby/Yl.snippet b/sources_non_forked/snipmate-snippets/ruby/Yl.snippet new file mode 100644 index 00000000..b37d1bb5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/Yl.snippet @@ -0,0 +1 @@ +File.open(${1:path_to_yml}) { |${2:file}| YAML.load(${3:$2}) } diff --git a/sources_non_forked/snipmate-snippets/ruby/am.snippet b/sources_non_forked/snipmate-snippets/ruby/am.snippet new file mode 100644 index 00000000..91209b9b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/am.snippet @@ -0,0 +1 @@ +alias_method :${1:new_name}, :${2:old_name} diff --git a/sources_non_forked/snipmate-snippets/ruby/as.snippet b/sources_non_forked/snipmate-snippets/ruby/as.snippet new file mode 100644 index 00000000..a8c7f5cb --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/as.snippet @@ -0,0 +1 @@ +assert ${1:test}, "${2:failure_message}" diff --git a/sources_non_forked/snipmate-snippets/ruby/asam.snippet b/sources_non_forked/snipmate-snippets/ruby/asam.snippet new file mode 100644 index 00000000..3c95b31c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asam.snippet @@ -0,0 +1 @@ +assert_alias_method ${1:object}, ${2:alias_name}, ${3:original_name} diff --git a/sources_non_forked/snipmate-snippets/ruby/asb.snippet b/sources_non_forked/snipmate-snippets/ruby/asb.snippet new file mode 100644 index 00000000..ab1eff71 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asb.snippet @@ -0,0 +1 @@ +assert_boolean ${1:actual} diff --git a/sources_non_forked/snipmate-snippets/ruby/asc.snippet b/sources_non_forked/snipmate-snippets/ruby/asc.snippet new file mode 100644 index 00000000..c6badc3e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asc.snippet @@ -0,0 +1 @@ +assert_compare ${1:expected}, ${2:operator}, ${3:actual} diff --git a/sources_non_forked/snipmate-snippets/ruby/ascd.snippet b/sources_non_forked/snipmate-snippets/ruby/ascd.snippet new file mode 100644 index 00000000..bc77908f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/ascd.snippet @@ -0,0 +1 @@ +assert_const_defined ${1:object}, ${2:constant_name} diff --git a/sources_non_forked/snipmate-snippets/ruby/ase.snippet b/sources_non_forked/snipmate-snippets/ruby/ase.snippet new file mode 100644 index 00000000..5f650990 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/ase.snippet @@ -0,0 +1 @@ +assert_equal ${1:expected}, ${2:actual} diff --git a/sources_non_forked/snipmate-snippets/ruby/asem.snippet b/sources_non_forked/snipmate-snippets/ruby/asem.snippet new file mode 100644 index 00000000..46428325 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asem.snippet @@ -0,0 +1 @@ +assert_empty ${1:object} diff --git a/sources_non_forked/snipmate-snippets/ruby/asf.snippet b/sources_non_forked/snipmate-snippets/ruby/asf.snippet new file mode 100644 index 00000000..27ff6da5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asf.snippet @@ -0,0 +1 @@ +assert_false ${1:actual} diff --git a/sources_non_forked/snipmate-snippets/ruby/asfa.snippet b/sources_non_forked/snipmate-snippets/ruby/asfa.snippet new file mode 100644 index 00000000..f45fa53f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asfa.snippet @@ -0,0 +1 @@ +assert_fail_assertion { ${1:block} } diff --git a/sources_non_forked/snipmate-snippets/ruby/asi.snippet b/sources_non_forked/snipmate-snippets/ruby/asi.snippet new file mode 100644 index 00000000..dedf94d2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asi.snippet @@ -0,0 +1 @@ +assert_include ${1:collection}, ${2:object} diff --git a/sources_non_forked/snipmate-snippets/ruby/asid.snippet b/sources_non_forked/snipmate-snippets/ruby/asid.snippet new file mode 100644 index 00000000..683fb06c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asid.snippet @@ -0,0 +1 @@ +assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:delta_float} diff --git a/sources_non_forked/snipmate-snippets/ruby/asie.snippet b/sources_non_forked/snipmate-snippets/ruby/asie.snippet new file mode 100644 index 00000000..f13d0a36 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asie.snippet @@ -0,0 +1 @@ +assert_in_epsilon ${1:expected_float}, ${2:actual_float} diff --git a/sources_non_forked/snipmate-snippets/ruby/asio.snippet b/sources_non_forked/snipmate-snippets/ruby/asio.snippet new file mode 100644 index 00000000..56f0ab7e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asio.snippet @@ -0,0 +1 @@ +assert_instance_of ${1:ExpectedClass}, ${2:actual_instance} diff --git a/sources_non_forked/snipmate-snippets/ruby/asko.snippet b/sources_non_forked/snipmate-snippets/ruby/asko.snippet new file mode 100644 index 00000000..555bf138 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asko.snippet @@ -0,0 +1 @@ +assert_kind_of ${1:ExpectedKind}, ${2:actual_instance} diff --git a/sources_non_forked/snipmate-snippets/ruby/asm.snippet b/sources_non_forked/snipmate-snippets/ruby/asm.snippet new file mode 100644 index 00000000..9860b4cf --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asm.snippet @@ -0,0 +1 @@ +assert_match /${1:expected_pattern}/, ${2:actual_string} diff --git a/sources_non_forked/snipmate-snippets/ruby/asn.snippet b/sources_non_forked/snipmate-snippets/ruby/asn.snippet new file mode 100644 index 00000000..36a2898e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asn.snippet @@ -0,0 +1 @@ +assert_nil ${1:instance} diff --git a/sources_non_forked/snipmate-snippets/ruby/asncd.snippet b/sources_non_forked/snipmate-snippets/ruby/asncd.snippet new file mode 100644 index 00000000..b4dcd735 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asncd.snippet @@ -0,0 +1 @@ +assert_not_const_defined ${1:object}, ${2:constant_name} diff --git a/sources_non_forked/snipmate-snippets/ruby/asne.snippet b/sources_non_forked/snipmate-snippets/ruby/asne.snippet new file mode 100644 index 00000000..91db286a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asne.snippet @@ -0,0 +1 @@ +assert_not_equal ${1:unexpected}, ${2:actual} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnem.snippet b/sources_non_forked/snipmate-snippets/ruby/asnem.snippet new file mode 100644 index 00000000..43d07728 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnem.snippet @@ -0,0 +1 @@ +assert_not_empty ${1:object} diff --git a/sources_non_forked/snipmate-snippets/ruby/asni.snippet b/sources_non_forked/snipmate-snippets/ruby/asni.snippet new file mode 100644 index 00000000..d450d9ea --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asni.snippet @@ -0,0 +1 @@ +assert_not_include ${1:collection}, ${2:object} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnid.snippet b/sources_non_forked/snipmate-snippets/ruby/asnid.snippet new file mode 100644 index 00000000..23e039ad --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnid.snippet @@ -0,0 +1 @@ +assert_not_in_delta ${1:expected_float}, ${2:actual_float} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnie.snippet b/sources_non_forked/snipmate-snippets/ruby/asnie.snippet new file mode 100644 index 00000000..25eb7515 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnie.snippet @@ -0,0 +1 @@ +assert_not_in_epsilon ${1:expected_float}, ${2:actual_float} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnm.snippet b/sources_non_forked/snipmate-snippets/ruby/asnm.snippet new file mode 100644 index 00000000..95dbf247 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnm.snippet @@ -0,0 +1 @@ +assert_no_match /${1:unexpected_pattern}/, ${2:actual_string} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnn.snippet b/sources_non_forked/snipmate-snippets/ruby/asnn.snippet new file mode 100644 index 00000000..9227bc8a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnn.snippet @@ -0,0 +1 @@ +assert_not_nil ${1:instance} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnp.snippet b/sources_non_forked/snipmate-snippets/ruby/asnp.snippet new file mode 100644 index 00000000..a540f84d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnp.snippet @@ -0,0 +1 @@ +assert_not_predicate ${1:object}, ${2:predicate} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnr.snippet b/sources_non_forked/snipmate-snippets/ruby/asnr.snippet new file mode 100644 index 00000000..fc9a8204 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnr.snippet @@ -0,0 +1 @@ +assert_nothing_raised { ${1:block} } diff --git a/sources_non_forked/snipmate-snippets/ruby/asnrt.snippet b/sources_non_forked/snipmate-snippets/ruby/asnrt.snippet new file mode 100644 index 00000000..fb063d28 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnrt.snippet @@ -0,0 +1 @@ +assert_not_respond_to ${1:object}, ${2:method} diff --git a/sources_non_forked/snipmate-snippets/ruby/asns.snippet b/sources_non_forked/snipmate-snippets/ruby/asns.snippet new file mode 100644 index 00000000..509e467a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asns.snippet @@ -0,0 +1 @@ +assert_not_same ${1:unexpected}, ${2:actual} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnse.snippet b/sources_non_forked/snipmate-snippets/ruby/asnse.snippet new file mode 100644 index 00000000..befde129 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnse.snippet @@ -0,0 +1 @@ +assert_not_send ${1:send_array} diff --git a/sources_non_forked/snipmate-snippets/ruby/asnt.snippet b/sources_non_forked/snipmate-snippets/ruby/asnt.snippet new file mode 100644 index 00000000..cb633c22 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asnt.snippet @@ -0,0 +1 @@ +assert_nothing_thrown { ${1} } diff --git a/sources_non_forked/snipmate-snippets/ruby/aso.snippet b/sources_non_forked/snipmate-snippets/ruby/aso.snippet new file mode 100644 index 00000000..5b7faf64 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/aso.snippet @@ -0,0 +1 @@ +assert_operator ${1:left}, :${2:operator}, ${3:right} diff --git a/sources_non_forked/snipmate-snippets/ruby/asp.snippet b/sources_non_forked/snipmate-snippets/ruby/asp.snippet new file mode 100644 index 00000000..c23fd3f6 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asp.snippet @@ -0,0 +1 @@ +assert_predicate ${1:object}, ${2:predicate} diff --git a/sources_non_forked/snipmate-snippets/ruby/aspe.snippet b/sources_non_forked/snipmate-snippets/ruby/aspe.snippet new file mode 100644 index 00000000..3a3eed4f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/aspe.snippet @@ -0,0 +1 @@ +assert_path_exist ${1:path} diff --git a/sources_non_forked/snipmate-snippets/ruby/aspne.snippet b/sources_non_forked/snipmate-snippets/ruby/aspne.snippet new file mode 100644 index 00000000..f7a8873a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/aspne.snippet @@ -0,0 +1 @@ +assert_path_not_exist ${1:path} diff --git a/sources_non_forked/snipmate-snippets/ruby/asr.snippet b/sources_non_forked/snipmate-snippets/ruby/asr.snippet new file mode 100644 index 00000000..834038d5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asr.snippet @@ -0,0 +1 @@ +assert_raise(${1:Exception}) { ${2} } diff --git a/sources_non_forked/snipmate-snippets/ruby/asrko.snippet b/sources_non_forked/snipmate-snippets/ruby/asrko.snippet new file mode 100644 index 00000000..f82820ed --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asrko.snippet @@ -0,0 +1 @@ +assert_raise_kind_of(${1:kinds...}) { ${2:block} } diff --git a/sources_non_forked/snipmate-snippets/ruby/asrm.snippet b/sources_non_forked/snipmate-snippets/ruby/asrm.snippet new file mode 100644 index 00000000..f62f208b --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asrm.snippet @@ -0,0 +1 @@ +assert_raise_message ${1:expected_message} diff --git a/sources_non_forked/snipmate-snippets/ruby/asrt.snippet b/sources_non_forked/snipmate-snippets/ruby/asrt.snippet new file mode 100644 index 00000000..ca8e84b7 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asrt.snippet @@ -0,0 +1 @@ +assert_respond_to ${1:object}, :${2:method} diff --git a/sources_non_forked/snipmate-snippets/ruby/asse.snippet b/sources_non_forked/snipmate-snippets/ruby/asse.snippet new file mode 100644 index 00000000..4fb9ef9a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/asse.snippet @@ -0,0 +1 @@ +assert_send ${1:send_array} diff --git a/sources_non_forked/snipmate-snippets/ruby/ast.snippet b/sources_non_forked/snipmate-snippets/ruby/ast.snippet new file mode 100644 index 00000000..8962cfb7 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/ast.snippet @@ -0,0 +1 @@ +assert_throws(:${1:expected}) { ${2} } diff --git a/sources_non_forked/snipmate-snippets/ruby/astr.snippet b/sources_non_forked/snipmate-snippets/ruby/astr.snippet new file mode 100644 index 00000000..b9d14f6e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/astr.snippet @@ -0,0 +1 @@ +assert_true ${1:actual} diff --git a/sources_non_forked/snipmate-snippets/ruby/bm.snippet b/sources_non_forked/snipmate-snippets/ruby/bm.snippet new file mode 100644 index 00000000..681c5621 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/bm.snippet @@ -0,0 +1,4 @@ +TESTS = ${1:10_000} +Benchmark.bmbm do |results| + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/case.snippet b/sources_non_forked/snipmate-snippets/ruby/case.snippet new file mode 100644 index 00000000..085a45db --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/case.snippet @@ -0,0 +1,5 @@ +case ${1} +when ${2} +else + ${3} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/class.snippet b/sources_non_forked/snipmate-snippets/ruby/class.snippet new file mode 100644 index 00000000..cb396704 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/class.snippet @@ -0,0 +1,3 @@ +class ${1:`Snippet_RubyClassNameFromFilename()`}${2} + ${3} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/classe.snippet b/sources_non_forked/snipmate-snippets/ruby/classe.snippet new file mode 100644 index 00000000..f683c688 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/classe.snippet @@ -0,0 +1 @@ +class ${1:ErrorClassName} < ${2:StandardError}; end${3} diff --git a/sources_non_forked/snipmate-snippets/ruby/def.snippet b/sources_non_forked/snipmate-snippets/ruby/def.snippet new file mode 100644 index 00000000..ad9bc8cf --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/def.snippet @@ -0,0 +1,3 @@ +def ${1:name} + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/defi.snippet b/sources_non_forked/snipmate-snippets/ruby/defi.snippet new file mode 100644 index 00000000..12c354c8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/defi.snippet @@ -0,0 +1,3 @@ +def initialize${1} + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/defmm.snippet b/sources_non_forked/snipmate-snippets/ruby/defmm.snippet new file mode 100644 index 00000000..e3b263a8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/defmm.snippet @@ -0,0 +1,3 @@ +def method_missing(meth, *args, &blk) + ${1} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/defs.snippet b/sources_non_forked/snipmate-snippets/ruby/defs.snippet new file mode 100644 index 00000000..837733f2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/defs.snippet @@ -0,0 +1,3 @@ +def self.${1:class_method_name} + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/deft.snippet b/sources_non_forked/snipmate-snippets/ruby/deft.snippet new file mode 100644 index 00000000..9c2adbff --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/deft.snippet @@ -0,0 +1,3 @@ +def test_${1:case_name} + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/detect.snippet b/sources_non_forked/snipmate-snippets/ruby/detect.snippet new file mode 100644 index 00000000..5fc24aaa --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/detect.snippet @@ -0,0 +1 @@ +detect { |${1:element}| ${2:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/detecto.snippet b/sources_non_forked/snipmate-snippets/ruby/detecto.snippet new file mode 100644 index 00000000..904b2a67 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/detecto.snippet @@ -0,0 +1,3 @@ +detect do |${1:element}| + ${2:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/dglob.snippet b/sources_non_forked/snipmate-snippets/ruby/dglob.snippet new file mode 100644 index 00000000..ca326ade --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/dglob.snippet @@ -0,0 +1 @@ +Dir.glob(${1:"<+dir}"+>) { |${2:file}| ${3} } diff --git a/sources_non_forked/snipmate-snippets/ruby/do.snippet b/sources_non_forked/snipmate-snippets/ruby/do.snippet new file mode 100644 index 00000000..596c11a9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/do.snippet @@ -0,0 +1,3 @@ +do + ${1} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/dop.snippet b/sources_non_forked/snipmate-snippets/ruby/dop.snippet new file mode 100644 index 00000000..9bf1898a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/dop.snippet @@ -0,0 +1,3 @@ +do |${1:param}| + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/ea.snippet b/sources_non_forked/snipmate-snippets/ruby/ea.snippet new file mode 100644 index 00000000..5f7edec0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/ea.snippet @@ -0,0 +1 @@ +each { |${1:element}| ${2:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/each.snippet b/sources_non_forked/snipmate-snippets/ruby/each.snippet new file mode 100644 index 00000000..5f7edec0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/each.snippet @@ -0,0 +1 @@ +each { |${1:element}| ${2:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/each_with_index.snippet b/sources_non_forked/snipmate-snippets/ruby/each_with_index.snippet new file mode 100644 index 00000000..f4d3ef11 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/each_with_index.snippet @@ -0,0 +1 @@ +each_with_index { |${1:element},${2:i}| ${3:} } diff --git a/sources_non_forked/snipmate-snippets/ruby/each_with_indexo.snippet b/sources_non_forked/snipmate-snippets/ruby/each_with_indexo.snippet new file mode 100644 index 00000000..e4fb7080 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/each_with_indexo.snippet @@ -0,0 +1,4 @@ +each_with_index do |${1:element},${2:i}| + ${3:body} +end + diff --git a/sources_non_forked/snipmate-snippets/ruby/eacho.snippet b/sources_non_forked/snipmate-snippets/ruby/eacho.snippet new file mode 100644 index 00000000..7c133426 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/eacho.snippet @@ -0,0 +1,3 @@ +each do |${1:element}| + ${2:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/eado.snippet b/sources_non_forked/snipmate-snippets/ruby/eado.snippet new file mode 100644 index 00000000..7c133426 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/eado.snippet @@ -0,0 +1,3 @@ +each do |${1:element}| + ${2:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/eawi.snippet b/sources_non_forked/snipmate-snippets/ruby/eawi.snippet new file mode 100644 index 00000000..f4d3ef11 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/eawi.snippet @@ -0,0 +1 @@ +each_with_index { |${1:element},${2:i}| ${3:} } diff --git a/sources_non_forked/snipmate-snippets/ruby/eawido.snippet b/sources_non_forked/snipmate-snippets/ruby/eawido.snippet new file mode 100644 index 00000000..e4fb7080 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/eawido.snippet @@ -0,0 +1,4 @@ +each_with_index do |${1:element},${2:i}| + ${3:body} +end + diff --git a/sources_non_forked/snipmate-snippets/ruby/elsif.snippet b/sources_non_forked/snipmate-snippets/ruby/elsif.snippet new file mode 100644 index 00000000..84d8134e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/elsif.snippet @@ -0,0 +1,2 @@ +elsif ${1:condition} + ${2} diff --git a/sources_non_forked/snipmate-snippets/ruby/fileeach.snippet b/sources_non_forked/snipmate-snippets/ruby/fileeach.snippet new file mode 100644 index 00000000..5076ef1a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/fileeach.snippet @@ -0,0 +1 @@ +File.foreach(${1:"<+path}"+>) { |${2:line}| ${3} } diff --git a/sources_non_forked/snipmate-snippets/ruby/fopen.snippet b/sources_non_forked/snipmate-snippets/ruby/fopen.snippet new file mode 100644 index 00000000..b630bfeb --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/fopen.snippet @@ -0,0 +1 @@ +File.open(${1:path}, "${2:rwab}") { |${3:file}| ${4} } diff --git a/sources_non_forked/snipmate-snippets/ruby/fread.snippet b/sources_non_forked/snipmate-snippets/ruby/fread.snippet new file mode 100644 index 00000000..d9e6074c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/fread.snippet @@ -0,0 +1 @@ +File.read(${1}) diff --git a/sources_non_forked/snipmate-snippets/ruby/http_get.snippet b/sources_non_forked/snipmate-snippets/ruby/http_get.snippet new file mode 100644 index 00000000..cba6d589 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/http_get.snippet @@ -0,0 +1,2 @@ +require 'net/http' +res = Net::HTTP.get URI.parse('${1:url}') diff --git a/sources_non_forked/snipmate-snippets/ruby/http_post.snippet b/sources_non_forked/snipmate-snippets/ruby/http_post.snippet new file mode 100644 index 00000000..3b2036ad --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/http_post.snippet @@ -0,0 +1,2 @@ +require 'net/http' +res = Net::HTTP.post_form URI.parse('${1:url}')${2:, params} diff --git a/sources_non_forked/snipmate-snippets/ruby/if.snippet b/sources_non_forked/snipmate-snippets/ruby/if.snippet new file mode 100644 index 00000000..b2d1e39e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/if.snippet @@ -0,0 +1,3 @@ +if ${1:condition} + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/ife.snippet b/sources_non_forked/snipmate-snippets/ruby/ife.snippet new file mode 100644 index 00000000..2a7468df --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/ife.snippet @@ -0,0 +1,4 @@ +if ${1:condition} + ${2} +else +end diff --git a/sources_non_forked/snipmate-snippets/ruby/inj.snippet b/sources_non_forked/snipmate-snippets/ruby/inj.snippet new file mode 100644 index 00000000..90dea0d8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/inj.snippet @@ -0,0 +1 @@ +inject(${1:init}) { |${2:total}, ${3:next}| ${4:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/injdo.snippet b/sources_non_forked/snipmate-snippets/ruby/injdo.snippet new file mode 100644 index 00000000..d3235e90 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/injdo.snippet @@ -0,0 +1,3 @@ +inject(${1:init}) do |${2:total}, ${3:next}| + ${4:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/inject.snippet b/sources_non_forked/snipmate-snippets/ruby/inject.snippet new file mode 100644 index 00000000..78ad721d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/inject.snippet @@ -0,0 +1 @@ +inject { |${1:total},${2:next}| ${3:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/injecto.snippet b/sources_non_forked/snipmate-snippets/ruby/injecto.snippet new file mode 100644 index 00000000..1631033d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/injecto.snippet @@ -0,0 +1,3 @@ +inject do |${1:total},${2:next}| + ${3:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/ip.snippet b/sources_non_forked/snipmate-snippets/ruby/ip.snippet new file mode 100644 index 00000000..91769768 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/ip.snippet @@ -0,0 +1 @@ +ip_addr = request.env['REMOTE_ADDR'] diff --git a/sources_non_forked/snipmate-snippets/ruby/map.snippet b/sources_non_forked/snipmate-snippets/ruby/map.snippet new file mode 100644 index 00000000..b3e7719f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/map.snippet @@ -0,0 +1 @@ +map { |${1:element}| ${2:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/mapdo.snippet b/sources_non_forked/snipmate-snippets/ruby/mapdo.snippet new file mode 100644 index 00000000..316e7c7c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/mapdo.snippet @@ -0,0 +1,3 @@ +map do |${1:element}| + ${2:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/mapo.snippet b/sources_non_forked/snipmate-snippets/ruby/mapo.snippet new file mode 100644 index 00000000..316e7c7c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/mapo.snippet @@ -0,0 +1,3 @@ +map do |${1:element}| + ${2:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/mod.snippet b/sources_non_forked/snipmate-snippets/ruby/mod.snippet new file mode 100644 index 00000000..457fd615 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/mod.snippet @@ -0,0 +1,3 @@ +module ${1:`Snippet_RubyClassNameFromFilename()`} + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/module.snippet b/sources_non_forked/snipmate-snippets/ruby/module.snippet new file mode 100644 index 00000000..78e025a1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/module.snippet @@ -0,0 +1,14 @@ +module ${1:`Snippet_RubyClassNameFromFilename()`} + module ClassMethods + ${2} + end + + module InstanceMethods + + end + + def self.included(receiver) + receiver.extend ClassMethods + receiver.send :include, InstanceMethods + end +end diff --git a/sources_non_forked/snipmate-snippets/ruby/nam.snippet b/sources_non_forked/snipmate-snippets/ruby/nam.snippet new file mode 100644 index 00000000..19b90a76 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/nam.snippet @@ -0,0 +1,3 @@ +namespace :${1:namespace} do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/ope.snippet b/sources_non_forked/snipmate-snippets/ruby/ope.snippet new file mode 100644 index 00000000..cfe92471 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/ope.snippet @@ -0,0 +1 @@ +open(${1:path}, "${2:rwab}") { |${3:io}| ${4} } diff --git a/sources_non_forked/snipmate-snippets/ruby/pathhere.snippet b/sources_non_forked/snipmate-snippets/ruby/pathhere.snippet new file mode 100644 index 00000000..f4ed9440 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/pathhere.snippet @@ -0,0 +1 @@ +File.join(File.dirname(__FILE__), *%w[${1:rel_path_here}]) diff --git a/sources_non_forked/snipmate-snippets/ruby/r.snippet b/sources_non_forked/snipmate-snippets/ruby/r.snippet new file mode 100644 index 00000000..f232fc94 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/r.snippet @@ -0,0 +1 @@ +attr_reader :${1:attr_names} diff --git a/sources_non_forked/snipmate-snippets/ruby/reject.snippet b/sources_non_forked/snipmate-snippets/ruby/reject.snippet new file mode 100644 index 00000000..07d2787f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/reject.snippet @@ -0,0 +1 @@ +reject { |${1:element}| ${2:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/rejecto.snippet b/sources_non_forked/snipmate-snippets/ruby/rejecto.snippet new file mode 100644 index 00000000..e906bd7e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/rejecto.snippet @@ -0,0 +1,3 @@ +reject do |${1:element}| + ${2:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/rep.snippet b/sources_non_forked/snipmate-snippets/ruby/rep.snippet new file mode 100644 index 00000000..04b77b0d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/rep.snippet @@ -0,0 +1 @@ +results.report("${1:name}:") { TESTS.times { ${2} } } diff --git a/sources_non_forked/snipmate-snippets/ruby/rw.snippet b/sources_non_forked/snipmate-snippets/ruby/rw.snippet new file mode 100644 index 00000000..1862da33 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/rw.snippet @@ -0,0 +1 @@ +attr_accessor :${1:attr_names} diff --git a/sources_non_forked/snipmate-snippets/ruby/select.snippet b/sources_non_forked/snipmate-snippets/ruby/select.snippet new file mode 100644 index 00000000..8ab228cc --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/select.snippet @@ -0,0 +1 @@ +select { |${1:element}| ${2:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/selecto.snippet b/sources_non_forked/snipmate-snippets/ruby/selecto.snippet new file mode 100644 index 00000000..a22a6505 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/selecto.snippet @@ -0,0 +1,3 @@ +select do |${1:element}| + ${2:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/sinc.snippet b/sources_non_forked/snipmate-snippets/ruby/sinc.snippet new file mode 100644 index 00000000..20e2c4c9 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/sinc.snippet @@ -0,0 +1 @@ +class << self; self end diff --git a/sources_non_forked/snipmate-snippets/ruby/sort.snippet b/sources_non_forked/snipmate-snippets/ruby/sort.snippet new file mode 100644 index 00000000..08a67c1a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/sort.snippet @@ -0,0 +1 @@ +sort { |${1:x},${2:y}| ${3:body} } diff --git a/sources_non_forked/snipmate-snippets/ruby/sorto.snippet b/sources_non_forked/snipmate-snippets/ruby/sorto.snippet new file mode 100644 index 00000000..76c38e40 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/sorto.snippet @@ -0,0 +1,3 @@ +sort do |${1:x},${2:y}| + ${3:body} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/tas.snippet b/sources_non_forked/snipmate-snippets/ruby/tas.snippet new file mode 100644 index 00000000..d949a6b5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/tas.snippet @@ -0,0 +1,4 @@ +desc "${1:Task description}" +task :${2:task_name}${3: => [:dependent, :tasks]} do + ${4} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/task.snippet b/sources_non_forked/snipmate-snippets/ruby/task.snippet new file mode 100644 index 00000000..d949a6b5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/task.snippet @@ -0,0 +1,4 @@ +desc "${1:Task description}" +task :${2:task_name}${3: => [:dependent, :tasks]} do + ${4} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/tc.snippet b/sources_non_forked/snipmate-snippets/ruby/tc.snippet new file mode 100644 index 00000000..3e28f61a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/tc.snippet @@ -0,0 +1,9 @@ +require "test/unit" + +require "${1:library_file_name}" + +class Test${2:`Snippet_RubyClassNameFromFilename()`} < Test::Unit::TestCase + def test_${3:case_name} + ${4} + end +end diff --git a/sources_non_forked/snipmate-snippets/ruby/unless.snippet b/sources_non_forked/snipmate-snippets/ruby/unless.snippet new file mode 100644 index 00000000..3495d2ba --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/unless.snippet @@ -0,0 +1,3 @@ +unless ${1:condition} + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/unlesse.snippet b/sources_non_forked/snipmate-snippets/ruby/unlesse.snippet new file mode 100644 index 00000000..d190b45e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/unlesse.snippet @@ -0,0 +1,4 @@ +unless ${1:condition} + ${2} +else +end diff --git a/sources_non_forked/snipmate-snippets/ruby/w.snippet b/sources_non_forked/snipmate-snippets/ruby/w.snippet new file mode 100644 index 00000000..0650e955 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/w.snippet @@ -0,0 +1 @@ +attr_writer :${1:attr_names} diff --git a/sources_non_forked/snipmate-snippets/ruby/while.snippet b/sources_non_forked/snipmate-snippets/ruby/while.snippet new file mode 100644 index 00000000..6e878fa3 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/while.snippet @@ -0,0 +1,3 @@ +while ${1:condition} + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/xmlr.snippet b/sources_non_forked/snipmate-snippets/ruby/xmlr.snippet new file mode 100644 index 00000000..eeb35802 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/xmlr.snippet @@ -0,0 +1 @@ +REXML::Document.new(File.read(${1:path})) diff --git a/sources_non_forked/snipmate-snippets/ruby/xpa.snippet b/sources_non_forked/snipmate-snippets/ruby/xpa.snippet new file mode 100644 index 00000000..5bff9508 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/xpa.snippet @@ -0,0 +1,3 @@ +elements.each(${1}) do |${2:node}| + ${3} +end diff --git a/sources_non_forked/snipmate-snippets/ruby/zip.snippet b/sources_non_forked/snipmate-snippets/ruby/zip.snippet new file mode 100644 index 00000000..b2c831ab --- /dev/null +++ b/sources_non_forked/snipmate-snippets/ruby/zip.snippet @@ -0,0 +1 @@ +zip(${1:enums}) { |${2:row}| ${3} } diff --git a/sources_non_forked/snipmate-snippets/sinatra/get.snippet b/sources_non_forked/snipmate-snippets/sinatra/get.snippet new file mode 100644 index 00000000..08f3fd5a --- /dev/null +++ b/sources_non_forked/snipmate-snippets/sinatra/get.snippet @@ -0,0 +1,3 @@ +get '${1:/}' do + ${2} +end diff --git a/sources_non_forked/snipmate-snippets/sshconfig/host.snippet b/sources_non_forked/snipmate-snippets/sshconfig/host.snippet new file mode 100644 index 00000000..5992a2d0 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/sshconfig/host.snippet @@ -0,0 +1,3 @@ +Host ${1:name} + Hostname ${2:example.com} + User ${3:username} diff --git a/sources_non_forked/snipmate-snippets/support_functions.vim b/sources_non_forked/snipmate-snippets/support_functions.vim new file mode 100644 index 00000000..a09e81da --- /dev/null +++ b/sources_non_forked/snipmate-snippets/support_functions.vim @@ -0,0 +1,115 @@ +"ruby {{{1 +function! Snippet_RubyClassNameFromFilename(...) + let name = expand("%:t:r") + if len(name) == 0 + if a:0 == 0 + let name = 'MyClass' + else + let name = a:1 + endif + endif + return Snippet_Camelcase(substitute(name, '_spec$', '', '')) +endfunction + +function! Snippet_MigrationNameFromFilename(...) + let name = substitute(expand("%:t:r"), '^.\{-}_', '', '') + if len(name) == 0 + if a:0 == 0 + let name = 'MyClass' + else + let name = a:1 + endif + endif + return Snippet_Camelcase(name) +endfunction + + +"python {{{1 +function! Snippet_PythonClassNameFromFilename(...) + let name = expand("%:t:r") + if len(name) == 0 + if a:0 == 0 + let name = 'MyClass' + else + let name = a:1 + endif + endif + return Snippet_Camelcase(name) +endfunction + +"php {{{1 +function! Snippet_PHPClassNameFromFilename(...) + let name = expand("%:t:r:r") + if len(name) == 0 + if a:0 == 0 + let name = 'MyClass' + else + let name = a:1 + endif + endif + return name +endfunction + +"java {{{1 +function! Snippet_JavaClassNameFromFilename(...) + let name = expand("%:t:r") + if len(name) == 0 + if a:0 == 0 + let name = 'MyClass' + else + let name = a:1 + endif + endif + return name +endfunction + +function! Snippet_JavaInstanceVarType(name) + let oldview = winsaveview() + if searchdecl(a:name) == 0 + normal! B + let old_reg = @" + normal! yaW + let type = @" + let @" = old_reg + call winrestview(oldview) + let type = substitute(type, '\s\+$', '', '') + + "searchdecl treats 'return foo;' as a declaration of foo + if type != 'return' + return type + endif + endif + return "<+type+>" +endfunction + + +"global {{{1 +function! s:start_comment() + return substitute(&commentstring, '^\([^ ]*\)\s*%s\(.*\)$', '\1', '') +endfunction + +function! s:end_comment() + return substitute(&commentstring, '^.*%s\(.*\)$', '\1', '') +endfunction + +function! Snippet_Modeline() + return s:start_comment() . " vim: set ${1:settings}:" . s:end_comment() +endfunction + +function! Snippet_Camelcase(s) + "upcase the first letter + let toReturn = substitute(a:s, '^\(.\)', '\=toupper(submatch(1))', '') + "turn all '_x' into 'X' + return substitute(toReturn, '_\(.\)', '\=toupper(submatch(1))', 'g') +endfunction + +function! Snippet_Underscore(s) + "down the first letter + let toReturn = substitute(a:s, '^\(.\)', '\=tolower(submatch(1))', '') + "turn all 'X' into '_x' + return substitute(toReturn, '\([A-Z]\)', '\=tolower("_".submatch(1))', 'g') +endfunction + + +" modeline {{{1 +" vim: set fdm=marker: diff --git a/sources_non_forked/snipmate-snippets/vim/au.snippet b/sources_non_forked/snipmate-snippets/vim/au.snippet new file mode 100644 index 00000000..d59720a5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/vim/au.snippet @@ -0,0 +1 @@ +autocmd ${1:events} ${2:pattern} ${3:command} diff --git a/sources_non_forked/snipmate-snippets/vim/com.snippet b/sources_non_forked/snipmate-snippets/vim/com.snippet new file mode 100644 index 00000000..b8eeb5b4 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/vim/com.snippet @@ -0,0 +1 @@ +command! -nargs=${1:number_of_args} ${2:other_params} ${2:name} ${2:command} diff --git a/sources_non_forked/snipmate-snippets/vim/func.snippet b/sources_non_forked/snipmate-snippets/vim/func.snippet new file mode 100644 index 00000000..8591a835 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/vim/func.snippet @@ -0,0 +1,8 @@ +"Function: $1 +"Desc: ${3:description} +" +"Arguments: +"${4} +function! ${1:name}(${2}) + ${5} +endfunction diff --git a/sources_non_forked/snipmate-snippets/vim/if.snippet b/sources_non_forked/snipmate-snippets/vim/if.snippet new file mode 100644 index 00000000..336e7a00 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/vim/if.snippet @@ -0,0 +1,3 @@ +if ${1} + ${2} +endif diff --git a/sources_non_forked/snipmate-snippets/vim/ife.snippet b/sources_non_forked/snipmate-snippets/vim/ife.snippet new file mode 100644 index 00000000..c5d16939 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/vim/ife.snippet @@ -0,0 +1,4 @@ +if ${1} + ${2} +else +endif diff --git a/sources_non_forked/snipmate-snippets/vim/log.snippet b/sources_non_forked/snipmate-snippets/vim/log.snippet new file mode 100644 index 00000000..5a867549 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/vim/log.snippet @@ -0,0 +1 @@ +echomsg ${1} diff --git a/sources_non_forked/snipmate-snippets/vim/try.snippet b/sources_non_forked/snipmate-snippets/vim/try.snippet new file mode 100644 index 00000000..cd4c0e72 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/vim/try.snippet @@ -0,0 +1,4 @@ +try + ${2} +catch /${1}/ +endtry diff --git a/sources_non_forked/snipmate-snippets/xslt/call.snippet b/sources_non_forked/snipmate-snippets/xslt/call.snippet new file mode 100644 index 00000000..2fe4f9d1 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/call.snippet @@ -0,0 +1,3 @@ + + ${2} + diff --git a/sources_non_forked/snipmate-snippets/xslt/choose.snippet b/sources_non_forked/snipmate-snippets/xslt/choose.snippet new file mode 100644 index 00000000..1a877543 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/choose.snippet @@ -0,0 +1,7 @@ + + + ${2} + + + + diff --git a/sources_non_forked/snipmate-snippets/xslt/mat.snippet b/sources_non_forked/snipmate-snippets/xslt/mat.snippet new file mode 100644 index 00000000..a566e0ec --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/mat.snippet @@ -0,0 +1,3 @@ + + ${2} + diff --git a/sources_non_forked/snipmate-snippets/xslt/out.snippet b/sources_non_forked/snipmate-snippets/xslt/out.snippet new file mode 100644 index 00000000..88e70c21 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/out.snippet @@ -0,0 +1 @@ + diff --git a/sources_non_forked/snipmate-snippets/xslt/param.snippet b/sources_non_forked/snipmate-snippets/xslt/param.snippet new file mode 100644 index 00000000..f4f9a504 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/param.snippet @@ -0,0 +1 @@ + diff --git a/sources_non_forked/snipmate-snippets/xslt/sty.snippet b/sources_non_forked/snipmate-snippets/xslt/sty.snippet new file mode 100644 index 00000000..f6751c74 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/sty.snippet @@ -0,0 +1,3 @@ + + ${1} + diff --git a/sources_non_forked/snipmate-snippets/xslt/tem.snippet b/sources_non_forked/snipmate-snippets/xslt/tem.snippet new file mode 100644 index 00000000..bcd86d6d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/tem.snippet @@ -0,0 +1,3 @@ + + ${2} + diff --git a/sources_non_forked/snipmate-snippets/xslt/value.snippet b/sources_non_forked/snipmate-snippets/xslt/value.snippet new file mode 100644 index 00000000..9128cc6d --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/value.snippet @@ -0,0 +1 @@ + diff --git a/sources_non_forked/snipmate-snippets/xslt/var.snippet b/sources_non_forked/snipmate-snippets/xslt/var.snippet new file mode 100644 index 00000000..d21b77c8 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/var.snippet @@ -0,0 +1,3 @@ + + ${2} + diff --git a/sources_non_forked/snipmate-snippets/xslt/wparam.snippet b/sources_non_forked/snipmate-snippets/xslt/wparam.snippet new file mode 100644 index 00000000..2284b71c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/wparam.snippet @@ -0,0 +1 @@ + diff --git a/sources_non_forked/snipmate-snippets/xslt/xdec.snippet b/sources_non_forked/snipmate-snippets/xslt/xdec.snippet new file mode 100644 index 00000000..f1e44209 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/xslt/xdec.snippet @@ -0,0 +1,2 @@ + + ${2} diff --git a/sources_non_forked/snipmate-snippets/zend/assert.snippet b/sources_non_forked/snipmate-snippets/zend/assert.snippet new file mode 100644 index 00000000..ca928f25 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/assert.snippet @@ -0,0 +1 @@ +$this->assertTrue(${1:somevar}, '${2:sometext}'); diff --git a/sources_non_forked/snipmate-snippets/zend/boolcol.snippet b/sources_non_forked/snipmate-snippets/zend/boolcol.snippet new file mode 100644 index 00000000..715fe19c --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/boolcol.snippet @@ -0,0 +1 @@ +$this->hasColumn('${1:active}', '${2:boolean}', ${3:1}, array('default' => '${4:1}','notnull' => true)); diff --git a/sources_non_forked/snipmate-snippets/zend/clac.snippet b/sources_non_forked/snipmate-snippets/zend/clac.snippet new file mode 100644 index 00000000..80972a11 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/clac.snippet @@ -0,0 +1,20 @@ +_flashMessenger->addMessage("${1}", '${2:error}'); diff --git a/sources_non_forked/snipmate-snippets/zend/getconf.snippet b/sources_non_forked/snipmate-snippets/zend/getconf.snippet new file mode 100644 index 00000000..10f2b202 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/getconf.snippet @@ -0,0 +1 @@ +$${1:conf} = Zend_Registry::get('${2:config}')->${3:general}; diff --git a/sources_non_forked/snipmate-snippets/zend/input.snippet b/sources_non_forked/snipmate-snippets/zend/input.snippet new file mode 100644 index 00000000..3c4ed27e --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/input.snippet @@ -0,0 +1,4 @@ +formInput(array( 'type' => '${1:hidden}', + 'name' => '${2}', + 'value' => ${3:}, + 'id' => '${4:}' )); ?> diff --git a/sources_non_forked/snipmate-snippets/zend/inputarr.snippet b/sources_non_forked/snipmate-snippets/zend/inputarr.snippet new file mode 100644 index 00000000..8e97bee5 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/inputarr.snippet @@ -0,0 +1,6 @@ +formInput(array( 'type' => '${1:dropdown}', + 'name' => '${2}', + 'label' => '${3:}', + 'errors' => ${4:}, + 'value' => ${5:}, + 'valueList' => ${6:} )); ?> diff --git a/sources_non_forked/snipmate-snippets/zend/intcol.snippet b/sources_non_forked/snipmate-snippets/zend/intcol.snippet new file mode 100644 index 00000000..caacaa61 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/intcol.snippet @@ -0,0 +1 @@ +$this->hasColumn('${1:id}', '${2:integer}', ${3:11}, array(${4:'notnull' => true)}); diff --git a/sources_non_forked/snipmate-snippets/zend/lib.snippet b/sources_non_forked/snipmate-snippets/zend/lib.snippet new file mode 100644 index 00000000..683e22ef --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/lib.snippet @@ -0,0 +1,5 @@ +hasColumn('id', 'integer', 4, array('notnull' => true, + 'primary' => true, + 'autoincrement' => true)); + ${3} + } + +} diff --git a/sources_non_forked/snipmate-snippets/zend/navi.snippet b/sources_non_forked/snipmate-snippets/zend/navi.snippet new file mode 100644 index 00000000..2724ff9f --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/navi.snippet @@ -0,0 +1 @@ +$this->view->navigationActive = array('topnavi' => '${1:home}','subnavi' => '${2:index}'); diff --git a/sources_non_forked/snipmate-snippets/zend/route.snippet b/sources_non_forked/snipmate-snippets/zend/route.snippet new file mode 100644 index 00000000..cdf834b2 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/route.snippet @@ -0,0 +1 @@ +$this->_redirector->gotoRoute(array('controller' => '${1}', 'action' => '${2:index}', 'id' => '${3:}'), '${4:admin_action}'); diff --git a/sources_non_forked/snipmate-snippets/zend/rp.snippet b/sources_non_forked/snipmate-snippets/zend/rp.snippet new file mode 100644 index 00000000..b5dcd1ff --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/rp.snippet @@ -0,0 +1,2 @@ +partial('${1:somefile}.phtml', + array(${2}))?> diff --git a/sources_non_forked/snipmate-snippets/zend/strcol.snippet b/sources_non_forked/snipmate-snippets/zend/strcol.snippet new file mode 100644 index 00000000..98d3cf34 --- /dev/null +++ b/sources_non_forked/snipmate-snippets/zend/strcol.snippet @@ -0,0 +1 @@ +$this->hasColumn('${1:title}', '${2:string}', ${3:255}, array(${4:'notnull' => true})); diff --git a/sources_non_forked/tabular/.gitignore b/sources_non_forked/tabular/.gitignore new file mode 100644 index 00000000..0a56e3fc --- /dev/null +++ b/sources_non_forked/tabular/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_non_forked/tabular/LICENSE.md b/sources_non_forked/tabular/LICENSE.md new file mode 100644 index 00000000..2cc76e9d --- /dev/null +++ b/sources_non_forked/tabular/LICENSE.md @@ -0,0 +1,24 @@ +Copyright (c) 2016, Matthew J. Wozniski +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sources_non_forked/tabular/README.md b/sources_non_forked/tabular/README.md new file mode 100644 index 00000000..adbfeb00 --- /dev/null +++ b/sources_non_forked/tabular/README.md @@ -0,0 +1,29 @@ +Tabular +============== +Sometimes, it's useful to line up text. Naturally, it's nicer to have the +computer do this for you, since aligning things by hand quickly becomes +unpleasant. While there are other plugins for aligning text, the ones I've +tried are either impossibly difficult to understand and use, or too simplistic +to handle complicated tasks. This plugin aims to make the easy things easy +and the hard things possible, without providing an unnecessarily obtuse +interface. It's still a work in progress, and criticisms are welcome. + +See [Aligning Text with Tabular.vim](http://vimcasts.org/episodes/aligning-text-with-tabular-vim/) +for a screencast that shows how Tabular.vim works. + +See [doc/Tabular.txt](http://raw.github.com/godlygeek/tabular/master/doc/Tabular.txt) +for detailed documentation. + +Installation +============== +If you don't have a preferred installation method, I recommend installing +[pathogen.vim](https://github.com/tpope/vim-pathogen), and then simply +copy and paste: + + mkdir -p ~/.vim/bundle + cd ~/.vim/bundle + git clone git://github.com/godlygeek/tabular.git + +Once help tags have been generated (either using Pathogen's `:Helptags` +command, or by pointing vim's `:helptags` command at the directory where you +installed Tabular), you can view the manual with `:help tabular`. diff --git a/sources_non_forked/tabular/after/plugin/TabularMaps.vim b/sources_non_forked/tabular/after/plugin/TabularMaps.vim new file mode 100644 index 00000000..998346fc --- /dev/null +++ b/sources_non_forked/tabular/after/plugin/TabularMaps.vim @@ -0,0 +1,73 @@ +" Copyright (c) 2016, Matthew J. Wozniski +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" * Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" * Redistributions in binary form must reproduce the above copyright +" notice, this list of conditions and the following disclaimer in the +" documentation and/or other materials provided with the distribution. +" * The names of the contributors may not be used to endorse or promote +" products derived from this software without specific prior written +" permission. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS +" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, +" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +if !exists(':Tabularize') || get(g:, 'no_default_tabular_maps', 0) + finish " Tabular.vim wasn't loaded or the default maps are unwanted +endif + +let s:save_cpo = &cpo +set cpo&vim + +AddTabularPattern! assignment /[|&+*/%<>=!~-]\@!=]=\|=\~\)\@![|&+*/%<>=!~-]*=/l1r1 +AddTabularPattern! two_spaces / /l0 + +AddTabularPipeline! multiple_spaces / / map(a:lines, "substitute(v:val, ' *', ' ', 'g')") | tabular#TabularizeStrings(a:lines, ' ', 'l0') + +AddTabularPipeline! argument_list /(.*)/ map(a:lines, 'substitute(v:val, ''\s*\([(,)]\)\s*'', ''\1'', ''g'')') + \ | tabular#TabularizeStrings(a:lines, '[(,)]', 'l0') + \ | map(a:lines, 'substitute(v:val, ''\(\s*\),'', '',\1 '', "g")') + \ | map(a:lines, 'substitute(v:val, ''\s*)'', ")", "g")') + +function! SplitCDeclarations(lines) + let rv = [] + for line in a:lines + " split the line into declaractions + let split = split(line, '\s*[,;]\s*') + " separate the type from the first declaration + let type = substitute(split[0], '\%(\%([&*]\s*\)*\)\=\k\+$', '', '') + " add the ; back on every declaration + call map(split, 'v:val . ";"') + " add the first element to the return as-is, and remove it from the list + let rv += [ remove(split, 0) ] + " transform the other elements by adding the type on at the beginning + call map(split, 'type . v:val') + " and add them all to the return + let rv += split + endfor + return rv +endfunction + +AddTabularPipeline! split_declarations /,.*;/ SplitCDeclarations(a:lines) + +AddTabularPattern! ternary_operator /^.\{-}\zs?\|:/l1 + +AddTabularPattern! cpp_io /<<\|>>/l1 + +AddTabularPattern! pascal_assign /:=/l1 + +AddTabularPattern! trailing_c_comments /\/\*\|\*\/\|\/\//l1 + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tabular/autoload/tabular.vim b/sources_non_forked/tabular/autoload/tabular.vim new file mode 100644 index 00000000..f60a73ca --- /dev/null +++ b/sources_non_forked/tabular/autoload/tabular.vim @@ -0,0 +1,409 @@ +" Tabular: Align columnar data using regex-designated column boundaries +" Maintainer: Matthew Wozniski (godlygeek@gmail.com) +" Date: Thu, 03 May 2012 20:49:32 -0400 +" Version: 1.0 +" +" Long Description: +" Sometimes, it's useful to line up text. Naturally, it's nicer to have the +" computer do this for you, since aligning things by hand quickly becomes +" unpleasant. While there are other plugins for aligning text, the ones I've +" tried are either impossibly difficult to understand and use, or too simplistic +" to handle complicated tasks. This plugin aims to make the easy things easy +" and the hard things possible, without providing an unnecessarily obtuse +" interface. It's still a work in progress, and criticisms are welcome. +" +" License: +" Copyright (c) 2012, Matthew J. Wozniski +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" * Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" * Redistributions in binary form must reproduce the above copyright +" notice, this list of conditions and the following disclaimer in the +" documentation and/or other materials provided with the distribution. +" * The names of the contributors may not be used to endorse or promote +" products derived from this software without specific prior written +" permission. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS +" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, +" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +" Stupid vimscript crap {{{1 +let s:savecpo = &cpo +set cpo&vim + +" Private Functions {{{1 + +" Return the number of bytes in a string after expanding tabs to spaces. {{{2 +" This expansion is done based on the current value of 'tabstop' +if exists('*strdisplaywidth') + " Needs vim 7.3 + let s:Strlen = function("strdisplaywidth") +else + function! s:Strlen(string) + " Implement the tab handling part of strdisplaywidth for vim 7.2 and + " earlier - not much that can be done about handling doublewidth + " characters. + let rv = 0 + let i = 0 + + for char in split(a:string, '\zs') + if char == "\t" + let rv += &ts - i + let i = 0 + else + let rv += 1 + let i = (i + 1) % &ts + endif + endfor + + return rv + endfunction +endif + +" Align a string within a field {{{2 +" These functions do not trim leading and trailing spaces. + +" Right align 'string' in a field of size 'fieldwidth' +function! s:Right(string, fieldwidth) + let spaces = a:fieldwidth - s:Strlen(a:string) + return matchstr(a:string, '^\s*') . repeat(" ", spaces) . substitute(a:string, '^\s*', '', '') +endfunction + +" Left align 'string' in a field of size 'fieldwidth' +function! s:Left(string, fieldwidth) + let spaces = a:fieldwidth - s:Strlen(a:string) + return a:string . repeat(" ", spaces) +endfunction + +" Center align 'string' in a field of size 'fieldwidth' +function! s:Center(string, fieldwidth) + let spaces = a:fieldwidth - s:Strlen(a:string) + let right = spaces / 2 + let left = right + (right * 2 != spaces) + return repeat(" ", left) . a:string . repeat(" ", right) +endfunction + +" Remove spaces around a string {{{2 + +" Remove all trailing spaces from a string. +function! s:StripTrailingSpaces(string) + return matchstr(a:string, '^.\{-}\ze\s*$') +endfunction + +" Remove all leading spaces from a string. +function! s:StripLeadingSpaces(string) + return matchstr(a:string, '^\s*\zs.*$') +endfunction + +" Split a string into fields and delimiters {{{2 +" Like split(), but include the delimiters as elements +" All odd numbered elements are delimiters +" All even numbered elements are non-delimiters (including zero) +function! s:SplitDelim(string, delim) + let rv = [] + let beg = 0 + + let len = len(a:string) + let searchoff = 0 + + while 1 + let mid = match(a:string, a:delim, beg + searchoff, 1) + if mid == -1 || mid == len + break + endif + + let matchstr = matchstr(a:string, a:delim, beg + searchoff, 1) + let length = strlen(matchstr) + + if length == 0 && beg == mid + " Zero-length match for a zero-length delimiter - advance past it + let searchoff += 1 + continue + endif + + if beg == mid + let rv += [ "" ] + else + let rv += [ a:string[beg : mid-1] ] + endif + + let rv += [ matchstr ] + + let beg = mid + length + let searchoff = 0 + endwhile + + let rv += [ strpart(a:string, beg) ] + + return rv +endfunction + +" Replace lines from `start' to `start + len - 1' with the given strings. {{{2 +" If more lines are needed to show all strings, they will be added. +" If there are too few strings to fill all lines, lines will be removed. +function! s:SetLines(start, len, strings) + if a:start > line('$') + 1 || a:start < 1 + throw "Invalid start line!" + endif + + if len(a:strings) > a:len + let fensave = &fen + let view = winsaveview() + call append(a:start + a:len - 1, repeat([''], len(a:strings) - a:len)) + call winrestview(view) + let &fen = fensave + elseif len(a:strings) < a:len + let fensave = &fen + let view = winsaveview() + sil exe (a:start + len(a:strings)) . ',' . (a:start + a:len - 1) . 'd_' + call winrestview(view) + let &fen = fensave + endif + + call setline(a:start, a:strings) +endfunction + +" Runs the given commandstring argument as an expression. {{{2 +" The commandstring expression is expected to reference the a:lines argument. +" If the commandstring expression returns a list the items of that list will +" replace the items in a:lines, otherwise the expression is assumed to have +" modified a:lines itself. +function! s:FilterString(lines, commandstring) + exe 'let rv = ' . a:commandstring + + if type(rv) == type(a:lines) && rv isnot a:lines + call filter(a:lines, 0) + call extend(a:lines, rv) + endif +endfunction + +" Public API {{{1 + +if !exists("g:tabular_default_format") + let g:tabular_default_format = "l1" +endif + +let s:formatelempat = '\%([lrc]\d\+\)' + +function! tabular#ElementFormatPattern() + return s:formatelempat +endfunction + +" Given a list of strings and a delimiter, split each string on every +" occurrence of the delimiter pattern, format each element according to either +" the provided format (optional) or the default format, and join them back +" together with enough space padding to guarantee that the nth delimiter of +" each string is aligned. +function! tabular#TabularizeStrings(strings, delim, ...) + if a:0 > 1 + echoerr "TabularizeStrings accepts only 2 or 3 arguments (got ".(a:0+2).")" + return 1 + endif + + let formatstr = (a:0 ? a:1 : g:tabular_default_format) + + if formatstr !~? s:formatelempat . '\+' + echoerr "Tabular: Invalid format \"" . formatstr . "\" specified!" + return 1 + endif + + let format = split(formatstr, s:formatelempat . '\zs') + + let lines = map(a:strings, 's:SplitDelim(v:val, a:delim)') + + " Strip spaces + " - Only from non-delimiters; spaces in delimiters must have been matched + " intentionally + " - Don't strip leading spaces from the first element; we like indenting. + for line in lines + if len(line) == 1 && s:do_gtabularize + continue " Leave non-matching lines unchanged for GTabularize + endif + + if line[0] !~ '^\s*$' + let line[0] = s:StripTrailingSpaces(line[0]) + endif + if len(line) >= 3 + for i in range(2, len(line)-1, 2) + let line[i] = s:StripLeadingSpaces(s:StripTrailingSpaces(line[i])) + endfor + endif + endfor + + " Find the max length of each field + let maxes = [] + for line in lines + if len(line) == 1 && s:do_gtabularize + continue " non-matching lines don't affect field widths for GTabularize + endif + + for i in range(len(line)) + if i == len(maxes) + let maxes += [ s:Strlen(line[i]) ] + else + let maxes[i] = max( [ maxes[i], s:Strlen(line[i]) ] ) + endif + endfor + endfor + + let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"')) + + " Concatenate the fields, according to the format pattern. + for idx in range(len(lines)) + let line = lines[idx] + + if len(line) == 1 && s:do_gtabularize + let lines[idx] = line[0] " GTabularize doesn't change non-matching lines + continue + endif + + for i in range(len(line)) + let how = format[i % len(format)][0] + let pad = format[i % len(format)][1:-1] + + if how =~? 'l' + let field = s:Left(line[i], maxes[i]) + elseif how =~? 'r' + let field = s:Right(line[i], maxes[i]) + elseif how =~? 'c' + let field = s:Center(line[i], maxes[i]) + endif + + let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad)) + endfor + + let lines[idx] = s:StripTrailingSpaces(join(line, '')) + endfor +endfunction + +" Apply 0 or more filters, in sequence, to selected text in the buffer {{{2 +" The lines to be filtered are determined as follows: +" If the function is called with a range containing multiple lines, then +" those lines will be used as the range. +" If the function is called with no range or with a range of 1 line, then +" if GTabularize mode is being used, +" the range will not be adjusted +" if "includepat" is not specified, +" that 1 line will be filtered, +" if "includepat" is specified and that line does not match it, +" no lines will be filtered +" if "includepat" is specified and that line does match it, +" all contiguous lines above and below the specified line matching the +" pattern will be filtered. +" +" The remaining arguments must each be a filter to apply to the text. +" Each filter must either be a String evaluating to a function to be called. +function! tabular#PipeRange(includepat, ...) range + exe a:firstline . ',' . a:lastline + \ . 'call tabular#PipeRangeWithOptions(a:includepat, a:000, {})' +endfunction + +" Extended version of tabular#PipeRange, which +" 1) Takes the list of filters as an explicit list rather than as varargs +" 2) Supports passing a dictionary of options to control the routine. +" Currently, the only supported option is 'mode', which determines whether +" to behave as :Tabularize or as :GTabularize +" This allows me to add new features here without breaking API compatibility +" in the future. +function! tabular#PipeRangeWithOptions(includepat, filterlist, options) range + let top = a:firstline + let bot = a:lastline + + let s:do_gtabularize = (get(a:options, 'mode', '') ==# 'GTabularize') + + if !s:do_gtabularize + " In the default mode, apply range extension logic + if a:includepat != '' && top == bot + if top < 0 || top > line('$') || getline(top) !~ a:includepat + return + endif + while top > 1 && getline(top-1) =~ a:includepat + let top -= 1 + endwhile + while bot < line('$') && getline(bot+1) =~ a:includepat + let bot += 1 + endwhile + endif + endif + + let lines = map(range(top, bot), 'getline(v:val)') + + for filter in a:filterlist + if type(filter) != type("") + echoerr "PipeRange: Bad filter: " . string(filter) + endif + + call s:FilterString(lines, filter) + + unlet filter + endfor + + call s:SetLines(top, bot - top + 1, lines) +endfunction + +" Part of the public interface so interested pipelines can query this and +" adjust their behavior appropriately. +function! tabular#DoGTabularize() + return s:do_gtabularize +endfunction + +function! s:SplitDelimTest(string, delim, expected) + let result = s:SplitDelim(a:string, a:delim) + + if result !=# a:expected + echomsg 'Test failed!' + echomsg ' string=' . string(a:string) . ' delim=' . string(a:delim) + echomsg ' Returned=' . string(result) + echomsg ' Expected=' . string(a:expected) + endif +endfunction + +function! tabular#SplitDelimUnitTest() + let assignment = '[|&+*/%<>=!~-]\@!=]=\|=\~\)\@![|&+*/%<>=!~-]*=' + let two_spaces = ' ' + let ternary_operator = '^.\{-}\zs?\|:' + let cpp_io = '<<\|>>' + let pascal_assign = ':=' + let trailing_c_comments = '\/\*\|\*\/\|\/\/' + + call s:SplitDelimTest('a+=b', assignment, ['a', '+=', 'b']) + call s:SplitDelimTest('a-=b', assignment, ['a', '-=', 'b']) + call s:SplitDelimTest('a!=b', assignment, ['a!=b']) + call s:SplitDelimTest('a==b', assignment, ['a==b']) + call s:SplitDelimTest('a&=b', assignment, ['a', '&=', 'b']) + call s:SplitDelimTest('a|=b', assignment, ['a', '|=', 'b']) + call s:SplitDelimTest('a=b=c', assignment, ['a', '=', 'b', '=', 'c']) + + call s:SplitDelimTest('a b c', two_spaces, ['a', ' ', 'b', ' ', 'c']) + call s:SplitDelimTest('a b c', two_spaces, ['a b', ' ', ' c']) + call s:SplitDelimTest('ab c', two_spaces, ['ab', ' ', '', ' ', 'c']) + + call s:SplitDelimTest('a?b:c', ternary_operator, ['a', '?', 'b', ':', 'c']) + + call s:SplitDelimTest('a< + :let g:tabular_loaded = 1 + +============================================================================== +1. Description *tabular-intro* + +Sometimes, it's useful to line up text. Naturally, it's nicer to have the +computer do this for you, since aligning things by hand quickly becomes +unpleasant. While there are other plugins for aligning text, the ones I've +tried are either impossibly difficult to understand and use, or too simplistic +to handle complicated tasks. This plugin aims to make the easy things easy +and the hard things possible, without providing an unnecessarily obtuse +interface. It's still a work in progress, and criticisms are welcome. + +============================================================================== +2. Walkthrough *tabular-walkthrough* *:Tabularize* + +Tabular's commands are based largely on regular expressions. The basic +technique used by Tabular is taking some regex to match field delimiters, +splitting the input lines at those delimiters, trimming unnecessary spaces +from the non-delimiter parts, padding the non-delimiter parts of the lines +with spaces to make them the same length, and joining things back together +again. + +For instance, consider starting with the following lines: +> + Some short phrase,some other phrase + A much longer phrase here,and another long phrase +< +Let's say we want to line these lines up at the commas. We can tell +Tabularize to do this by passing a pattern matching , to the Tabularize +command: +> + :Tabularize /, + + Some short phrase , some other phrase + A much longer phrase here , and another long phrase +< +I encourage you to try copying those lines to another buffer and trying to +call :Tabularize. You'll want to take notice of two things quickly: First, +instead of requiring a range, Tabularize tries to figure out what you want to +happen. Since it knows that you want to act on lines matching a comma, it +will look upwards and downwards for lines around the current line that match a +comma, and consider all contiguous lines matching the pattern to be the range +to be acted upon. You can always override this by specifying a range, though. + +The second thing you should notice is that you'll almost certainly be able to +abbreviate :Tabularize to :Tab - using this form in mappings and scripts is +discouraged as it will make conflicts with other scripts more likely, but for +interactive use it's a nice timesaver. Another convenience feature is that +running :Tabularize without providing a new pattern will cause it to reuse the +last pattern it was called with. + +So, anyway, now the commas line up. Splitting the lines on commas, Tabular +realized that 'Some short phrase' would need to be padded with spaces to match +the length of 'A much longer phrase here', and it did that before joining the +lines back together. You'll also notice that, in addition to the spaces +inserting for padding, extra spaces were inserted between fields. That's +because by default, Tabular prints things left-aligned with one space between +fields. If you wanted to print things right-aligned with no spaces between +fields, you would provide a different format to the Tabularize command: +> + :Tabularize /,/r0 + + Some short phrase, some other phrase + A much longer phrase here,and another long phrase +< +A format specifier is either l, r, or c, followed by one or more digits. If +the letter is l, the field will be left aligned, similarly for r and right +aligning and c and center aligning. The number following the letter is the +number of spaces padding to insert before the start of the next field. +Multiple format specifiers can be added to the same command - each field will +be printed with the next format specifier in the list; when they all have been +used the first will be used again, and so on. So, the last command right +aligned every field, then inserted 0 spaces of padding before the next field. +What if we wanted to right align the text before the comma, and left align the +text after the comma? The command would look like this: +> + :Tabularize /,/r1c1l0 + + Some short phrase , some other phrase + A much longer phrase here , and another long phrase +< +That command would be read as "Align the matching text, splitting fields on +commas. Print everything before the first comma right aligned, then 1 space, +then the comma center aligned, then 1 space, then everything after the comma +left aligned." Notice that the alignment of the field the comma is in is +irrelevant - since it's only 1 cell wide, it looks the same whether it's right, +left, or center aligned. Also notice that the 0 padding spaces specified for +the 3rd field are unused - but they would be used if there were enough fields +to require looping through the fields again. For instance: +> + abc,def,ghi + a,b + a,b,c + + :Tabularize /,/r1c1l0 + + abc , def, ghi + a , b + a , b , c +< +Notice that now, the format pattern has been reused; field 4 (the second comma) +is right aligned, field 5 is center aligned. No spaces were inserted between +the 3rd field (containing "def") and the 4th field (the second comma) because +the format specified 'l0'. + +But, what if you only wanted to act on the first comma on the line, rather than +all of the commas on the line? Let's say we want everything before the first +comma right aligned, then the comma, then everything after the comma left +aligned: +> + abc,def,ghi + a,b + a,b,c + + :Tabularize /^[^,]*\zs,/r0c0l0 + + abc,def,ghi + a,b + a,b,c +< +Here, we used a Vim regex that would only match the first comma on the line. +It matches the beginning of the line, followed by all the non-comma characters +up to the first comma, and then forgets about what it matched so far and +pretends that the match starts exactly at the comma. + +But, now that this command does exactly what we want it to, it's become pretty +unwieldy. It would be unpleasant to need to type that more than once or +twice. The solution is to assign a name to it. +> + :AddTabularPattern first_comma /^[^,]*\zs,/r0c0l0 +< +Now, typing ":Tabularize first_comma" will do the same thing as typing the +whole pattern out each time. Of course this is more useful if you store the +name in a file to be used later. + +NOTE: In order to make these new commands available every time vim starts, +you'll need to put those new commands into a .vim file in a plugin directory +somewhere in your 'runtimepath'. In order to make sure that Tabular.vim has +already been loaded before your file tries to use :AddTabularPattern or +:AddTabularPipeline, the new file should be installed in an after/plugin +directory in 'runtimepath'. In general, it will be safe to find out where the +TabularMaps.vim plugin was installed, and place other files extending +Tabular.vim in the same directory as TabularMaps.vim. For more information, +and some suggested best practices, check out the |tabular-scripting| section. + +Lastly, we'll approach the case where tabular cannot achieve your desired goal +just by splitting lines appart, trimming whitespace, padding with whitespace, +and rejoining the lines. As an example, consider the multiple_spaces command +from TabularMaps.vim. The goal is to split using two or more spaces as a +field delimiter, and join fields back together, properly lined up, with only +two spaces between the end of each field and the beginning of the next. +Unfortunately, Tabular can't do this with only the commands we know so far: +> + :Tabularize / / +< +The above function won't work, because it will consider "a b" as 5 fields +delimited by two pairs of 2 spaces ( 'a', ' ', '', ' ', 'b' ) instead of as +3 fields delimited by one set of 2 or more spaces ( 'a', ' ', 'b' ). +> + :Tabularize / \+/ +< +The above function won't work either, because it will leave the delimiter as 4 +spaces when used against "a b", meaning that we would fail at our goal of +collapsing everything down to two spaces between fields. So, we need a new +command to get around this: +> + :AddTabularPipeline multiple_spaces / \{2,}/ + \ map(a:lines, "substitute(v:val, ' \{2,}', ' ', 'g')") + \ | tabular#TabularizeStrings(a:lines, ' ', 'l0') +< +Yeah. I know it looks complicated. Bear with me. I probably will try to add +in some shortcuts for this syntax, but this verbose will be guaranteed to +always work. + +You should already recognize the name being assigned. The next thing to +happen is / \{2,}/ which is a pattern specifying which lines should +automatically be included in the range when no range is given. Without this, +there would be no pattern to use for extending the range. Everything after +that is a | separated list of expressions to be evaluated. In the context in +which they will be evaluated, a:lines will be set to a List of Strings +containing the text of the lines being filtered as they procede through the +pipeline you've set up. The \ at the start of the lines are just vim's line +continuation marker; you needn't worry much about them. So, the first +expression in the pipeline transforms each line by replacing every instance of +2 or more spaces with exactly two spaces. The second command in the pipeline +performs the equivalent of ":Tabularize / /l0"; the only difference is that +it is operating on a List of Strings rather than text in the buffer. At the +end of the pipeline, the Strings in the modified a:lines (or the return value +of the last expression in the pipeline, if it returns a List) will replace the +chosen range. + +============================================================================== +3. Extending *tabular-scripting* + +As mentioned above, the most important consideration when extending Tabular +with new maps or commands is that your plugin must be loaded after Tabular.vim +has finished loading, and only if Tabular.vim has loaded successfully. The +easiest approach to making sure it loads after Tabular.vim is simply putting +the new file (we'll call it "tabular_extra.vim" as an example) into an +"after/plugin/" directory in 'runtimepath', for instance: +> + ~/.vim/after/plugin/tabular_extra.vim +< +The default set of mappings, found in "TabularMaps.vim", is installed in +the after/plugin/ subdirectory of whatever directory Tabular was installed to. + +The other important consideration is making sure that your commands are only +called if Tabular.vim was actually loaded. The easiest way to do this is by +checking for the existence of the :Tabularize command at the start of your +plugin. A short example plugin would look like this: +> + " after/plugin/my_tabular_commands.vim + " Provides extra :Tabularize commands + + if !exists(':Tabularize') + finish " Give up here; the Tabular plugin musn't have been loaded + endif + + " Make line wrapping possible by resetting the 'cpo' option, first saving it + let s:save_cpo = &cpo + set cpo&vim + + AddTabularPattern! asterisk /*/l1 + + AddTabularPipeline! remove_leading_spaces /^ / + \ map(a:lines, "substitute(v:val, '^ *', '', '')") + + " Restore the saved value of 'cpo' + let &cpo = s:save_cpo + unlet s:save_cpo +< +============================================================================== +vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: diff --git a/sources_non_forked/tabular/plugin/Tabular.vim b/sources_non_forked/tabular/plugin/Tabular.vim new file mode 100644 index 00000000..e73329ac --- /dev/null +++ b/sources_non_forked/tabular/plugin/Tabular.vim @@ -0,0 +1,346 @@ +" Tabular: Align columnar data using regex-designated column boundaries +" Maintainer: Matthew Wozniski (godlygeek@gmail.com) +" Date: Thu, 03 May 2012 20:49:32 -0400 +" Version: 1.0 +" +" Long Description: +" Sometimes, it's useful to line up text. Naturally, it's nicer to have the +" computer do this for you, since aligning things by hand quickly becomes +" unpleasant. While there are other plugins for aligning text, the ones I've +" tried are either impossibly difficult to understand and use, or too simplistic +" to handle complicated tasks. This plugin aims to make the easy things easy +" and the hard things possible, without providing an unnecessarily obtuse +" interface. It's still a work in progress, and criticisms are welcome. +" +" License: +" Copyright (c) 2012, Matthew J. Wozniski +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" * Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" * Redistributions in binary form must reproduce the above copyright +" notice, this list of conditions and the following disclaimer in the +" documentation and/or other materials provided with the distribution. +" * The names of the contributors may not be used to endorse or promote +" products derived from this software without specific prior written +" permission. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS +" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, +" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +" Abort if running in vi-compatible mode or the user doesn't want us. +if &cp || exists('g:tabular_loaded') + if &cp && &verbose + echo "Not loading Tabular in compatible mode." + endif + finish +endif + +let g:tabular_loaded = 1 + +" Stupid vimscript crap {{{1 +let s:savecpo = &cpo +set cpo&vim + +" Private Things {{{1 + +" Dictionary of command name to command +let s:TabularCommands = {} + +" Generate tab completion list for :Tabularize {{{2 +" Return a list of commands that match the command line typed so far. +" NOTE: Tries to handle commands with spaces in the name, but Vim doesn't seem +" to handle that terribly well... maybe I should give up on that. +function! s:CompleteTabularizeCommand(argstart, cmdline, cursorpos) + let names = keys(s:TabularCommands) + if exists("b:TabularCommands") + let names += keys(b:TabularCommands) + endif + + let cmdstart = substitute(a:cmdline, '^\s*\S\+\s*', '', '') + + return filter(names, 'v:val =~# ''^\V'' . escape(cmdstart, ''\'')') +endfunction + +" Choose the proper command map from the given command line {{{2 +" Returns [ command map, command line with leading removed ] +function! s:ChooseCommandMap(commandline) + let map = s:TabularCommands + let cmd = a:commandline + + if cmd =~# '^\s\+' + if !exists('b:TabularCommands') + let b:TabularCommands = {} + endif + let map = b:TabularCommands + let cmd = substitute(cmd, '^\s\+', '', '') + endif + + return [ map, cmd ] +endfunction + +" Parse '/pattern/format' into separate pattern and format parts. {{{2 +" If parsing fails, return [ '', '' ] +function! s:ParsePattern(string) + if a:string[0] != '/' + return ['',''] + endif + + let pat = '\\\@ 0)] =~ '^\s*$' + throw "Empty element" + endif + + if end == -1 + let rv = [ a:string ] + else + let rv = [ a:string[0 : end-1] ] + s:SplitCommands(a:string[end+1 : -1]) + endif + + return rv +endfunction + +" Public Things {{{1 + +" Command associating a command name with a simple pattern command {{{2 +" AddTabularPattern[!] [] name /pattern[/format] +" +" If is provided, the command will only be available in the current +" buffer, and will be used instead of any global command with the same name. +" +" If a command with the same name and scope already exists, it is an error, +" unless the ! is provided, in which case the existing command will be +" replaced. +" +" pattern is a regex describing the delimiter to be used. +" +" format describes the format pattern to be used. The default will be used if +" none is provided. +com! -nargs=+ -bang AddTabularPattern + \ call AddTabularPattern(, 0) + +function! AddTabularPattern(command, force) + try + let [ commandmap, rest ] = s:ChooseCommandMap(a:command) + + let name = matchstr(rest, '.\{-}\ze\s*/') + let pattern = substitute(rest, '.\{-}\s*\ze/', '', '') + + let [ pattern, format ] = s:ParsePattern(pattern) + + if empty(name) || empty(pattern) + throw "Invalid arguments!" + endif + + if !a:force && has_key(commandmap, name) + throw string(name) . " is already defined, use ! to overwrite." + endif + + let command = "tabular#TabularizeStrings(a:lines, " . string(pattern) + + if !empty(format) + let command .= ", " . string(format) + endif + + let command .= ")" + + let commandmap[name] = { 'pattern' : pattern, 'commands' : [ command ] } + catch + echohl ErrorMsg + echomsg "AddTabularPattern: " . v:exception + echohl None + endtry +endfunction + +" Command associating a command name with a pipeline of functions {{{2 +" AddTabularPipeline[!] [] name /pattern/ func [ | func2 [ | func3 ] ] +" +" If is provided, the command will only be available in the current +" buffer, and will be used instead of any global command with the same name. +" +" If a command with the same name and scope already exists, it is an error, +" unless the ! is provided, in which case the existing command will be +" replaced. +" +" pattern is a regex that will be used to determine which lines will be +" filtered. If the cursor line doesn't match the pattern, using the command +" will be a no-op, otherwise the cursor and all contiguous lines matching the +" pattern will be filtered. +" +" Each 'func' argument represents a function to be called. This function +" will have access to a:lines, a List containing one String per line being +" filtered. +com! -nargs=+ -bang AddTabularPipeline + \ call AddTabularPipeline(, 0) + +function! AddTabularPipeline(command, force) + try + let [ commandmap, rest ] = s:ChooseCommandMap(a:command) + + let name = matchstr(rest, '.\{-}\ze\s*/') + let pattern = substitute(rest, '.\{-}\s*\ze/', '', '') + + let commands = matchstr(pattern, '^/.\{-}\\\@CompleteTabularizeCommand + \ Tabularize ,call Tabularize() + +function! Tabularize(command, ...) range + let piperange_opt = {} + if a:0 + let piperange_opt = a:1 + endif + + if empty(a:command) + if !exists("s:last_tabularize_command") + echohl ErrorMsg + echomsg "Tabularize hasn't been called yet; no pattern/command to reuse!" + echohl None + return + endif + else + let s:last_tabularize_command = a:command + endif + + let command = s:last_tabularize_command + + let range = a:firstline . ',' . a:lastline + + try + let [ pattern, format ] = s:ParsePattern(command) + + if !empty(pattern) + let cmd = "tabular#TabularizeStrings(a:lines, " . string(pattern) + + if !empty(format) + let cmd .= "," . string(format) + endif + + let cmd .= ")" + + exe range . 'call tabular#PipeRangeWithOptions(pattern, [ cmd ], ' + \ . 'piperange_opt)' + else + if exists('b:TabularCommands') && has_key(b:TabularCommands, command) + let usercmd = b:TabularCommands[command] + elseif has_key(s:TabularCommands, command) + let usercmd = s:TabularCommands[command] + else + throw "Unrecognized command " . string(command) + endif + + exe range . 'call tabular#PipeRangeWithOptions(usercmd["pattern"], ' + \ . 'usercmd["commands"], piperange_opt)' + endif + catch + echohl ErrorMsg + echomsg "Tabularize: " . v:exception + echohl None + return + endtry +endfunction + +" GTabularize /pattern[/format] {{{2 +" GTabularize name +" +" Align text on only matching lines, either using the given pattern, or the +" command associated with the given name. Mnemonically, this is similar to +" the :global command, which takes some action on all rows matching a pattern +" in a range. This command is different from normal :Tabularize in 3 ways: +" 1) If a line in the range does not match the pattern, it will be left +" unchanged, and not in any way affect the outcome of other lines in the +" range (at least, normally - but Pipelines can and will still look at +" non-matching rows unless they are specifically written to be aware of +" tabular#DoGTabularize() and handle it appropriately). +" 2) No automatic range determination - :Tabularize automatically expands +" a single-line range (or a call with no range) to include all adjacent +" matching lines. That behavior does not make sense for this command. +" 3) If called without a range, it will act on all lines in the buffer (like +" :global) rather than only a single line +com! -nargs=* -range=% -complete=customlist,CompleteTabularizeCommand + \ GTabularize , + \ call Tabularize(, { 'mode': 'GTabularize' } ) + +" Stupid vimscript crap, part 2 {{{1 +let &cpo = s:savecpo +unlet s:savecpo + +" vim:set sw=2 sts=2 fdm=marker: diff --git a/sources_non_forked/tlib/README b/sources_non_forked/tlib/README new file mode 100644 index 00000000..f5a6792e --- /dev/null +++ b/sources_non_forked/tlib/README @@ -0,0 +1,72 @@ +This is a mirror of http://www.vim.org/scripts/script.php?script_id=1863 + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +The most useful functions provided by this library probably are: + +tlib#input#List(), tlib#input#ListW() + - Display a list + - Dynamically filter items matching a pattern (somethat like google) + - E.g. you filter for "foo -bar": show all entries containing foo but not bar. + - Select items from a list + - Do stuff + - Developers can define keys that trigger some action with the + selected items + - Demo: http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + +tlib#input#EditList + + Edit a list (copy, cut, paste, delete, edit ...) + +:TLet VAR = VALUE + Set a variable only if it doesn't already exist. + +:TScratch + Open a scratch buffer (a buffer without a file). + +:TVarArg VAR1, [VAR2, DEFAULT2] ... + Handle "rest" (variable) arguments in functions. + EXAMPLES: + function! Foo(...) + TVarArg ['a', 1], 'b' + echo 'a='. a + echo 'b='. b + endf + +TBrowseOutput COMMAND + Every wondered how to effciently browse the output of a command + without redirecting it to a file? This command takes a command as + argument and presents the output via |tlib#input#List()| so that you + can easily search for a keyword (e.g. the name of a variable or + function) and the like. + + If you press enter, the selected line will be copied to the command + line. Press ESC to cancel browsing. + + EXAMPLES: + TBrowseOutput 20verb TeaseTheCulprit + TBrowseOutput let + TBrowseOutput map + + +Related (small) plugins that utilize tlib and thus provide some degree of uniform user experience: + tbibtools (vimscript #1915): bibtex-related utilities (sort, reformat, list contents ...) + tmarks (vimscript #2594): Browse, place, & delete marks + tmboxbrowser (vimscript #1906): A mbox browser -- Read your e-mails with vim + tmru (vimscript #1864): Most Recently Used Files + trag (vimscript #2033): A slightly language-aware alternative to grep + tregisters (vimscript #2017): List, edit, and run/execute registers/clipboards + tselectbuffer (vimscript #1866): A quick buffer selector/switcher + tselectfiles (vimscript #1865): A quick file selector/browser/explorer (sort of) + ttagecho (vimscript #2055): Show current tag information + ttagcomplete (vimscript #2069): Context-sensitive tags-based completion and code skeletons + ttags (vimscript #2018): Tag list browser (List, filter, preview, jump to tags) + ttoc (vimscript #2014): A regexp-based table of contents of the current buffer + vikitasks (vimscript #2894): Search viki files for tasks and display them in a list + + +For full details, please see: +http://github.com/tomtom/tlib_vim/blob/master/doc/tlib.txt + +Also available via git +http://github.com/tomtom/tlib_vim diff --git a/sources_non_forked/tlib/autoload/tlib.vim b/sources_non_forked/tlib/autoload/tlib.vim new file mode 100644 index 00000000..5d805ac9 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib.vim @@ -0,0 +1,8 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 13 + +" :nodefault: +TLet g:tlib#debug = 0 + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim new file mode 100644 index 00000000..0bcb6c0e --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim @@ -0,0 +1,151 @@ +" Filter_cnf.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-11-18. +" @Revision: 0.0.114 + +let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + +" The search pattern for |tlib#input#List()| is in conjunctive normal +" form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... +" The pattern is a '/\V' very no-'/magic' regexp pattern. +" +" Pressing joins two patterns with AND. +" Pressing | joins two patterns with OR. +" I.e. In order to get "lala AND (foo OR bar)", you type +" "lala foo|bar". +" +" This is also the base class for other filters. +function! tlib#Filter_cnf#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 +endf + + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call a:world.PushHelp( + \ printf('"%s", "%s", "%sWORD"', g:tlib#input#and, g:tlib#input#or, g:tlib#input#not), + \ 'AND, OR, NOT') +endf + + +" :nodoc: +function! s:prototype.AssessName(world, name) dict "{{{3 + let xa = 0 + let prefix = self.FilterRxPrefix() + for flt in a:world.filter_pos + " let flt = prefix . a:world.GetRx(fltl) + " if flt =~# '\u' && a:name =~# flt + " let xa += 5 + " endif + + if a:name =~ '\^'. flt + let xa += 4 + elseif a:name =~ '\<'. flt + let xa += 3 + " elseif a:name =~ '[[:punct:][:space:][:digit:]]'. flt + " let xa += 2 + elseif a:name =~ '\A'. flt .'\|'. flt .'\A' + let xa += 1 + endif + endfor + " TLogVAR a:name, xa + return xa +endf + + +" :nodoc: +function! s:prototype.Match(world, text) dict "{{{3 + " TLogVAR a:text + " let sc = &smartcase + " let ic = &ignorecase + " if &ignorecase + " set smartcase + " endif + " try + if !empty(a:world.filter_neg) + for rx in a:world.filter_neg + " TLogVAR rx + if a:text =~ rx + return 0 + endif + endfor + endif + if !empty(a:world.filter_pos) + for rx in a:world.filter_pos + " TLogVAR rx + if a:text !~ rx + return 0 + endif + endfor + endif + " finally + " let &smartcase = sc + " let &ignorecase = ic + " endtry + return 1 +endf + + +" :nodoc: +function! s:prototype.DisplayFilter(filter) dict "{{{3 + let filter1 = deepcopy(a:filter) + call map(filter1, '"(". join(reverse(self.Pretty(v:val)), " OR ") .")"') + return join(reverse(filter1), ' AND ') +endf + + +function! s:prototype.Pretty(filter) dict "{{{3 + " call map(a:filter, 'substitute(v:val, ''\\\.\\{-}'', ''=>'', ''g'')') + call map(a:filter, 'self.CleanFilter(v:val)') + return a:filter +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let a:world.filter[0] = reverse(split(a:pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let a:world.filter[0][0] .= nr2char(a:char) +endf + + +" :nodoc: +function! s:prototype.ReduceFrontFilter(world) dict "{{{3 + let filter = a:world.filter[0][0] + " TLogVAR filter + let str = matchstr(filter, '\(\\\(\.\\{-}\|[.?*+$^]\)\|\)$') + if empty(str) + let filter = filter[0 : -2] + else + let filter = strpart(filter, 0, len(filter) - len(str)) + endif + " TLogVAR str, filter + let a:world.filter[0][0] = filter +endf + + +" :nodoc: +function! s:prototype.FilterRxPrefix() dict "{{{3 + return '\V' +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return a:filter +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim new file mode 100644 index 00000000..27f00fe1 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim @@ -0,0 +1,53 @@ +" Filter_cnfd.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-01-23. +" @Revision: 0.0.57 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. +" As a consequence, patterns cannot match dots. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_cnfd#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp('.', 'Any characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, '\.', '\\.\\{-}', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let a:world.filter[0][0] .= a:char == 46 ? '\.\{-}' : nr2char(a:char) +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return substitute(a:filter, '\\.\\{-}', '.', 'g') +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim b/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim new file mode 100644 index 00000000..349bfd57 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim @@ -0,0 +1,83 @@ +" Filter_fuzzy.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2013-09-25. +" @Revision: 0.0.47 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" Support for "fuzzy" pattern matching in |tlib#input#List()|. +" Patterns are interpreted as if characters were connected with '.\{-}'. +" +" In "fuzzy" mode, the pretty printing of filenames is disabled. +function! tlib#Filter_fuzzy#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 + " TLogVAR a:world.display_format + " :nodoc: + function! a:world.Set_display_format(value) dict + if a:value == 'filename' + let self.display_format = '' + else + let self.display_format = a:value + endif + endf +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp('Patterns are interpreted as if characters were connected with .\{-}') +endf + + +" :nodoc: +function! s:prototype.DisplayFilter(filter) dict "{{{3 + " TLogVAR a:filter + let filter1 = deepcopy(a:filter) + call map(filter1, '"{". join(reverse(v:val), " OR ") ."}"') + return join(reverse(filter1), ' AND ') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let a:world.filter[0] = map(reverse(split(a:pattern, '\s*|\s*')), 'join(map(split(v:val, ''\zs''), ''tlib#rx#Escape(v:val, "V")''), ''\.\{-}'')') + a:world.filter[0][1 : -1] + endif +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let ch = tlib#rx#Escape(nr2char(a:char), 'V') + if empty(a:world.filter[0][0]) + let a:world.filter[0][0] .= ch + else + let a:world.filter[0][0] .= '\.\{-}'. ch + endif +endf + + +" :nodoc: +function! s:prototype.ReduceFrontFilter(world) dict "{{{3 + let a:world.filter[0][0] = substitute(a:world.filter[0][0], '\(\\\.\\{-}\)\?.$', '', '') +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return substitute(a:filter, '\\\.\\{-}', '', 'g') +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim b/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim new file mode 100644 index 00000000..904b2261 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim @@ -0,0 +1,68 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-11-18. +" @Revision: 0.0.82 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_glob'], 'name': 'glob'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" A character that should be expanded to '\.\{-}'. +TLet g:tlib#Filter_glob#seq = '*' + + +" A character that should be expanded to '\.\?'. +TLet g:tlib#Filter_glob#char = '?' + + +" The same as |tlib#Filter_cnf#New()| but a a customizable character +" |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and +" |g:tlib#Filter_glob#char| is expanded to '\.'. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_glob#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp(g:tlib#Filter_glob#seq, 'Any characters') + call a:world.PushHelp(g:tlib#Filter_glob#char, 'Single characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#seq, 'V'), '\\.\\{-}', 'g') + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#char, 'V'), '\\.', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + " TLogVAR a:char, nr2char(a:char) + if a:char == char2nr(g:tlib#Filter_glob#seq) + let char = '\.\{-}' + elseif a:char == char2nr(g:tlib#Filter_glob#char) + let char = '\.' + else + let char = nr2char(a:char) + endif + let a:world.filter[0][0] .= char +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + let filter = substitute(a:filter, '\\\.\\{-}', g:tlib#Filter_glob#seq, 'g') + let filter = substitute(filter, '\\\.', g:tlib#Filter_glob#char, 'g') + return filter +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Object.vim b/sources_non_forked/tlib/autoload/tlib/Object.vim new file mode 100644 index 00000000..21f38b24 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Object.vim @@ -0,0 +1,154 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 127 + +" :filedoc: +" Provides a prototype plus some OO-like methods. + +let s:id_counter = 0 +let s:prototype = {'_class': ['object'], '_super': [], '_id': 0} "{{{2 + +" :def: function! tlib#Object#New(?fields={}) +" This function creates a prototype that provides some kind of +" inheritance mechanism and a way to call parent/super methods. +" +" The usage demonstrated in the following example works best when every +" class/prototype is defined in a file of its own. +" +" The reason for why there is a dedicated constructor function is that +" this layout facilitates the use of templates and that methods are +" hidden from the user. Other solutions are possible. +" +" EXAMPLES: > +" let s:prototype = tlib#Object#New({ +" \ '_class': ['FooBar'], +" \ 'foo': 1, +" \ 'bar': 2, +" \ }) +" " Constructor +" function! FooBar(...) +" let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) +" return object +" endf +" function! s:prototype.babble() { +" echo "I think, therefore I am ". (self.foo * self.bar) ." months old." +" } +" +" < This could now be used like this: > +" let myfoo = FooBar({'foo': 3}) +" call myfoo.babble() +" => I think, therefore I am 6 months old. +" echo myfoo.IsA('FooBar') +" => 1 +" echo myfoo.IsA('object') +" => 1 +" echo myfoo.IsA('Foo') +" => 0 +" echo myfoo.RespondTo('babble') +" => 1 +" echo myfoo.RespondTo('speak') +" => 0 +function! tlib#Object#New(...) "{{{3 + return s:prototype.New(a:0 >= 1 ? a:1 : {}) +endf + + +function! s:prototype.New(...) dict "{{{3 + let object = deepcopy(self) + let s:id_counter += 1 + let object._id = s:id_counter + if a:0 >= 1 && !empty(a:1) + " call object.Extend(deepcopy(a:1)) + call object.Extend(a:1) + endif + return object +endf + + +function! s:prototype.Inherit(object) dict "{{{3 + let class = copy(self._class) + " TLogVAR class + let objid = self._id + for c in get(a:object, '_class', []) + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:object, 'keep') + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, a:object) + return self +endf + + +function! s:prototype.Extend(dictionary) dict "{{{3 + let super = copy(self) + let class = copy(self._class) + " TLogVAR class + let objid = self._id + let thisclass = get(a:dictionary, '_class', []) + for c in type(thisclass) == 3 ? thisclass : [thisclass] + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:dictionary) + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, super) + return self +endf + + +function! s:prototype.IsA(class) dict "{{{3 + return index(self._class, a:class) != -1 +endf + + +function! s:prototype.IsRelated(object) dict "{{{3 + return len(filter(a:object._class, 'self.IsA(v:val)')) > 1 +endf + + +function! s:prototype.RespondTo(name) dict "{{{3 + " return has_key(self, a:name) && type(self[a:name]) == 2 + return has_key(self, a:name) +endf + + +function! s:prototype.Super(method, arglist) dict "{{{3 + for o in self._super + " TLogVAR o + if o.RespondTo(a:method) + " let self._tmp_method = o[a:method] + " TLogVAR self._tmp_method + " return call(self._tmp_method, a:arglist, self) + return call(o[a:method], a:arglist, self) + endif + endfor + echoerr 'tlib#Object: Does not respond to '. a:method .': '. string(self) +endf + + +function! tlib#Object#Methods(object, ...) "{{{3 + TVarArg ['pattern', '\d\+'] + let o = items(a:object) + call filter(o, 'type(v:val[1]) == 2 && string(v:val[1]) =~ "^function(''\\d\\+'')"') + let acc = {} + for e in o + let id = matchstr(string(e[1]), pattern) + if !empty(id) + let acc[id] = e[0] + endif + endfor + return acc +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Test.vim b/sources_non_forked/tlib/autoload/tlib/Test.vim new file mode 100644 index 00000000..4a4281e8 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Test.vim @@ -0,0 +1,19 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 11 + +" :enddoc: + + +let s:prototype = tlib#Object#New({'_class': ['Test']}) "{{{2 +function! tlib#Test#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'Test.vim' +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/TestChild.vim b/sources_non_forked/tlib/autoload/tlib/TestChild.vim new file mode 100644 index 00000000..16979a75 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/TestChild.vim @@ -0,0 +1,19 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 15 + +" :enddoc: + + +let s:prototype = tlib#Test#New({'_class': ['TestChild']}) "{{{2 +function! tlib#TestChild#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'TestChild.vim' +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/World.vim b/sources_non_forked/tlib/autoload/tlib/World.vim new file mode 100644 index 00000000..fddf7b2f --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/World.vim @@ -0,0 +1,1404 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 1432 + +" :filedoc: +" A prototype used by |tlib#input#List|. +" Inherits from |tlib#Object#New|. + + +" Size of the input list window (in percent) from the main size (of &lines). +" See |tlib#input#List()|. +TLet g:tlib_inputlist_pct = 50 + +" Size of filename columns when listing filenames. +" See |tlib#input#List()|. +TLet g:tlib_inputlist_width_filename = '&co / 3' +" TLet g:tlib_inputlist_width_filename = 25 + +" If true, |tlib#input#List()| will show some indicators about the +" status of a filename (e.g. buflisted(), bufloaded() etc.). +" This is disabled by default because vim checks also for the file on +" disk when doing this. +TLet g:tlib_inputlist_filename_indicators = 0 + +" If not null, display only a short info about the filter. +TLet g:tlib_inputlist_shortmessage = 0 + + + +" Known keys & values: +" scratch_split ... See |tlib#scratch#UseScratch()| +let s:prototype = tlib#Object#New({ + \ '_class': 'World', + \ 'name': 'world', + \ 'allow_suspend': 1, + \ 'base': [], + \ 'bufnr': -1, + \ 'buffer_local': 1, + \ 'cache_var': '', + \ 'display_format': '', + \ 'fileencoding': &fileencoding, + \ 'fmt_display': {}, + \ 'fmt_filter': {}, + \ 'fmt_options': {}, + \ 'filetype': '', + \ 'filter': [['']], + \ 'filter_format': '', + \ 'filter_options': '', + \ 'follow_cursor': '', + \ 'has_menu': 0, + \ 'help_extra': [], + \ 'index_table': [], + \ 'initial_filter': [['']], + \ 'initial_index': 1, + \ 'initial_display': 1, + \ 'initialized': 0, + \ 'key_handlers': [], + \ 'list': [], + \ 'matcher': {}, + \ 'next_agent': '', + \ 'next_eval': '', + \ 'next_state': '', + \ 'numeric_chars': g:tlib#input#numeric_chars, + \ 'offset': 1, + \ 'offset_horizontal': 0, + \ 'on_leave': [], + \ 'pick_last_item': tlib#var#Get('tlib#input#pick_last_item', 'bg'), + \ 'post_handlers': [], + \ 'query': '', + \ 'resize': 0, + \ 'resize_vertical': 0, + \ 'restore_from_cache': [], + \ 'filtered_items': [], + \ 'resume_state': '', + \ 'retrieve_eval': '', + \ 'return_agent': '', + \ 'rv': '', + \ 'scratch': '__InputList__', + \ 'scratch_filetype': 'tlibInputList', + \ 'scratch_hidden': g:tlib#scratch#hidden, + \ 'scratch_vertical': 0, + \ 'scratch_split': 1, + \ 'sel_idx': [], + \ 'show_empty': 0, + \ 'state': 'display', + \ 'state_handlers': [], + \ 'sticky': 0, + \ 'temp_lines': [], + \ 'temp_prompt': [], + \ 'timeout': 0, + \ 'timeout_resolution': 2, + \ 'tabpagenr': -1, + \ 'type': '', + \ 'win_wnr': -1, + \ 'win_height': -1, + \ 'win_width': -1, + \ 'win_pct': 25, + \ }) + " \ 'handlers': [], + " \ 'filter_options': '\c', + +function! tlib#World#New(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + call object.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'g', 'cnf')) + return object +endf + + +" :nodoc: +function! s:prototype.Set_display_format(value) dict "{{{3 + if a:value == 'filename' + call self.Set_highlight_filename() + let self.display_format = 'world.FormatFilename(%s)' + else + let self.display_format = a:value + endif +endf + + +" :nodoc: +function! s:prototype.DisplayFormat(list) dict "{{{3 + let display_format = self.display_format + if !empty(display_format) + if has_key(self, 'InitFormatName') + call self.InitFormatName() + endif + let cache = self.fmt_display + " TLogVAR display_format, fmt_entries + return map(copy(a:list), 'self.FormatName(cache, display_format, v:val)') + else + return a:list + endif +endf + + +" :nodoc: +function! s:prototype.Set_highlight_filename() dict "{{{3 + let self.tlib_UseInputListScratch = 'call world.Highlight_filename()' +endf + + +if g:tlib#input#format_filename == 'r' + + " :nodoc: + function! s:prototype.Highlight_filename() dict "{{{3 + syntax match TLibDir /\s\+\zs.\{-}[\/]\ze[^\/]\+$/ + hi def link TLibDir Directory + syntax match TLibFilename /[^\/]\+$/ + hi def link TLibFilename Normal + endf + + " :nodoc: + function! s:prototype.FormatFilename(file) dict "{{{3 + if !has_key(self.fmt_options, 'maxlen') + let maxco = &co - len(len(self.base)) - eval(g:tlib#input#filename_padding_r) + let maxfi = max(map(copy(self.base), 'strwidth(v:val)')) + let self.fmt_options.maxlen = min([maxco, maxfi]) + " TLogVAR maxco, maxfi, self.fmt_options.maxlen + endif + let max = self.fmt_options.maxlen + if len(a:file) > max + let filename = '...' . strpart(a:file, len(a:file) - max + 3) + else + let filename = printf('% '. max .'s', a:file) + endif + return filename + endf + +else + + " :nodoc: + function! s:prototype.Highlight_filename() dict "{{{3 + " let self.width_filename = 1 + eval(g:tlib_inputlist_width_filename) + " TLogVAR self.base + let self.width_filename = min([ + \ get(self, 'width_filename', &co), + \ empty(g:tlib#input#filename_max_width) ? &co : eval(g:tlib#input#filename_max_width), + \ max(map(copy(self.base), 'strwidth(matchstr(v:val, "[^\\/]*$"))')) + \ ]) + " TLogVAR self.width_filename + exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir' + " exec 'syntax match TLibDir /\(|\|\[.\{-}\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + " exec 'syntax match TLibMarker /\(|\|\[.\{-}\]\) \S.*$/ contains=TLibDir' + exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir' + hi def link TLibMarker Special + hi def link TLibDir Directory + hi def link TLibFilename NonText + " :nodoc: + function! self.Highlighter(rx) dict + let rx = '/\c\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) .\{-}\zs'. escape(a:rx, '/') .'/' + exec 'match' self.matcher.highlight rx + endf + endf + + + " :nodoc: + function! s:prototype.UseFilenameIndicators() dict "{{{3 + return g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators') + endf + + + " :nodoc: + function! s:prototype.InitFormatName() dict "{{{3 + if self.UseFilenameIndicators() + let self._buffers = {} + for bufnr in range(1, bufnr('$')) + let filename = fnamemodify(bufname(bufnr), ':p') + " TLogVAR filename + let bufdef = { + \ 'bufnr': bufnr, + \ } + " '&buflisted' + for opt in ['&modified', '&bufhidden'] + let bufdef[opt] = getbufvar(bufnr, opt) + endfor + let self._buffers[filename] = bufdef + endfor + endif + endf + + + " :nodoc: + function! s:prototype.FormatFilename(file) dict "{{{3 + " TLogVAR a:file + let width = self.width_filename + let split = match(a:file, '[/\\]\zs[^/\\]\+$') + if split == -1 + let fname = a:file + let dname = a:file + else + let fname = strpart(a:file, split) + " let dname = strpart(a:file, 0, split - 1) + let dname = a:file + endif + if strwidth(fname) > width + let fname = strpart(fname, 0, width - 3) .'...' + endif + let dnmax = &co - max([width, strwidth(fname)]) - 8 - self.index_width - &fdc + let use_indicators = self.UseFilenameIndicators() + " TLogVAR use_indicators + let marker = [] + if use_indicators + call insert(marker, '[') + if g:tlib_inputlist_filename_indicators + let bufdef = get(self._buffers, a:file, {}) + " let bnr = bufnr(a:file) + let bnr = get(bufdef, 'bufnr', -1) + " TLogVAR a:file, bnr, self.bufnr + if bnr != -1 + if bnr == self.bufnr + call add(marker, '%') + else + call add(marker, bnr) + endif + if get(bufdef, '&modified', 0) + call add(marker, '+') + endif + if get(bufdef, '&bufhidden', '') == 'hide' + call add(marker, 'h') + endif + " if !get(bufdef, '&buflisted', 1) + " call add(marker, 'u') + " endif + " echom "DBG" a:file string(get(self,'filename_indicators')) + endif + endif + if has_key(self, 'filename_indicators') && has_key(self.filename_indicators, a:file) + if len(marker) > 1 + call add(marker, '|') + endif + call add(marker, self.filename_indicators[a:file]) + endif + if len(marker) <= 1 + call add(marker, ' ') + endif + call add(marker, ']') + else + call add(marker, '|') + endif + let markers = join(marker, '') + if !empty(markers) + let dnmax -= len(markers) + endif + if strwidth(dname) > dnmax + let dname = '...'. strpart(dname, len(dname) - dnmax) + endif + return printf("%-*s %s %s", + \ self.width_filename + len(fname) - strwidth(fname), + \ fname, markers, dname) + endf + +endif + + +" :nodoc: +function! s:prototype.GetSelectedItems(current) dict "{{{3 + " TLogVAR a:current + if stridx(self.type, 'i') != -1 + let rv = copy(self.sel_idx) + else + let rv = map(copy(self.sel_idx), 'self.GetBaseItem(v:val)') + endif + if !empty(a:current) + " TLogVAR a:current, rv, type(a:current) + if tlib#type#IsNumber(a:current) || tlib#type#IsString(a:current) + call s:InsertSelectedItems(rv, a:current) + elseif tlib#type#IsList(a:current) + for item in a:current + call s:InsertSelectedItems(rv, item) + endfor + elseif tlib#type#IsDictionary(a:current) + for [inum, item] in items(a:current) + call s:InsertSelectedItems(rv, item) + endfor + endif + endif + " TAssert empty(rv) || rv[0] == a:current + if stridx(self.type, 'i') != -1 + if !empty(self.index_table) + " TLogVAR rv, self.index_table + call map(rv, 'self.index_table[v:val - 1]') + " TLogVAR rv + endif + endif + return rv +endf + + +function! s:InsertSelectedItems(rv, current) "{{{3 + let ci = index(a:rv, a:current) + if ci != -1 + call remove(a:rv, ci) + endif + call insert(a:rv, a:current) +endf + + +" :nodoc: +function! s:prototype.SelectItemsByNames(mode, items) dict "{{{3 + for item in a:items + let bi = index(self.base, item) + 1 + " TLogVAR item, bi + if bi > 0 + let si = index(self.sel_idx, bi) + " TLogVAR self.sel_idx + " TLogVAR si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode == 'toggle' + call remove(self.sel_idx, si) + endif + endif + endfor + return 1 +endf + + +" :nodoc: +function! s:prototype.SelectItem(mode, index) dict "{{{3 + " TLogVAR a:mode, a:index + let bi = self.GetBaseIdx(a:index) + " if self.RespondTo('MaySelectItem') + " if !self.MaySelectItem(bi) + " return 0 + " endif + " endif + " TLogVAR bi + let si = index(self.sel_idx, bi) + " TLogVAR self.sel_idx + " TLogVAR si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode == 'toggle' + call remove(self.sel_idx, si) + endif + return 1 +endf + + +" :nodoc: +function! s:prototype.FormatBaseFromData() abort dict "{{{3 + if has_key(self, 'format_data') && has_key(self, 'data') + let self.base = map(copy(self.data), 'call(self.format_data, [v:val], self)') + endif +endf + + +" :nodoc: +function! s:prototype.FormatArgs(format_string, arg) dict "{{{3 + let nargs = len(substitute(a:format_string, '%%\|[^%]', '', 'g')) + return [a:format_string] + repeat([string(a:arg)], nargs) +endf + + +" :nodoc: +function! s:prototype.GetRx(filter) dict "{{{3 + return '\('. join(filter(copy(a:filter), 'v:val[0] != "!"'), '\|') .'\)' +endf + + +" :nodoc: +function! s:prototype.GetRx0(...) dict "{{{3 + exec tlib#arg#Let(['negative']) + let rx0 = [] + for filter in self.filter + " TLogVAR filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + " TLogVAR rx + if !empty(rx) && (negative ? rx[0] == g:tlib#input#not : rx[0] != g:tlib#input#not) + call add(rx0, rx) + endif + endfor + let rx0s = join(rx0, '\|') + if empty(rx0s) + return '' + else + return self.FilterRxPrefix() .'\('. rx0s .'\)' + endif +endf + + +" :nodoc: +function! s:prototype.FormatName(cache, format, value) dict "{{{3 + " TLogVAR a:format, a:value + " TLogDBG has_key(self.fmt_display, a:value) + if has_key(a:cache, a:value) + " TLogDBG "cached" + return a:cache[a:value] + else + let world = self + let ftpl = self.FormatArgs(a:format, a:value) + let fn = call(function("printf"), ftpl) + let fmt = eval(fn) + " TLogVAR ftpl, fn, fmt + let a:cache[a:value] = fmt + return fmt + endif +endf + + +" :nodoc: +function! s:prototype.GetItem(idx) dict "{{{3 + return self.list[a:idx - 1] +endf + + +" :nodoc: +function! s:prototype.GetListIdx(baseidx) dict "{{{3 + " if empty(self.index_table) + let baseidx = a:baseidx + " else + " let baseidx = 0 + self.index_table[a:baseidx - 1] + " " TLogVAR a:baseidx, baseidx, self.index_table + " endif + let rv = index(self.table, baseidx) + " TLogVAR rv, self.table + return rv +endf + + +" :nodoc: +" The first index is 1. +function! s:prototype.GetBaseIdx(idx) dict "{{{3 + " TLogVAR a:idx, self.table, self.index_table + if !empty(self.table) && a:idx > 0 && a:idx <= len(self.table) + return self.table[a:idx - 1] + else + return 0 + endif +endf + + +" :nodoc: +function! s:prototype.GetBaseIdx0(idx) dict "{{{3 + let idx0 = self.GetBaseIdx(a:idx) - 1 + if idx0 < 0 + call tlib#notify#Echo('TLIB: Internal Error: GetBaseIdx0: idx0 < 0', 'WarningMsg') + endif + return idx0 +endf + + +" :nodoc: +function! s:prototype.GetBaseItem(idx) dict "{{{3 + return self.base[a:idx - 1] +endf + + +" :nodoc: +function! s:prototype.SetBaseItem(idx, item) dict "{{{3 + let self.base[a:idx - 1] = a:item +endf + + +" :nodoc: +function! s:prototype.GetLineIdx(lnum) dict "{{{3 + let line = getline(a:lnum) + let prefidx = substitute(matchstr(line, '^\d\+\ze[*:]'), '^0\+', '', '') + return prefidx +endf + + +" :nodoc: +function! s:prototype.SetPrefIdx() dict "{{{3 + " let pref = sort(range(1, self.llen), 'self.SortPrefs') + " let self.prefidx = get(pref, 0, self.initial_index) + let pref_idx = -1 + let pref_weight = -1 + " TLogVAR self.filter_pos, self.filter_neg + " let t0 = localtime() " DBG + for idx in range(1, self.llen) + let item = self.GetItem(idx) + let weight = self.matcher.AssessName(self, item) + " TLogVAR item, weight + if weight > pref_weight + let pref_idx = idx + let pref_weight = weight + endif + endfor + " TLogVAR localtime() - t0 + " TLogVAR pref_idx + " TLogDBG self.GetItem(pref_idx) + if pref_idx == -1 + let self.prefidx = self.initial_index + else + let self.prefidx = pref_idx + endif +endf + + +" " :nodoc: +" function! s:prototype.GetCurrentItem() dict "{{{3 +" let idx = self.prefidx +" " TLogVAR idx +" if stridx(self.type, 'i') != -1 +" return idx +" elseif !empty(self.list) +" if len(self.list) >= idx +" let idx1 = idx - 1 +" let rv = self.list[idx - 1] +" " TLogVAR idx, idx1, rv, self.list +" return rv +" endif +" else +" return '' +" endif +" endf + + +" :nodoc: +function! s:prototype.CurrentItem() dict "{{{3 + if stridx(self.type, 'i') != -1 + return self.GetBaseIdx(self.llen == 1 ? 1 : self.prefidx) + else + if self.llen == 1 + " TLogVAR self.llen + return self.list[0] + elseif self.prefidx > 0 + " TLogVAR self.prefidx + " return self.GetCurrentItem() + if len(self.list) >= self.prefidx + let rv = self.list[self.prefidx - 1] + " TLogVAR idx, rv, self.list + return rv + endif + else + return '' + endif + endif +endf + + +" :nodoc: +function! s:prototype.FilterRxPrefix() dict "{{{3 + return self.matcher.FilterRxPrefix() +endf + + +" :nodoc: +function! s:prototype.SetFilter() dict "{{{3 + " let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '') + let mrx = self.FilterRxPrefix() . self.filter_options + let self.filter_pos = [] + let self.filter_neg = [] + " TLogVAR mrx, self.filter + for filter in self.filter + " TLogVAR filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + " TLogVAR rx + if !empty(rx) + if rx =~ '\u' + let mrx1 = mrx .'\C' + else + let mrx1 = mrx + endif + " TLogVAR rx + if rx[0] == g:tlib#input#not + if len(rx) > 1 + call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)') + endif + else + call add(self.filter_pos, mrx1 .'\('. rx .'\)') + endif + endif + endfor + " TLogVAR self.filter_pos, self.filter_neg +endf + + +" :nodoc: +function! s:prototype.IsValidFilter() dict "{{{3 + let last = self.FilterRxPrefix() .'\('. self.filter[0][0] .'\)' + Tlibtrace 'tlib', last + " TLogVAR last + try + let a = match("", last) + return 1 + catch + Tlibtrace 'tlib', v:exception + return 0 + endtry +endf + + +" :nodoc: +function! s:prototype.SetMatchMode(match_mode) dict "{{{3 + " TLogVAR a:match_mode + if !empty(a:match_mode) + unlet self.matcher + try + let self.matcher = tlib#Filter_{a:match_mode}#New() + call self.matcher.Init(self) + catch /^Vim\%((\a\+)\)\=:E117/ + throw 'tlib: Unknown mode for tlib#input#filter_mode: '. a:match_mode + endtry + endif +endf + + +" function! s:prototype.Match(text) dict "{{{3 +" return self.matcher.Match(self, text) +" endf + + +" :nodoc: +function! s:prototype.MatchBaseIdx(idx) dict "{{{3 + let text = self.GetBaseItem(a:idx) + if !empty(self.filter_format) + let text = self.FormatName(self.fmt_filter, self.filter_format, text) + endif + " TLogVAR text + " return self.Match(text) + return self.matcher.Match(self, text) +endf + + +" :nodoc: +function! s:prototype.BuildTableList() dict "{{{3 + " let time0 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time0 + call self.SetFilter() + " TLogVAR self.filter_neg, self.filter_pos + let self.table = range(1, len(self.base)) + " TLogVAR self.filtered_items + let copy_base = 1 + if !empty(self.filtered_items) + let self.table = filter(self.table, 'index(self.filtered_items, v:val) != -1') + let copy_base = 0 + endif + if !empty(self.filter_pos) || !empty(self.filter_neg) + let self.table = filter(self.table, 'self.MatchBaseIdx(v:val)') + let copy_base = 0 + endif + if copy_base + let self.list = copy(self.base) + else + let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)') + endif +endf + + +" :nodoc: +function! s:prototype.ReduceFilter() dict "{{{3 + " TLogVAR self.filter + let reduced = 0 + while !reduced + if self.filter[0] == [''] && len(self.filter) > 1 + call remove(self.filter, 0) + elseif empty(self.filter[0][0]) && len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + else + call self.matcher.ReduceFrontFilter(self) + endif + if self.IsValidFilter() + let reduced = 1 + endif + endwh +endf + + +" :nodoc: +" filter is either a string or a list of list of strings. +function! s:prototype.SetInitialFilter(filter) dict "{{{3 + " let self.initial_filter = [[''], [a:filter]] + Tlibtrace 'tlib', a:filter + if type(a:filter) == 3 + let self.initial_filter = deepcopy(a:filter) + else + let self.initial_filter = [[a:filter]] + endif +endf + + +" :nodoc: +function! s:prototype.PopFilter() dict "{{{3 + " TLogVAR self.filter + if len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + elseif len(self.filter) > 1 + call remove(self.filter, 0) + else + let self.filter[0] = [''] + endif +endf + + +" :nodoc: +function! s:prototype.FilterIsEmpty() dict "{{{3 + " TLogVAR self.filter + return self.filter == copy(self.initial_filter) +endf + + +" :nodoc: +function! s:prototype.DisplayFilter() dict "{{{3 + let filter1 = copy(self.filter) + call filter(filter1, 'v:val != [""]') + " TLogVAR self.matcher['_class'] + let rv = self.matcher.DisplayFilter(filter1) + let rv = self.CleanFilter(rv) + return rv +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(pattern) dict "{{{3 + call self.matcher.SetFrontFilter(self, a:pattern) +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(char) dict "{{{3 + call self.matcher.PushFrontFilter(self, a:char) +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return self.matcher.CleanFilter(a:filter) +endf + + +" :nodoc: +function! s:prototype.UseScratch() dict "{{{3 + " if type(self.scratch) != 0 && get(self, 'buffer_local', 1) + " if self.scratch != fnamemodify(self.scratch, ':p') + " let self.scratch = tlib#file#Join([expand('%:p:h'), self.scratch]) + " " TLogVAR self.scratch + " endif + " " let self.scratch_hidden = 'wipe' + " endif + keepjumps keepalt let rv = tlib#scratch#UseScratch(self) + " if expand('%:t') == self.scratch + let b:tlib_world = self + " endif + return rv +endf + + +" :nodoc: +function! s:prototype.CloseScratch(...) dict "{{{3 + TVarArg ['reset_scratch', 0] + " TVarArg ['reset_scratch', 1] + " TLogVAR reset_scratch + if self.sticky + return 0 + else + let rv = tlib#scratch#CloseScratch(self, reset_scratch) + " TLogVAR rv + if rv + call self.SwitchWindow('win') + endif + return rv + endif +endf + + +" :nodoc: +function! s:prototype.Initialize() dict "{{{3 + let self.initialized = 1 + call self.SetOrigin(1) + call self.Reset(1) + if !empty(self.cache_var) && exists(self.cache_var) + for prop in self.restore_from_cache + exec 'let self[prop] = get('. self.cache_var .', prop, self[prop])' + endfor + exec 'unlet '. self.cache_var + endif +endf + + +" :nodoc: +function! s:prototype.Leave() dict "{{{3 + if !empty(self.cache_var) + exec 'let '. self.cache_var .' = self' + endif + for handler in self.on_leave + call call(handler, [self]) + endfor +endf + + +" :nodoc: +function! s:prototype.UseInputListScratch() dict "{{{3 + let scratch = self.UseScratch() + if !exists('b:tlib_list_init') + call tlib#autocmdgroup#Init() + autocmd TLib VimResized call feedkeys("\", 't') + " autocmd TLib WinLeave let b:tlib_world_event = 'WinLeave' | call feedkeys("\", 't') + let b:tlib_list_init = 1 + endif + if !exists('w:tlib_list_init') + " TLogVAR scratch + if has_key(self, 'index_next_syntax') + if type(self.index_next_syntax) == 1 + exec 'syntax match InputlListIndex /^\d\+:\s/ nextgroup='. self.index_next_syntax + elseif type(self.index_next_syntax) == 4 + for [n, nsyn] in items(self.index_next_syntax) + let fn = printf('%0'. world.index_width .'d', n) + exec 'syntax match InputlListIndex /^'. fn .':\s/ nextgroup='. nsyn + endfor + endif + else + syntax match InputlListIndex /^\d\+:\s/ + endif + call tlib#hook#Run('tlib_UseInputListScratch', self) + syntax match InputlListCursor /^\d\+\* .*$/ contains=InputlListIndex + syntax match InputlListSelected /^\d\+# .*$/ contains=InputlListIndex + hi def link InputlListIndex Constant + hi def link InputlListCursor Search + hi def link InputlListSelected IncSearch + setlocal nowrap + " hi def link InputlListIndex Special + " let b:tlibDisplayListMarks = {} + let b:tlibDisplayListMarks = [] + let b:tlibDisplayListWorld = self + let w:tlib_list_init = 1 + endif + return scratch +endf + + +" s:prototype.Reset(?initial=0) +" :nodoc: +function! s:prototype.Reset(...) dict "{{{3 + TVarArg ['initial', 0] + " TLogVAR initial + Tlibtrace 'tlib', initial, self.initial_filter + let self.state = 'display' + let self.offset = 1 + let self.filter = deepcopy(self.initial_filter) + let self.idx = '' + let self.prefidx = 0 + let self.initial_display = 1 + let self.fmt_display = {} + let self.fmt_filter = {} + call self.UseInputListScratch() + call self.ResetSelected() + call self.Retrieve(!initial) + call self.FormatBaseFromData() + return self +endf + + +" :nodoc: +function! s:prototype.ResetSelected() dict "{{{3 + let self.sel_idx = [] +endf + + +" :nodoc: +function! s:prototype.Retrieve(anyway) dict "{{{3 + " TLogVAR a:anyway, self.base + " TLogDBG (a:anyway || empty(self.base)) + if (a:anyway || empty(self.base)) + let ra = self.retrieve_eval + " TLogVAR ra + if !empty(ra) + let back = self.SwitchWindow('win') + let world = self + let self.base = eval(ra) + " TLogVAR self.base + exec back + return 1 + endif + endif + return 0 +endf + + +function! s:FormatHelp(help) "{{{3 + " TLogVAR a:help + let max = [0, 0] + for item in a:help + " TLogVAR item + if type(item) == 3 + let itemlen = map(copy(item), 'strwidth(v:val)') + " TLogVAR itemlen + let max = map(range(2), 'max[v:val] >= itemlen[v:val] ? max[v:val] : itemlen[v:val]') + endif + unlet item + endfor + " TLogVAR max + let cols = float2nr((winwidth(0) - &foldcolumn - 1) / (max[0] + max[1] + 2)) + if cols < 1 + let cols = 1 + endif + let fmt = printf('%%%ds: %%-%ds', max[0], max[1]) + " TLogVAR cols, fmt + let help = [] + let idx = -1 + let maxidx = len(a:help) + while idx < maxidx + let push_item = 0 + let accum = [] + for i in range(cols) + let idx += 1 + if idx >= maxidx + break + endif + let item = a:help[idx] + if type(item) == 3 + call add(accum, item) + else + let push_item = 1 + break + endif + unlet item + endfor + if !empty(accum) + call add(help, s:FormatHelpItem(accum, fmt)) + endif + if push_item + call add(help, a:help[idx]) + endif + endwh + " TLogVAR help + return help +endf + + +function! s:FormatHelpItem(item, fmt) "{{{3 + let args = [join(repeat([a:fmt], len(a:item)), ' ')] + for item in a:item + " TLogVAR item + let args += item + endfor + " TLogVAR args + return call('printf', args) +endf + + +" :nodoc: +function! s:prototype.InitHelp() dict "{{{3 + return [] +endf + + +" :nodoc: +function! s:prototype.PushHelp(...) dict "{{{3 + " TLogVAR a:000 + if a:0 == 1 + if type(a:1) == 3 + let self.temp_lines += a:1 + else + call add(self.temp_lines, a:1) + endif + elseif a:0 == 2 + call add(self.temp_lines, a:000) + else + throw "TLIB: PushHelp: Wrong number of arguments: ". string(a:000) + endif + " TLogVAR helpstring +endf + + +" :nodoc: +function! s:prototype.DisplayHelp() dict "{{{3 + let self.temp_lines = self.InitHelp() + call self.PushHelp('', self.key_mode == 'default' ? 'Abort' : 'Reset keymap') + call self.PushHelp('Enter, ', 'Pick the current item') + call self.PushHelp('Mouse', 'L: Pick item, R: Show menu') + call self.PushHelp('', 'Select an item') + call self.PushHelp(', ', 'Reduce filter') + call self.PushHelp('', 'Complete word') + call self.PushHelp(', ', 'Enter command') + + if self.key_mode == 'default' + call self.PushHelp('', 'Reset the display') + call self.PushHelp('Up/Down', 'Next/previous item') + call self.PushHelp('', 'Edit top filter string') + call self.PushHelp('Page Up/Down', 'Scroll') + call self.PushHelp('', 'Enter * Wildcard') + if self.allow_suspend + call self.PushHelp('', 'Suspend/Resume') + call self.PushHelp('', 'Switch to origin') + endif + if stridx(self.type, 'm') != -1 + call self.PushHelp('', '(Un)Select items') + call self.PushHelp('#', '(Un)Select the current item') + call self.PushHelp('', '(Un)Select all items') + call self.PushHelp('', '(Un)Restrict view to selection') + " \ ' ... Show only selected', + endif + endif + + " TLogVAR len(self.temp_lines) + call self.matcher.Help(self) + + " TLogVAR self.key_mode + for handler in values(self.key_map[self.key_mode]) + " TLogVAR handler + let key = get(handler, 'key_name', '') + " TLogVAR key + if !empty(key) + let desc = get(handler, 'help', '') + if empty(desc) + let desc = get(handler, 'agent', '') + endif + call self.PushHelp(key, desc) + endif + endfor + + if !has_key(self.key_map[self.key_mode], 'unknown_key') + call self.PushHelp('Letter', 'Filter the list') + endif + + if self.key_mode == 'default' && !empty(self.help_extra) + call self.PushHelp(self.help_extra) + endif + + " TLogVAR len(self.temp_lines) + call self.PushHelp([ + \ '', + \ 'Matches at word boundaries are prioritized.', + \ ]) + let self.temp_lines = s:FormatHelp(self.temp_lines) + call self.PrintLines() +endf + + +function! s:prototype.PrintLines() dict "{{{3 + let self.temp_prompt = ['Press any key to continue.', 'Question'] + call tlib#buffer#DeleteRange('1', '$') + call append(0, self.temp_lines) + call tlib#buffer#DeleteRange('$', '$') + 1 + call self.Resize(len(self.temp_lines), 0) + let self.temp_lines = [] +endf + + +" :nodoc: +function! s:prototype.Resize(hsize, vsize) dict "{{{3 + " TLogVAR self.scratch_vertical, a:hsize, a:vsize + let world_resize = '' + let winpos = '' + let scratch_split = get(self, 'scratch_split', 1) + " TLogVAR scratch_split + if scratch_split > 0 + if self.scratch_vertical + if a:vsize + let world_resize = 'vert resize '. a:vsize + let winpos = tlib#fixes#Winpos() + " let w:winresize = {'v': a:vsize} + setlocal winfixwidth + endif + else + if a:hsize + let world_resize = 'resize '. a:hsize + " let w:winresize = {'h': a:hsize} + setlocal winfixheight + endif + endif + endif + if !empty(world_resize) + " TLogVAR world_resize, winpos + exec world_resize + if !empty(winpos) + exec winpos + endif + " redraw! + endif +endf + + +" :nodoc: +function! s:prototype.GetResize(size) dict "{{{3 + let resize0 = get(self, 'resize', 0) + let resize = empty(resize0) ? 0 : eval(resize0) + " TLogVAR resize0, resize + let resize = resize == 0 ? a:size : min([a:size, resize]) + " let min = self.scratch_vertical ? &cols : &lines + let min1 = (self.scratch_vertical ? self.win_width : self.win_height) * g:tlib_inputlist_pct + let min2 = (self.scratch_vertical ? &columns : &lines) * self.win_pct + let min = max([min1, min2]) + let resize = min([resize, (min / 100)]) + " TLogVAR resize, a:size, min, min1, min2 + return resize +endf + + +" function! s:prototype.DisplayList(?query=self.Query(), ?list=[]) +" :nodoc: +function! s:prototype.DisplayList(...) dict "{{{3 + " TLogVAR self.state + let query = a:0 >= 1 ? a:1 : self.Query() + let list = a:0 >= 2 ? a:2 : [] + " TLogVAR query, len(list) + " TLogDBG 'len(list) = '. len(list) + call self.UseScratch() + " TLogVAR self.scratch + " TAssert IsNotEmpty(self.scratch) + if self.state == 'scroll' + call self.ScrollToOffset() + elseif self.state == 'help' + call self.DisplayHelp() + call self.SetStatusline(query) + elseif self.state == 'printlines' + call self.PrintLines() + call self.SetStatusline(query) + else + " TLogVAR query + " let ll = len(list) + let ll = self.llen + " let x = len(ll) + 1 + let x = self.index_width + 1 + " TLogVAR ll + if self.state =~ '\' + call self.Resize(self.GetResize(ll), eval(get(self, 'resize_vertical', 0))) + call tlib#normal#WithRegister('gg"tdG', 't') + let lines = copy(list) + let lines = map(lines, 'substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g")') + let w = winwidth(0) - &fdc + " let w = winwidth(0) - &fdc - 1 + let lines = map(lines, 'printf("%-'. w .'.'. w .'s", v:val)') + " TLogVAR lines + call append(0, lines) + call tlib#normal#WithRegister('G"tddgg', 't') + endif + " TLogVAR self.prefidx + let base_pref = self.GetBaseIdx(self.prefidx) + " TLogVAR base_pref + if self.state =~ '\' + call filter(b:tlibDisplayListMarks, 'index(self.sel_idx, v:val) == -1 && v:val != base_pref') + " TLogVAR b:tlibDisplayListMarks + call map(b:tlibDisplayListMarks, 'self.DisplayListMark(x, v:val, ":")') + " let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + " call add(b:tlibDisplayListMarks, self.prefidx) + " call self.DisplayListMark(x, self.GetBaseIdx(self.prefidx), '*') + endif + let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + call add(b:tlibDisplayListMarks, base_pref) + call self.DisplayListMark(x, base_pref, '*') + call self.SetOffset() + call self.SetStatusline(query) + " TLogVAR self.offset + call self.ScrollToOffset() + let rx0 = self.GetRx0() + " TLogVAR rx0 + if !empty(self.matcher.highlight) + if empty(rx0) + match none + elseif self.IsValidFilter() + if has_key(self, 'Highlighter') + call self.Highlighter(rx0) + else + exec 'match '. self.matcher.highlight .' /\c'. escape(rx0, '/') .'/' + endif + endif + endif + endif + redraw +endf + + +" :nodoc: +function! s:prototype.SetStatusline(query) dict "{{{3 + " TLogVAR a:query + if !empty(self.temp_prompt) + let echo = get(self.temp_prompt, 0, '') + let hl = get(self.temp_prompt, 1, 'Normal') + let self.temp_prompt = [] + else + let hl = 'Normal' + let query = a:query + let options = [self.matcher.name] + if self.sticky + call add(options, '#') + endif + if self.key_mode != 'default' + call add(options, 'map:'. self.key_mode) + endif + if !empty(self.filtered_items) + if g:tlib_inputlist_shortmessage + call add(options, 'R') + else + call add(options, 'restricted') + endif + endif + if !empty(options) + let sopts = printf('[%s]', join(options, ', ')) + " let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts + let echo = query . ' ' . sopts + " let query .= '%%='. sopts .' ' + endif + " TLogVAR &l:statusline, query + " let &l:statusline = query + endif + echo + if hl != 'Normal' + exec 'echohl' hl + echo echo + echohl None + else + echo echo + endif +endf + + +" :nodoc: +function! s:prototype.Query() dict "{{{3 + let flt = self.DisplayFilter() + if g:tlib_inputlist_shortmessage + let query = 'Filter: '. flt + else + let query = self.query .' (filter: '. flt .'; press for help)' + endif + return query +endf + + +" :nodoc: +function! s:prototype.ScrollToOffset() dict "{{{3 + " TLogVAR self.scratch_vertical, self.llen, winheight(0) + exec 'norm! '. self.offset .'zt' +endf + + +" :nodoc: +function! s:prototype.SetOffset() dict "{{{3 + " TLogVAR self.prefidx, self.offset + " TLogDBG winheight(0) + " TLogDBG self.prefidx > self.offset + winheight(0) - 1 + let listtop = len(self.list) - winheight(0) + 1 + if listtop < 1 + let listtop = 1 + endif + if self.prefidx > listtop + let self.offset = listtop + elseif self.prefidx > self.offset + winheight(0) - 1 + let listoff = self.prefidx - winheight(0) + 1 + let self.offset = min([listtop, listoff]) + " TLogVAR self.prefidx + " TLogDBG len(self.list) + " TLogDBG winheight(0) + " TLogVAR listtop, listoff, self.offset + elseif self.prefidx < self.offset + let self.offset = self.prefidx + endif + " TLogVAR self.offset +endf + + +" :nodoc: +function! s:prototype.ClearAllMarks() dict "{{{3 + let x = self.index_width + 1 + call map(range(1, line('$')), 'self.DisplayListMark(x, v:val, ":")') +endf + + +" :nodoc: +function! s:prototype.MarkCurrent(y) dict "{{{3 + let x = self.index_width + 1 + call self.DisplayListMark(x, a:y, '*') +endf + + +" :nodoc: +function! s:prototype.DisplayListMark(x, y, mark) dict "{{{3 + " TLogVAR a:y, a:mark + if a:x > 0 && a:y >= 0 + " TLogDBG a:x .'x'. a:y .' '. a:mark + let sy = self.GetListIdx(a:y) + 1 + " TLogVAR sy + if sy >= 1 + call setpos('.', [0, sy, a:x, 0]) + exec 'norm! r'. a:mark + " exec 'norm! '. a:y .'gg'. a:x .'|r'. a:mark + endif + endif + return a:y +endf + + +" :nodoc: +function! s:prototype.SwitchWindow(where) dict "{{{3 + " TLogDBG string(tlib#win#List()) + if self.tabpagenr != tabpagenr() + call tlib#tab#Set(self.tabpagenr) + endif + let wnr = get(self, a:where.'_wnr') + " TLogVAR self, wnr + return tlib#win#Set(wnr) +endf + + +" :nodoc: +function! s:prototype.FollowCursor() dict "{{{3 + if !empty(self.follow_cursor) + let back = self.SwitchWindow('win') + " TLogVAR back + " TLogDBG winnr() + try + call call(self.follow_cursor, [self, [self.CurrentItem()]]) + finally + exec back + endtry + endif +endf + + +" :nodoc: +function! s:prototype.SetOrigin(...) dict "{{{3 + TVarArg ['winview', 0] + " TLogVAR self.win_wnr, self.bufnr + " TLogDBG bufname('%') + " TLogDBG winnr() + " TLogDBG winnr('$') + let self.win_wnr = winnr() + let self.win_height = winheight(self.win_wnr) + let self.win_width = winwidth(self.win_wnr) + " TLogVAR self.win_wnr, self.win_height, self.win_width + let self.bufnr = bufnr('%') + let self.tabpagenr = tabpagenr() + let self.cursor = getpos('.') + if winview + let self.winview = tlib#win#GetLayout() + endif + " TLogVAR self.win_wnr, self.bufnr, self.winview + return self +endf + + +" :nodoc: +function! s:prototype.RestoreOrigin(...) dict "{{{3 + TVarArg ['winview', 0] + if winview + " TLogVAR winview + call tlib#win#SetLayout(self.winview) + endif + " TLogVAR self.win_wnr, self.bufnr, self.cursor, &splitbelow + " TLogDBG "RestoreOrigin0 ". string(tlib#win#List()) + " If &splitbelow or &splitright is false, we cannot rely on + " self.win_wnr to be our source buffer since, e.g, opening a buffer + " in a split window changes the whole layout. + " Possible solutions: + " - Restrict buffer switching to cases when the number of windows + " hasn't changed. + " - Guess the right window, which we try to do here. + if &splitbelow == 0 || &splitright == 0 + let wn = bufwinnr(self.bufnr) + " TLogVAR wn + if wn == -1 + let wn = 1 + end + else + let wn = self.win_wnr + endif + if wn != winnr() + exec wn .'wincmd w' + endif + exec 'buffer! '. self.bufnr + call setpos('.', self.cursor) + " TLogDBG "RestoreOrigin1 ". string(tlib#win#List()) +endf + + +function! s:prototype.Suspend() dict "{{{3 + call tlib#agent#Suspend(self, self.rv) +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/agent.vim b/sources_non_forked/tlib/autoload/tlib/agent.vim new file mode 100644 index 00000000..98275f12 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/agent.vim @@ -0,0 +1,664 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 328 + + +" :filedoc: +" Various agents for use as key handlers in tlib#input#List() + +" Number of items to move when pressing in the input list window. +TLet g:tlib_scroll_lines = 10 + + +" General {{{1 + +function! tlib#agent#Exit(world, selected) "{{{3 + if a:world.key_mode == 'default' + call a:world.CloseScratch() + let a:world.state = 'exit empty escape' + let a:world.list = [] + " let a:world.base = [] + call a:world.ResetSelected() + else + let a:world.key_mode = 'default' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#CopyItems(world, selected) "{{{3 + let @* = join(a:selected, "\n") + let a:world.state = 'redisplay' + return a:world +endf + + + +" InputList related {{{1 + +function! tlib#agent#PageUp(world, selected) "{{{3 + let a:world.offset -= (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#PageDown(world, selected) "{{{3 + let a:world.offset += (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#Home(world, selected) "{{{3 + let a:world.prefidx = 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#End(world, selected) "{{{3 + let a:world.prefidx = len(a:world.list) + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Up(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + let a:world.idx = '' + if a:world.prefidx > lines + let a:world.prefidx -= lines + else + let a:world.prefidx = len(a:world.list) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Down(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + let a:world.idx = '' + if a:world.prefidx <= (len(a:world.list) - lines) + let a:world.prefidx += lines + else + let a:world.prefidx = 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#UpN(world, selected) "{{{3 + return tlib#agent#Up(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#DownN(world, selected) "{{{3 + return tlib#agent#Down(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#ShiftLeft(world, selected) "{{{3 + let a:world.offset_horizontal -= (winwidth(0) / 2) + if a:world.offset_horizontal < 0 + let a:world.offset_horizontal = 0 + endif + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#ShiftRight(world, selected) "{{{3 + let a:world.offset_horizontal += (winwidth(0) / 2) + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#Reset(world, selected) "{{{3 + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#ToggleRestrictView(world, selected) "{{{3 + if empty(a:world.filtered_items) + return tlib#agent#RestrictView(a:world, a:selected) + else + return tlib#agent#UnrestrictView(a:world, a:selected) + endif +endf + + +function! tlib#agent#RestrictView(world, selected) "{{{3 + " TLogVAR a:selected + let filtered_items = map(copy(a:selected), 'index(a:world.base, v:val) + 1') + " TLogVAR 1, filtered_items + let filtered_items = filter(filtered_items, 'v:val > 0') + " TLogVAR 2, filtered_items + if !empty(filtered_items) + let a:world.filtered_items = filtered_items + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#UnrestrictView(world, selected) "{{{3 + let a:world.filtered_items = [] + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Input(world, selected) "{{{3 + let flt0 = a:world.CleanFilter(a:world.filter[0][0]) + let flt1 = input('Filter: ', flt0) + echo + if flt1 != flt0 + if empty(flt1) + call getchar(0) + else + call a:world.SetFrontFilter(flt1) + endif + endif + let a:world.state = 'display' + return a:world +endf + + +" Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the +" original position in the parent window. +function! tlib#agent#SuspendToParentWindow(world, selected) "{{{3 + let world = a:world + let winnr = world.win_wnr + " TLogVAR winnr + if winnr != -1 + let world = tlib#agent#Suspend(world, a:selected) + if world.state =~ '\' + call world.SwitchWindow('win') + " let pos = world.cursor + " " TLogVAR pos + " if !empty(pos) + " call setpos('.', pos) + " endif + return world + endif + endif + let world.state = 'redisplay' + return world +endf + + +" Suspend lets you temporarily leave the input loop of +" |tlib#input#List|. You can resume editing the list by pressing , +" . , or in the suspended window. +" and will immediatly select the item under the cursor. +" < will select the item but the window will remain opened. +function! tlib#agent#Suspend(world, selected) "{{{3 + if a:world.allow_suspend + " TAssert IsNotEmpty(a:world.scratch) + " TLogDBG bufnr('%') + let br = tlib#buffer#Set(a:world.scratch) + " TLogVAR br, a:world.bufnr, a:world.scratch + if bufnr('%') != a:world.scratch + echohl WarningMsg + echom "tlib#agent#Suspend: Internal error: Not a scratch buffer:" bufname('%') + echohl NONE + endif + " TLogVAR bufnr('%'), bufname('%'), a:world.scratch + call tlib#autocmdgroup#Init() + exec 'autocmd TLib BufEnter call tlib#input#Resume("world", 0, '. a:world.scratch .')' + let b:tlib_world = a:world + exec br + let a:world.state = 'exit suspend' + else + echom 'Suspend disabled' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#Help(world, selected) "{{{3 + let a:world.state = 'help' + return a:world +endf + + +function! tlib#agent#OR(world, selected) "{{{3 + if !empty(a:world.filter[0]) + call insert(a:world.filter[0], '') + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#AND(world, selected) "{{{3 + if !empty(a:world.filter[0]) + call insert(a:world.filter, ['']) + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#ReduceFilter(world, selected) "{{{3 + call a:world.ReduceFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#PopFilter(world, selected) "{{{3 + call a:world.PopFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Debug(world, selected) "{{{3 + " echo string(world.state) + echo string(a:world.filter) + echo string(a:world.idx) + echo string(a:world.prefidx) + echo string(a:world.sel_idx) + call getchar() + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Select(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + " let a:world.state = 'display keepcursor' + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectUp(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx > 1 + let a:world.prefidx -= 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectDown(world, selected) "{{{3 + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx < len(a:world.list) + let a:world.prefidx += 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectAll(world, selected) "{{{3 + let listrange = range(1, len(a:world.list)) + let mode = empty(filter(copy(listrange), 'index(a:world.sel_idx, a:world.GetBaseIdx(v:val)) == -1')) + \ ? 'toggle' : 'set' + for i in listrange + call a:world.SelectItem(mode, i) + endfor + let a:world.state = 'display keepcursor' + return a:world +endf + + +function! tlib#agent#ToggleStickyList(world, selected) "{{{3 + let a:world.sticky = !a:world.sticky + let a:world.state = 'display keepcursor' + return a:world +endf + + + +" EditList related {{{1 + +function! tlib#agent#EditItem(world, selected) "{{{3 + let lidx = a:world.prefidx + " TLogVAR lidx + " TLogVAR a:world.table + let bidx = a:world.GetBaseIdx(lidx) + " TLogVAR bidx + let item = a:world.GetBaseItem(bidx) + let item = input(lidx .'@'. bidx .': ', item) + if item != '' + call a:world.SetBaseItem(bidx, item) + endif + let a:world.state = 'display' + return a:world +endf + + +" Insert a new item below the current one. +function! tlib#agent#NewItem(world, selected) "{{{3 + let basepi = a:world.GetBaseIdx(a:world.prefidx) + let item = input('New item: ') + call insert(a:world.base, item, basepi) + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#DeleteItems(world, selected) "{{{3 + let remove = copy(a:world.sel_idx) + let basepi = a:world.GetBaseIdx(a:world.prefidx) + if index(remove, basepi) == -1 + call add(remove, basepi) + endif + " call map(remove, 'a:world.GetBaseIdx(v:val)') + for idx in reverse(sort(remove)) + call remove(a:world.base, idx - 1) + endfor + let a:world.state = 'display' + call a:world.ResetSelected() + " let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#Cut(world, selected) "{{{3 + let world = tlib#agent#Copy(a:world, a:selected) + return tlib#agent#DeleteItems(world, a:selected) +endf + + +function! tlib#agent#Copy(world, selected) "{{{3 + let a:world.clipboard = [] + let bidxs = copy(a:world.sel_idx) + call add(bidxs, a:world.GetBaseIdx(a:world.prefidx)) + for bidx in sort(bidxs) + call add(a:world.clipboard, a:world.GetBaseItem(bidx)) + endfor + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Paste(world, selected) "{{{3 + if has_key(a:world, 'clipboard') + for e in reverse(copy(a:world.clipboard)) + call insert(a:world.base, e, a:world.prefidx) + endfor + endif + let a:world.state = 'display' + call a:world.ResetSelected() + return a:world +endf + + +function! tlib#agent#EditReturnValue(world, rv) "{{{3 + return [a:world.state !~ '\', a:world.base] +endf + + + +" Files related {{{1 + +function! tlib#agent#ViewFile(world, selected) "{{{3 + if !empty(a:selected) + let back = a:world.SwitchWindow('win') + " TLogVAR back + for filename in a:selected + call tlib#file#Edit(filename) + endfor + " if !&hidden && &l:modified + " let cmd0 = 'split' + " let cmd1 = 'sbuffer' + " else + " let cmd0 = 'edit' + " let cmd1 = 'buffer' + " endif + " call tlib#file#With(cmd0, cmd1, a:selected, a:world) + " TLogVAR &filetype + exec back + let a:world.state = 'display' + endif + return a:world +endf + + +function! tlib#agent#EditFile(world, selected) "{{{3 + return tlib#agent#Exit(tlib#agent#ViewFile(a:world, a:selected), a:selected) +endf + + +function! tlib#agent#EditFileInSplit(world, selected) "{{{3 + call a:world.CloseScratch() + " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) + " call tlib#file#With('split', 'sbuffer', a:selected[1:-1], a:world) + call tlib#file#With('split', 'sbuffer', a:selected, a:world) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInVSplit(world, selected) "{{{3 + call a:world.CloseScratch() + " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) + " call tlib#file#With('vertical split', 'vertical sbuffer', a:selected[1:-1], a:world) + let winpos = tlib#fixes#Winpos() + call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world) + if !empty(winpos) + exec winpos + endif + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInTab(world, selected) "{{{3 + " TLogVAR a:selected + call a:world.CloseScratch() + call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#ToggleScrollbind(world, selected) "{{{3 + let a:world.scrollbind = get(a:world, 'scrollbind') ? 0 : 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#ShowInfo(world, selected) + let lines = [] + for f in a:selected + if filereadable(f) + let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)] + call add(lines, fnamemodify(f, ':p')) + call add(lines, ' '. join(desc, '; ')) + endif + endfor + let a:world.temp_lines = lines + let a:world.state = 'printlines' + return a:world +endf + + + +" Buffer related {{{1 + +function! tlib#agent#PreviewLine(world, selected) "{{{3 + let l = a:selected[0] + let ww = winnr() + exec a:world.win_wnr .'wincmd w' + call tlib#buffer#ViewLine(l, 1) + exec ww .'wincmd w' + let a:world.state = 'redisplay' + return a:world +endf + + +" If not called from the scratch, we assume/guess that we don't have to +" suspend the input-evaluation loop. +function! tlib#agent#GotoLine(world, selected) "{{{3 + if !empty(a:selected) + + " let l = a:selected[0] + " " TLogVAR l + " let back = a:world.SwitchWindow('win') + " " TLogVAR back + " " if a:world.win_wnr != winnr() + " " let world = tlib#agent#Suspend(a:world, a:selected) + " " exec a:world.win_wnr .'wincmd w' + " " endif + " call tlib#buffer#ViewLine(l) + " exec back + " let a:world.state = 'display' + + let l = a:selected[0] + if a:world.win_wnr != winnr() + let world = tlib#agent#Suspend(a:world, a:selected) + exec a:world.win_wnr .'wincmd w' + endif + call tlib#buffer#ViewLine(l, 1) + + endif + return a:world +endf + + +function! tlib#agent#DoAtLine(world, selected) "{{{3 + if !empty(a:selected) + let cmd = input('Command: ', '', 'command') + if !empty(cmd) + call a:world.SwitchWindow('win') + " let pos = getpos('.') + let view = winsaveview() + for l in a:selected + call tlib#buffer#ViewLine(l, '') + exec cmd + endfor + " call setpos('.', pos) + call winrestview(view) + endif + endif + call a:world.ResetSelected() + let a:world.state = 'exit' + return a:world +endf + + +function! tlib#agent#Wildcard(world, selected) "{{{3 + if !empty(a:world.filter[0]) + let rx_type = a:world.matcher.FilterRxPrefix() + let flt0 = a:world.CleanFilter(a:world.filter[0][0]) + if rx_type == '\V' + let flt0 .= '\.\{-}' + else + let flt0 .= '.\{-}' + endif + call a:world.SetFrontFilter(flt0) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Null(world, selected) "{{{3 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#ExecAgentByName(world, selected) "{{{3 + let s:agent_names_world = a:world + let agent_names = {'Help': 'tlib#agent#Help'} + for def in values(a:world.key_map[a:world.key_mode]) + if has_key(def, 'help') && !empty(def.help) && has_key(def, 'agent') && !empty(def.agent) + let agent_names[def.help] = def.agent + endif + endfor + let s:agent_names = sort(keys(agent_names)) + let command = input('Command: ', '', 'customlist,tlib#agent#CompleteAgentNames') + " TLogVAR command + if !has_key(agent_names, command) + " TLogVAR command + silent! let matches = filter(keys(agent_names), 'v:val =~ command') + " TLogVAR matches + if len(matches) == 1 + let command = matches[0] + endif + endif + if has_key(agent_names, command) + let agent = agent_names[command] + return call(agent, [a:world, a:selected]) + else + if !empty(command) + echohl WarningMsg + echom "Unknown command:" command + echohl NONE + sleep 1 + endif + let a:world.state = 'display' + return a:world + endif +endf + + +function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) + return filter(copy(s:agent_names), 'stridx(v:val, a:ArgLead) != -1') +endf + + +function! tlib#agent#Complete(world, selected) abort "{{{3 + let rxprefix = a:world.matcher.FilterRxPrefix() + let flt = a:world.filter[0][0] + " TLogVAR flt + let fltrx = rxprefix . flt . '\m[^[:space:][:cntrl:][:punct:]<>*+?&~{}()\[\]\\/]\+' + let fltrx0 = '\m^' . fltrx + " TLogVAR fltrx, fltrx0 + let words = {} + for item in a:world.list + let parts = split(item, '\ze'. fltrx) + " TLogVAR item, parts + for part in parts + let word = matchstr(part, fltrx0) + " TLogVAR part, word + if !empty(word) + let words[word] = 1 + endif + endfor + endfor + " TLogVAR keys(words) + let completions = keys(words) + " let completions = filter(keys(words), 'matchstr(v:val, fltrx0)') + let completions = sort(completions, 's:SortCompletions') + let completions = tlib#list#Uniq(completions) + " TLogVAR 0, completions + while len(completions) > 1 + let nchar = strwidth(completions[0]) - 1 + let completions = map(completions, 'strpart(v:val, 0, nchar)') + " TLogVAR 'reduce', completions + let completions = tlib#list#Uniq(completions) + " TLogVAR 'unique', len(completions), completions + endwh + " TLogVAR 9, completions + if empty(completions) + let a:world.state = 'redisplay update' + else + let a:world.filter[0][0] = completions[0] + let a:world.state = 'display update' + endif + return a:world +endf + + +function! s:SortCompletions(a, b) abort "{{{3 + let i1 = strwidth(a:a) + let i2 = strwidth(a:b) + return i2 - i1 +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/arg.vim b/sources_non_forked/tlib/autoload/tlib/arg.vim new file mode 100644 index 00000000..2e995146 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/arg.vim @@ -0,0 +1,328 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-11-19. +" @Revision: 251 + + +" :def: function! tlib#arg#Get(n, var, ?default="", ?test='') +" Set a positional argument from a variable argument list. +" See tlib#string#RemoveBackslashes() for an example. +function! tlib#arg#Get(n, var, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let atest = a:0 >= 2 ? a:2 : '' + " TLogVAR default, atest + if !empty(atest) + let atest = ' && (a:'. a:n .' '. atest .')' + endif + let test = printf('a:0 >= %d', a:n) . atest + return printf('let %s = %s ? a:%d : %s', a:var, test, a:n, string(default)) +endf + + +" :def: function! tlib#arg#Let(list, ?default='') +" Set a positional arguments from a variable argument list. +" See tlib#input#List() for an example. +function! tlib#arg#Let(list, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let list = map(copy(a:list), 'type(v:val) == 3 ? v:val : [v:val, default]') + let args = map(range(1, len(list)), 'call("tlib#arg#Get", [v:val] + list[v:val - 1])') + return join(args, ' | ') +endf + + +" :def: function! tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':', ?booleans=0) +function! tlib#arg#StringAsKeyArgs(string, ...) "{{{1 + TVarArg ['keys', {}], ['evaluate', 0], ['sep', ':'], ['booleans', 0] + let keyargs = {} + let args = split(a:string, '\\\@= 0 + let keyargs['__posargs__'] = range(0, pos) + endif + return keyargs +endf + + +function! tlib#arg#StringAsKeyArgsEqual(string) "{{{1 + return tlib#arg#StringAsKeyArgs(a:string, [], 0, '=', 1) +endf + + +" :display: tlib#arg#GetOpts(args, ?def={}) +" Convert a list of strings of command-line arguments into a dictonary. +" +" The main use case is to pass [], i.e. the command-line +" arguments of a command as list, from a command definition to this +" function. +" +" Example: +" ['-h'] +" => If def contains a 'help' key, invoke |:help| on its value. +" +" ['-ab', '--foo', '--bar=BAR', 'bla', bla'] +" => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} +" +" ['-ab', '--', '--foo', '--bar=BAR'] +" => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} +function! tlib#arg#GetOpts(args, ...) abort "{{{3 + let throw = a:0 == 0 + TVarArg ['def', {}] + " TLogVAR def + let opts = {'__exit__': 0} + for [key, vdef] in items(get(def, 'values', {})) + if has_key(vdef, 'default') + let opts[key] = vdef.default + endif + endfor + let idx = 0 + for o in a:args + let [break, idx] = s:SetOpt(def, opts, idx, o) + if break == 1 + break + elseif break == 2 + if throw + throw 'tlib#arg#GetOpts: Show help' + else + let opts.__exit__ = 5 + endif + endif + endfor + let opts.__rest__ = a:args[idx : -1] + return opts +endf + + +function! s:GetValueType(def) abort "{{{3 + return get(a:def, 'type', type(get(a:def, 'default', ''))) +endf + + +function! s:SetOpt(def, opts, idx, opt) abort "{{{3 + " TLogVAR a:def + let idx = a:idx + 1 + let break = 0 + let long = get(a:def, 'long', 1) + let short = get(a:def, 'short', 1) + if (short && a:opt =~# '^-[?h]$') || (long && a:opt ==# '--help') + if has_key(a:def, 'help') + exec 'help' a:def.help + else + " TLogVAR a:def + let values = get(a:def, 'values', {}) + let flags = get(a:def, 'flags', {}) + if empty(values) && empty(flags) + echom 'No help' + else + if !empty(values) + echom 'Options:' + for [key, vdef] in sort(items(values)) + let opt = key + let default = get(vdef, 'default', '') + let type = s:GetValueType(vdef) + if default =~ '^-\?\d\+\%(\.\d\+\)$' + if type == -1 + let opt .= ' (flag)' + elseif type == 1 + let opt .= '=INT' + else + let opt .= '=INT or maybe BOOL' + endif + elseif type(default) == 1 + let opt .= '=STRING' + elseif type(default) == 3 + let opt .= '=COMMA-LIST' + endif + echom printf(' --%20s (default: %s)', opt, string(default)) + endfor + endif + if !empty(flags) + echom 'Short flags:' + for [sflag, lflag] in sort(items(flags)) + echom printf(' -%s -> %s', sflag, lflag) + endfor + endif + endif + endif + let break = 2 + elseif long && a:opt =~# '^--no-.\+' + let key = matchstr(a:opt, '^--no-\zs.\+$') + let a:opts[key] = s:Validate(a:def, key, 0) + elseif long && a:opt =~# '^--\w\+$' + let key = matchstr(a:opt, '^--\zs.\+$') + let a:opts[key] = s:Validate(a:def, key, 1) + elseif long && a:opt =~# '^--\w\+=' + let ml = matchlist(a:opt, '^--\(\w\+\)=\(.*\)$') + if empty(ml) + throw 'tlib#arg#GetOpts: Cannot parse: '. a:opt + else + let values = get(a:def, 'values', {}) + if has_key(values, ml[1]) + let vdef = values[ml[1]] + let type = s:GetValueType(vdef) + if type == -1 + let opt_value = !!str2nr(ml[2]) + elseif type == 0 + let opt_value = str2nr(ml[2]) + elseif type == 1 + let opt_value = ml[2] + elseif type == 2 + let opt_value = function(ml[2]) + elseif type == 3 + let opt_value = tlib#string#SplitCommaList(ml[2]) + elseif type == 4 + throw 'tlib#arg#GetOpts: Unsupported type conversion for '. ml[1] + elseif type == 5 + let opt_value = str2float(ml[2]) + endif + else + let opt_value = ml[2] + endif + let a:opts[ml[1]] = s:Validate(a:def, ml[1], opt_value) + unlet opt_value + endif + elseif short && a:opt =~# '^-\w=' + let flagdefs = get(a:def, 'flags', {}) + let flag = matchstr(a:opt, '^-\zs\w') + let rest = matchstr(a:opt, '^-\w\zs.*$') + call s:SetFlag(a:def, a:opts, idx, flag, rest, flagdefs) + elseif short && a:opt =~# '^-\w\+$' + let flagdefs = get(a:def, 'flags', {}) + for flag in split(substitute(a:opt, '^-', '', ''), '\zs') + call s:SetFlag(a:def, a:opts, idx, flag, '', flagdefs) + endfor + else + let break = 1 + if a:opt !=# '--' + let idx -= 1 + endif + endif + return [break, idx] +endf + + +function! s:SetFlag(def, opts, idx, flag, rest, flagdefs) abort "{{{3 + " TLogVAR a:def + if has_key(a:flagdefs, a:flag) + call s:SetOpt(a:def, a:opts, a:idx, a:flagdefs[a:flag] . a:rest) + else + let a:opts[a:flag] = s:Validate(a:def, a:flag, 1) + endif +endf + + +function! s:Validate(def, name, value) abort "{{{3 + let values = get(a:def, 'values', {}) + if has_key(values, a:name) + let vdef = values[a:name] + if has_key(vdef, 'validate') + if !call(vdef.validate, [a:value]) + throw printf('tlib#arg: %s has invalid value: %s', string(a:name), string(a:value)) + endif + endif + endif + return a:value +endf + + +":nodoc: +function! tlib#arg#CComplete(def, ArgLead) abort "{{{3 + let values = get(a:def, 'values', {}) + let opt = matchstr(a:ArgLead, '^--\zs\w\+\ze=') + if has_key(values, opt) + let words = [] + let vals = values[opt] + let complete_customlist = get(vals, 'complete_customlist', '') + if !empty(complete_customlist) + let words = eval(complete_customlist) + " else + " let complete = get(vals, 'complete', '') + " if !empty(complete) + " endif + endif + if !empty(words) + let lead = substitute(a:ArgLead, '^--\w\+=', '', '') + if !empty(lead) + let nchar = len(lead) + call filter(words, 'strpart(v:val, 0, nchar) ==# lead') + endif + let words = map(words, '"--". opt ."=". v:val') + return sort(words) + endif + endif + let cs = {'-h': 1, '--help': 1} + for [name, vdef] in items(values) + let type = s:GetValueType(vdef) + if type >= 0 + let name .= '=' + else + let cs['--no-'. name] = 1 + endif + let cs['--'. name] = 1 + endfor + for [name, subst] in items(get(a:def, 'flags', {})) + let ldef = get(values, substitute(subst, '^--', '', ''), {}) + let type = s:GetValueType(ldef) + if type >= 0 + let name .= '=' + endif + let cs['-'. name] = 1 + endfor + let nchar = len(a:ArgLead) + if nchar > 0 + call filter(cs, 'strpart(v:key, 0, nchar) ==# a:ArgLead') + endif + return sort(keys(cs)) +endf + + + +""" Command line {{{1 + +" :def: function! tlib#arg#Ex(arg, ?chars='%#! ') +" Escape some characters in a string. +" +" Use |fnamescape()| if available. +" +" EXAMPLES: > +" exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +function! tlib#arg#Ex(arg, ...) "{{{3 + if exists('*fnameescape') && a:0 == 0 + return fnameescape(a:arg) + else + " let chars = '%# \' + let chars = '%#! ' + if a:0 >= 1 + let chars .= a:1 + endif + return escape(a:arg, chars) + endif +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/assert.vim b/sources_non_forked/tlib/autoload/tlib/assert.vim new file mode 100644 index 00000000..dbf48369 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/assert.vim @@ -0,0 +1,44 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-11-23 +" @Revision: 38 + + +" Enable tracing via |:Tlibassert|. +function! tlib#assert#Enable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bar Tlibassert call tlib#assert#Assert(expand(''), , []) +endf + + +" Disable tracing via |:Tlibassert|. +function! tlib#assert#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bang -bar Tlibassert : +endf + + +function! tlib#assert#Assert(caller, check, vals) abort "{{{3 + for val in a:vals + " TLogVAR val + if type(val) == 3 + call tlib#assert#Assert(a:caller, a:check, val) + elseif !val + throw 'Tlibassert: '. tlib#trace#Backtrace(a:caller) .': '. a:check + endif + endfor +endf + + +function! tlib#assert#Map(vals, expr) abort "{{{3 + return tlib#assert#All(map(a:vals, a:expr)) +endf + + +function! tlib#assert#All(vals) abort "{{{3 + " TLogVAR a:vals, empty(filter(a:vals, '!v:val')) + return empty(filter(a:vals, '!v:val')) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim b/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim new file mode 100644 index 00000000..84395248 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim @@ -0,0 +1,14 @@ +" autocmdgroup.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 7 + +augroup TLib + autocmd! +augroup END + + +function! tlib#autocmdgroup#Init() "{{{3 +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/balloon.vim b/sources_non_forked/tlib/autoload/tlib/balloon.vim new file mode 100644 index 00000000..69675239 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/balloon.vim @@ -0,0 +1,73 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-08-30. +" @Last Change: 2015-11-23. +" @Revision: 48 + + +function! tlib#balloon#Register(expr) "{{{3 + if !has('balloon_eval') + return + endif + if !exists('b:tlib_balloons') + let b:tlib_balloons = [] + endif + if !&ballooneval + setlocal ballooneval + endif + if &balloonexpr != 'tlib#balloon#Expr()' + if !empty(&balloonexpr) + call add(b:tlib_balloons, &balloonexpr) + endif + setlocal ballooneval balloonexpr=tlib#balloon#Expr() + endif + if index(b:tlib_balloons, a:expr) == -1 + call add(b:tlib_balloons, a:expr) + endif +endf + + +function! tlib#balloon#Remove(expr) "{{{3 + if exists('b:tlib_balloons') + call filter(b:tlib_balloons, 'v:val != a:expr') + if empty(b:tlib_balloons) + setlocal ballooneval& + setlocal balloonexpr& + unlet b:tlib_balloons + endif + endif +endf + + +function! tlib#balloon#Expr() "{{{3 + " TLogVAR exists('b:tlib_balloons') + if !exists('b:tlib_balloons') + return '' + endif + let text = map(copy(b:tlib_balloons), 'eval(v:val)') + " TLogVAR b:tlib_balloons, text + call filter(text, '!empty(v:val)') + if has('balloon_multiline') + return join(text, "\n----------------------------------\n") + else + return get(text, 0, '') + endif +endf + + +function! tlib#balloon#Expand(expr) abort "{{{3 + if v:beval_bufnr != bufnr('%') + " TLogVAR v:beval_bufnr, bufnr('%') + return '' + endif + let win = winsaveview() + try + call setpos('.', [v:beval_bufnr, v:beval_lnum, v:beval_col, 0]) + return expand(a:expr) + finally + call winrestview(win) + endtry +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/bitwise.vim b/sources_non_forked/tlib/autoload/tlib/bitwise.vim new file mode 100644 index 00000000..54a4258d --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/bitwise.vim @@ -0,0 +1,141 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 124 + + +function! tlib#bitwise#Num2Bits(num) "{{{3 + if type(a:num) <= 1 || type(a:num) == 5 + let bits = reverse(tlib#number#ConvertBase(a:num, 2, 'list')) + elseif type(a:num) == 3 + let bits = copy(a:num) + else + throw "tlib#bitwise#Num2Bits: Must be number of list: ". string(a:num) + endif + return bits +endf + + +function! tlib#bitwise#Bits2Num(bits, ...) "{{{3 + let base = a:0 >= 1 ? a:1 : 10 + " TLogVAR a:bits + let num = 0.0 + for i in range(len(a:bits)) + if get(a:bits, i, 0) + let num += pow(2, i) + endif + endfor + " TLogVAR num + if base == 10 + if type(base) == 5 + return num + else + return float2nr(num) + endif + else + return tlib#number#ConvertBase(num, base) + endif +endf + + +function! tlib#bitwise#AND(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) && get(bits2, v:val)') +endf + + +function! tlib#bitwise#OR(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) || get(bits2, v:val)') +endf + + +function! tlib#bitwise#XOR(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) ? !get(bits2, v:val) : get(bits2, v:val)') +endf + + +function! s:BitwiseComparison(num1, num2, rtype, expr) "{{{3 + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + let bits = map(range, a:expr) + if a:rtype == 'num' || (a:rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + + +function! tlib#bitwise#ShiftRight(bits, n) "{{{3 + let bits = a:bits[a:n : -1] + if empty(bits) + let bits = [0] + endif + return bits +endf + + +function! tlib#bitwise#ShiftLeft(bits, n) "{{{3 + let bits = repeat([0], a:n) + a:bits + return bits +endf + + +function! tlib#bitwise#Add(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + " TLogVAR bits1, bits2, range + let carry = 0 + let bits = [] + for i in range + let sum = get(bits1, i) + get(bits2, i) + carry + if sum == 3 + let bit = 1 + let carry = 1 + elseif sum == 2 + let bit = 0 + let carry = 1 + elseif sum == 1 + let bit = 1 + let carry = 0 + elseif sum == 0 + let bit = 0 + let carry = 0 + endif + call add(bits, bit) + " TLogVAR i, bits, bit + endfor + if carry == 1 + call add(bits, carry) + endif + if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + + +function! tlib#bitwise#Sub(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + let bits2 = map(range, '!get(bits2, v:val)') + let bits2 = tlib#bitwise#Add(bits2, [1], 'bits') + let bits3 = tlib#bitwise#Add(bits1, bits2, 'bits') + let bits = bits3[0 : -2] + if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/buffer.vim b/sources_non_forked/tlib/autoload/tlib/buffer.vim new file mode 100644 index 00000000..24e4e0a7 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/buffer.vim @@ -0,0 +1,401 @@ +" buffer.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2015-11-06. +" @Revision: 7.1.352 + + +" Where to display the line when using |tlib#buffer#ViewLine|. +" For possible values for position see |scroll-cursor|. +TLet g:tlib_viewline_position = 'zz' + + +let s:bmru = [] + + +function! tlib#buffer#EnableMRU() "{{{3 + call tlib#autocmdgroup#Init() + autocmd TLib BufEnter * call s:BMRU_Push(bufnr('%')) +endf + + +function! tlib#buffer#DisableMRU() "{{{3 + call tlib#autocmdgroup#Init() + autocmd! TLib BufEnter +endf + + +function! s:BMRU_Push(bnr) "{{{3 + let i = index(s:bmru, a:bnr) + if i >= 0 + call remove(s:bmru, i) + endif + call insert(s:bmru, a:bnr) +endf + + +function! s:CompareBuffernameByBasename(a, b) "{{{3 + let rx = '"\zs.\{-}\ze" \+\S\+ \+\d\+$' + let an = matchstr(a:a, rx) + let an = fnamemodify(an, ':t') + let bn = matchstr(a:b, rx) + let bn = fnamemodify(bn, ':t') + let rv = an == bn ? 0 : an > bn ? 1 : -1 + return rv +endf + + +function! s:CompareBufferNrByMRU(a, b) "{{{3 + let an = matchstr(a:a, '\s*\zs\d\+\ze') + let bn = matchstr(a:b, '\s*\zs\d\+\ze') + let ai = index(s:bmru, 0 + an) + if ai == -1 + return 1 + else + let bi = index(s:bmru, 0 + bn) + if bi == -1 + return -1 + else + return ai == bi ? 0 : ai > bi ? 1 : -1 + endif + endif +endf + + +" Set the buffer to buffer and return a command as string that can be +" evaluated by |:execute| in order to restore the original view. +function! tlib#buffer#Set(buffer) "{{{3 + let lazyredraw = &lazyredraw + set lazyredraw + try + let cb = bufnr('%') + let sn = bufnr(a:buffer) + if sn != cb + let ws = bufwinnr(sn) + if ws != -1 + let wb = bufwinnr('%') + exec ws.'wincmd w' + return wb.'wincmd w' + else + silent exec 'sbuffer! '. sn + return 'wincmd c' + endif + else + return '' + endif + finally + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#Eval(buffer, code) +" Evaluate CODE in BUFFER. +" +" EXAMPLES: > +" call tlib#buffer#Eval('foo.txt', 'echo b:bar') +function! tlib#buffer#Eval(buffer, code) "{{{3 + " let cb = bufnr('%') + " let wb = bufwinnr('%') + " " TLogVAR cb + " let sn = bufnr(a:buffer) + " let sb = sn != cb + let lazyredraw = &lazyredraw + set lazyredraw + let restore = tlib#buffer#Set(a:buffer) + try + exec a:code + " if sb + " let ws = bufwinnr(sn) + " if ws != -1 + " try + " exec ws.'wincmd w' + " exec a:code + " finally + " exec wb.'wincmd w' + " endtry + " else + " try + " silent exec 'sbuffer! '. sn + " exec a:code + " finally + " wincmd c + " endtry + " endif + " else + " exec a:code + " endif + finally + exec restore + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') +" Possible values for the "order" argument: +" bufnr :: Default behaviour +" mru :: Sort buffers according to most recent use +" basename :: Sort by the file's basename (last component) +" +" NOTE: MRU order works on second invocation only. If you want to always +" use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. +function! tlib#buffer#GetList(...) + TVarArg ['show_hidden', 0], ['show_number', 0], ['order', ''] + " TLogVAR show_hidden, show_number, order + let ls_bang = show_hidden ? '!' : '' + redir => bfs + exec 'silent ls'. ls_bang + redir END + let buffer_list = split(bfs, '\n') + if order == 'mru' + if empty(s:bmru) + call tlib#buffer#EnableMRU() + echom 'tlib: Installed Buffer MRU logger; disable with: call tlib#buffer#DisableMRU()' + else + call sort(buffer_list, function('s:CompareBufferNrByMRU')) + endif + elseif order == 'basename' + call sort(buffer_list, function('s:CompareBuffernameByBasename')) + endif + let buffer_nr = map(copy(buffer_list), 'str2nr(matchstr(v:val, ''\s*\zs\d\+\ze''))') + " TLogVAR buffer_list, buffer_nr + if show_number + call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+.\{-}\ze\s\+\S\+ \d\+\s*$'')') + else + call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+\zs.\{-}\ze\s\+\S\+ \d\+\s*$'')') + endif + " TLogVAR buffer_list + " call map(buffer_list, 'matchstr(v:val, ''^.\{-}\ze\s\+line \d\+\s*$'')') + " TLogVAR buffer_list + call map(buffer_list, 'matchstr(v:val, ''^[^"]\+''). printf("%-20s %s", fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":t"), fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":h"))') + " TLogVAR buffer_list + return [buffer_nr, buffer_list] +endf + + +" :def: function! tlib#buffer#ViewLine(line, ?position='z') +" line is either a number or a string that begins with a number. +" For possible values for position see |scroll-cursor|. +" See also |g:tlib_viewline_position|. +function! tlib#buffer#ViewLine(line, ...) "{{{3 + if a:line + TVarArg 'pos' + let ln = matchstr(a:line, '^\d\+') + let lt = matchstr(a:line, '^\d\+: \zs.*') + " TLogVAR pos, ln, lt + exec ln + if empty(pos) + let pos = tlib#var#Get('tlib_viewline_position', 'wbg') + endif + " TLogVAR pos + if !empty(pos) + exec 'norm! '. pos + endif + call tlib#buffer#HighlightLine(ln) + " let @/ = '\%'. ln .'l.*' + endif +endf + + +function! s:UndoHighlightLine() "{{{3 + 2match none + autocmd! TLib CursorMoved,CursorMovedI + autocmd! TLib CursorHold,CursorHoldI + autocmd! TLib InsertEnter,InsertChange,InsertLeave + autocmd! TLib BufLeave,BufWinLeave,WinLeave,BufHidden +endf + + +function! tlib#buffer#HighlightLine(...) "{{{3 + TVarArg ['line', line('.')] + " exec '2match MatchParen /^\%'. a:line .'l.*/' + exec '2match Search /^\%'. line .'l.*/' + call tlib#autocmdgroup#Init() + exec 'autocmd TLib CursorMoved,CursorMovedI if line(".") != '. line .' | call s:UndoHighlightLine() | endif' + autocmd TLib CursorHold,CursorHoldI call s:UndoHighlightLine() + autocmd TLib InsertEnter call s:UndoHighlightLine() + " autocmd TLib BufLeave,BufWinLeave,WinLeave,BufHidden call s:UndoHighlightLine() +endf + + +" Delete the lines in the current buffer. Wrapper for |:delete|. +function! tlib#buffer#DeleteRange(line1, line2) "{{{3 + let r = @t + try + exec a:line1.','.a:line2.'delete t' + finally + let @t = r + endtry +endf + + +" Replace a range of lines. +function! tlib#buffer#ReplaceRange(line1, line2, lines) + call tlib#buffer#DeleteRange(a:line1, a:line2) + call append(a:line1 - 1, a:lines) +endf + + +" Initialize some scratch area at the bottom of the current buffer. +function! tlib#buffer#ScratchStart() "{{{3 + norm! Go + let b:tlib_inbuffer_scratch = line('$') + return b:tlib_inbuffer_scratch +endf + + +" Remove the in-buffer scratch area. +function! tlib#buffer#ScratchEnd() "{{{3 + if !exists('b:tlib_inbuffer_scratch') + echoerr 'tlib: In-buffer scratch not initalized' + endif + call tlib#buffer#DeleteRange(b:tlib_inbuffer_scratch, line('$')) + unlet b:tlib_inbuffer_scratch +endf + + +" Run exec on all buffers via bufdo and return to the original buffer. +function! tlib#buffer#BufDo(exec) "{{{3 + let bn = bufnr('%') + exec 'bufdo '. a:exec + exec 'buffer! '. bn +endf + + +" :def: function! tlib#buffer#InsertText(text, keyargs) +" Keyargs: +" 'shift': 0|N +" 'col': col('.')|N +" 'lineno': line('.')|N +" 'indent': 0|1 +" 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) +" Insert text (a string) in the buffer. +function! tlib#buffer#InsertText(text, ...) "{{{3 + TVarArg ['keyargs', {}] + " TLogVAR a:text, keyargs + let keyargs = extend({ + \ 'shift': 0, 'col': col('.'), 'lineno': line('.'), 'pos': 'e', 'indent': 0 + \ }, keyargs) + " TLogVAR keyargs + let grow = 0 + let post_del_last_line = line('$') == 1 + let line = getline(keyargs.lineno) + if keyargs.col + keyargs.shift > 0 + let pre = line[0 : (keyargs.col - 1 + keyargs.shift)] + let post = line[(keyargs.col + keyargs.shift): -1] + else + let pre = '' + let post = line + endif + " TLogVAR keyargs.lineno, line, pre, post + let text0 = pre . a:text . post + let text = split(text0, '\n', 1) + " TLogVAR text + let icol = len(pre) + " exec 'norm! '. keyargs.lineno .'G' + call cursor(keyargs.lineno, keyargs.col) + if keyargs.indent && keyargs.col > 1 + if &fo =~# '[or]' + " FIXME: Is the simple version sufficient? + " VERSION 1 + " " This doesn't work because it's not guaranteed that the + " " cursor is set. + " let cline = getline('.') + " norm! a + " "norm! o + " " TAssertExec redraw | sleep 3 + " let idt = strpart(getline('.'), 0, keyargs.col('.') + keyargs.shift) + " " TLogVAR idt + " let idtl = len(idt) + " -1,.delete + " " TAssertExec redraw | sleep 3 + " call append(keyargs.lineno - 1, cline) + " call cursor(keyargs.lineno, keyargs.col) + " " TAssertExec redraw | sleep 3 + " if idtl == 0 && icol != 0 + " let idt = matchstr(pre, '^\s\+') + " let idtl = len(idt) + " endif + " VERSION 2 + let idt = matchstr(pre, '^\s\+') + let idtl = len(idt) + else + let [m_0, idt, iline; rest] = matchlist(pre, '^\(\s*\)\(.*\)$') + let idtl = len(idt) + endif + if idtl < icol + let idt .= repeat(' ', icol - idtl) + endif + " TLogVAR idt + let idtl1 = len(idt) + for i in range(1, len(text) - 1) + let text[i] = idt . text[i] + let grow += idtl1 + endfor + endif + " TLogVAR text + " exec 'norm! '. keyargs.lineno .'Gdd' + call tlib#normal#WithRegister('"tdd', 't') + call append(keyargs.lineno - 1, text) + if post_del_last_line + call tlib#buffer#KeepCursorPosition('$delete') + endif + let tlen = len(text) + let posshift = matchstr(keyargs.pos, '\d\+') + " TLogVAR keyargs.pos + if keyargs.pos =~ '^e' + exec keyargs.lineno + tlen - 1 + exec 'norm! 0'. (len(text[-1]) - len(post) + posshift - 1) .'l' + elseif keyargs.pos =~ '^s' + " TLogVAR keyargs.lineno, pre, posshift + exec keyargs.lineno + exec 'norm! '. len(pre) .'|' + if !empty(posshift) + exec 'norm! '. posshift .'h' + endif + endif + " TLogDBG getline(keyargs.lineno) + " TLogDBG string(getline(1, '$')) + return grow +endf + + +function! tlib#buffer#InsertText0(text, ...) "{{{3 + TVarArg ['keyargs', {}] + let mode = get(keyargs, 'mode', 'i') + " TLogVAR mode + if !has_key(keyargs, 'shift') + let col = col('.') + " if mode =~ 'i' + " let col += 1 + " endif + let keyargs.shift = col >= col('$') ? 0 : -1 + " let keyargs.shift = col('.') >= col('$') ? 0 : -1 + " TLogVAR col + " TLogDBG col('.') .'-'. col('$') .': '. string(getline('.')) + endif + " TLogVAR keyargs.shift + return tlib#buffer#InsertText(a:text, keyargs) +endf + + +function! tlib#buffer#CurrentByte() "{{{3 + return line2byte(line('.')) + col('.') +endf + + +" Evaluate cmd while maintaining the cursor position and jump registers. +function! tlib#buffer#KeepCursorPosition(cmd) "{{{3 + " let pos = getpos('.') + let view = winsaveview() + try + keepjumps exec a:cmd + finally + " call setpos('.', pos) + call winrestview(view) + endtry +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/cache.vim b/sources_non_forked/tlib/autoload/tlib/cache.vim new file mode 100644 index 00000000..7d2266fd --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/cache.vim @@ -0,0 +1,356 @@ +" cache.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2015-10-24. +" @Revision: 31.1.243 + + +" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. +" You might want to delete old files from this directory from time to +" time with a command like: > +" find ~/vimfiles/cache/ -atime +31 -type f -print -delete +TLet g:tlib_cache = '' + +" |tlib#cache#Purge()|: Remove cache files older than N days. +TLet g:tlib#cache#purge_days = 31 + +" Purge the cache every N days. Disable automatic purging by setting +" this value to a negative value. +TLet g:tlib#cache#purge_every_days = 31 + +" The encoding used for the purge-cache script. +" Default: 'enc' +TLet g:tlib#cache#script_encoding = &enc + +" Whether to run the directory removal script: +" 0 ... No +" 1 ... Query user +" 2 ... Yes +TLet g:tlib#cache#run_script = 1 + +" Verbosity level: +" 0 ... Be quiet +" 1 ... Display informative message +" 2 ... Display detailed messages +TLet g:tlib#cache#verbosity = 1 + +" A list of regexps that are matched against partial filenames of the +" cached files. If a regexp matches, the file won't be removed by +" |tlib#cache#Purge()|. +TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$'] + +" If the cache filename is longer than N characters, use +" |pathshorten()|. +TLet g:tlib#cache#max_filename = 200 + +let s:cache = {} + + +" :display: tlib#cache#Dir(?mode = 'bg') +" The default cache directory. +function! tlib#cache#Dir(...) "{{{3 + TVarArg ['mode', 'bg'] + let dir = tlib#var#Get('tlib_cache', mode) + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache']) + endif + return dir +endf + + +" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') +function! tlib#cache#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let dir0 = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir() + let dir = dir0 + if a:0 >= 1 && !empty(a:1) + let file = a:1 + else + if empty(expand('%:t')) + return '' + endif + let file = expand('%:p') + let file = tlib#file#Relative(file, tlib#file#Join([dir, '..'])) + endif + " TLogVAR file, dir + let mkdir = a:0 >= 2 ? a:2 : 0 + let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g') + let dirs = [dir, a:type] + let dirf = fnamemodify(file, ':h') + if dirf != '.' + call add(dirs, dirf) + endif + let dir = tlib#file#Join(dirs) + " TLogVAR dir + let dir = tlib#dir#PlainName(dir) + " TLogVAR dir + let file = fnamemodify(file, ':t') + " TLogVAR file, dir, mkdir + let cache_file = tlib#file#Join([dir, file]) + if len(cache_file) > g:tlib#cache#max_filename + if v:version >= 704 + let shortfilename = pathshorten(file) .'_'. sha256(file) + else + let shortfilename = pathshorten(file) .'_'. tlib#hash#Adler32(file) + endif + let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0) + else + if mkdir && !isdirectory(dir) + try + call mkdir(dir, 'p') + catch /^Vim\%((\a\+)\)\=:E739:/ + if filereadable(dir) && !isdirectory(dir) + echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir + " call delete(dir) + " call mkdir(dir, 'p') + endif + endtry + endif + endif + " TLogVAR cache_file + return cache_file +endf + + +let s:timestamps = {} + + +function! s:SetTimestamp(cfile, type) "{{{3 + if !has_key(s:timestamps, a:cfile) + let s:timestamps[a:cfile] = {} + endif + let s:timestamps[a:cfile].atime = getftime(a:cfile) + let s:timestamps[a:cfile][a:type] = s:timestamps[a:cfile].atime +endf + + +function! tlib#cache#Save(cfile, dictionary, ...) "{{{3 + TVarArg ['options', {}] + let in_memory = get(options, 'in_memory', 0) + if in_memory + " TLogVAR in_memory, a:cfile, localtime() + let s:cache[a:cfile] = {'mtime': localtime(), 'data': a:dictionary} + elseif !empty(a:cfile) + " TLogVAR a:dictionary + call writefile([string(a:dictionary)], a:cfile, 'b') + call s:SetTimestamp(a:cfile, 'write') + endif +endf + + +function! tlib#cache#MTime(cfile) "{{{3 + let mtime = {'mtime': getftime(a:cfile)} + let mtime = extend(mtime, get(s:timestamps, a:cfile, {})) + return mtime +endf + + +function! tlib#cache#Get(cfile, ...) "{{{3 + TVarArg ['default', {}], ['options', {}] + let in_memory = get(options, 'in_memory', 0) + if in_memory + " TLogVAR in_memory, a:cfile + return get(get(s:cache, a:cfile, {}), 'data', default) + else + call tlib#cache#MaybePurge() + if !empty(a:cfile) && filereadable(a:cfile) + let val = readfile(a:cfile, 'b') + call s:SetTimestamp(a:cfile, 'read') + return eval(join(val, "\n")) + else + return default + endif + endif +endf + + +" :display: tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) +" Get a cached value from cfile. If it is outdated (compared to ftime) +" or does not exist, create it calling a generator function. +function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3 + TVarArg ['args', []], ['options', {}] + let in_memory = get(options, 'in_memory', 0) + let not_found = in_memory ? !has_key(s:cache, a:cfile) : !filereadable(a:cfile) + " TLogVAR in_memory, not_found + let cftime = in_memory ? (not_found ? 0 : s:cache[a:cfile].mtime) : getftime(a:cfile) + if not_found || (a:ftime != 0 && cftime < a:ftime) + " TLogVAR a:generator, args + let val = call(a:generator, args) + " TLogVAR val + let cval = {'val': val} + " TLogVAR cval + call tlib#cache#Save(a:cfile, cval, options) + return val + else + let val = tlib#cache#Get(a:cfile, {}, options) + if !has_key(val, 'val') + throw 'tlib#cache#Value: Internal error: '. a:cfile + else + return val.val + endif + endif +endf + + +" Call |tlib#cache#Purge()| if the last purge was done before +" |g:tlib#cache#purge_every_days|. +function! tlib#cache#MaybePurge() "{{{3 + if g:tlib#cache#purge_every_days < 0 + return + endif + let dir = tlib#cache#Dir('g') + let last_purge = tlib#file#Join([dir, '.last_purge']) + let last_purge_exists = filereadable(last_purge) + if last_purge_exists + let threshold = localtime() - g:tlib#cache#purge_every_days * g:tlib#date#dayshift + let should_purge = getftime(last_purge) < threshold + else + let should_purge = 0 " should ignore empty dirs, like the tmru one: !empty(glob(tlib#file#Join([dir, '**']))) + endif + if should_purge + if last_purge_exists + let yn = 'y' + else + let txt = "TLib: The cache directory '". dir ."' should be purged of old files.\nDelete files older than ". g:tlib#cache#purge_days ." days now?" + let yn = tlib#input#Dialog(txt, ['yes', 'no'], 'no') + endif + if yn =~ '^y\%[es]$' + call tlib#cache#Purge() + else + let g:tlib#cache#purge_every_days = -1 + if !last_purge_exists + call s:PurgeTimestamp(dir) + endif + echohl WarningMsg + echom "TLib: Please run :call tlib#cache#Purge() to clean up ". dir + echohl NONE + endif + elseif !last_purge_exists + call s:PurgeTimestamp(dir) + endif +endf + + +" Delete old files. +function! tlib#cache#Purge() "{{{3 + let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift + let dir = tlib#cache#Dir('g') + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir + echohl NONE + endif + let files = tlib#cache#ListFilesInCache() + let deldir = [] + let newer = [] + let msg = [] + let more = &more + set nomore + try + for file in files + if isdirectory(file) + if empty(filter(copy(newer), 'strpart(v:val, 0, len(file)) ==# file')) + call add(deldir, file) + endif + else + if getftime(file) < threshold + if delete(file) + call add(msg, "TLib: Could not delete cache file: ". file) + elseif g:tlib#cache#verbosity >= 2 + call add(msg, "TLib: Delete cache file: ". file) + endif + else + call add(newer, file) + endif + endif + endfor + finally + let &more = more + endtry + if !empty(msg) && g:tlib#cache#verbosity >= 1 + echo join(msg, "\n") + endif + if !empty(deldir) + if &shell =~ 'sh\(\.exe\)\?$' + let scriptfile = 'deldir.sh' + let rmdir = 'rm -rf %s' + else + let scriptfile = 'deldir.bat' + let rmdir = 'rmdir /S /Q %s' + endif + let enc = g:tlib#cache#script_encoding + if has('multi_byte') && enc != &enc + call map(deldir, 'iconv(v:val, &enc, enc)') + endif + let scriptfile = tlib#file#Join([dir, scriptfile]) + if filereadable(scriptfile) + let script = readfile(scriptfile) + else + let script = [] + endif + let script += map(copy(deldir), 'printf(rmdir, shellescape(v:val, 1))') + let script = tlib#list#Uniq(script) + call writefile(script, scriptfile) + call inputsave() + if g:tlib#cache#run_script == 0 + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + if g:tlib#cache#verbosity >= 2 + echom "TLib: Purged cache. Need to run script to delete directories" + endif + echom "TLib: Please review and execute: ". scriptfile + echohl NONE + endif + else + try + let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no') + if yn =~ '^y\%[es]$' + exec 'cd '. fnameescape(dir) + exec '! ' &shell shellescape(scriptfile, 1) + exec 'cd -' + call delete(scriptfile) + elseif yn =~ '^e\%[dit]$' + exec 'edit '. fnameescape(scriptfile) + endif + finally + call inputrestore() + endtry + endif + endif + call s:PurgeTimestamp(dir) +endf + + +function! s:PurgeTimestamp(dir) "{{{3 + let last_purge = tlib#file#Join([a:dir, '.last_purge']) + " TLogVAR last_purge + call writefile([" "], last_purge) +endf + +function! tlib#cache#ListFilesInCache(...) "{{{3 + let dir = a:0 >= 1 ? a:1 : tlib#cache#Dir('g') + if v:version > 702 || (v:version == 702 && has('patch51')) + let filess = glob(tlib#file#Join([dir, '**']), 1) + else + let filess = glob(tlib#file#Join([dir, '**'])) + endif + let files = reverse(split(filess, '\n')) + let pos0 = len(tlib#dir#CanonicName(dir)) + call filter(files, 's:ShouldPurge(strpart(v:val, pos0))') + return files +endf + + +function! s:ShouldPurge(partial_filename) "{{{3 + " TLogVAR a:partial_filename + for rx in g:tlib#cache#dont_purge + if a:partial_filename =~ rx + " TLogVAR a:partial_filename, rx + return 0 + endif + endfor + return 1 +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/char.vim b/sources_non_forked/tlib/autoload/tlib/char.vim new file mode 100644 index 00000000..d3d2cb6f --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/char.vim @@ -0,0 +1,59 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 38 + + +" :def: function! tlib#char#Get(?timeout=0) +" Get a character. +" +" EXAMPLES: > +" echo tlib#char#Get() +" echo tlib#char#Get(5) +function! tlib#char#Get(...) "{{{3 + TVarArg ['timeout', 0], ['resolution', 0], ['getmod', 0] + let char = -1 + let mode = 0 + if timeout == 0 || !has('reltime') + let char = getchar() + else + let char = tlib#char#GetWithTimeout(timeout, resolution) + endif + if getmod + if char != -1 + let mode = getcharmod() + endif + return [char, mode] + else + return char + endif +endf + + +function! tlib#char#IsAvailable() "{{{3 + let ch = getchar(1) + return type(ch) == 0 && ch != 0 +endf + + +function! tlib#char#GetWithTimeout(timeout, ...) "{{{3 + TVarArg ['resolution', 2] + " TLogVAR a:timeout, resolution + let start = tlib#time#MSecs() + while 1 + let c = getchar(0) + if type(c) != 0 || c != 0 + return c + else + let now = tlib#time#MSecs() + let diff = tlib#time#DiffMSecs(now, start, resolution) + " TLogVAR diff + if diff > a:timeout + return -1 + endif + endif + endwh + return -1 +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/cmd.vim b/sources_non_forked/tlib/autoload/tlib/cmd.vim new file mode 100644 index 00000000..f65a2372 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/cmd.vim @@ -0,0 +1,117 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 58 + + +let g:tlib#cmd#last_output = [] + + +function! tlib#cmd#OutputAsList(command) "{{{3 + " TLogVAR a:command + if exists('s:redir_lines') + redir END + let cache = s:redir_lines + endif + let s:redir_lines = '' + redir =>> s:redir_lines + silent! exec a:command + redir END + let g:tlib#cmd#last_output = split(s:redir_lines, '\n') + unlet s:redir_lines + if exists('cache') + let s:redir_lines = cache + redir =>> s:redir_lines + endif + return g:tlib#cmd#last_output +endf + + +" See |:TBrowseOutput|. +function! tlib#cmd#BrowseOutput(command) "{{{3 + call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#DefaultBrowseOutput", a:command) +endf + +" :def: function! tlib#cmd#BrowseOutputWithCallback(callback, command) +" Execute COMMAND and present its output in a |tlib#input#List()|; +" when a line is selected, execute the function named as the CALLBACK +" and pass in that line as an argument. +" +" The CALLBACK function gives you an opportunity to massage the COMMAND output +" and possibly act on it in a meaningful way. For example, if COMMAND listed +" all URIs found in the current buffer, CALLBACK could validate and then open +" the selected URI in the system's default browser. +" +" This function is meant to be a tool to help compose the implementations of +" powerful commands that use |tlib#input#List()| as a common interface. See +" |TBrowseScriptnames| as an example. +" +" EXAMPLES: > +" call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') +function! tlib#cmd#BrowseOutputWithCallback(callback, command) "{{{3 + let list = tlib#cmd#OutputAsList(a:command) + let cmds = tlib#input#List('m', 'Output of: '. a:command, list) + if !empty(cmds) + for cmd in cmds + let Callback = function(a:callback) + call call(Callback, [cmd]) + endfor + endif +endf + +function! tlib#cmd#DefaultBrowseOutput(cmd) "{{{3 + call feedkeys(':'. a:cmd) +endf + +function! tlib#cmd#ParseScriptname(line) "{{{3 + " let parsedValue = substitute(a:line, '^.\{-}\/', '/', '') + let parsedValue = matchstr(a:line, '^\s*\d\+:\s*\zs.*$') + exe 'drop '. fnameescape(parsedValue) +endf + + +function! tlib#cmd#TBrowseScriptnames() abort "{{{3 + call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#ParseScriptname", "scriptnames") +endf + + +" :def: function! tlib#cmd#UseVertical(?rx='') +" Look at the history whether the command was called with vertical. If +" an rx is provided check first if the last entry in the history matches +" this rx. +function! tlib#cmd#UseVertical(...) "{{{3 + TVarArg ['rx'] + let h0 = histget(':') + let rx0 = '\C\\s\+' + if !empty(rx) + let rx0 .= '.\{-}'.rx + endif + " TLogVAR h0, rx0 + return h0 =~ rx0 +endf + + +" Print the time in seconds or milliseconds (if your version of VIM +" has |+reltime|) a command takes. +function! tlib#cmd#Time(cmd) "{{{3 + if has('reltime') + let start = tlib#time#Now() + exec a:cmd + let end = tlib#time#Now() + let diff = string(tlib#time#Diff(end, start)) .'ms' + else + let start = localtime() + exec a:cmd + let diff = (localtime() - start) .'s' + endif + echom 'Time: '. diff .': '. a:cmd +endf + + +function! tlib#cmd#Capture(cmd) "{{{3 + redir => s + silent exec a:cmd + redir END + return s +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/comments.vim b/sources_non_forked/tlib/autoload/tlib/comments.vim new file mode 100644 index 00000000..879cde17 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/comments.vim @@ -0,0 +1,26 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 25 + + +" function! tlib#comments#Comments(?rx='') +function! tlib#comments#Comments(...) + TVarArg ['rx', ''] + let comments = {} + let co = &comments + while !empty(co) + " TLogVAR co + let [m_0, m_key, m_val, m_val1, co0, co; rest] = matchlist(co, '^\([^:]*\):\(\(\\.\|[^,]*\)\+\)\(,\(.*\)$\|$\)') + " TLogVAR m_key, m_val, co + if empty(m_key) + let m_key = ':' + endif + if empty(rx) || m_key =~ rx + let comments[m_key] = m_val + endif + endwh + return comments +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/date.vim b/sources_non_forked/tlib/autoload/tlib/date.vim new file mode 100644 index 00000000..7be5e9fb --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/date.vim @@ -0,0 +1,163 @@ +" date.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-03-25. +" @Last Change: 2015-11-23. +" @Revision: 21.0.34 + + +if !exists('g:tlib#date#ShortDatePrefix') | let g:tlib#date#ShortDatePrefix = '20' | endif "{{{2 +if !exists('g:tlib#date#TimeZoneShift') | let g:tlib#date#TimeZoneShift = 0 | endif "{{{2 + +let g:tlib#date#dayshift = 60 * 60 * 24 +" let g:tlib#date#date_rx = '\<\(\d\{4}\)-\(\d\d\)-\(\d\d\)\%(\s\+\(\(\d\d\):\(\d\d\)\)\)\?\>' +let g:tlib#date#date_rx = '\<\(\d\{4}\)-\(\d\d\)-\(\d\d\)\>' +let g:tlib#date#date_format = '%Y-%m-%d' + + +function! tlib#date#IsDate(text) abort "{{{3 + return a:text =~# '^'. g:tlib#date#date_rx .'$' +endf + + +function! tlib#date#Format(secs1970) abort "{{{3 + return strftime(g:tlib#date#date_format, a:secs1970) +endf + + +" :display: tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) +function! tlib#date#DiffInDays(date, ...) + let allow_zero = a:0 >= 2 ? a:2 : 0 + let s0 = tlib#date#SecondsSince1970(a:date, 0, allow_zero) + let s1 = a:0 >= 1 ? tlib#date#SecondsSince1970(a:1, 0, allow_zero) : localtime() + let dd = (s0 - s1) / g:tlib#date#dayshift + " TLogVAR dd + return dd +endf + + +" :display: tlib#date#Parse(date, ?allow_zero=0) "{{{3 +function! tlib#date#Parse(date, ...) "{{{3 + let min = a:0 >= 1 && a:1 ? 0 : 1 + " TLogVAR a:date, min + let m = matchlist(a:date, '^\(\d\{2}\|\d\{4}\)-\(\d\{1,2}\)-\(\d\{1,2}\)$') + if !empty(m) + let year = m[1] + let month = m[2] + let days = m[3] + else + let m = matchlist(a:date, '^\(\d\+\)/\(\d\{1,2}\)/\(\d\{1,2}\)$') + if !empty(m) + let year = m[1] + let month = m[3] + let days = m[2] + else + let m = matchlist(a:date, '^\(\d\{1,2}\)\.\s*\(\d\{1,2}\)\.\s*\(\d\d\{2}\|\d\{4}\)$') + if !empty(m) + let year = m[3] + let month = m[2] + let days = m[1] + endif + endif + endif + if empty(m) || year == '' || month == '' || days == '' || + \ month < min || month > 12 || days < min || days > 31 + echoerr 'TLib: Invalid date: '. a:date + return [] + endif + if strlen(year) == 2 + let year = g:tlib#date#ShortDatePrefix . year + endif + return [0 + year, 0 + month, 0 + days] +endf + + +" tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) +function! tlib#date#SecondsSince1970(date, ...) "{{{3 + let allow_zero = a:0 >= 2 ? a:2 : 0 + " TLogVAR a:date, allow_zero + let date = tlib#date#Parse(a:date, allow_zero) + if empty(date) + return 0 + endif + let [year, month, days] = date + if a:0 >= 1 && a:1 > 0 + let days = days + a:1 + end + let days_passed = days + let i = 1970 + while i < year + let days_passed = days_passed + 365 + if i % 4 == 0 || i == 2000 + let days_passed = days_passed + 1 + endif + let i = i + 1 + endwh + let i = 1 + while i < month + if i == 1 + let days_passed = days_passed + 31 + elseif i == 2 + let days_passed = days_passed + 28 + if year % 4 == 0 || year == 2000 + let days_passed = days_passed + 1 + endif + elseif i == 3 + let days_passed = days_passed + 31 + elseif i == 4 + let days_passed = days_passed + 30 + elseif i == 5 + let days_passed = days_passed + 31 + elseif i == 6 + let days_passed = days_passed + 30 + elseif i == 7 + let days_passed = days_passed + 31 + elseif i == 8 + let days_passed = days_passed + 31 + elseif i == 9 + let days_passed = days_passed + 30 + elseif i == 10 + let days_passed = days_passed + 31 + elseif i == 11 + let days_passed = days_passed + 30 + endif + let i = i + 1 + endwh + let seconds = (days_passed - 1) * 24 * 60 * 60 + let seconds = seconds + (strftime('%H') + g:tlib#date#TimeZoneShift) * 60 * 60 + let seconds = seconds + strftime('%M') * 60 + let seconds = seconds + strftime('%S') + return seconds +endf + + +function! tlib#date#Shift(date, shift) abort "{{{3 + let n = str2nr(matchstr(a:shift, '\d\+')) + let ml = matchlist(a:date, g:tlib#date#date_rx) + " TLogVAR a:date, a:shift, n, ml + if a:shift =~ 'd$' + let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * n + " TLogVAR secs + let date = tlib#date#Format(secs) + elseif a:shift =~ 'w$' + let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * n * 7 + let date = tlib#date#Format(secs) + elseif a:shift =~ 'm$' + let d = str2nr(ml[3]) + let ms = str2nr(ml[2]) + n + let m = (ms - 1) % 12 + 1 + let yr = str2nr(ml[1]) + ms / 12 + let date = printf('%04d-%02d-%02d', yr, m, d) + " TLogVAR d, ms, m, yr, date + elseif a:shift =~ 'y$' + let yr = str2nr(ml[1]) + n + let date = substitute(a:date, '^\d\{4}', yr, '') + endif + " if !empty(ml[4]) && date !~ '\s'. ml[4] .'$' + " let date .= ' '. ml[4] + " endif + " TLogVAR date + return date +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/dictionary.vim b/sources_non_forked/tlib/autoload/tlib/dictionary.vim new file mode 100644 index 00000000..77712b03 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/dictionary.vim @@ -0,0 +1,15 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-10-14 +" @Revision: 2 + + +function! tlib#dictionary#Rev(dict) abort "{{{3 + let rev = {} + for [m, f] in items(a:dict) + let rev[f] = m + endfor + return rev +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/dir.vim b/sources_non_forked/tlib/autoload/tlib/dir.vim new file mode 100644 index 00000000..f6f3e4e9 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/dir.vim @@ -0,0 +1,93 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 40 + +" TLet g:tlib#dir#sep = '/' +TLet g:tlib#dir#sep = exists('+shellslash') && !&shellslash ? '\' : '/' + + +let s:dir_stack = [] + +" EXAMPLES: > +" tlib#dir#CanonicName('foo/bar') +" => 'foo/bar/' +function! tlib#dir#CanonicName(dirname) "{{{3 + let dirname = tlib#file#Canonic(a:dirname) + if dirname !~ '[/\\]$' + return dirname . g:tlib#dir#sep + endif + return dirname +endf + + +" EXAMPLES: > +" tlib#dir#NativeName('foo/bar/') +" On Windows: +" => 'foo\bar\' +" On Linux: +" => 'foo/bar/' +function! tlib#dir#NativeName(dirname) "{{{3 + let sep = tlib#rx#EscapeReplace(g:tlib#dir#sep) + let dirname = substitute(a:dirname, '[\/]', sep, 'g') + return dirname +endf + + +" EXAMPLES: > +" tlib#dir#PlainName('foo/bar/') +" => 'foo/bar' +function! tlib#dir#PlainName(dirname) "{{{3 + let dirname = a:dirname + while index(['/', '\'], dirname[-1 : -1]) != -1 + let dirname = dirname[0 : -2] + endwh + return dirname + " return substitute(a:dirname, tlib#rx#Escape(g:tlib#dir#sep).'\+$', '', '') +endf + + +" Create a directory if it doesn't already exist. +function! tlib#dir#Ensure(dir) "{{{3 + if !isdirectory(a:dir) + let dir = tlib#dir#PlainName(a:dir) + return mkdir(dir, 'p') + endif + return 1 +endf + + +" Return the first directory in &rtp. +function! tlib#dir#MyRuntime() "{{{3 + return get(split(&rtp, ','), 0) +endf + + +" :def: function! tlib#dir#CD(dir, ?locally=0) => CWD +function! tlib#dir#CD(dir, ...) "{{{3 + TVarArg ['locally', 0] + let cmd = locally ? 'lcd! ' : 'cd! ' + " let cwd = getcwd() + let cmd .= tlib#arg#Ex(a:dir) + " TLogVAR a:dir, locally, cmd + exec cmd + " return cwd + return getcwd() +endf + + +" :def: function! tlib#dir#Push(dir, ?locally=0) => CWD +function! tlib#dir#Push(dir, ...) "{{{3 + TVarArg ['locally', 0] + call add(s:dir_stack, [getcwd(), locally]) + return tlib#dir#CD(a:dir, locally) +endf + + +" :def: function! tlib#dir#Pop() => CWD +function! tlib#dir#Pop() "{{{3 + let [dir, locally] = remove(s:dir_stack, -1) + return tlib#dir#CD(dir, locally) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/eval.vim b/sources_non_forked/tlib/autoload/tlib/eval.vim new file mode 100644 index 00000000..117209ed --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/eval.vim @@ -0,0 +1,72 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 56 + + +function! tlib#eval#FormatValue(value, ...) "{{{3 + TVarArg ['indent', 0] + " TLogVAR a:value, indent + let indent1 = indent + 1 + let indenti = repeat(' ', &sw) + let type = type(a:value) + let acc = [] + if type == 0 || type == 1 || type == 2 + " TLogDBG 'Use string() for type='. type + call add(acc, string(a:value)) + elseif type == 3 "List + " TLogDBG 'List' + call add(acc, '[') + for e in a:value + call add(acc, printf('%s%s,', indenti, tlib#eval#FormatValue(e, indent1))) + unlet e + endfor + call add(acc, ']') + elseif type == 4 "Dictionary + " TLogDBG 'Dictionary' + call add(acc, '{') + let indent1 = indent + 1 + for [k, v] in items(a:value) + call add(acc, printf("%s%s: %s,", indenti, string(k), tlib#eval#FormatValue(v, indent1))) + unlet k v + endfor + call add(acc, '}') + else + " TLogDBG 'Unknown type: '. string(a:value) + call add(acc, string(a:value)) + endif + if indent > 0 + let is = repeat(' ', indent * &sw) + for i in range(1,len(acc) - 1) + let acc[i] = is . acc[i] + endfor + endif + return join(acc, "\n") +endf + + +function! tlib#eval#Extend(a, b, ...) abort "{{{3 + let mode = a:0 >= 1 ? a:1 : 'force' + if type(a:a) != type(a:b) + throw 'tlib#eval#Extend: Incompatible types: a='. string(a:a) .' b='. string(a:b) + elseif type(a:a) == 3 " list + return extend(a:a, a:b, mode) + elseif type(a:a) == 4 " dict + for k in keys(a:b) + if has_key(a:a, k) + if mode == 'force' + let a:a[k] = tlib#eval#Extend(copy(a:a[k]), a:b[k], mode) + elseif mode == 'error' + throw 'tlib#eval#Extend: Key already exists: '. k + endif + else + let a:a[k] = a:b[k] + endif + unlet! k + endfor + return a:a + else + return a:b + endif +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/file.vim b/sources_non_forked/tlib/autoload/tlib/file.vim new file mode 100644 index 00000000..d0f89b96 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/file.vim @@ -0,0 +1,278 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 168 + + +if !exists('g:tlib#file#drop') + " If true, use |:drop| to edit loaded buffers (only available with GUI). + let g:tlib#file#drop = has('gui') "{{{2 +endif + + +if !exists('g:tlib#file#use_tabs') + let g:tlib#file#use_tabs = 0 "{{{2 +endif + + +if !exists('g:tlib#file#edit_cmds') + let g:tlib#file#edit_cmds = g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {} "{{{2 +endif + + +if !exists('g:tlib#file#absolute_filename_rx') + let g:tlib#file#absolute_filename_rx = '^\~\?[\/]' "{{{2 +endif + +""" File related {{{1 +" For the following functions please see ../../test/tlib.vim for examples. + + +" EXAMPLES: > +" tlib#file#Split('foo/bar/filename.txt') +" => ['foo', 'bar', 'filename.txt'] +function! tlib#file#Split(filename) "{{{3 + let prefix = matchstr(a:filename, '^\(\w\+:\)\?/\+') + " TLogVAR prefix + if !empty(prefix) + let filename = a:filename[len(prefix) : -1] + else + let filename = a:filename + endif + let rv = split(filename, '[\/]') + " let rv = split(filename, '[\/]', 1) + if !empty(prefix) + call insert(rv, prefix[0:-2]) + endif + return rv +endf + + +" :display: tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) +" EXAMPLES: > +" tlib#file#Join(['foo', 'bar', 'filename.txt']) +" => 'foo/bar/filename.txt' +function! tlib#file#Join(filename_parts, ...) "{{{3 + TVarArg ['strip_slashes', 1], 'maybe_absolute' + " TLogVAR a:filename_parts, strip_slashes + if maybe_absolute + let filename_parts = [] + for part in a:filename_parts + if part =~ g:tlib#file#absolute_filename_rx + let filename_parts = [] + endif + call add(filename_parts, part) + endfor + else + let filename_parts = a:filename_parts + endif + if strip_slashes + " let rx = tlib#rx#Escape(g:tlib#dir#sep) .'$' + let rx = '[/\\]\+$' + let parts = map(copy(filename_parts), 'substitute(v:val, rx, "", "")') + " TLogVAR parts + return join(parts, g:tlib#dir#sep) + else + return join(filename_parts, g:tlib#dir#sep) + endif +endf + + +" EXAMPLES: > +" tlib#file#Relative('foo/bar/filename.txt', 'foo') +" => 'bar/filename.txt' +function! tlib#file#Relative(filename, basedir) "{{{3 + " TLogVAR a:filename, a:basedir + " TLogDBG getcwd() + " TLogDBG expand('%:p') + let b0 = tlib#file#Absolute(a:basedir) + let b = tlib#file#Split(b0) + " TLogVAR b + let f0 = tlib#file#Absolute(a:filename) + let fn = fnamemodify(f0, ':t') + let fd = fnamemodify(f0, ':h') + let f = tlib#file#Split(fd) + " TLogVAR f0, fn, fd, f + if f[0] != b[0] + let rv = f0 + else + while !empty(f) && !empty(b) + if f[0] != b[0] + break + endif + call remove(f, 0) + call remove(b, 0) + endwh + " TLogVAR f, b + let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn]) + endif + " TLogVAR rv + return rv +endf + + +function! tlib#file#Absolute(filename, ...) "{{{3 + if filereadable(a:filename) + let filename = fnamemodify(a:filename, ':p') + elseif a:filename =~ '^\(/\|[^\/]\+:\)' + let filename = a:filename + else + let cwd = a:0 >= 1 ? a:1 : getcwd() + let filename = tlib#file#Join([cwd, a:filename]) + endif + let filename = substitute(filename, '\(^\|[\/]\)\zs\.[\/]', '', 'g') + let filename = substitute(filename, '[\/]\zs[^\/]\+[\/]\.\.[\/]', '', 'g') + return filename +endf + + +function! tlib#file#Canonic(filename, ...) "{{{3 + TVarArg ['mode', ''] + if a:filename =~ '^\\\\' + let mode = 'windows' + elseif a:filename =~ '^\(file\|ftp\|http\)s\?:' + let mode = 'url' + elseif (empty(mode) && g:tlib#sys#windows) + let mode = 'windows' + endif + let filename = a:filename + if mode == 'windows' + let filename = substitute(filename, '/', '\\', 'g') + else + let filename = substitute(filename, '\\', '/', 'g') + endif + return filename +endf + + +function! s:SetScrollBind(world) "{{{3 + let sb = get(a:world, 'scrollbind', &scrollbind) + if sb != &scrollbind + let &scrollbind = sb + endif +endf + + +" :def: function! tlib#file#With(fcmd, bcmd, files, ?world={}) +function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3 + " TLogVAR a:fcmd, a:bcmd, a:files + exec tlib#arg#Let([['world', {}]]) + call tlib#autocmdgroup#Init() + augroup TLibFileRead + autocmd! + augroup END + for f in a:files + let bn = bufnr('^'.f.'$') + " TLogVAR f, bn + let bufloaded = bufloaded(bn) + let ok = 0 + let s:bufread = "" + if bn != -1 && buflisted(bn) + if !empty(a:bcmd) + " TLogDBG a:bcmd .' '. bn + exec a:bcmd .' '. bn + let ok = 1 + call s:SetScrollBind(world) + endif + else + if filereadable(f) + if !empty(a:fcmd) + " TLogDBG a:fcmd .' '. tlib#arg#Ex(f) + exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand(":p")' + try + exec a:fcmd .' '. tlib#arg#Ex(f) + finally + exec 'autocmd! TLibFileRead BufRead' + endtry + let ok = 1 + call s:SetScrollBind(world) + endif + else + echohl error + echom 'File not readable: '. f + echohl NONE + endif + endif + " TLogVAR ok, bufloaded, &filetype + if empty(s:bufread) && ok && !bufloaded && empty(&filetype) + doautocmd BufRead + endif + endfor + augroup! TLibFileRead + unlet! s:bufread + " TLogDBG "done" +endf + + +" Return 0 if the file isn't readable/doesn't exist. +" Otherwise return 1. +function! tlib#file#Edit(fileid) "{{{3 + if type(a:fileid) == 0 + let bn = a:fileid + let filename = fnamemodify(bufname(bn), ':p') + else + let filename = fnamemodify(a:fileid, ':p') + let bn = bufnr(filename) + endif + if filename == expand('%:p') + return 1 + else + " TLogVAR a:fileid, bn, filename, g:tlib#file#drop, filereadable(filename) + if bn != -1 && buflisted(bn) + if g:tlib#file#drop + " echom "DBG" get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + exec get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + else + " echom "DBG" get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + exec get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + endif + return 1 + elseif filereadable(filename) + try + " let file = tlib#arg#Ex(filename) + " " TLogVAR file + " echom "DBG" get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) + exec get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) + catch /E325/ + " swap file exists, let the user handle it + catch + echohl error + echom v:exception + echohl NONE + endtry + return 1 + else + echom "TLIB: File not readable: " . filename + if filename != a:fileid + echom "TLIB: original filename: " . a:fileid + endif + endif + endif + return 0 +endf + + +if v:version > 704 || (v:version == 704 && has('patch279')) + + function! tlib#file#Glob(pattern) abort "{{{3 + return glob(a:pattern, 0, 1) + endf + + function! tlib#file#Globpath(path, pattern) abort "{{{3 + return globpath(a:path, a:pattern, 0, 1) + endf + +else + + " :nodoc: + function! tlib#file#Glob(pattern) abort "{{{3 + return split(glob(a:pattern), '\n') + endf + + " :nodoc: + function! tlib#file#Globpath(path, pattern) abort "{{{3 + return split(globpath(a:path, a:pattern), '\n') + endf + +endif + diff --git a/sources_non_forked/tlib/autoload/tlib/fixes.vim b/sources_non_forked/tlib/autoload/tlib/fixes.vim new file mode 100644 index 00000000..e9247dd6 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/fixes.vim @@ -0,0 +1,14 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2013-02-22. +" @Revision: 3 + + +function! tlib#fixes#Winpos() "{{{3 + if has('gui_win32') + return 'winpos '. getwinposx() .' '. getwinposy() + else + return '' + endif +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/grep.vim b/sources_non_forked/tlib/autoload/tlib/grep.vim new file mode 100644 index 00000000..894b1ee7 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/grep.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2013-10-16. +" @Revision: 31 + + +function! tlib#grep#Do(cmd, rx, files) "{{{3 + " TLogVAR a:cmd, a:rx, a:files + let files = join(map(copy(a:files), 'tlib#arg#Ex(v:val, "")'), ' ') + let rx = '/'. escape(a:rx, '/') .'/j' + " TLogVAR rx, files + silent exec a:cmd rx files +endf + + +function! tlib#grep#LocList(rx, files) "{{{3 + return tlib#grep#Do('noautocmd lvimgrep', a:rx, a:files) +endf + + +function! tlib#grep#QuickFixList(rx, files) "{{{3 + return tlib#grep#Do('noautocmd vimgrep', a:rx, a:files) +endf + + +function! tlib#grep#List(rx, files) "{{{3 + call setqflist([]) + call tlib#grep#Do('noautocmd vimgrepadd', a:rx, a:files) + let qfl = getqflist() + " TLogVAR qfl + " try + silent! colder + " catch + " call setqflist([], 'r') + " endtry + return qfl +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/hash.vim b/sources_non_forked/tlib/autoload/tlib/hash.vim new file mode 100644 index 00000000..29c9ef67 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/hash.vim @@ -0,0 +1,145 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 276 + + +if !exists('g:tlib#hash#use_crc32') + let g:tlib#hash#use_crc32 = '' "{{{2 +endif + + +if !exists('g:tlib#hash#use_adler32') + let g:tlib#hash#use_adler32 = '' "{{{2 +endif + + +function! tlib#hash#CRC32B(chars) "{{{3 + if !empty(g:tlib#hash#use_crc32) + let use = g:tlib#hash#use_crc32 + elseif has('ruby') + let use = 'ruby' + else + let use = 'vim' + endif + if exists('*tlib#hash#CRC32B_'. use) + return tlib#hash#CRC32B_{use}(a:chars) + else + throw "Unknown version of tlib#hash#CRC32B: ". use + endif +endf + + +function! tlib#hash#CRC32B_ruby(chars) "{{{3 + if has('ruby') + let rv = '' + if !exists('s:loaded_ruby_zlib') + ruby require 'zlib' + let s:loaded_ruby_zlib = 1 + endif + ruby VIM::command('let rv = "%08X"' % Zlib.crc32(VIM::evaluate("a:chars"))) + return rv + else + throw "tlib#hash#CRC32B_ruby not supported in this version of vim" + endif +endf + + +function! tlib#hash#CRC32B_vim(chars) "{{{3 + if !exists('s:crc_table') + let cfile = tlib#persistent#Filename('tlib', 'crc_table', 1) + let s:crc_table = tlib#persistent#Value(cfile, 'tlib#hash#CreateCrcTable', 0) + endif + let xFFFF_FFFF = repeat([1], 32) + let crc = tlib#bitwise#XOR([0], xFFFF_FFFF, 'bits') + for char in split(a:chars, '\zs') + let octet = char2nr(char) + let r1 = tlib#bitwise#ShiftRight(crc, 8) + let i0 = tlib#bitwise#AND(crc, xFFFF_FFFF, 'bits') + let i1 = tlib#bitwise#XOR(i0, octet, 'bits') + let i2 = tlib#bitwise#Bits2Num(tlib#bitwise#AND(i1, 0xff, 'bits')) + let r2 = s:crc_table[i2] + let crc = tlib#bitwise#XOR(r1, r2, 'bits') + endfor + let crc = tlib#bitwise#XOR(crc, xFFFF_FFFF, 'bits') + let rv = tlib#bitwise#Bits2Num(crc, 16) + if len(rv) < 8 + let rv = repeat('0', 8 - len(rv)) . rv + endif + return rv +endf + + +" :nodoc: +function! tlib#hash#CreateCrcTable() "{{{3 + let sum = 0.0 + for exponent in [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32] + let exp = tlib#bitwise#Bits2Num(repeat([0], 32 - exponent) + [1], 10.0) + let sum += exp + endfor + let divisor = tlib#bitwise#Num2Bits(sum) + let crc_table = [] + for octet in range(256) + let remainder = tlib#bitwise#Num2Bits(octet) + for i in range(8) + if get(remainder, i) != 0 + let remainder = tlib#bitwise#XOR(remainder, tlib#bitwise#ShiftLeft(divisor, i), "bits") + endif + endfor + let remainder = tlib#bitwise#ShiftRight(remainder, 8) + call add(crc_table, remainder) + endfor + return crc_table +endf + + +function! tlib#hash#Adler32(chars) "{{{3 + if !empty(g:tlib#hash#use_adler32) + let use = g:tlib#hash#use_adler32 + elseif exists('*or') + let use = 'vim' + else + let use = 'tlib' + endif + if exists('*tlib#hash#Adler32_'. use) + return tlib#hash#Adler32_{use}(a:chars) + else + throw "Unknown version of tlib#hash#Adler32_: ". use + endif +endf + + +function! tlib#hash#Adler32_vim(chars) "{{{3 + if exists('*or') + let mod_adler = 65521 + let a = 1 + let b = 0 + for index in range(len(a:chars)) + let c = char2nr(a:chars[index]) + let a = (a + c) % mod_adler + let b = (b + a) % mod_adler + endfor + let bb = b * float2nr(pow(2, 16)) + let checksum = or(bb, a) + " TLogVAR checksum, a, b, bb + return printf("%08X", checksum) + else + throw "TLIB: Vim version doesn't support bitwise or()" + endif +endf + + +function! tlib#hash#Adler32_tlib(chars) "{{{3 + let mod_adler = 65521 + let a = 1 + let b = 0 + for index in range(len(a:chars)) + let c = char2nr(a:chars[index]) + let a = (a + c) % mod_adler + let b = (b + a) % mod_adler + endfor + let bb = tlib#bitwise#ShiftLeft(tlib#bitwise#Num2Bits(b), 16) + let checksum = tlib#bitwise#OR(bb, a, "bits") + return printf('%08s', tlib#bitwise#Bits2Num(checksum, 16)) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/hook.vim b/sources_non_forked/tlib/autoload/tlib/hook.vim new file mode 100644 index 00000000..07d05041 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/hook.vim @@ -0,0 +1,25 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 11 + + +" :def: function! tlib#hook#Run(hook, ?dict={}) +" Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. +function! tlib#hook#Run(hook, ...) "{{{3 + TVarArg ['dict', {}] + if has_key(dict, a:hook) + let hook = dict[a:hook] + else + let hook = tlib#var#Get(a:hook, 'wbg') + endif + if empty(hook) + return 0 + else + let world = dict + exec hook + return 1 + endif +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/input.vim b/sources_non_forked/tlib/autoload/tlib/input.vim new file mode 100644 index 00000000..e8f892b0 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/input.vim @@ -0,0 +1,1336 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 1366 + + +" :filedoc: +" Input-related, select from a list etc. + +" If a list is bigger than this value, don't try to be smart when +" selecting an item. Be slightly faster instead. +" See |tlib#input#List()|. +TLet g:tlib#input#sortprefs_threshold = 200 + + +" If a list contains more items, |tlib#input#List()| does not perform an +" incremental "live search" but uses |input()| to query the user for a +" filter. This is useful on slower machines or with very long lists. +TLet g:tlib#input#livesearch_threshold = 1000 + + +" Determine how |tlib#input#List()| and related functions work. +" Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: +" glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, +" |g:tlib#Filter_glob#char|) are interpreted as glob-like +" |wildcards| (this is the default method) +" - Examples: +" - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" "far". +" - Otherwise it is a derivate of the cnf method (see below). +" - See also |tlib#Filter_glob#New()|. +" cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is +" expanded to "\.\{-}" +" - A period character (".") acts as a wildcard as if ".\{-}" (see +" |/\{-|) were entered. +" - Examples: +" - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" "far". +" - Otherwise it is a derivate of the cnf method (see below). +" - See also |tlib#Filter_cnfd#New()|. +" cnf .... Match substrings +" - A blank creates an AND conjunction, i.e. the next pattern has to +" match too. +" - A pipe character ("|") creates an OR conjunction, either this or +" the next next pattern has to match. +" - Patterns are very 'nomagic' |regexp| with a |\V| prefix. +" - A pattern starting with "-" makes the filter exclude items +" matching that pattern. +" - Examples: +" - "foo bar" matches items that contain the strings "foo" AND +" "bar". +" - "foo|bar boo|far" matches items that contain either ("foo" OR +" "bar") AND ("boo" OR "far"). +" - See also |tlib#Filter_cnf#New()|. +" seq .... Match sequences of characters +" - |tlib#Filter_seq#New()| +" fuzzy .. Match fuzzy character sequences +" - |tlib#Filter_fuzzy#New()| +TLet g:tlib#input#filter_mode = 'glob' + + +" The highlight group to use for showing matches in the input list +" window. +" See |tlib#input#List()|. +TLet g:tlib#input#higroup = 'IncSearch' + +" When 1, automatically select the last remaining item only if the list +" had only one item to begin with. +" When 2, automatically select a last remaining item after applying +" any filters. +" See |tlib#input#List()|. +TLet g:tlib_pick_last_item = 1 + + +" :doc: +" Keys for |tlib#input#List|~ + +TLet g:tlib#input#and = ' ' +TLet g:tlib#input#or = '|' +TLet g:tlib#input#not = '-' + +" When editing a list with |tlib#input#List|, typing these numeric chars +" (as returned by getchar()) will select an item based on its index, not +" based on its name. I.e. in the default setting, typing a "4" will +" select the fourth item, not the item called "4". +" In order to make keys 0-9 filter the items in the list and make +" select an item by its index, remove the keys 48 to 57 from +" this dictionary. +" Format: [KEY] = BASE ... the number is calculated as KEY - BASE. +" :nodefault: +TLet g:tlib#input#numeric_chars = { + \ 176: 176, + \ 177: 176, + \ 178: 176, + \ 179: 176, + \ 180: 176, + \ 181: 176, + \ 182: 176, + \ 183: 176, + \ 184: 176, + \ 185: 176, + \} + " \ 48: 48, + " \ 49: 48, + " \ 50: 48, + " \ 51: 48, + " \ 52: 48, + " \ 53: 48, + " \ 54: 48, + " \ 55: 48, + " \ 56: 48, + " \ 57: 48, + + +" :nodefault: +" The default key bindings for single-item-select list views. +" +" This variable is best customized via the variable +" g:tlib_extend_keyagents_InputList_s. If you want to use , +" to move the cursor up and down, add these two lines to your |vimrc| +" file: +" +" let g:tlib_extend_keyagents_InputList_s = { +" \ 10: 'tlib#agent#Down', +" \ 11: 'tlib#agent#Up' +" \ } +TLet g:tlib#input#keyagents_InputList_s = { + \ "\": 'tlib#agent#PageUp', + \ "\": 'tlib#agent#PageDown', + \ "\": 'tlib#agent#Home', + \ "\": 'tlib#agent#End', + \ "\": 'tlib#agent#Up', + \ "\": 'tlib#agent#Down', + \ 9: 'tlib#agent#Complete', + \ "\": 'tlib#agent#UpN', + \ "\": 'tlib#agent#DownN', + \ "\": 'tlib#agent#ShiftLeft', + \ "\": 'tlib#agent#ShiftRight', + \ 18: 'tlib#agent#Reset', + \ 242: 'tlib#agent#Reset', + \ 17: 'tlib#agent#Input', + \ 241: 'tlib#agent#Input', + \ 27: 'tlib#agent#Exit', + \ 26: 'tlib#agent#Suspend', + \ 250: 'tlib#agent#Suspend', + \ 15: 'tlib#agent#SuspendToParentWindow', + \ "\": 'tlib#agent#Help', + \ "\": 'tlib#agent#ExecAgentByName', + \ "\": 'tlib#agent#ExecAgentByName', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#Wildcard', + \ 191: 'tlib#agent#Debug', + \ char2nr(g:tlib#input#or): 'tlib#agent#OR', + \ char2nr(g:tlib#input#and): 'tlib#agent#AND', + \ } + " \ 63: 'tlib#agent#Help', + +if exists('g:tlib_extend_keyagents_InputList_s') + let g:tlib#input#keyagents_InputList_s = extend(g:tlib#input#keyagents_InputList_s, g:tlib_extend_keyagents_InputList_s) +endif + + +" :nodefault: +TLet g:tlib#input#keyagents_InputList_m = { + \ 35: 'tlib#agent#Select', + \ "\": 'tlib#agent#SelectUp', + \ "\": 'tlib#agent#SelectDown', + \ 1: 'tlib#agent#SelectAll', + \ 225: 'tlib#agent#SelectAll', + \ "\": 'tlib#agent#ToggleRestrictView', + \ } +" "\": 'tlib#agent#Select' + +if exists('g:tlib_extend_keyagents_InputList_m') + let g:tlib#input#keyagents_InputList_m = extend(g:tlib#input#keyagents_InputList_m, g:tlib_extend_keyagents_InputList_m) +endif + + + +" :nodefault: +TLet g:tlib#input#handlers_EditList = [ + \ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '', 'help': 'Edit item'}, + \ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '', 'help': 'Delete item(s)'}, + \ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '', 'help': 'New item'}, + \ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '', 'help': 'Cut item(s)'}, + \ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '', 'help': 'Copy item(s)'}, + \ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '', 'help': 'Paste item(s)'}, + \ {'pick_last_item': 0}, + \ {'return_agent': 'tlib#agent#EditReturnValue'}, + \ {'help_extra': [ + \ 'Submit changes by pressing ENTER or or ', + \ 'Cancel editing by pressing c' + \ ]}, + \ ] + + +" A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to +" customize keyboard shortcuts in the list view. +TLet g:tlib#input#user_shortcuts = {} + + +" If true, define a popup menu for |tlib#input#List()| and related +" functions. +TLet g:tlib#input#use_popup = has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32')) + + +" How to format filenames: +" l ... Show basenames on the left side, separated from the +" directory names +" r ... Show basenames on the right side +TLet g:tlib#input#format_filename = 'l' + + +" If g:tlib#input#format_filename == 'r', how much space should be kept +" free on the right side. +TLet g:tlib#input#filename_padding_r = '&co / 10' + + +" If g:tlib#input#format_filename == 'l', an expression that +" |eval()|uates to the maximum display width of filenames. +TLet g:tlib#input#filename_max_width = '&co / 2' + + +" Functions related to tlib#input#List(type, ...) "{{{2 + +" :def: function! tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) +" Select a single or multiple items from a list. Return either the list +" of selected elements or its indexes. +" +" By default, typing numbers will select an item by its index. See +" |g:tlib#input#numeric_chars| to find out how to change this. +" +" The item is automatically selected if the numbers typed equals the +" number of digits of the list length. I.e. if a list contains 20 items, +" typing 1 will first highlight item 1 but it won't select/use it +" because 1 is an ambiguous input in this context. If you press enter, +" the first item will be selected. If you press another digit (e.g. 0), +" item 10 will be selected. Another way to select item 1 would be to +" type 01. If the list contains only 9 items, typing 1 would select the +" first item right away. +" +" type can be: +" s ... Return one selected element +" si ... Return the index of the selected element +" m ... Return a list of selected elements +" mi ... Return a list of indexes +" +" Several pattern matching styles are supported. See +" |g:tlib#input#filter_mode|. +" +" Users can type to complete the current filter with the longest +" match. +" +" EXAMPLES: > +" echo tlib#input#List('s', 'Select one item', [100,200,300]) +" echo tlib#input#List('si', 'Select one item', [100,200,300]) +" echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) +" echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) +" +" See ../samples/tlib/input/tlib_input_list.vim (move the cursor over +" the filename and press gf) for a more elaborated example. +function! tlib#input#List(type, ...) "{{{3 + exec tlib#arg#Let([ + \ ['query', ''], + \ ['list', []], + \ ['handlers', []], + \ ['rv', ''], + \ ['timeout', 0], + \ ]) + " let handlers = a:0 >= 1 ? a:1 : [] + " let rv = a:0 >= 2 ? a:2 : '' + " let timeout = a:0 >= 3 ? a:3 : 0 + " let backchar = ["\", "\"] + + if a:type =~ '^resume' + let world = b:tlib_{matchstr(a:type, ' \zs.\+')} + else + let world = tlib#World#New({ + \ 'type': a:type, + \ 'base': list, + \ 'query': query, + \ 'timeout': timeout, + \ 'rv': rv, + \ 'handlers': handlers, + \ }) + let scratch_name = tlib#list#Find(handlers, 'has_key(v:val, "scratch_name")', '', 'v:val.scratch_name') + if !empty(scratch_name) + let world.scratch = scratch_name + endif + let world.scratch_vertical = tlib#list#Find(handlers, 'has_key(v:val, "scratch_vertical")', 0, 'v:val.scratch_vertical') + call world.Set_display_format(tlib#list#Find(handlers, 'has_key(v:val, "display_format")', '', 'v:val.display_format')) + let world.initial_index = tlib#list#Find(handlers, 'has_key(v:val, "initial_index")', 1, 'v:val.initial_index') + let world.index_table = tlib#list#Find(handlers, 'has_key(v:val, "index_table")', [], 'v:val.index_table') + let world.state_handlers = filter(copy(handlers), 'has_key(v:val, "state")') + let world.post_handlers = filter(copy(handlers), 'has_key(v:val, "postprocess")') + let world.filter_format = tlib#list#Find(handlers, 'has_key(v:val, "filter_format")', '', 'v:val.filter_format') + let world.return_agent = tlib#list#Find(handlers, 'has_key(v:val, "return_agent")', '', 'v:val.return_agent') + let world.help_extra = tlib#list#Find(handlers, 'has_key(v:val, "help_extra")', '', 'v:val.help_extra') + let world.resize = tlib#list#Find(handlers, 'has_key(v:val, "resize")', '', 'v:val.resize') + let world.show_empty = tlib#list#Find(handlers, 'has_key(v:val, "show_empty")', 0, 'v:val.show_empty') + let world.pick_last_item = tlib#list#Find(handlers, 'has_key(v:val, "pick_last_item")', + \ tlib#var#Get('tlib_pick_last_item', 'bg'), 'v:val.pick_last_item') + let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")', + \ g:tlib#input#numeric_chars, 'v:val.numeric_chars') + let world.key_handlers = filter(copy(handlers), 'has_key(v:val, "key")') + let filter = tlib#list#Find(handlers, 'has_key(v:val, "filter")', '', 'v:val.filter') + if !empty(filter) + " let world.initial_filter = [[''], [filter]] + " let world.initial_filter = [[filter]] + " TLogVAR world.initial_filter + call world.SetInitialFilter(filter) + endif + endif + return tlib#input#ListW(world) +endf + + +" A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from +" dict. +function! tlib#input#ListD(dict) "{{{3 + return tlib#input#ListW(tlib#World#New(a:dict)) +endf + + +" :def: function! tlib#input#ListW(world, ?command='') +" The second argument (command) is meant for internal use only. +" The same as |tlib#input#List| but the arguments are packed into world +" (an instance of tlib#World as returned by |tlib#World#New|). +function! tlib#input#ListW(world, ...) "{{{3 + TVarArg 'cmd' + " let time0 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time0 + let world = a:world + if world.pick_last_item >= 1 && stridx(world.type, 'e') == -1 && len(world.base) <= 1 + let rv = get(world.base, 0, world.rv) + if stridx(world.type, 'm') != -1 + return [rv] + else + return rv + endif + endif + call s:Init(world, cmd) + " TLogVAR world.state, world.sticky, world.initial_index + " let statusline = &l:statusline + " let laststatus = &laststatus + let showmode = &showmode + set noshowmode + let lastsearch = @/ + let scrolloff = &l:scrolloff + let &l:scrolloff = 0 + let @/ = '' + let dlist = [] + let post_keys = '' + " let &laststatus = 2 + + try + while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base)) + let post_keys = '' + " TLogDBG 'while' + " TLogVAR world.state + " let time01 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time01, time01 - time0 + try + let world = s:RunStateHandlers(world) + + " if exists('b:tlib_world_event') + " let event = b:tlib_world_event + " unlet! b:tlib_world_event + " if event == 'WinLeave' + " " let world.resume_state = world.state + " let world = tlib#agent#Suspend(world, world.rv) + " break + " endif + " endif + + " let time02 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time02, time02 - time0 + if world.state =~ '\' + " TLogDBG 'reset' + " call world.Reset(world.state =~ '\') + call world.Reset() + continue + endif + + call s:SetOffset(world) + + " let time02 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time02, time02 - time0 + " TLogDBG 1 + " TLogVAR world.state + if world.state == 'scroll' + let world.prefidx = world.offset + let world.state = 'redisplay' + endif + + if world.state =~ '\' + let world.sticky = 1 + endif + + " TLogVAR world.filter + " TLogVAR world.sticky + if world.state =~ '\' + " TLogVAR world.rv + throw 'picked' + elseif world.state =~ '\' + let world.rv = world.CurrentItem() + " TLogVAR world.rv + throw 'picked' + elseif world.state =~ 'display' + if world.state =~ '^display' + " let time03 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time03, time03 - time0 + if world.IsValidFilter() + + " let time1 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time1, time1 - time0 + call world.BuildTableList() + " let time2 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time2, time2 - time0 + " TLogDBG 2 + " TLogDBG len(world.table) + " TLogVAR world.table + " let world.list = map(copy(world.table), 'world.GetBaseItem(v:val)') + " TLogDBG 3 + let world.llen = len(world.list) + " TLogVAR world.index_table + if empty(world.index_table) + let dindex = range(1, world.llen) + let world.index_width = len(world.llen) + else + let dindex = world.index_table + let world.index_width = len(max(dindex)) + endif + " let time3 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time3, time3 - time0 + if world.llen == 0 && !world.show_empty + call world.ReduceFilter() + let world.offset = 1 + " TLogDBG 'ReduceFilter' + continue + else + if world.llen == 1 + let world.last_item = world.list[0] + if world.pick_last_item >= 2 + " echom 'Pick last item: '. world.list[0] + let world.prefidx = '1' + " TLogDBG 'pick last item' + throw 'pick' + endif + else + let world.last_item = '' + endif + endif + " let time4 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time4, time4 - time0 + " TLogDBG 4 + " TLogVAR world.idx, world.llen, world.state + " TLogDBG world.FilterIsEmpty() + if world.state == 'display' + if world.idx == '' && world.llen < g:tlib#input#sortprefs_threshold && !world.FilterIsEmpty() + call world.SetPrefIdx() + else + let world.prefidx = world.idx == '' ? world.initial_index : world.idx + endif + if world.prefidx > world.llen + let world.prefidx = world.llen + elseif world.prefidx < 1 + let world.prefidx = 1 + endif + endif + " let time5 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time5, time5 - time0 + " TLogVAR world.initial_index, world.prefidx + " TLogDBG 5 + " TLogDBG len(world.list) + " TLogVAR world.list + let dlist = world.DisplayFormat(world.list) + " TLogVAR world.prefidx + " TLogDBG 6 + " let time6 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time6, time6 - time0 + if world.offset_horizontal > 0 + call map(dlist, 'v:val[world.offset_horizontal:-1]') + endif + " let time7 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time7, time7 - time0 + " TLogVAR dindex + let dlist = map(range(0, world.llen - 1), 'printf("%0'. world.index_width .'d", dindex[v:val]) .": ". dlist[v:val]') + " TLogVAR dlist + " let time8 = str2float(reltimestr(reltime())) " DBG + " TLogVAR time8, time8 - time0 + + else + + let dlist = ['Malformed filter'] + + endif + else + if world.prefidx == 0 + let world.prefidx = 1 + endif + endif + " TLogVAR world.idx, world.prefidx + + " TLogDBG 7 + " TLogVAR world.prefidx, world.offset + " TLogDBG (world.prefidx > world.offset + winheight(0) - 1) + " if world.prefidx > world.offset + winheight(0) - 1 + " let listtop = world.llen - winheight(0) + 1 + " let listoff = world.prefidx - winheight(0) + 1 + " let world.offset = min([listtop, listoff]) + " TLogVAR world.prefidx + " TLogDBG len(list) + " TLogDBG winheight(0) + " TLogVAR listtop, listoff, world.offset + " elseif world.prefidx < world.offset + " let world.offset = world.prefidx + " endif + " TLogDBG 8 + " TLogVAR world.initial_display, !tlib#char#IsAvailable() + if world.state =~ '\' || world.initial_display || !tlib#char#IsAvailable() + " TLogDBG len(dlist) + call world.DisplayList(world.Query(), dlist) + call world.FollowCursor() + let world.initial_display = 0 + " TLogDBG 9 + endif + if world.state =~ '\' + let world.state = 'suspend' + else + let world.state = '' + endif + else + " if world.state == 'scroll' + " let world.prefidx = world.offset + " endif + call world.DisplayList() + if world.state == 'help' || world.state == 'printlines' + let world.state = 'display' + else + let world.state = '' + call world.FollowCursor() + endif + endif + " TAssert IsNotEmpty(world.scratch) + let world.list_wnr = winnr() + + " TLogVAR world.state, world.next_state + if !empty(world.next_state) + let world.state = world.next_state + let world.next_state = '' + endif + + if world.state =~ '\' + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + continue + endif + + if world.state =~ '\' + let query = matchstr(world.state, '\" + if v:mouse_win == world.list_wnr + let world.prefidx = world.GetLineIdx(v:mouse_lnum) + " let world.offset = world.prefidx + if empty(world.prefidx) + " call feedkeys(c, 't') + let c = s:GetModdedChar(world) + let world.state = 'help' + continue + endif + throw 'pick' + else + let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c + if world.allow_suspend + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + else + let world.state = 'exit empty' + endif + endif + elseif c == "\" + if v:mouse_win == world.list_wnr + call s:BuildMenu(world) + let world.state = 'redisplay' + if s:PopupmenuExists() == 1 + " if v:mouse_lnum != line('.') + " endif + let world.prefidx = world.GetLineIdx(v:mouse_lnum) + let world.next_state = 'eval[Waiting for popup menu ... Press ESC to continue]' + call world.DisplayList() + if line('w$') - v:mouse_lnum < 6 + popup ]TLibInputListPopupMenu + else + popup! ]TLibInputListPopupMenu + endif + endif + else + let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c + if world.allow_suspend + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + else + let world.state = 'exit empty' + endif + endif + " TLogVAR world.prefidx, world.state + elseif has_key(world.key_map[world.key_mode], 'unknown_key') + let agent = world.key_map[world.key_mode].unknown_key.agent + " let world = call(agent, [world, c]) + " call s:CheckAgentReturnValue(agent, world) + let world = s:CallAgent({'agent': agent}, world, c) + elseif c >= 32 + let world.state = 'display' + let numbase = get(world.numeric_chars, c, -99999) + " TLogVAR numbase, world.numeric_chars, c + if numbase != -99999 + let world.idx .= (c - numbase) + if len(world.idx) == world.index_width + let world.prefidx = world.idx + " TLogVAR world.prefidx + throw 'pick' + endif + else + let world.idx = '' + " TLogVAR world.filter + if world.llen > g:tlib#input#livesearch_threshold + let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c)) + if empty(pattern) + let world.state = 'exit empty' + else + call world.SetFrontFilter(pattern) + echo + endif + elseif c == 124 + call insert(world.filter[0], []) + else + call world.PushFrontFilter(c) + endif + " continue + if c == 45 && world.filter[0][0] == '-' + let world.state = 'redisplay' + end + endif + else + let world.state = 'redisplay' + " let world.state = 'continue' + endif + + catch /^picked$/ + call world.ClearAllMarks() + call world.MarkCurrent(world.prefidx) + let world.state = 'exit' + + catch /^pick$/ + call world.ClearAllMarks() + call world.MarkCurrent(world.prefidx) + let world.state = '' + " TLogDBG 'Pick item #'. world.prefidx + + finally + " TLogDBG 'finally 1', world.state + if world.state =~ '\' + " if !world.allow_suspend + " echom "Cannot be suspended" + " let world.state = 'redisplay' + " endif + elseif !empty(world.list) && !empty(world.base) + " TLogVAR world.list + if empty(world.state) + let world.rv = world.CurrentItem() + " TLogVAR world.state, world.rv + endif + " TLogVAR "postprocess" + for handler in world.post_handlers + let state = get(handler, 'postprocess', '') + " TLogVAR handler + " TLogVAR state + " TLogVAR world.state + if state == world.state + let agent = handler.agent + let [world, world.rv] = call(agent, [world, world.rv]) + " TLogVAR world.state, world.rv + call s:CheckAgentReturnValue(agent, world) + endif + endfor + endif + " TLogDBG 'state0='. world.state + endtry + " TLogDBG 'state1='. world.state + endwh + + " TLogVAR world.state + " TLogDBG string(tlib#win#List()) + " TLogDBG 'exit while loop' + " TLogVAR world.list + " TLogVAR world.sel_idx + " TLogVAR world.idx + " TLogVAR world.prefidx + " TLogVAR world.rv + " TLogVAR world.type, world.state, world.return_agent, world.index_table, world.rv + if world.state =~ '\<\(empty\|escape\)\>' + let world.sticky = 0 + endif + if world.state =~ '\' + " TLogDBG 'return suspended' + " TLogVAR world.prefidx + " exec world.prefidx + return + elseif world.state =~ '\' + " TLog "empty" + " TLogDBG 'return empty' + " TLogVAR world.type + if stridx(world.type, 'm') != -1 + return [] + elseif stridx(world.type, 'i') != -1 + return 0 + else + return '' + endif + elseif !empty(world.return_agent) + " TLogDBG 'return agent' + " TLogVAR world.return_agent + call world.CloseScratch() + " TLogDBG "return_agent ". string(tlib#win#List()) + " TAssert IsNotEmpty(world.scratch) + return call(world.return_agent, [world, world.GetSelectedItems(world.rv)]) + elseif stridx(world.type, 'w') != -1 + " TLog "return_world" + " TLogDBG 'return world' + return world + elseif stridx(world.type, 'm') != -1 + " TLog "return_multi" + " TLogDBG 'return multi' + return world.GetSelectedItems(world.rv) + elseif stridx(world.type, 'i') != -1 + " TLog "return_index" + " TLogDBG 'return index' + if empty(world.index_table) + return world.rv + else + return world.index_table[world.rv - 1] + endif + else + " TLog "return_else" + " TLogDBG 'return normal' + return world.rv + endif + + finally + call world.Leave() + + " TLogVAR statusline + " let &l:statusline = statusline + " let &laststatus = laststatus + if &showmode != showmode + let &showmode = showmode + endif + silent! let @/ = lastsearch + let &l:scrolloff = scrolloff + if s:PopupmenuExists() == 1 + silent! aunmenu ]TLibInputListPopupMenu + endif + + " TLogDBG 'finally 2' + " TLogDBG string(world.Methods()) + " TLogVAR world.state + " TLogDBG string(tlib#win#List()) + if world.state !~ '\' + " redraw + " TLogVAR world.sticky, bufnr("%") + if world.sticky + " TLogDBG "sticky" + " TLogVAR world.bufnr + " TLogDBG bufwinnr(world.bufnr) + if world.scratch_split > 0 + if bufwinnr(world.bufnr) == -1 + " TLogDBG "UseScratch" + call world.UseScratch() + endif + let world = tlib#agent#SuspendToParentWindow(world, world.GetSelectedItems(world.rv)) + endif + else + " TLogDBG "non sticky" + " TLogVAR world.state, world.win_wnr, world.bufnr + if world.CloseScratch() + " TLogVAR world.winview + call tlib#win#SetLayout(world.winview) + endif + endif + endif + " for i in range(0,5) + " call getchar(0) + " endfor + echo + redraw! + if !empty(post_keys) + " TLogVAR post_keys + call feedkeys(post_keys) + endif + endtry +endf + + +function! s:CallAgent(handler, world, list) abort "{{{3 + let agent = a:handler.agent + let args = [a:world, a:list] + if has_key(a:handler, 'args') + let args += a:handler.args + endif + let world = call(agent, args) + " TLogVAR world.state, world.rv + call s:CheckAgentReturnValue(agent, world) + return world +endf + +function! s:GetModdedChar(world) "{{{3 + let [char, mode] = tlib#char#Get(a:world.timeout, a:world.timeout_resolution, 1) + if char !~ '\D' && char > 0 && mode != 0 + return printf("<%s-%s>", mode, char) + else + return char + endif +endf + + +function! s:Init(world, cmd) "{{{3 + " TLogVAR a:cmd + let a:world.initial_display = 1 + if a:cmd =~ '\' + let a:world.sticky = 1 + endif + if a:cmd =~ '^resume' + call a:world.UseInputListScratch() + let a:world.initial_index = line('.') + if a:cmd =~ '\' + let a:world.state = 'pick' + let a:world.prefidx = a:world.initial_index + else + call a:world.Retrieve(1) + endif + " if !empty(a:world.resume_state) + " let a:world.state = a:world.resume_state + " endif + elseif !a:world.initialized + " TLogVAR a:world.initialized, a:world.win_wnr, a:world.bufnr + let a:world.filetype = &filetype + let a:world.fileencoding = &fileencoding + call a:world.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'wb')) + call a:world.Initialize() + if !has_key(a:world, 'key_mode') + let a:world.key_mode = 'default' + endif + " TLogVAR has_key(a:world,'key_map') + if has_key(a:world, 'key_map') + " TLogVAR has_key(a:world.key_map,a:world.key_mode) + if has_key(a:world.key_map, a:world.key_mode) + let a:world.key_map[a:world.key_mode] = extend( + \ a:world.key_map[a:world.key_mode], + \ copy(g:tlib#input#keyagents_InputList_s), + \ 'keep') + else + let a:world.key_map[a:world.key_mode] = copy(g:tlib#input#keyagents_InputList_s) + endif + else + let a:world.key_map = { + \ a:world.key_mode : copy(g:tlib#input#keyagents_InputList_s) + \ } + endif + " TLogVAR a:world.type + if stridx(a:world.type, 'm') != -1 + call extend(a:world.key_map[a:world.key_mode], g:tlib#input#keyagents_InputList_m, 'force') + endif + for key_mode in keys(a:world.key_map) + let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}') + endfor + " TLogVAR a:world.key_mode + if type(a:world.key_handlers) == 3 + call s:ExtendKeyMap(a:world, a:world.key_mode, a:world.key_handlers) + elseif type(a:world.key_handlers) == 4 + for [world_key_mode, world_key_handlers] in items(a:world.key_handlers) + call s:ExtendKeyMap(a:world, world_key_mode, world_key_handlers) + endfor + else + throw "tlib#input#ListW: key_handlers must be either a list or a dictionary" + endif + " TLogVAR a:world.type, a:world.key_map + if !empty(a:cmd) + let a:world.state .= ' '. a:cmd + endif + endif + " TLogVAR a:world.state, a:world.sticky +endf + + +function! s:ExtendKeyMap(world, key_mode, key_handlers) "{{{3 + for handler in a:key_handlers + let k = get(handler, 'key', '') + if !empty(k) + let a:world.key_map[a:key_mode][k] = handler + endif + endfor +endf + + +function! s:PopupmenuExists() + if !g:tlib#input#use_popup + \ || exists(':popup') != 2 + \ || !(has('gui_win32') || has('gui_gtk') || has('gui_gtk2')) + " \ || !has('gui_win32') + let rv = -1 + else + try + let rv = 1 + silent amenu ]TLibInputListPopupMenu + catch + let rv = 0 + endtry + endif + " TLogVAR rv + return rv +endf + + +function! s:BuildMenu(world) "{{{3 + if g:tlib#input#use_popup && s:PopupmenuExists() == 0 + call s:BuildItem('Pick\ selected\ item', {'key_name': '', 'eval': 'let world.state = "pick"'}) + call s:BuildItem('Cancel', {'key_name': '', 'agent': 'tlib#agent#Exit'}) + call s:BuildItem('Select', {'key_name': '#', 'agent': 'tlib#agent#Select'}) + call s:BuildItem('Select\ all', {'key_name': '', 'agent': 'tlib#agent#SelectAll'}) + call s:BuildItem('Reset\ list', {'key_name': '', 'agent': 'tlib#agent#Reset'}) + call s:BuildItem('-StandardEntries-', {'key': ":", 'eval': 'let world.state = "redisplay"'}) + for [key_mode, key_handlers] in items(a:world.key_map) + let keys = sort(keys(key_handlers)) + let mitems = {} + for key in keys + let handler = key_handlers[key] + let k = get(handler, 'key', '') + if !empty(k) && has_key(handler, 'help') && !empty(handler.help) + if empty(key_mode) || key_mode == 'default' + let mname = '' + else + let mname = escape(key_mode, ' .\') .'.' + endif + if has_key(handler, 'submenu') + let submenu = escape(handler.submenu, ' .\') + else + let submenu = '~' + endif + for mfield in ['menu', 'help', 'key_name', 'agent'] + if has_key(handler, mfield) + let mname .= escape(handler[mfield], ' .\') + break + endif + endfor + if !has_key(mitems, submenu) + let mitems[submenu] = {} + endif + let mitems[submenu][mname] = handler + endif + endfor + for msubname in sort(keys(mitems)) + let msubitems = mitems[msubname] + if msubname == '~' + let msubmname = '' + else + let msubmname = msubname .'.' + endif + for mname in sort(keys(msubitems)) + let msname = msubmname . mname + let handler = msubitems[mname] + call s:BuildItem(msname, handler) + " if has_key(handler, 'agent') + " call s:BuildItem(msname, {'agent': handler.agent}) + " else + " call s:BuildItem(msname, {'key': handler.key_name}) + " endif + endfor + endfor + endfor + endif +endf + + +function! s:BuildItem(menu, def) "{{{3 + if has('gui_win32') + let key_mode = 'c' + elseif has('gui_gtk') || has('gui_gtk2') + let key_mode = 'raw' + endif + for k in ['agent', 'eval', 'key_name', 'key'] + if has('gui_win32') + elseif has('gui_gtk') || has('gui_gtk') + if k == 'agent' || k == 'eval' + continue + endif + endif + try + if has_key(a:def, k) + let v = a:def[k] + if k == 'key' + if key_mode == 'c' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' + else + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) v + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) v + endif + elseif k == 'key_name' + if key_mode == 'c' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' + else + let key = v + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) key + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) key + endif + elseif k == 'agent' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' + elseif k == 'eval' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' + endif + return + endif + catch + endtry + endfor +endf + + +function! s:RunStateHandlers(world) "{{{3 + " Provide the variable "world" in the environment of an "exec" + " handler (ea). + let world = a:world + for handler in a:world.state_handlers + let eh = get(handler, 'state', '') + if !empty(eh) && a:world.state =~ eh + let ea = get(handler, 'exec', '') + if !empty(ea) + exec ea + else + let agent = get(handler, 'agent', '') + " let world = call(agent, [a:world, a:world.GetSelectedItems(a:world.CurrentItem())]) + " call s:CheckAgentReturnValue(agent, a:world) + let world = s:CallAgent({'agent': agent}, world, world.GetSelectedItems(world.CurrentItem())) + endif + endif + endfor + return world +endf + + +function! s:CheckAgentReturnValue(name, value) "{{{3 + if type(a:value) != 4 && !has_key(a:value, 'state') + echoerr 'Malformed agent: '. a:name + endif + return a:value +endf + + +function! s:SetOffset(world) "{{{3 + let llenw = len(a:world.base) - winheight(0) + 1 + if a:world.offset > llenw + let a:world.offset = llenw + endif + if a:world.offset < 1 + let a:world.offset = 1 + endif +endf + + +" Functions related to tlib#input#EditList(type, ...) "{{{2 + +" :def: function! tlib#input#EditList(query, list, ?timeout=0) +" Edit a list. +" +" EXAMPLES: > +" echo tlib#input#EditList('Edit:', [100,200,300]) +function! tlib#input#EditList(query, list, ...) "{{{3 + let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib#input#handlers_EditList + let default = a:0 >= 2 ? a:2 : [] + let timeout = a:0 >= 3 ? a:3 : 0 + " TLogVAR handlers + let rv = tlib#input#List('me', a:query, copy(a:list), handlers, default, timeout) + " TLogVAR rv + if empty(rv) + return a:list + else + let [success, list] = rv + return success ? list : a:list + endif +endf + + +function! tlib#input#Resume(name, pick, bufnr) "{{{3 + " TLogVAR a:name, a:pick + echo + if bufnr('%') != a:bufnr + if g:tlib#debug + echohl WarningMsg + echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%') + echohl NONE + endif + let br = tlib#buffer#Set(a:bufnr) + endif + if !exists('b:tlib_'. a:name) + if g:tlib#debug + echohl WarningMsg + echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%') + echohl NONE + redir => varss + silent let b: + redir END + let vars = split(varss, '\n') + call filter(vars, 'v:val =~ "^b:tlib_"') + echom "DEBUG tlib#input#Resume" string(vars) + endif + else + call tlib#autocmdgroup#Init() + autocmd! TLib BufEnter + if b:tlib_{a:name}.state =~ '\' + let b:tlib_{a:name}.state = 'redisplay' + else + let b:tlib_{a:name}.state .= ' redisplay' + endif + " call tlib#input#List('resume '. a:name) + let cmd = 'resume '. a:name + if a:pick >= 1 + let cmd .= ' pick' + if a:pick >= 2 + let cmd .= ' sticky' + end + endif + call tlib#input#ListW(b:tlib_{a:name}, cmd) + endif +endf + + +" :def: function! tlib#input#CommandSelect(command, ?keyargs={}) +" Take a command, view the output, and let the user select an item from +" its output. +" +" EXAMPLE: > +" command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') +" command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +function! tlib#input#CommandSelect(command, ...) "{{{3 + TVarArg ['args', {}] + if has_key(args, 'retrieve') + let list = call(args.retrieve) + elseif has_key(args, 'list') + let list = args.list + else + let list = tlib#cmd#OutputAsList(a:command) + endif + if has_key(args, 'filter') + call map(list, args.filter) + endif + let type = has_key(args, 'type') ? args.type : 's' + let handlers = has_key(args, 'handlers') ? args.handlers : [] + let rv = tlib#input#List(type, 'Select', list, handlers) + if !empty(rv) + if has_key(args, 'process') + let rv = call(args.process, [rv]) + endif + endif + return rv +endf + + +" :def: function! tlib#input#Edit(name, value, callback, ?cb_args=[]) +" +" Edit a value (asynchronously) in a scratch buffer. Use name for +" identification. Call callback when done (or on cancel). +" In the scratch buffer: +" Press or to enter the new value, c to cancel +" editing. +" EXAMPLES: > +" fun! FooContinue(success, text) +" if a:success +" let b:var = a:text +" endif +" endf +" call tlib#input#Edit('foo', b:var, 'FooContinue') +function! tlib#input#Edit(name, value, callback, ...) "{{{3 + " TLogVAR a:value + TVarArg ['args', []] + let sargs = {'scratch': '__EDIT__'. a:name .'__', 'win_wnr': winnr()} + let scr = tlib#scratch#UseScratch(sargs) + + " :nodoc: + map c :call EditCallback(0) + " :nodoc: + imap c call EditCallback(0) + " :nodoc: + map :call EditCallback(1) + " :nodoc: + imap call EditCallback(1) + " :nodoc: + map :call EditCallback(1) + " :nodoc: + imap call EditCallback(1) + + call tlib#normal#WithRegister('gg"tdG', 't') + call append(1, split(a:value, "\", 1)) + " let hrm = 'DON''T DELETE THIS HEADER' + " let hr3 = repeat('"', (tlib#win#Width(0) - len(hrm)) / 2) + let s:horizontal_line = repeat('`', tlib#win#Width(0)) + " hr3.hrm.hr3 + let hd = ['Keys: , ... save/accept; c ... cancel', s:horizontal_line] + call append(1, hd) + call tlib#normal#WithRegister('gg"tdd', 't') + syntax match TlibEditComment /^\%1l.*/ + syntax match TlibEditComment /^```.*/ + hi link TlibEditComment Comment + exec len(hd) + 1 + if type(a:callback) == 4 + let b:tlib_scratch_edit_callback = get(a:callback, 'submit', '') + call call(get(a:callback, 'init', ''), []) + else + let b:tlib_scratch_edit_callback = a:callback + endif + let b:tlib_scratch_edit_args = args + let b:tlib_scratch_edit_scratch = sargs + " exec 'autocmd BufDelete,BufHidden,BufUnload call s:EditCallback('. string(a:name) .')' + " echohl MoreMsg + " echom 'Press to enter, c to cancel editing.' + " echohl NONE +endf + + +function! s:EditCallback(...) "{{{3 + TVarArg ['ok', -1] + " , ['bufnr', -1] + " autocmd! BufDelete,BufHidden,BufUnload + if ok == -1 + let ok = confirm('Use value') + endif + let start = getline(2) == s:horizontal_line ? 3 : 1 + let text = ok ? join(getline(start, '$'), "\n") : '' + let cb = b:tlib_scratch_edit_callback + let args = b:tlib_scratch_edit_args + let sargs = b:tlib_scratch_edit_scratch + " TLogVAR cb, args, sargs + call tlib#scratch#CloseScratch(b:tlib_scratch_edit_scratch) + call tlib#win#Set(sargs.win_wnr) + call call(cb, args + [ok, text]) +endf + + +function! tlib#input#Dialog(text, options, default) "{{{3 + if has('dialog_con') || has('dialog_gui') + let opts = join(map(a:options, '"&". v:val'), "\n") + let val = confirm(a:text, opts) + if val + let yn = a:options[val - 1] + else + let yn = a:default + endif + else + let oi = index(a:options, a:default) + if oi == -1 + let opts = printf("(%s|%s)", join(a:options, '/'), a:default) + else + let options = copy(a:options) + let options[oi] = toupper(options[oi]) + let opts = printf("(%s)", join(a:options, '/')) + endif + let yn = inputdialog(a:text .' '. opts) + endif + return yn +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/list.vim b/sources_non_forked/tlib/autoload/tlib/list.vim new file mode 100644 index 00000000..dbbc702f --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/list.vim @@ -0,0 +1,183 @@ +" list.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2015-10-21. +" @Revision: 61 + + +""" List related functions {{{1 +" For the following functions please see ../../test/tlib.vim for examples. + +" :def: function! tlib#list#Inject(list, initial_value, funcref) +" EXAMPLES: > +" echo tlib#list#Inject([1,2,3], 0, function('Add') +" => 6 +function! tlib#list#Inject(list, value, Function) "{{{3 + if empty(a:list) + return a:value + else + let item = a:list[0] + let rest = a:list[1:-1] + let value = call(a:Function, [a:value, item]) + return tlib#list#Inject(rest, value, a:Function) + endif +endf + + +" EXAMPLES: > +" tlib#list#Compact([0,1,2,3,[], {}, ""]) +" => [1,2,3] +function! tlib#list#Compact(list) "{{{3 + return filter(copy(a:list), '!empty(v:val)') +endf + + +" EXAMPLES: > +" tlib#list#Flatten([0,[1,2,[3,""]]]) +" => [0,1,2,3,""] +function! tlib#list#Flatten(list) "{{{3 + let acc = [] + for e in a:list + if type(e) == 3 + let acc += tlib#list#Flatten(e) + else + call add(acc, e) + endif + unlet e + endfor + return acc +endf + + +" :def: function! tlib#list#FindAll(list, filter, ?process_expr="") +" Basically the same as filter() +" +" EXAMPLES: > +" tlib#list#FindAll([1,2,3], 'v:val >= 2') +" => [2, 3] +function! tlib#list#FindAll(list, filter, ...) "{{{3 + let rv = filter(copy(a:list), a:filter) + if a:0 >= 1 && a:1 != '' + let rv = map(rv, a:1) + endif + return rv +endf + + +" :def: function! tlib#list#Find(list, filter, ?default="", ?process_expr="") +" +" EXAMPLES: > +" tlib#list#Find([1,2,3], 'v:val >= 2') +" => 2 +function! tlib#list#Find(list, filter, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let expr = a:0 >= 2 ? a:2 : '' + return get(tlib#list#FindAll(a:list, a:filter, expr), 0, default) +endf + + +" EXAMPLES: > +" tlib#list#Any([1,2,3], 'v:val >= 2') +" => 1 +function! tlib#list#Any(list, expr) "{{{3 + return !empty(tlib#list#FindAll(a:list, a:expr)) +endf + + +" EXAMPLES: > +" tlib#list#All([1,2,3], 'v:val >= 2') +" => 0 +function! tlib#list#All(list, expr) "{{{3 + return len(tlib#list#FindAll(a:list, a:expr)) == len(a:list) +endf + + +" EXAMPLES: > +" tlib#list#Remove([1,2,1,2], 2) +" => [1,1,2] +function! tlib#list#Remove(list, element) "{{{3 + let idx = index(a:list, a:element) + if idx != -1 + call remove(a:list, idx) + endif + return a:list +endf + + +" EXAMPLES: > +" tlib#list#RemoveAll([1,2,1,2], 2) +" => [1,1] +function! tlib#list#RemoveAll(list, element) "{{{3 + call filter(a:list, 'v:val != a:element') + return a:list +endf + + +" :def: function! tlib#list#Zip(lists, ?default='') +" EXAMPLES: > +" tlib#list#Zip([[1,2,3], [4,5,6]]) +" => [[1,4], [2,5], [3,6]] +function! tlib#list#Zip(lists, ...) "{{{3 + TVarArg 'default' + let lists = copy(a:lists) + let max = 0 + for l in lists + let ll = len(l) + if ll > max + let max = ll + endif + endfor + " TLogVAR default, max + return map(range(0, max - 1), 's:GetNthElement(v:val, lists, default)') +endf + +function! s:GetNthElement(n, lists, default) "{{{3 + " TLogVAR a:n, a:lists, a:default + return map(copy(a:lists), 'get(v:val, a:n, a:default)') +endf + + +function! tlib#list#Uniq(list, ...) "{{{3 + " TLogVAR a:list + TVarArg ['get_value', ''], ['remove_empty', 0] + if remove_empty + call filter(a:list, 'type(v:val) == 0 || !empty(v:val)') + endif + " CREDITS: Based on syntastic#util#unique(list) by scrooloose + let seen = {} + let uniques = [] + if empty(get_value) + for e in a:list + if !has_key(seen, e) + let seen[e] = 1 + call add(uniques, e) + endif + unlet e + endfor + else + for e in a:list + let v = eval(printf(get_value, string(e))) + if !has_key(seen, v) + let seen[v] = 1 + call add(uniques, e) + endif + unlet e + endfor + endif + return uniques +endf + + +function! tlib#list#ToDictionary(list, default, ...) "{{{3 + TVarArg ['generator', ''] + let dict = {} + for item in a:list + if !empty(item) + let dict[item] = empty(generator) ? a:default : call(generator, [item, a:default]) + endif + endfor + return dict +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/loclist.vim b/sources_non_forked/tlib/autoload/tlib/loclist.vim new file mode 100644 index 00000000..198dd1be --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/loclist.vim @@ -0,0 +1,13 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-10-24 +" @Revision: 2 + + +function! tlib#loclist#Browse(...) abort "{{{3 + let list = getloclist(0) + return call(function('tlib#qfl#QflList'), [list] + a:000) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/map.vim b/sources_non_forked/tlib/autoload/tlib/map.vim new file mode 100644 index 00000000..c1af13f6 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/map.vim @@ -0,0 +1,23 @@ +" map.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-08-23. +" @Last Change: 2009-08-23. +" @Revision: 0.0.4 + +let s:save_cpo = &cpo +set cpo&vim + + +" If |pumvisible()| is true, return "\". Otherwise return a:key. +" For use in maps like: > +" imap tlib#map#PumAccept("\") +function! tlib#map#PumAccept(key) "{{{3 + return pumvisible() ? "\" : a:key +endf + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/normal.vim b/sources_non_forked/tlib/autoload/tlib/normal.vim new file mode 100644 index 00000000..faaa4448 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/normal.vim @@ -0,0 +1,34 @@ +" normal.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-10-06. +" @Last Change: 2010-09-22. +" @Revision: 28 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') +" Execute a normal command while maintaining all registers. +function! tlib#normal#WithRegister(cmd, ...) "{{{3 + TVarArg ['register', 't'], ['norm_cmd', 'norm!'] + let registers = {} + for reg in split('123456789'. register, '\zs') + exec 'let registers[reg] = @'. reg + endfor + exec 'let reg = @'. register + try + exec norm_cmd .' '. a:cmd + exec 'return @'. register + finally + for [reg, value] in items(registers) + exec 'let @'. reg .' = value' + endfor + endtry +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/notify.vim b/sources_non_forked/tlib/autoload/tlib/notify.vim new file mode 100644 index 00000000..2f45bdb8 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/notify.vim @@ -0,0 +1,105 @@ +" notify.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-09-19. +" @Last Change: 2015-04-07. +" @Revision: 0.3.19 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: tlib#notify#Echo(text, ?style='') +" Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' +" in order to prevent |press-enter| messages. +function! tlib#notify#Echo(text, ...) + TVarArg 'style' + let ruler = &ruler + let showcmd = &showcmd + let text = substitute(a:text, '\n', '|', 'g') + try + set noruler + set noshowcmd + if !empty(style) + exec 'echohl' style + endif + echo strpart(text, 0, &columns - 1) + finally + if !empty(style) + echohl None + endif + let &ruler = ruler + let &showcmd = showcmd + endtry +endf + + +" Contributed by Erik Falor: +" If the line containing the message is too long, echoing it will cause +" a 'Hit ENTER' prompt to appear. This function cleans up the line so +" that does not happen. +" The echoed line is too long if it is wider than the width of the +" window, minus cmdline space taken up by the ruler and showcmd +" features. +function! tlib#notify#TrimMessage(message) "{{{3 + let filler = '...' + + " If length of message with tabs converted into spaces + length of + " line number + 2 (for the ': ' that follows the line number) is + " greater than the width of the screen, truncate in the middle + let to_fill = &columns + " TLogVAR to_fill + + " Account for space used by elements in the command-line to avoid + " 'Hit ENTER' prompts. + " If showcmd is on, it will take up 12 columns. + " If the ruler is enabled, but not displayed in the statusline, it + " will in its default form take 17 columns. If the user defines a + " custom &rulerformat, they will need to specify how wide it is. + if has('cmdline_info') + if &showcmd + let to_fill -= 12 + else + let to_fill -= 1 + endif + " TLogVAR &showcmd, to_fill + + " TLogVAR &laststatus, &ruler, &rulerformat + if &ruler + if &laststatus == 0 || winnr('$') == 1 + if has('statusline') + if &rulerformat == '' + " default ruler is 17 chars wide + let to_fill -= 17 + elseif exists('g:MP_rulerwidth') + let to_fill -= g:MP_rulerwidth + else + " tml: fallback: guess length + let to_fill -= strlen(&rulerformat) + endif + else + endif + endif + else + endif + else + let to_fill -= 1 + endif + + " TLogVAR to_fill + " TLogDBG strlen(a:message) + if strlen(a:message) > to_fill + let front = to_fill / 2 - 1 + let back = front + if to_fill % 2 == 0 | let back -= 1 | endif + return strpart(a:message, 0, front) . filler . + \strpart(a:message, strlen(a:message) - back) + else + return a:message + endif +endfunction + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/number.vim b/sources_non_forked/tlib/autoload/tlib/number.vim new file mode 100644 index 00000000..94fde02f --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/number.vim @@ -0,0 +1,30 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 14 + + +function! tlib#number#ConvertBase(num, base, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'string' + " TLogVAR a:num, a:base, rtype + let rv = [] + let num = 0.0 + a:num + while floor(num) > 0.0 + let div = floor(num / a:base) + let num1 = float2nr(num - a:base * div) + if a:base <= 10 + call insert(rv, num1) + elseif a:base == 16 + let char = "0123456789ABCDEF"[num1] + call insert(rv, char) + endif + let num = num / a:base + endwh + " TLogVAR rv + if rtype == 'list' + return rv + else + return join(rv, '') + endif +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/paragraph.vim b/sources_non_forked/tlib/autoload/tlib/paragraph.vim new file mode 100644 index 00000000..dd0d1123 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/paragraph.vim @@ -0,0 +1,97 @@ +" paragraph.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-10-26. +" @Last Change: 2011-04-03. +" @Revision: 62 + +let s:save_cpo = &cpo +set cpo&vim + + +" Return an object describing a |paragraph|. +function! tlib#paragraph#GetMetric() "{{{3 + let sp = {'text_start': line("'{") + 1} + if line("'}") == line("$") + let sp.last = 1 + let sp.text_end = line("'}") + if line("'{") == 1 + let sp.ws_start = 0 + let sp.ws_end = 0 + let sp.top = sp.text_start + let sp.bottom = sp.text_end + else + let sp.ws_start = prevnonblank(line("'{")) + 1 + let sp.ws_end = line("'{") + let sp.top = sp.ws_start + let sp.bottom = sp.text_end + endif + else + let sp.last = 0 + let sp.text_end = line("'}") - 1 + let sp.ws_start = line("'}") + for i in range(line("'}"), line('$')) + if getline(i) =~ '\w' + let sp.ws_end = i - 1 + break + elseif i == line("$") + let sp.ws_end = i + endif + endfor + let sp.top = sp.text_start + let sp.bottom = sp.ws_end + endif + return sp +endf + + +" This function can be used with the tinymode plugin to move around +" paragraphs. +" +" Example configuration: > +" +" call tinymode#EnterMap("para_move", "gp") +" call tinymode#ModeMsg("para_move", "Move paragraph: j/k") +" call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") +" call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") +" call tinymode#ModeArg("para_move", "owncount", 1) +function! tlib#paragraph#Move(direction, count) + " TLogVAR a:direction, a:count + let mycount = empty(a:count) ? 1 : a:count + for i in range(1, mycount) + let para = tlib#paragraph#GetMetric() + " TLogVAR para + let text = getline(para.text_start, para.text_end) + let ws = getline(para.ws_start, para.ws_end) + " TLogVAR text, ws + exec para.top .','. para.bottom .'delete' + if a:direction == "Down" + let other = tlib#paragraph#GetMetric() + let target = other.bottom + 1 + if other.last + let lines = ws + text + let pos = target + len(ws) + else + let lines = text + ws + let pos = target + endif + elseif a:direction == "Up" + if !para.last + norm! { + endif + let other = tlib#paragraph#GetMetric() + let target = other.text_start + let lines = text + ws + let pos = target + endif + " TLogVAR other, target + " TLogVAR lines + call append(target - 1, lines) + exec pos + endfor +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/persistent.vim b/sources_non_forked/tlib/autoload/tlib/persistent.vim new file mode 100644 index 00000000..de3d4878 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/persistent.vim @@ -0,0 +1,47 @@ +" persistent.vim -- Persistent data +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-05-11. +" @Last Change: 2012-05-11. +" @Revision: 12 + +" The directory for persistent data files. If empty, use +" |tlib#dir#MyRuntime|.'/share'. +TLet g:tlib_persistent = '' + + +" :display: tlib#persistent#Dir(?mode = 'bg') +" Return the full directory name for persistent data files. +function! tlib#persistent#Dir() "{{{3 + TVarArg ['mode', 'bg'] + let dir = tlib#var#Get('tlib_persistent', mode) + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'share']) + endif + return dir +endf + +" :def: function! tlib#persistent#Filename(type, ?file=%, ?mkdir=0) +function! tlib#persistent#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let file = a:0 >= 1 ? a:1 : '' + let mkdir = a:0 >= 2 ? a:2 : 0 + return tlib#cache#Filename(a:type, file, mkdir, tlib#persistent#Dir()) +endf + +function! tlib#persistent#Get(...) "{{{3 + return call('tlib#cache#Get', a:000) +endf + +function! tlib#persistent#MTime(cfile) "{{{3 + return tlib#cache#MTime(a:cfile) +endf + +function! tlib#persistent#Value(...) "{{{3 + return call('tlib#cache#Value', a:000) +endf + +function! tlib#persistent#Save(cfile, dictionary) "{{{3 + call tlib#cache#Save(a:cfile, a:dictionary) +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/progressbar.vim b/sources_non_forked/tlib/autoload/tlib/progressbar.vim new file mode 100644 index 00000000..e739eb3c --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/progressbar.vim @@ -0,0 +1,72 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 72 + +let s:statusline = [] +let s:laststatus = [] +let s:max = [] +let s:format = [] +let s:width = [] +let s:value = [] +let s:timestamp = -1 + +" EXAMPLE: > +" call tlib#progressbar#Init(20) +" try +" for i in range(20) +" call tlib#progressbar#Display(i) +" call DoSomethingThatTakesSomeTime(i) +" endfor +" finally +" call tlib#progressbar#Restore() +" endtry +function! tlib#progressbar#Init(max, ...) "{{{3 + TVarArg ['format', '%s'], ['width', 10] + call insert(s:statusline, &statusline) + call insert(s:laststatus, &laststatus) + call insert(s:max, a:max) + call insert(s:format, format) + call insert(s:width, width) + call insert(s:value, -1) + let &laststatus = 2 + let s:timestamp = localtime() +endf + + +function! tlib#progressbar#Display(value, ...) "{{{3 + TVarArg 'extra', ['always', 0] + let ts = localtime() + if !always && ts == s:timestamp + return + else + let s:timestamp = ts + endif + let val = a:value * s:width[0] / s:max[0] + if always || val != s:value[0] + let s:value[0] = val + let pbl = repeat('#', val) + let pbr = repeat('.', s:width[0] - val) + let txt = printf(s:format[0], '['.pbl.pbr.']') . extra + let &l:statusline = txt + " TLogDBG txt + redrawstatus + " redraw + " call tlib#notify#Echo(txt) + endif +endf + + +function! tlib#progressbar#Restore() "{{{3 + let &l:statusline = remove(s:statusline, 0) + let &laststatus = remove(s:laststatus, 0) + redrawstatus + " redraw + " echo + call remove(s:max, 0) + call remove(s:format, 0) + call remove(s:width, 0) + call remove(s:value, 0) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/qfl.vim b/sources_non_forked/tlib/autoload/tlib/qfl.vim new file mode 100644 index 00000000..7d4b442d --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/qfl.vim @@ -0,0 +1,314 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-11-13 +" @Revision: 59 + +" :nodoc: +TLet g:tlib#qfl#world = { + \ 'type': 'mi', + \ 'query': 'Select entry', + \ 'pick_last_item': 0, + \ 'resize_vertical': 0, + \ 'resize': 20, + \ 'scratch': '__TLibQFL__', + \ 'tlib_UseInputListScratch': 'call tlib#qfl#InitListBuffer(world)', + \ 'key_handlers': [ + \ {'key': 5, 'agent': 'tlib#qfl#AgentWithSelected', 'key_name': '', 'help': 'Run a command on selected lines'}, + \ {'key': 16, 'agent': 'tlib#qfl#AgentPreviewQFE', 'key_name': '', 'help': 'Preview'}, + \ {'key': 60, 'agent': 'tlib#qfl#AgentGotoQFE', 'key_name': '<', 'help': 'Jump (don''t close the list)'}, + \ {'key': 19, 'agent': 'tlib#qfl#AgentSplitBuffer', 'key_name': '', 'help': 'Show in split buffer'}, + \ {'key': 20, 'agent': 'tlib#qfl#AgentTabBuffer', 'key_name': '', 'help': 'Show in tab'}, + \ {'key': 22, 'agent': 'tlib#qfl#AgentVSplitBuffer', 'key_name': '', 'help': 'Show in vsplit buffer'}, + \ {'key': 12, 'agent': 'tlib#qfl#AgentEditLine', 'key_name': '', 'help': 'Edit selected line(s)'}, + \ {'key': "\", 'agent': 'tlib#qfl#SetFollowCursor', 'key_name': '', 'help': 'Toggle trace cursor'}, + \ ], + \ 'return_agent': 'tlib#qfl#AgentEditQFE', + \ } + + +function! tlib#qfl#FormatQFLE(qfe) dict abort "{{{3 + let filename = tlib#qfl#QfeFilename(a:qfe) + if get(self, 'qfl_short_filename', '') + let filename = pathshorten(filename) + endif + return printf("%s|%d| %s", filename, a:qfe.lnum, get(a:qfe, "text")) +endf + + +function! tlib#qfl#QfeFilename(qfe) abort "{{{3 + let filename = get(a:qfe, 'filename') + if empty(filename) + let filename = bufname(get(a:qfe, 'bufnr')) + endif + return filename +endf + + +function! tlib#qfl#InitListBuffer(world) "{{{3 + let set_syntax = get(a:world, 'set_syntax', 'tlib#qfl#SetSyntax') + call call(set_syntax, [], a:world) + if has('balloon_eval') + setlocal ballooneval balloonexpr=tlib#qfl#Balloon() + endif +endf + + +function! tlib#qfl#SetSyntax() dict abort "{{{3 + let syntax = get(self, 'qfl_list_syntax', '') + let nextgroup = get(self, 'qfl_list_syntax_nextgroup', '') + " TLogVAR syntax, nextgroup + if !empty(syntax) + exec printf('runtime syntax/%s.vim', syntax) + endif + syn match TTagedFilesFilename /\%(\f\+\| \)\+\ze|\d\+| / nextgroup=TTagedFilesLNum + if !empty(nextgroup) + exec 'syn match TTagedFilesLNum /|\d\+|\s\+/ nextgroup='. nextgroup + else + syn match TTagedFilesLNum /|\d\+|/ + endif + hi def link TTagedFilesFilename Directory + hi def link TTagedFilesLNum LineNr +endf + + +function! tlib#qfl#Balloon() "{{{3 + let world = getbufvar(v:beval_bufnr, 'tlibDisplayListWorld') + let current = max([1, world.offset]) + v:beval_lnum - 1 + if current > len(world.table) + let current = len(world.table) + endif + let baseidx = world.GetBaseIdx0(current) + " TLogVAR world.offset, v:beval_lnum, current, baseidx + let item = world.data[baseidx] + let bufnr = get(item, 'bufnr', 0) + let bufname = get(item, 'filename', '') + if bufnr == 0 && !empty(bufname) + let bufnr = bufnr(bufname) + endif + if empty(bufname) && bufnr > 0 + let bufname = bufname(bufnr) + endif + " TLogVAR item + if bufnr == 0 + return '' + else + let lines = [printf("%d#%d: %s", bufnr, item.lnum, bufname)] + if has('balloon_multiline') + let desc = {'nr': 'Error number', 'type': 'Error type', 'text': ''} + for key in ['nr', 'type', 'text'] + if has_key(item, key) && !empty(item[key]) + let keydesc = get(desc, key, key) + if empty(keydesc) + let text = item[key] + else + let text = printf("%s: %s", key, item[key]) + endif + call add(lines, text) + endif + endfor + endif + return join(lines, "\n") + endif + " v:beval_bufnr number of the buffer in which balloon is going to show + " v:beval_winnr number of the window + " v:beval_lnum line number + " v:beval_col column number (byte index) + " v:beval_text word under or after the mouse pointer +endf + + +function! tlib#qfl#AgentEditQFE(world, selected, ...) "{{{3 + TVarArg ['cmd_edit', ''], ['cmd_buffer', ''] + " TVarArg ['cmd_edit', 'edit'], ['cmd_buffer', 'buffer'] + " TLogVAR a:selected + if empty(a:selected) + call a:world.RestoreOrigin() + " call a:world.ResetSelected() + else + call a:world.RestoreOrigin() + for idx in a:selected + let idx -= 1 + " TLogVAR idx + if idx >= 0 + " TLogVAR a:world.data + " call tlog#Debug(string(map(copy(a:world.data), 'v:val.bufnr'))) + " TLogVAR idx, a:world.data[idx] + let qfe = a:world.data[idx] + " let back = a:world.SwitchWindow('win') + " TLogVAR cmd_edit, cmd_buffer, qfe + let fn = tlib#qfl#QfeFilename(qfe) + " TLogVAR cmd_edit, cmd_buffer, fn + if empty(cmd_edit) && empty(cmd_buffer) + if tlib#file#Edit(fn) + call tlib#buffer#ViewLine(qfe.lnum) + endif + else + call tlib#file#With(cmd_edit, cmd_buffer, [fn], a:world) + " TLogDBG bufname('%') + " TLogVAR &filetype + call tlib#buffer#ViewLine(qfe.lnum) + " call a:world.SetOrigin() + " exec back + endif + endif + endfor + endif + return a:world +endf + + +function! tlib#qfl#AgentPreviewQFE(world, selected) "{{{3 + " TLogVAR a:selected + let back = a:world.SwitchWindow('win') + call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0]) + exec back + redraw + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#qfl#AgentGotoQFE(world, selected) "{{{3 + if !empty(a:selected) + if a:world.win_wnr != winnr() + let world = tlib#agent#Suspend(a:world, a:selected) + exec a:world.win_wnr .'wincmd w' + endif + call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0]) + endif + return a:world +endf + + +function! tlib#qfl#AgentWithSelected(world, selected, ...) "{{{3 + let cmd = a:0 >= 1 ? a:1 : input('Ex command: ', '', 'command') + let world = a:world + if !empty(cmd) + let world = tlib#qfl#RunCmdOnSelected(world, a:selected, cmd) + else + let world.state = 'redisplay' + endif + return world +endf + + +function! tlib#qfl#RunCmdOnSelected(world, selected, cmd, ...) "{{{3 + let close_scratch = a:0 >= 1 ? a:1 : 1 + if close_scratch + call a:world.CloseScratch() + endif + " TLogVAR a:cmd + for entry in a:selected + " TLogVAR entry, a:world.GetBaseItem(entry) + call tlib#qfl#AgentEditQFE(a:world, [entry]) + " TLogDBG bufname('%') + exec a:cmd + " let item = a:world.data[a:world.GetBaseIdx(entry - 1)] + " <+TODO+> + let item = a:world.data[entry - 1] + " TLogVAR entry, item, getline('.') + if has_key(a:world, 'GetBufferLines') + let lines = a:world.GetBufferLines('.', '.') + else + let lines = getline('.', '.') + endif + let item['text'] = tlib#string#Strip(lines[0]) + endfor + if has_key(a:world, 'AfterRunCmd') + if bufnr('%') == a:world.bufnr + call a:world.AfterRunCmd() + else + " <+TODO+> Run in other buffer + endif + endif + " call s:FormatBase(a:world) + call a:world.RestoreOrigin() + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#qfl#AgentSplitBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'split', 'sbuffer') +endf + + +function! tlib#qfl#AgentTabBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'tabedit', 'tab sbuffer') +endf + + +function! tlib#qfl#AgentVSplitBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'vertical split', 'vertical sbuffer') +endf + + +" function! tlib#qfl#AgentOpenBuffer(world, selected) "{{{3 +" endf + + +function! tlib#qfl#AgentEditLine(world, selected) "{{{3 + call a:world.CloseScratch() + let cmd = 'call tlib#qfl#EditLine(".")' + return tlib#qfl#RunCmdOnSelected(a:world, a:selected, cmd) + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#qfl#EditLine(lnum) "{{{3 + call inputsave() + let line = input('', getline(a:lnum)) + call inputrestore() + if !empty(line) + call setline(line(a:lnum), line) + endif +endf + + +function! tlib#qfl#SetFollowCursor(world, selected) "{{{3 + if empty(a:world.follow_cursor) + let a:world.follow_cursor = 'tlib#qfl#AgentPreviewQFE' + else + let a:world.follow_cursor = '' + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#qfl#QflList(list, ...) abort "{{{3 + TVarArg ['world_dict', {}], ['anyway', 0], ['suspended', 0] + Tlibtrace 'tlib', world_dict, anyway, suspended + " TLogVAR a:list, world_dict, anyway, suspended + if !anyway && empty(a:list) + return + endif + let world = copy(g:tlib#qfl#world) + if !empty(world_dict) + let world = tlib#eval#Extend(world, world_dict) + endif + " TLogVAR world + let world = tlib#World#New(world) + " echom "DBG world" string(sort(keys(world))) + let world.data = copy(a:list) + if !has_key(world, 'format_data') + let world.format_data = 'tlib#qfl#FormatQFLE' + endif + " TLogVAR world + " TLogVAR world.data + " call s:FormatBase(world) + " TLogVAR world.base + return tlib#input#ListW(world, suspended ? 'hibernate' : '') +endf + + +function! tlib#qfl#Browse(...) abort "{{{3 + let list = getqflist() + return call(function('tlib#qfl#QflList'), [list] + a:000) +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/rx.vim b/sources_non_forked/tlib/autoload/tlib/rx.vim new file mode 100644 index 00000000..83899838 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/rx.vim @@ -0,0 +1,60 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 113 + + +" :def: function! tlib#rx#Escape(text, ?magic='m') +" magic can be one of: m, M, v, V +" See :help 'magic' +function! tlib#rx#Escape(text, ...) "{{{3 + TVarArg 'magic' + if empty(magic) + let magic = 'm' + endif + if magic =~# '^\\\?m$' + return escape(a:text, '^$.*\[]~') + elseif magic =~# '^\\\?M$' + return escape(a:text, '^$\') + elseif magic =~# '^\\\?V$' + return escape(a:text, '\') + elseif magic =~# '^\\\?v$' + return substitute(a:text, '[^0-9a-zA-Z_]', '\\&', 'g') + else + echoerr 'tlib: Unsupported magic type' + return a:text + endif +endf + +" :def: function! tlib#rx#EscapeReplace(text, ?magic='m') +" Escape return |sub-replace-special|. +function! tlib#rx#EscapeReplace(text, ...) "{{{3 + TVarArg ['magic', 'm'] + if magic ==# 'm' || magic ==# 'v' + return escape(a:text, '\&~') + elseif magic ==# 'M' || magic ==# 'V' + return escape(a:text, '\') + else + echoerr 'magic must be one of: m, v, M, V' + endif +endf + + +function! tlib#rx#Suffixes(...) "{{{3 + TVarArg ['magic', 'm'] + let sfx = split(&suffixes, ',') + call map(sfx, 'tlib#rx#Escape(v:val, magic)') + if magic ==# 'v' + return '('. join(sfx, '|') .')$' + elseif magic ==# 'V' + return '\('. join(sfx, '\|') .'\)\$' + else + return '\('. join(sfx, '\|') .'\)$' + endif +endf + + +function! tlib#rx#LooksLikeRegexp(text) abort "{{{3 + return a:text =~ '[.?*+{}\[\]]' +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/scratch.vim b/sources_non_forked/tlib/autoload/tlib/scratch.vim new file mode 100644 index 00000000..c9df64d3 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/scratch.vim @@ -0,0 +1,136 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 255 + + +" Scratch window position. By default the list window is opened on the +" bottom. Set this variable to 'topleft' or '' to change this behaviour. +" See |tlib#input#List()|. +TLet g:tlib_scratch_pos = 'botright' + +" If you want the scratch buffer to be fully removed, you might want to +" set this variable to 'wipe'. +" See also https://github.com/tomtom/tlib_vim/pull/16 +TLet g:tlib#scratch#hidden = 'hide' + + +" :def: function! tlib#scratch#UseScratch(?keyargs={}) +" Display a scratch buffer (a buffer with no file). See :TScratch for an +" example. +" Return the scratch buffer's number. +" Values for keyargs: +" scratch_split ... 1: split, 0: window, -1: tab +function! tlib#scratch#UseScratch(...) "{{{3 + exec tlib#arg#Let([['keyargs', {}]]) + " TLogDBG string(keys(keyargs)) + let id = get(keyargs, 'scratch', '__Scratch__') + " TLogVAR id, bufwinnr(id) + " TLogVAR bufnr(id), bufname(id) + " TLogVAR 1, winnr(), bufnr('%'), bufname("%") + if bufwinnr(id) != -1 + " echom 'DBG noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' + exec 'noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' + " TLogVAR "reuse", bufnr("%"), bufname("%") + else + let winpos = '' + let bn = bufnr(id) + let wpos = get(keyargs, 'scratch_pos', g:tlib_scratch_pos) + " TLogVAR keyargs.scratch_vertical + if get(keyargs, 'scratch_vertical') + let wpos .= ' vertical' + let winpos = tlib#fixes#Winpos() + endif + " TLogVAR wpos + let scratch_split = get(keyargs, 'scratch_split', 1) + if bn != -1 + " TLogVAR bn + let wn = bufwinnr(bn) + if wn != -1 + " TLogVAR wn + exec 'noautocmd keepalt keepj' (wn .'wincmd w') + else + if scratch_split == 1 + let cmd = wpos.' sbuffer!' + elseif scratch_split == -1 + let cmd = wpos.' tab sbuffer!' + else + let cmd = 'buffer!' + endif + " TLogVAR cmd, bn + silent exec 'noautocmd keepalt keepj' cmd bn + endif + else + " TLogVAR id + if scratch_split == 1 + let cmd = wpos.' split' + elseif scratch_split == -1 + let cmd = wpos.' tab split' + else + let cmd = 'edit' + endif + " TLogVAR cmd, id + silent exec 'noautocmd keepalt keepj' cmd escape(id, '%#\ ') + " silent exec 'split '. id + endif + let ft = get(keyargs, 'scratch_filetype', '') + " TLogVAR ft, winpos + if !empty(winpos) + exec winpos + endif + setlocal buftype=nofile + let &l:bufhidden = get(keyargs, 'scratch_hidden', g:tlib#scratch#hidden) + setlocal noswapfile + setlocal nobuflisted + setlocal foldmethod=manual + setlocal foldcolumn=0 + setlocal nospell + setlocal modifiable + setlocal noreadonly + " TLogVAR &ft, ft + if !empty(ft) + let &l:ft = ft + endif + endif + let keyargs.scratch = bufnr('%') + let keyargs.scratch_tabpagenr = tabpagenr() + let keyargs.scratch_winnr = winnr() + " TLogVAR 2, winnr(), bufnr('%'), bufname("%"), keyargs.scratch + return keyargs.scratch +endf + + +" Close a scratch buffer as defined in keyargs (usually a World). +" Return 1 if the scratch buffer is closed (or if it already was +" closed). +function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3 + TVarArg ['reset_scratch', 1] + let scratch = get(a:keyargs, 'scratch', '') + " TLogVAR scratch, reset_scratch + " TLogDBG string(tlib#win#List()) + if !empty(scratch) && winnr('$') > 1 + let wn = bufwinnr(scratch) + " TLogVAR wn + try + if wn != -1 + " TLogDBG winnr() + let wb = tlib#win#Set(wn) + let winpos = tlib#fixes#Winpos() + wincmd c + if get(a:keyargs, 'scratch_vertical') && !empty(winpos) + exec winpos + endif + " exec wb + " redraw + " TLogVAR winnr() + endif + return 1 + finally + if reset_scratch + let a:keyargs.scratch = '' + endif + endtry + endif + return 0 +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/signs.vim b/sources_non_forked/tlib/autoload/tlib/signs.vim new file mode 100644 index 00000000..16646807 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/signs.vim @@ -0,0 +1,103 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-03-12. +" @Last Change: 2011-03-10. +" @Revision: 0.0.45 + +let s:save_cpo = &cpo +set cpo&vim + + +let s:base = 2327 +let s:register = {} + + +" Clear all signs with name SIGN. +function! tlib#signs#ClearAll(sign) "{{{3 + " TLog a:sign + for bn in keys(s:register) + let idxs = keys(s:register) + call filter(idxs, 's:register[v:val].sign == a:sign') + " TLogVAR bns + for idx in idxs + exec 'sign unplace '. idx .' buffer='. s:register[idx].bn + call remove(s:register, idx) + endfor + endfor +endf + + +" Clear all signs with name SIGN in buffer BUFNR. +function! tlib#signs#ClearBuffer(sign, bufnr) "{{{3 + for bn in keys(s:register) + let idxs = keys(s:register) + call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == a:bufnr') + " TLogVAR bns + for idx in idxs + exec 'sign unplace '. idx .' buffer='. s:register[idx].bn + call remove(s:register, idx) + endfor + endfor +endf + + +" function! tlib#signs#Clear(sign, list) "{{{3 +" " TLogVAR a:sign +" let done = [] +" for item in a:list +" let bn = get(item, 'bufnr', -1) +" if index(done, bn) == -1 +" let idxs = keys(s:register) +" call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == bn') +" for idx in idxs +" exec 'sign unplace '. idx .' buffer='. s:register[idx].bn +" call remove(s:register, idx) +" endfor +" call add(done, bn) +" endif +" endfor +" endf + + +" Add signs for all locations in LIST. LIST must adhere with the +" quickfix list format (see |getqflist()|; only the fields lnum and +" bufnr are required). +" +" list:: a quickfix or location list +" sign:: a sign defined with |:sign-define| +function! tlib#signs#Mark(sign, list) "{{{3 + " TLogVAR a:sign + for item in a:list + let idx = s:SignId(item) + if idx >= 0 + let lnum = get(item, 'lnum', 0) + if lnum > 0 + let bn = get(item, 'bufnr') + exec ':sign place '. idx .' line='. lnum .' name='. a:sign .' buffer='. bn + let s:register[idx] = {'sign': a:sign, 'bn': bn} + endif + endif + endfor +endf + + +function! s:SignId(item) "{{{3 + " TLogVAR a:item + " let bn = bufnr('%') + let bn = get(a:item, 'bufnr', -1) + if bn == -1 + return -1 + else + let idx = s:base + bn * 500 + while has_key(s:register, idx) + let idx += 1 + endwh + return idx + endif +endf + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/string.vim b/sources_non_forked/tlib/autoload/tlib/string.vim new file mode 100644 index 00000000..e5f8943a --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/string.vim @@ -0,0 +1,158 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 121 + + +" :def: function! tlib#string#RemoveBackslashes(text, ?chars=' ') +" Remove backslashes from text (but only in front of the characters in +" chars). +function! tlib#string#RemoveBackslashes(text, ...) "{{{3 + exec tlib#arg#Get(1, 'chars', ' ') + " TLogVAR chars + let rv = substitute(a:text, '\\\(['. chars .']\)', '\1', 'g') + return rv +endf + + +" :display: tlib#string#Chomp(string, ?max=0) +function! tlib#string#Chomp(string, ...) "{{{3 + let quant = a:0 >= 1 ? '\{,'. a:1 .'}' : '\+' + return substitute(a:string, '[[:cntrl:][:space:]]'. quant .'$', '', '') +endf + + +function! tlib#string#Format(template, dict) "{{{3 + let parts = split(a:template, '\ze%\({.\{-}}\|.\)') + let out = [] + for part in parts + let ml = matchlist(part, '^%\({\(.\{-}\)}\|\(.\)\)\(.*\)$') + if empty(ml) + let rest = part + else + let var = empty(ml[2]) ? ml[3] : ml[2] + let rest = ml[4] + if has_key(a:dict, var) + call add(out, a:dict[var]) + elseif var == '%%' + call add(out, '%') + else + call add(out, ml[1]) + endif + endif + call add(out, rest) + endfor + return join(out, '') +endf + + +" This function deviates from |printf()| in certain ways. +" Additional items: +" %{rx} ... insert escaped regexp +" %{fuzzyrx} ... insert typo-tolerant regexp +function! tlib#string#Printf1(format, string) "{{{3 + let s = split(a:format, '%.\zs') + " TLogVAR s + return join(map(s, 's:PrintFormat(v:val, a:string)'), '') +endf + +function! s:PrintFormat(format, string) "{{{3 + let cut = match(a:format, '%\({.\{-}}\|.\)$') + if cut == -1 + return a:format + else + let head = cut > 0 ? a:format[0 : cut - 1] : '' + let tail = a:format[cut : -1] + " TLogVAR head, tail + if tail == '%{fuzzyrx}' + let frx = [] + for i in range(len(a:string)) + if i > 0 + let pb = i - 1 + else + let pb = 0 + endif + let slice = tlib#rx#Escape(a:string[pb : i + 1]) + call add(frx, '['. slice .']') + call add(frx, '.\?') + endfor + let tail = join(frx, '') + elseif tail == '%{rx}' + let tail = tlib#rx#Escape(a:string) + elseif tail == '%%' + let tail = '%' + elseif tail == '%s' + let tail = a:string + endif + " TLogVAR tail + return head . tail + endif +endf +" function! tlib#string#Printf1(format, string) "{{{3 +" let n = len(split(a:format, '%\@ 0 +" let pb = i - 1 +" else +" let pb = 0 +" endif +" let slice = tlib#rx#Escape(a:string[pb : i + 1]) +" call add(frx, '['. slice .']') +" call add(frx, '.\?') +" endfor +" let f = s:RewriteFormatString(f, '%{fuzzyrx}', join(frx, '')) +" endif +" if f =~ '%\@= 1 ? a:1 : ',\s*' + let parts = split(a:text, '\\\@= 1 ? a:1 : !g:tlib#sys#windows + if !executable && !ignore_cyg + let executable = tlib#sys#IsCygwinBin(a:cmd) + " TLogVAR 2, executable + endif + let s:executables[a:cmd] = executable + endif + " echom "DBG s:executables[a:cmd]" s:executables[a:cmd] + return s:executables[a:cmd] +endf + + +if !exists('g:tlib#sys#check_cygpath') + " If true, check whether we have to convert a path via cyppath -- + " see |tlib#sys#MaybeUseCygpath| + let g:tlib#sys#check_cygpath = g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1) "{{{2 +endif + + +if !exists('g:tlib#sys#cygwin_path_rx') + " If a full windows filename (with slashes instead of backslashes) + " matches this |regexp|, it is assumed to be a cygwin executable. + let g:tlib#sys#cygwin_path_rx = '/cygwin/' "{{{2 +endif + + +if !exists('g:tlib#sys#cygwin_expr') + " For cygwin binaries, convert command calls using this vim + " expression. + let g:tlib#sys#cygwin_expr = '"bash -c ''". escape(%s, "''\\") ."''"' "{{{2 +endif + + +function! tlib#sys#GetCmd(cmd) "{{{3 + if !empty(g:tlib#sys#cygwin_expr) && tlib#sys#IsCygwinBin(matchstr(a:cmd, '^\S\+')) + let cmd = eval(printf(g:tlib#sys#cygwin_expr, string(a:cmd))) + " TLogVAR cmd + return cmd + else + return a:cmd + endif +endf + + +" If cmd seems to be a cygwin executable, use cygpath to convert +" filenames. This assumes that cygwin's which command returns full +" filenames for non-cygwin executables. +function! tlib#sys#MaybeUseCygpath(cmd) "{{{3 + " echom "DBG" a:cmd + if g:tlib#sys#check_cygpath && tlib#sys#IsCygwinBin(a:cmd) + return 'cygpath -u "%s"' + endif + return '' +endf + + +function! tlib#sys#ConvertPath(converter, filename) "{{{3 + return tlib#string#Chomp(system(printf(a:converter, shellescape(a:filename)))) +endf + + +let s:native_filenames = {} + +function! tlib#sys#FileArgs(cmd, files) "{{{3 + let cygpath = tlib#sys#MaybeUseCygpath(a:cmd) + " TLogVAR cygpath + if empty(cygpath) + return a:files + else + let files = map(copy(a:files), 'has_key(s:native_filenames, v:val) ? s:native_filenames[v:val] : tlib#sys#CygPath(v:val)') + return files + endif +endf + + +" Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it +" is a special file that should not be opened in vim. +function! tlib#sys#IsSpecial(filename) abort "{{{3 + return a:filename =~ g:tlib#sys#system_rx +endf + + +" Open filename with the default OS application (see +" |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. +" Returns 1 if successful or 0 otherwise. +function! tlib#sys#Open(filename) abort "{{{3 + Tlibtrace 'tlib', a:filename + if !empty(g:tlib#sys#system_browser) && tlib#sys#IsSpecial(a:filename) + try + let cmd = printf(g:tlib#sys#system_browser, escape(a:filename, ' %#!')) + Tlibtrace 'tlib', cmd + exec cmd + return 1 + catch + echohl ErrorMsg + echom v:exception + echohl NONE + endtry + endif + return 0 +endf + + +" :def: function! tlib#sys#SystemInDir(dir, expr, ?input='') +function! tlib#sys#SystemInDir(dir, ...) abort "{{{3 + call tlib#dir#CD(a:dir) + try + return call(function('system'), a:000) + finally + cd! - + endtry +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/tab.vim b/sources_non_forked/tlib/autoload/tlib/tab.vim new file mode 100644 index 00000000..fa6bb8d0 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/tab.vim @@ -0,0 +1,49 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 31 + + +" Return a dictionary of bufnumbers => [[tabpage, winnr] ...] +function! tlib#tab#BufMap() "{{{3 + let acc = {} + for t in range(tabpagenr('$')) + let bb = tabpagebuflist(t + 1) + for b in range(len(bb)) + let bn = bb[b] + let bd = [t + 1, b + 1] + if has_key(acc, bn) + call add(acc[bn], bd) + else + let acc[bn] = [bd] + endif + endfor + endfor + return acc +endf + + +" Find a buffer's window at some tab page. +function! tlib#tab#TabWinNr(buffer) "{{{3 + let bn = bufnr(a:buffer) + let bt = tlib#tab#BufMap() + let tn = tabpagenr() + let wn = winnr() + let bc = get(bt, bn) + if !empty(bc) + for [t, w] in bc + if t == tn + return [t, w] + endif + endfor + return bc[0] + endif +endf + + +function! tlib#tab#Set(tabnr) "{{{3 + if a:tabnr > 0 + exec a:tabnr .'tabnext' + endif +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/tag.vim b/sources_non_forked/tlib/autoload/tlib/tag.vim new file mode 100644 index 00000000..e4239d37 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/tag.vim @@ -0,0 +1,132 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 59 + + +" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. +TLet g:tlib_tags_extra = '' + +" Filter the tag description through |substitute()| for these filetypes. +" This applies only if the tag cmd field (see |taglist()|) is used. +" :nodefault: +TLet g:tlib_tag_substitute = { + \ 'java': [['\s*{\s*$', '', '']], + \ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']], + \ 'vim': [ + \ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''], + \ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''], + \ ['"\?\s*{{{\d.*$', '', ''], + \ ], + \ } + + +" :def: function! tlib#tag#Retrieve(rx, ?extra_tags=0) +" Get all tags matching rx. Basically, this function simply calls +" |taglist()|, but when extra_tags is true, the list of the tag files +" (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. +" +" Example use: +" If you want to include tags for, eg, JDK, normal tags use can become +" slow. You could proceed as follows: +" 1. Create a tags file for the JDK sources. When creating the tags +" file, make sure to include inheritance information and the like +" (command-line options like --fields=+iaSm --extra=+q should be ok). +" In this example, we want tags only for public methods (there are +" most likely better ways to do this): > +" ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src +" head -n 6 tags > tags0 +" grep access:public tags >> tags0 +" < 2. Make 'tags' include project specific tags files. In +" ~/vimfiles/after/ftplugin/java.vim insert: > +" let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +" < 3. When this function is invoked as > +" echo tlib#tag#Retrieve('print') +" < it will return only project-local tags. If it is invoked as > +" echo tlib#tag#Retrieve('print', 1) +" < tags from the JDK will be included. +function! tlib#tag#Retrieve(rx, ...) "{{{3 + TVarArg ['extra_tags', 0] + " TLogVAR a:rx, extra_tags + if extra_tags + let tags_orig = &l:tags + if empty(tags_orig) + setlocal tags< + endif + try + let more_tags = tlib#var#Get('tlib_tags_extra', 'bg') + if !empty(more_tags) + let &l:tags .= ','. more_tags + endif + let taglist = taglist(a:rx) + finally + let &l:tags = tags_orig + endtry + else + let taglist = taglist(a:rx) + endif + return taglist +endf + + +" Retrieve tags that meet the constraints (a dictionnary of fields and +" regexp, with the exception of the kind field which is a list of chars). +" For the use of the optional use_extra argument see +" |tlib#tag#Retrieve()|. +" :def: function! tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) +function! tlib#tag#Collect(constraints, ...) "{{{3 + TVarArg ['use_extra', 0], ['match_end', 1], ['match_front', 1] + " TLogVAR a:constraints, use_extra + let rx = get(a:constraints, 'name', '') + if empty(rx) || rx == '*' + let rx = '.' + else + let rxl = ['\C'] + if match_front + call add(rxl, '^') + endif + " call add(rxl, tlib#rx#Escape(rx)) + call add(rxl, rx) + if match_end + call add(rxl, '$') + endif + let rx = join(rxl, '') + endif + " TLogVAR rx, use_extra + let tags = tlib#tag#Retrieve(rx, use_extra) + " TLogDBG len(tags) + for [field, rx] in items(a:constraints) + if !empty(rx) && rx != '*' + " TLogVAR field, rx + if field == 'kind' + call filter(tags, 'v:val.kind =~ "['. rx .']"') + elseif field != 'name' + call filter(tags, '!empty(get(v:val, field)) && get(v:val, field) =~ rx') + endif + endif + endfor + " TLogVAR tags + return tags +endf + + +function! tlib#tag#Format(tag) "{{{3 + if has_key(a:tag, 'signature') + let name = a:tag.name . a:tag.signature + elseif a:tag.cmd[0] == '/' + let name = a:tag.cmd + let name = substitute(name, '^/\^\?\s*', '', '') + let name = substitute(name, '\s*\$\?/$', '', '') + let name = substitute(name, '\s\{2,}', ' ', 'g') + let tsub = tlib#var#Get('tlib_tag_substitute', 'bg') + if has_key(tsub, &filetype) + for [rx, rplc, sub] in tsub[&filetype] + let name = substitute(name, rx, rplc, sub) + endfor + endif + else + let name = a:tag.name + endif + return name +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/textobjects.vim b/sources_non_forked/tlib/autoload/tlib/textobjects.vim new file mode 100644 index 00000000..fb4170e5 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/textobjects.vim @@ -0,0 +1,45 @@ +" textobjects.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-01-09. +" @Last Change: 2010-01-10. +" @Revision: 0.0.29 + +let s:save_cpo = &cpo +set cpo&vim + + +" :tag: standard-paragraph +" Select a "Standard Paragraph", i.e. a text block followed by blank +" lines. Other than |ap|, the last paragraph in a document is handled +" just the same. +" +" The |text-object| can be accessed as "sp". Example: > +" +" vsp ... select the current standard paragraph +" +" Return 1, if the paragraph is the last one in the document. +function! tlib#textobjects#StandardParagraph() "{{{3 + if line("'}") == line('$') + norm! vip + return 1 + else + norm! vap + return 0 + endif +endf + + +function! tlib#textobjects#Init() "{{{3 + if !exists('s:tlib_done_textobjects') + " sp ... Standard paragraph (for use as |text-objects|). + vnoremap sp :call tlib#textobjects#StandardParagraph() + onoremap sp :normal Vsp + let s:tlib_done_textobjects = 1 + endif +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/time.vim b/sources_non_forked/tlib/autoload/tlib/time.vim new file mode 100644 index 00000000..2273d555 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/time.vim @@ -0,0 +1,67 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 36 + + +function! tlib#time#MSecs() "{{{3 + let rts = reltimestr(reltime()) + return substitute(rts, '\.', '', '') +endf + + +function! tlib#time#Now() "{{{3 + if has('reltime') + let rts = reltimestr(reltime()) + let rtl = map(split(rts, '\.'), 'str2nr(v:val)') + else + let rtl = [localtime()] + endif + return rtl +endf + + +function! tlib#time#FormatNow() "{{{3 + let rtl = tlib#time#Now() + if len(rtl) == 2 + let rts = strftime(g:tlib#date#date_format .' %H:%M:%S', rtl[0]) .'.'. rtl[1] + else + let rts = strftime(g:tlib#date#date_format .' %H:%M:%S', rtl[0]) + endif + return rts +endf + + +function! tlib#time#Diff(a, b, ...) "{{{3 + TVarArg ['resolution', 2] + let [as, am] = a:a + let [bs, bm] = a:b + let rv = 0 + (as - bs) + if resolution > 0 + let rv .= repeat('0', resolution) + let am = am[0 : resolution - 1] + let bm = bm[0 : resolution - 1] + let rv += (am - bm) + endif + return rv +endf + + +function! tlib#time#DiffMSecs(a, b, ...) "{{{3 + TVarArg ['resolution', 2] + if a:a == a:b + return 0 + endif + let a = printf('%30s', a:a[0 : -(7 - resolution)]) + let b = printf('%30s', a:b[0 : -(7 - resolution)]) + for i in range(0, 29) + if a[i] != b[i] + let a = a[i : -1] + let b = b[i : -1] + return a - b + endif + endfor + return 0 +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/trace.vim b/sources_non_forked/tlib/autoload/tlib/trace.vim new file mode 100644 index 00000000..0a98d1e9 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/trace.vim @@ -0,0 +1,117 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-11-23 +" @Revision: 134 + + +if !exists('g:tlib#trace#backtrace') + " The length of the backtrace that should be included in + " |tlib#trace#Print()|. + let g:tlib#trace#backtrace = 2 "{{{2 +endif + + +if !exists('g:tlib#trace#printf') + " The command used for printing traces from |tlib#trace#Print()|. + let g:tlib#trace#printf = 'echom %s' "{{{2 +endif + + +let s:trace_hl = {'error': 'ErrorMsg', 'fatal': 'ErrorMsg', 'warning': 'WarningMsg'} + + +" Set |g:tlib#trace#printf| to make |tlib#trace#Print()| print to +" `filename`. +function! tlib#trace#PrintToFile(filename) abort "{{{3 + let g:tlib#trace#printf = 'call writefile([%s], '. string(a:filename) .', "a")' +endf + + +" Set the tracing |regexp|. See |:Tlibtrace|. +" This will also call |tlib#trace#Enable()|. +" +" Examples: +" call tlib#trace#Set(["+foo", "-bar"]) +" call tlib#trace#Set("+foo,-bar") +function! tlib#trace#Set(vars) abort "{{{3 + call tlib#trace#Enable() + if type(a:vars) == 1 + let vars = tlib#string#SplitCommaList(a:vars, '[,[:space:]]\+') + else + let vars = a:vars + endif + for rx in vars + let rx1 = substitute(rx, '^[+-]', '', 'g') + if rx1 !~# '^\%(error\|fatal\)$' && s:trace_rx !~# '[(|]'. tlib#rx#Escape(rx1) .'\\' + " TLogVAR rx, rx1 + if rx =~ '^+' + let s:trace_rx = substitute(s:trace_rx, '\ze\\)\$', '\\|'. tlib#rx#EscapeReplace(rx1), '') + elseif rx =~ '^-' + let s:trace_rx = substitute(s:trace_rx, '\\|'. tlib#rx#Escape(rx1), '', '') + else + echohl WarningMsg + echom 'tlib#trace#Print: Unsupported syntax:' rx + echohl NONE + endif + endif + endfor + echom "SetTrace:" s:trace_rx +endf + + +function! tlib#trace#Backtrace(caller) abort "{{{3 + let caller = split(a:caller, '\.\.') + let start = max([0, len(caller) - g:tlib#trace#backtrace - 1]) + let caller = caller[start : -1] + return join(caller, '..') +endf + + +" Print the values of vars. The first value is a "guard" (see +" |:Tlibtrace|). +function! tlib#trace#Print(caller, vars, values) abort "{{{3 + let msg = ['TRACE'] + let guard = a:values[0] + if type(guard) == 0 + let cond = guard + else + let cond = guard =~# s:trace_rx + endif + " TLogVAR guard, cond, a:vars, a:values + if cond + call add(msg, guard) + call add(msg, tlib#time#FormatNow() .':') + if g:tlib#trace#backtrace > 0 + let bt = tlib#trace#Backtrace(a:caller) + if !empty(bt) + call add(msg, bt .':') + endif + endif + for i in range(1, len(a:vars) - 1) + let v = substitute(a:vars[i], ',$', '', '') + let r = string(a:values[i]) + call add(msg, v .'='. r .';') + endfor + exec printf(g:tlib#trace#printf, string(join(msg))) + endif +endf + + +" Enable tracing via |:Tlibtrace|. +function! tlib#trace#Enable() abort "{{{3 + if !exists('s:trace_rx') + let s:trace_rx = '^\%(error\)$' + " :nodoc: + command! -nargs=+ -bar Tlibtrace call tlib#trace#Print(expand(''), [], []) + endif +endf + + +" Disable tracing via |:Tlibtrace|. +function! tlib#trace#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bang -bar Tlibtrace : + unlet! s:trace_rx +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/type.vim b/sources_non_forked/tlib/autoload/tlib/type.vim new file mode 100644 index 00000000..455343f9 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/type.vim @@ -0,0 +1,71 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-09-30. +" @Last Change: 2015-11-23. +" @Revision: 6 + + +function! tlib#type#IsNumber(expr) + return tlib#type#Is(a:expr, 0) +endf + + +function! tlib#type#IsString(expr) + return tlib#type#Is(a:expr, 1) +endf + + +function! tlib#type#IsFuncref(expr) + return tlib#type#Is(a:expr, 2) +endf + + +function! tlib#type#IsList(expr) + return tlib#type#Is(a:expr, 3) +endf + + +function! tlib#type#IsDictionary(expr) + return tlib#type#Is(a:expr, 4) +endf + + +function! tlib#type#Is(val, type) abort "{{{3 + if type(a:type) == 0 + let type = a:type + elseif a:type =~? '^n\%[umber]' + let type = 0 + elseif a:type =~? '^s\%[tring]' + let type = 1 + elseif a:type =~? '^fu\%[ncref]' + let type = 2 + elseif a:type =~? '^l\%[ist]' + let type = 3 + elseif a:type =~? '^d\%[ictionary]' + let type = 4 + elseif a:type =~? '^fl\%[oat]' + let type = 5 + else + throw 'tlib#type#Is: Unknown type: ' a:type + endif + " TLogVAR a:val, a:type, type, type(a:val), type(a:val) == a:type + return type(a:val) == type +endf + + +function! tlib#type#Are(vals, type) abort "{{{3 + return tlib#assert#Map(a:vals, 'tlib#type#Is(v:val,'. string(a:type) .')') +endf + + +function! tlib#type#Has(val, lst) abort "{{{3 + return tlib#assert#All(map(a:lst, 'has_key(a:val, v:val)')) +endf + + +function! tlib#type#Have(vals, lst) abort "{{{3 + return tlib#assert#Map(a:vals, 'tlib#type#Has(v:val,'. string(a:lst) .')') +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/url.vim b/sources_non_forked/tlib/autoload/tlib/url.vim new file mode 100644 index 00000000..b948d48a --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/url.vim @@ -0,0 +1,52 @@ +" url.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2011-03-10. +" @Revision: 0.0.28 + + +" TODO: These functions could use printf() now. + +" Decode an encoded URL. +function! tlib#url#Decode(url) "{{{3 + return substitute(a:url, '\(+\|%\(%\|\x\x\)\)', '\=tlib#url#DecodeChar(submatch(1))', 'g') +endf + + +" Decode a single character. +function! tlib#url#DecodeChar(char) "{{{3 + if a:char == '%%' + return '%' + elseif a:char == '+' + return ' ' + else + return nr2char("0x".a:char[1 : -1]) + endif +endf + + +" Encode a single character. +function! tlib#url#EncodeChar(char) "{{{3 + if a:char == '%' + return '%%' + elseif a:char == ' ' + return '+' + else + return printf("%%%X", char2nr(a:char)) + endif +endf + + +" Encode an URL. +function! tlib#url#Encode(url, ...) "{{{3 + TVarArg ['extrachars', ''] + let rx = '\([^a-zA-Z0-9_.'. extrachars .'-]\)' + " TLogVAR a:url, rx + let rv = substitute(a:url, rx, '\=tlib#url#EncodeChar(submatch(1))', 'g') + " TLogVAR rv + return rv +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/var.vim b/sources_non_forked/tlib/autoload/tlib/var.vim new file mode 100644 index 00000000..dcd9264b --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/var.vim @@ -0,0 +1,83 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 30 + + +" Define a variable called NAME if yet undefined. +" You can also use the :TLLet command. +" +" EXAMPLES: > +" exec tlib#var#Let('g:foo', 1) +" TLet g:foo = 1 +function! tlib#var#Let(name, val) "{{{3 + return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, string(a:val)) + " return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, a:val) +endf + + +" :def: function! tlib#var#EGet(var, namespace, ?default='') +" Retrieve a variable by searching several namespaces. +" +" EXAMPLES: > +" let g:foo = 1 +" let b:foo = 2 +" let w:foo = 3 +" echo eval(tlib#var#EGet('foo', 'vg')) => 1 +" echo eval(tlib#var#EGet('foo', 'bg')) => 2 +" echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +function! tlib#var#EGet(var, namespace, ...) "{{{3 + let pre = [] + let post = [] + for namespace in split(a:namespace, '\zs') + let var = namespace .':'. a:var + call add(pre, printf('exists("%s") ? %s : (', var, var)) + call add(post, ')') + endfor + let default = a:0 >= 1 ? a:1 : '' + return join(pre) . string(default) . join(post) +endf + + +" :def: function! tlib#var#Get(var, namespace, ?default='') +" Retrieve a variable by searching several namespaces. +" +" EXAMPLES: > +" let g:foo = 1 +" let b:foo = 2 +" let w:foo = 3 +" echo tlib#var#Get('foo', 'bg') => 1 +" echo tlib#var#Get('foo', 'bg') => 2 +" echo tlib#var#Get('foo', 'wbg') => 3 +function! tlib#var#Get(var, namespace, ...) "{{{3 + let var_ = substitute(a:var, '#', '_', 'g') + for namespace in split(a:namespace, '\zs') + let vname = namespace == 'g' ? a:var : var_ + let var = namespace .':'. vname + if exists(var) + return {var} + endif + endfor + return a:0 >= 1 ? a:1 : '' +endf + + +" :def: function! tlib#var#List(rx, ?prefix='') +" Get a list of variables matching rx. +" EXAMPLE: +" echo tlib#var#List('tlib_', 'g:') +function! tlib#var#List(rx, ...) "{{{3 + TVarArg ['prefix', 'g:'] + if v:version >= 704 + exec 'let varlist = keys('. prefix .')' + else + redir => vars + silent! exec 'let '. prefix + redir END + let varlist = split(vars, '\n') + call map(varlist, 'matchstr(v:val, ''^\S\+'')') + endif + call filter(varlist, 'v:val =~ a:rx') + return varlist +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/vcs.vim b/sources_non_forked/tlib/autoload/tlib/vcs.vim new file mode 100644 index 00000000..15d051fa --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/vcs.vim @@ -0,0 +1,189 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-03-08. +" @Last Change: 2015-11-07. +" @Revision: 190 + +scriptencoding utf-8 + + +" A dictionarie of supported VCS (currently: git, hg, svn, bzr). +" :display: g:tlib#vcs#def {...} +TLet g:tlib#vcs#def = { + \ 'git': { + \ 'dir': '.git', + \ 'ls': 'git ls-files --full-name', + \ 'ls.postprocess': '*tlib#vcs#GitLsPostprocess', + \ 'diff': 'git diff --no-ext-diff -U0 %s' + \ }, + \ 'hg': { + \ 'dir': '.hg', + \ 'diff': 'hg diff -U0 %s', + \ 'ls': 'hg manifest' + \ }, + \ 'svn': { + \ 'dir': '.svn', + \ 'diff': 'svn diff --diff-cmd diff --extensions -U0 %s', + \ }, + \ 'bzr': { + \ 'dir': '.bzr', + \ 'diff': 'bzr diff --diff-options=-U0 %s', + \ } + \ } + + +" A dictionary of custom executables for VCS commands. If the value is +" empty, support for that VCS will be removed. If no key is present, it +" is assumed that the VCS "type" is the name of the executable. +" :display: g:tlib#vcs#executables {...} +TLet g:tlib#vcs#executables = {} + + +" If non-empty, use it as a format string to check whether a VCS is +" installed on your computer. +TLet g:tlib#vcs#check = has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s' + + +if !empty(g:tlib#vcs#check) + for [s:cmd, s:def] in items(g:tlib#vcs#def) + if !has_key(g:tlib#vcs#executables, s:cmd) + let s:cmd1 = printf(g:tlib#vcs#check, s:cmd) + let g:tlib#vcs#executables[s:cmd] = executable(s:cmd1) ? s:cmd1 : '' + endif + endfor + unlet! s:cmd s:def s:cmd1 +endif + + +function! tlib#vcs#Executable(type) "{{{3 + return get(g:tlib#vcs#executables, a:type, '') +endf + + +function! tlib#vcs#FindVCS(filename) "{{{3 + let type = '' + let dir = '' + let dirname = fnamemodify(a:filename, isdirectory(a:filename) ? ':p' : ':p:h') + let path = escape(dirname, ';') .';' + " TLogVAR a:filename, dirname, path + Tlibtrace 'tlib', a:filename, path + let depth = -1 + for vcs in keys(g:tlib#vcs#def) + let subdir = g:tlib#vcs#def[vcs].dir + let vcsdir = finddir(subdir, path) + " TLogVAR vcs, subdir, vcsdir + Tlibtrace 'tlib', vcs, subdir, vcsdir + if !empty(vcsdir) + let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/')) + if vcsdir_depth > depth + let depth = vcsdir_depth + let type = vcs + let dir = vcsdir + " TLogVAR type, depth + endif + endif + endfor + Tlibtrace 'tlib', type, dir + " TLogVAR type, dir + if empty(type) + return ['', ''] + else + return [type, dir] + endif +endf + + +function! s:GetCmd(vcstype, cmd) + let vcsdef = get(g:tlib#vcs#def, a:vcstype, {}) + if has_key(vcsdef, a:cmd) + let cmd = vcsdef[a:cmd] + if cmd =~ '^\*' + let cmd = substitute(cmd, '^\*', '', '') + else + let bin = get(g:tlib#vcs#executables, a:vcstype, '') + if empty(bin) + let cmd = '' + elseif bin != a:vcstype + " let bin = escape(shellescape(bin), '\') + let bin = escape(bin, '\') + let cmd = substitute(cmd, '^.\{-}\zs'. escape(a:vcstype, '\'), bin, '') + endif + endif + return cmd + else + return '' + endif +endf + + +" :display: tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) +" Return the files under VCS. +function! tlib#vcs#Ls(...) "{{{3 + if a:0 >= 2 + let vcs = a:2 + else + let vcs = tlib#vcs#FindVCS(a:0 >= 1 ? a:1 : bufname('%')) + endif + Tlibtrace 'tlib', vcs, a:000 + " TLogVAR vcs + if !empty(vcs) + let [vcstype, vcsdir] = vcs + if has_key(g:tlib#vcs#def, vcstype) + let ls = s:GetCmd(vcstype, 'ls') + " TLogVAR ls + if !empty(ls) + let rootdir = fnamemodify(vcsdir, ':p:h:h') + " TLogVAR vcsdir, rootdir + if ls =~ '%s' + let cmd = printf(ls, shellescape(rootdir)) + else + let cmd = ls + endif + " TLogVAR cmd, getcwd() + Tlibtrace 'tlib', getcwd(), vcstype, vcsdir, rootdir, cmd + let filess = tlib#sys#SystemInDir(rootdir, cmd) + " TLogVAR filess + let files = split(filess, '\n') + let postprocess = s:GetCmd(vcstype, 'ls.postprocess') + if !empty(postprocess) + call map(files, 'call(postprocess, [v:val])') + endif + call map(files, 'join([rootdir, v:val], "/")') + " TLogVAR files + return files + endif + endif + endif + return [] +endf + + +" :display: tlib#vcs#Diff(filename, ?vcs=[type, dir]) +" Return the diff for "filename" +function! tlib#vcs#Diff(filename, ...) "{{{3 + let vcs = a:0 >= 1 ? a:1 : tlib#vcs#FindVCS(a:filename) + if !empty(vcs) + let [vcstype, vcsdir] = vcs + let diff = s:GetCmd(vcstype, 'diff') + if !empty(diff) + let cmd = printf(diff, shellescape(fnamemodify(a:filename, ':p'))) + let patch = system(cmd) + return patch + endif + endif + return [] +endf + + +function! tlib#vcs#GitLsPostprocess(filename) abort "{{{3 + if a:filename =~ '^".\{-}"$' + let filename = matchstr(a:filename, '^"\zs.\{-}\ze"$') + let filename = substitute(filename, '\%(\\\@= 1 ? a:1 : 0 + redir => oldfn + exec 'silent function' a:old + redir END + if exists('*'. a:new) + if overwrite > 0 + exec 'delfunction' a:new + elseif overwrite < 0 + throw 'tlib#vim##CopyFunction: Function already exists: '. a:old .' -> '. a:new + else + return + endif + endif + let fn = split(oldfn, '\n') + let fn = map(fn, 'substitute(v:val, ''^\d\+'', "", "")') + let fn[0] = substitute(fn[0], '\V\^\s\*fu\%[nction]!\?\s\+\zs'. a:old, a:new, '') + let t = @t + try + let @t = join(fn, "\n") + redir => out + @t + redir END + finally + let @t = t + endtry +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/win.vim b/sources_non_forked/tlib/autoload/tlib/win.vim new file mode 100644 index 00000000..4963af15 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/win.vim @@ -0,0 +1,128 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 55 + + +" Return vim code to jump back to the original window. +function! tlib#win#Set(winnr) "{{{3 + if a:winnr > 0 + " TLogVAR a:winnr + " TLogDBG winnr() + " TLogDBG string(tlib#win#List()) + if winnr() != a:winnr && winbufnr(a:winnr) != -1 + let rv = winnr().'wincmd w' + exec a:winnr .'wincmd w' + " TLogVAR rv + " TLogDBG string(tlib#win#List()) + return rv + endif + endif + return '' +endf + + +" :def: function! tlib#win#GetLayout(?save_view=0) +function! tlib#win#GetLayout(...) "{{{3 + TVarArg ['save_view', 0] + let views = {} + if save_view + let winnr = winnr() + windo let views[winnr()] = winsaveview() + " for w in range(1, winnr('$')) + " call tlib#win#Set(w) + " let views[w] = winsaveview() + " endfor + call tlib#win#Set(winnr) + endif + return {'winnr': winnr('$'), 'winrestcmd': winrestcmd(), 'views': views, 'cmdheight': &cmdheight, 'guioptions': &guioptions, 'tabpagenr': tabpagenr()} +endf + + +function! tlib#win#SetLayout(layout) "{{{3 + if a:layout.tabpagenr == tabpagenr() && a:layout.winnr == winnr('$') + " TLogVAR a:layout.winrestcmd + " TLogDBG string(tlib#win#List()) + exec a:layout.winrestcmd + if !empty(a:layout.views) + let winnr = winnr() + " TLogVAR winnr + for [w, v] in items(a:layout.views) + " TLogVAR w, v + call tlib#win#Set(w) + call winrestview(v) + endfor + call tlib#win#Set(winnr) + endif + if a:layout.cmdheight != &cmdheight + let &cmdheight = a:layout.cmdheight + endif + " TLogDBG string(tlib#win#List()) + return 1 + endif + return 0 +endf + + +function! tlib#win#List() "{{{3 + let wl = {} + for wn in range(1, winnr('$')) + let wl[wn] = bufname(winbufnr(wn)) + endfor + return wl +endf + + +" " :def: function! tlib#win#GetLayout1(?save_view=0) +" " Contrary to |tlib#win#GetLayout|, this version doesn't use +" " |winrestcmd()|. It can also save windows views. +" function! tlib#win#GetLayout1(...) "{{{3 +" TVarArg ['save_view', 0] +" let winnr = winnr() +" let acc = {} +" for w in range(1, winnr('$')) +" let def = {'h': winheight(w), 'w': winwidth(w)} +" if save_view +" call tlib#win#Set(w) +" let def.view = winsaveview() +" endif +" let acc[w] = def +" endfor +" call tlib#win#Set(winnr) +" return acc +" endf +" +" +" " Reset layout from the value of |tlib#win#GetLayout1|. +" function! tlib#win#SetLayout1(layout) "{{{3 +" if len(a:layout) != winnr('$') +" return 0 +" endif +" let winnr = winnr() +" for [w, def] in items(a:layout) +" if tlib#win#Set(w) +" exec 'resize '. def.h +" exec 'vertical resize '. def.w +" if has_key(def, 'view') +" call winrestview(def.view) +" endif +" else +" break +" endif +" endfor +" call tlib#win#Set(winnr) +" return 1 +" endf + + +function! tlib#win#Width(wnr) "{{{3 + return winwidth(a:wnr) - &fdc +endf + + +function! tlib#win#WinDo(ex) "{{{3 + let w = winnr() + exec 'windo '. a:ex + exec w .'wincmd w' +endf + diff --git a/sources_non_forked/tlib/doc/tlib.txt b/sources_non_forked/tlib/doc/tlib.txt new file mode 100644 index 00000000..379dc549 --- /dev/null +++ b/sources_non_forked/tlib/doc/tlib.txt @@ -0,0 +1,2497 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Tom Link, micathom at gmail com + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +======================================================================== +Contents~ + + :TLet .................................. |:TLet| + :TScratch .............................. |:TScratch| + :TVarArg ............................... |:TVarArg| + :TBrowseOutput ......................... |:TBrowseOutput| + :TBrowseScriptnames .................... |:TBrowseScriptnames| + :Tlibtrace ............................. |:Tlibtrace| + :Tlibtraceset .......................... |:Tlibtraceset| + :Tlibassert ............................ |:Tlibassert| + Add .................................... |Add()| + TestGetArg ............................. |TestGetArg()| + TestGetArg1 ............................ |TestGetArg1()| + TestArgs ............................... |TestArgs()| + TestArgs1 .............................. |TestArgs1()| + TestArgs2 .............................. |TestArgs2()| + TestArgs3 .............................. |TestArgs3()| + g:tlib#debug ........................... |g:tlib#debug| + tlib#notify#Echo ....................... |tlib#notify#Echo()| + tlib#notify#TrimMessage ................ |tlib#notify#TrimMessage()| + g:tlib#trace#backtrace ................. |g:tlib#trace#backtrace| + g:tlib#trace#printf .................... |g:tlib#trace#printf| + tlib#trace#PrintToFile ................. |tlib#trace#PrintToFile()| + tlib#trace#Set ......................... |tlib#trace#Set()| + tlib#trace#Backtrace ................... |tlib#trace#Backtrace()| + tlib#trace#Print ....................... |tlib#trace#Print()| + tlib#trace#Enable ...................... |tlib#trace#Enable()| + tlib#trace#Disable ..................... |tlib#trace#Disable()| + tlib#dictionary#Rev .................... |tlib#dictionary#Rev()| + g:tlib_persistent ...................... |g:tlib_persistent| + tlib#persistent#Dir .................... |tlib#persistent#Dir()| + tlib#persistent#Filename ............... |tlib#persistent#Filename()| + tlib#persistent#Get .................... |tlib#persistent#Get()| + tlib#persistent#MTime .................. |tlib#persistent#MTime()| + tlib#persistent#Value .................. |tlib#persistent#Value()| + tlib#persistent#Save ................... |tlib#persistent#Save()| + g:tlib#vim#simalt_maximize ............. |g:tlib#vim#simalt_maximize| + g:tlib#vim#simalt_restore .............. |g:tlib#vim#simalt_restore| + g:tlib#vim#use_vimtweak ................ |g:tlib#vim#use_vimtweak| + tlib#vim#Maximize ...................... |tlib#vim#Maximize()| + tlib#vim#RestoreWindow ................. |tlib#vim#RestoreWindow()| + g:tlib#vim#use_wmctrl .................. |g:tlib#vim#use_wmctrl| + tlib#vim#CopyFunction .................. |tlib#vim#CopyFunction()| + tlib#progressbar#Init .................. |tlib#progressbar#Init()| + tlib#progressbar#Display ............... |tlib#progressbar#Display()| + tlib#progressbar#Restore ............... |tlib#progressbar#Restore()| + tlib#eval#FormatValue .................. |tlib#eval#FormatValue()| + tlib#eval#Extend ....................... |tlib#eval#Extend()| + tlib#list#Inject ....................... |tlib#list#Inject()| + tlib#list#Compact ...................... |tlib#list#Compact()| + tlib#list#Flatten ...................... |tlib#list#Flatten()| + tlib#list#FindAll ...................... |tlib#list#FindAll()| + tlib#list#Find ......................... |tlib#list#Find()| + tlib#list#Any .......................... |tlib#list#Any()| + tlib#list#All .......................... |tlib#list#All()| + tlib#list#Remove ....................... |tlib#list#Remove()| + tlib#list#RemoveAll .................... |tlib#list#RemoveAll()| + tlib#list#Zip .......................... |tlib#list#Zip()| + tlib#list#Uniq ......................... |tlib#list#Uniq()| + tlib#list#ToDictionary ................. |tlib#list#ToDictionary()| + tlib#cmd#OutputAsList .................. |tlib#cmd#OutputAsList()| + tlib#cmd#BrowseOutput .................. |tlib#cmd#BrowseOutput()| + tlib#cmd#BrowseOutputWithCallback ...... |tlib#cmd#BrowseOutputWithCallback()| + tlib#cmd#DefaultBrowseOutput ........... |tlib#cmd#DefaultBrowseOutput()| + tlib#cmd#ParseScriptname ............... |tlib#cmd#ParseScriptname()| + tlib#cmd#TBrowseScriptnames ............ |tlib#cmd#TBrowseScriptnames()| + tlib#cmd#UseVertical ................... |tlib#cmd#UseVertical()| + tlib#cmd#Time .......................... |tlib#cmd#Time()| + tlib#cmd#Capture ....................... |tlib#cmd#Capture()| + tlib#syntax#Collect .................... |tlib#syntax#Collect()| + tlib#syntax#Names ...................... |tlib#syntax#Names()| + tlib#balloon#Register .................. |tlib#balloon#Register()| + tlib#balloon#Remove .................... |tlib#balloon#Remove()| + tlib#balloon#Expr ...................... |tlib#balloon#Expr()| + tlib#balloon#Expand .................... |tlib#balloon#Expand()| + g:tlib#vcs#def ......................... |g:tlib#vcs#def| + g:tlib#vcs#executables ................. |g:tlib#vcs#executables| + g:tlib#vcs#check ....................... |g:tlib#vcs#check| + tlib#vcs#Executable .................... |tlib#vcs#Executable()| + tlib#vcs#FindVCS ....................... |tlib#vcs#FindVCS()| + tlib#vcs#Ls ............................ |tlib#vcs#Ls()| + tlib#vcs#Diff .......................... |tlib#vcs#Diff()| + tlib#vcs#GitLsPostprocess .............. |tlib#vcs#GitLsPostprocess()| + tlib#char#Get .......................... |tlib#char#Get()| + tlib#char#IsAvailable .................. |tlib#char#IsAvailable()| + tlib#char#GetWithTimeout ............... |tlib#char#GetWithTimeout()| + g:tlib#Filter_glob#seq ................. |g:tlib#Filter_glob#seq| + g:tlib#Filter_glob#char ................ |g:tlib#Filter_glob#char| + tlib#Filter_glob#New ................... |tlib#Filter_glob#New()| + g:tlib_scratch_pos ..................... |g:tlib_scratch_pos| + g:tlib#scratch#hidden .................. |g:tlib#scratch#hidden| + tlib#scratch#UseScratch ................ |tlib#scratch#UseScratch()| + tlib#scratch#CloseScratch .............. |tlib#scratch#CloseScratch()| + tlib#autocmdgroup#Init ................. |tlib#autocmdgroup#Init()| + g:tlib_cache ........................... |g:tlib_cache| + g:tlib#cache#purge_days ................ |g:tlib#cache#purge_days| + g:tlib#cache#purge_every_days .......... |g:tlib#cache#purge_every_days| + g:tlib#cache#script_encoding ........... |g:tlib#cache#script_encoding| + g:tlib#cache#run_script ................ |g:tlib#cache#run_script| + g:tlib#cache#verbosity ................. |g:tlib#cache#verbosity| + g:tlib#cache#dont_purge ................ |g:tlib#cache#dont_purge| + g:tlib#cache#max_filename .............. |g:tlib#cache#max_filename| + tlib#cache#Dir ......................... |tlib#cache#Dir()| + tlib#cache#Filename .................... |tlib#cache#Filename()| + tlib#cache#Save ........................ |tlib#cache#Save()| + tlib#cache#MTime ....................... |tlib#cache#MTime()| + tlib#cache#Get ......................... |tlib#cache#Get()| + tlib#cache#Value ....................... |tlib#cache#Value()| + tlib#cache#MaybePurge .................. |tlib#cache#MaybePurge()| + tlib#cache#Purge ....................... |tlib#cache#Purge()| + tlib#cache#ListFilesInCache ............ |tlib#cache#ListFilesInCache()| + tlib#normal#WithRegister ............... |tlib#normal#WithRegister()| + tlib#time#MSecs ........................ |tlib#time#MSecs()| + tlib#time#Now .......................... |tlib#time#Now()| + tlib#time#FormatNow .................... |tlib#time#FormatNow()| + tlib#time#Diff ......................... |tlib#time#Diff()| + tlib#time#DiffMSecs .................... |tlib#time#DiffMSecs()| + tlib#var#Let ........................... |tlib#var#Let()| + tlib#var#EGet .......................... |tlib#var#EGet()| + tlib#var#Get ........................... |tlib#var#Get()| + tlib#var#List .......................... |tlib#var#List()| + g:tlib_scroll_lines .................... |g:tlib_scroll_lines| + tlib#agent#Exit ........................ |tlib#agent#Exit()| + tlib#agent#CopyItems ................... |tlib#agent#CopyItems()| + tlib#agent#PageUp ...................... |tlib#agent#PageUp()| + tlib#agent#PageDown .................... |tlib#agent#PageDown()| + tlib#agent#Home ........................ |tlib#agent#Home()| + tlib#agent#End ......................... |tlib#agent#End()| + tlib#agent#Up .......................... |tlib#agent#Up()| + tlib#agent#Down ........................ |tlib#agent#Down()| + tlib#agent#UpN ......................... |tlib#agent#UpN()| + tlib#agent#DownN ....................... |tlib#agent#DownN()| + tlib#agent#ShiftLeft ................... |tlib#agent#ShiftLeft()| + tlib#agent#ShiftRight .................. |tlib#agent#ShiftRight()| + tlib#agent#Reset ....................... |tlib#agent#Reset()| + tlib#agent#ToggleRestrictView .......... |tlib#agent#ToggleRestrictView()| + tlib#agent#RestrictView ................ |tlib#agent#RestrictView()| + tlib#agent#UnrestrictView .............. |tlib#agent#UnrestrictView()| + tlib#agent#Input ....................... |tlib#agent#Input()| + tlib#agent#SuspendToParentWindow ....... |tlib#agent#SuspendToParentWindow()| + tlib#agent#Suspend ..................... |tlib#agent#Suspend()| + tlib#agent#Help ........................ |tlib#agent#Help()| + tlib#agent#OR .......................... |tlib#agent#OR()| + tlib#agent#AND ......................... |tlib#agent#AND()| + tlib#agent#ReduceFilter ................ |tlib#agent#ReduceFilter()| + tlib#agent#PopFilter ................... |tlib#agent#PopFilter()| + tlib#agent#Debug ....................... |tlib#agent#Debug()| + tlib#agent#Select ...................... |tlib#agent#Select()| + tlib#agent#SelectUp .................... |tlib#agent#SelectUp()| + tlib#agent#SelectDown .................. |tlib#agent#SelectDown()| + tlib#agent#SelectAll ................... |tlib#agent#SelectAll()| + tlib#agent#ToggleStickyList ............ |tlib#agent#ToggleStickyList()| + tlib#agent#EditItem .................... |tlib#agent#EditItem()| + tlib#agent#NewItem ..................... |tlib#agent#NewItem()| + tlib#agent#DeleteItems ................. |tlib#agent#DeleteItems()| + tlib#agent#Cut ......................... |tlib#agent#Cut()| + tlib#agent#Copy ........................ |tlib#agent#Copy()| + tlib#agent#Paste ....................... |tlib#agent#Paste()| + tlib#agent#EditReturnValue ............. |tlib#agent#EditReturnValue()| + tlib#agent#ViewFile .................... |tlib#agent#ViewFile()| + tlib#agent#EditFile .................... |tlib#agent#EditFile()| + tlib#agent#EditFileInSplit ............. |tlib#agent#EditFileInSplit()| + tlib#agent#EditFileInVSplit ............ |tlib#agent#EditFileInVSplit()| + tlib#agent#EditFileInTab ............... |tlib#agent#EditFileInTab()| + tlib#agent#ToggleScrollbind ............ |tlib#agent#ToggleScrollbind()| + tlib#agent#ShowInfo .................... |tlib#agent#ShowInfo()| + tlib#agent#PreviewLine ................. |tlib#agent#PreviewLine()| + tlib#agent#GotoLine .................... |tlib#agent#GotoLine()| + tlib#agent#DoAtLine .................... |tlib#agent#DoAtLine()| + tlib#agent#Wildcard .................... |tlib#agent#Wildcard()| + tlib#agent#Null ........................ |tlib#agent#Null()| + tlib#agent#ExecAgentByName ............. |tlib#agent#ExecAgentByName()| + tlib#agent#CompleteAgentNames .......... |tlib#agent#CompleteAgentNames()| + tlib#agent#Complete .................... |tlib#agent#Complete()| + tlib#bitwise#Num2Bits .................. |tlib#bitwise#Num2Bits()| + tlib#bitwise#Bits2Num .................. |tlib#bitwise#Bits2Num()| + tlib#bitwise#AND ....................... |tlib#bitwise#AND()| + tlib#bitwise#OR ........................ |tlib#bitwise#OR()| + tlib#bitwise#XOR ....................... |tlib#bitwise#XOR()| + tlib#bitwise#ShiftRight ................ |tlib#bitwise#ShiftRight()| + tlib#bitwise#ShiftLeft ................. |tlib#bitwise#ShiftLeft()| + tlib#bitwise#Add ....................... |tlib#bitwise#Add()| + tlib#bitwise#Sub ....................... |tlib#bitwise#Sub()| + tlib#url#Decode ........................ |tlib#url#Decode()| + tlib#url#DecodeChar .................... |tlib#url#DecodeChar()| + tlib#url#EncodeChar .................... |tlib#url#EncodeChar()| + tlib#url#Encode ........................ |tlib#url#Encode()| + tlib#signs#ClearAll .................... |tlib#signs#ClearAll()| + tlib#signs#ClearBuffer ................. |tlib#signs#ClearBuffer()| + tlib#signs#Mark ........................ |tlib#signs#Mark()| + tlib#rx#Escape ......................... |tlib#rx#Escape()| + tlib#rx#EscapeReplace .................. |tlib#rx#EscapeReplace()| + tlib#rx#Suffixes ....................... |tlib#rx#Suffixes()| + tlib#rx#LooksLikeRegexp ................ |tlib#rx#LooksLikeRegexp()| + g:tlib_tags_extra ...................... |g:tlib_tags_extra| + g:tlib_tag_substitute .................. |g:tlib_tag_substitute| + tlib#tag#Retrieve ...................... |tlib#tag#Retrieve()| + tlib#tag#Collect ....................... |tlib#tag#Collect()| + tlib#tag#Format ........................ |tlib#tag#Format()| + tlib#map#PumAccept ..................... |tlib#map#PumAccept()| + tlib#Filter_cnfd#New ................... |tlib#Filter_cnfd#New()| + g:tlib#input#sortprefs_threshold ....... |g:tlib#input#sortprefs_threshold| + g:tlib#input#livesearch_threshold ...... |g:tlib#input#livesearch_threshold| + g:tlib#input#filter_mode ............... |g:tlib#input#filter_mode| + g:tlib#input#higroup ................... |g:tlib#input#higroup| + g:tlib_pick_last_item .................. |g:tlib_pick_last_item| + g:tlib#input#and ....................... |g:tlib#input#and| + g:tlib#input#or ........................ |g:tlib#input#or| + g:tlib#input#not ....................... |g:tlib#input#not| + g:tlib#input#numeric_chars ............. |g:tlib#input#numeric_chars| + g:tlib#input#keyagents_InputList_s ..... |g:tlib#input#keyagents_InputList_s| + g:tlib#input#keyagents_InputList_m ..... |g:tlib#input#keyagents_InputList_m| + g:tlib#input#handlers_EditList ......... |g:tlib#input#handlers_EditList| + g:tlib#input#user_shortcuts ............ |g:tlib#input#user_shortcuts| + g:tlib#input#use_popup ................. |g:tlib#input#use_popup| + g:tlib#input#format_filename ........... |g:tlib#input#format_filename| + g:tlib#input#filename_padding_r ........ |g:tlib#input#filename_padding_r| + g:tlib#input#filename_max_width ........ |g:tlib#input#filename_max_width| + tlib#input#List ........................ |tlib#input#List()| + tlib#input#ListD ....................... |tlib#input#ListD()| + tlib#input#ListW ....................... |tlib#input#ListW()| + tlib#input#EditList .................... |tlib#input#EditList()| + tlib#input#Resume ...................... |tlib#input#Resume()| + tlib#input#CommandSelect ............... |tlib#input#CommandSelect()| + tlib#input#Edit ........................ |tlib#input#Edit()| + tlib#input#Dialog ...................... |tlib#input#Dialog()| + tlib#number#ConvertBase ................ |tlib#number#ConvertBase()| + g:tlib#file#drop ....................... |g:tlib#file#drop| + g:tlib#file#use_tabs ................... |g:tlib#file#use_tabs| + g:tlib#file#edit_cmds .................. |g:tlib#file#edit_cmds| + g:tlib#file#absolute_filename_rx ....... |g:tlib#file#absolute_filename_rx| + tlib#file#Split ........................ |tlib#file#Split()| + tlib#file#Join ......................... |tlib#file#Join()| + tlib#file#Relative ..................... |tlib#file#Relative()| + tlib#file#Absolute ..................... |tlib#file#Absolute()| + tlib#file#Canonic ...................... |tlib#file#Canonic()| + tlib#file#With ......................... |tlib#file#With()| + tlib#file#Edit ......................... |tlib#file#Edit()| + tlib#file#Glob ......................... |tlib#file#Glob()| + tlib#file#Globpath ..................... |tlib#file#Globpath()| + g:tlib#sys#special_protocols ........... |g:tlib#sys#special_protocols| + g:tlib#sys#special_suffixes ............ |g:tlib#sys#special_suffixes| + g:tlib#sys#system_rx ................... |g:tlib#sys#system_rx| + g:tlib#sys#system_browser .............. |g:tlib#sys#system_browser| + g:tlib#sys#windows ..................... |g:tlib#sys#windows| + g:tlib#sys#null ........................ |g:tlib#sys#null| + tlib#sys#IsCygwinBin ................... |tlib#sys#IsCygwinBin()| + tlib#sys#IsExecutable .................. |tlib#sys#IsExecutable()| + g:tlib#sys#check_cygpath ............... |g:tlib#sys#check_cygpath| + g:tlib#sys#cygwin_path_rx .............. |g:tlib#sys#cygwin_path_rx| + g:tlib#sys#cygwin_expr ................. |g:tlib#sys#cygwin_expr| + tlib#sys#GetCmd ........................ |tlib#sys#GetCmd()| + tlib#sys#MaybeUseCygpath ............... |tlib#sys#MaybeUseCygpath()| + tlib#sys#ConvertPath ................... |tlib#sys#ConvertPath()| + tlib#sys#FileArgs ...................... |tlib#sys#FileArgs()| + tlib#sys#IsSpecial ..................... |tlib#sys#IsSpecial()| + tlib#sys#Open .......................... |tlib#sys#Open()| + tlib#sys#SystemInDir ................... |tlib#sys#SystemInDir()| + tlib#paragraph#GetMetric ............... |tlib#paragraph#GetMetric()| + tlib#paragraph#Move .................... |tlib#paragraph#Move()| + g:tlib_inputlist_pct ................... |g:tlib_inputlist_pct| + g:tlib_inputlist_width_filename ........ |g:tlib_inputlist_width_filename| + g:tlib_inputlist_filename_indicators ... |g:tlib_inputlist_filename_indicators| + g:tlib_inputlist_shortmessage .......... |g:tlib_inputlist_shortmessage| + tlib#World#New ......................... |tlib#World#New()| + prototype.PrintLines + prototype.Suspend + tlib#loclist#Browse .................... |tlib#loclist#Browse()| + tlib#tab#BufMap ........................ |tlib#tab#BufMap()| + tlib#tab#TabWinNr ...................... |tlib#tab#TabWinNr()| + tlib#tab#Set ........................... |tlib#tab#Set()| + tlib#date#IsDate ....................... |tlib#date#IsDate()| + tlib#date#Format ....................... |tlib#date#Format()| + tlib#date#DiffInDays ................... |tlib#date#DiffInDays()| + tlib#date#Parse ........................ |tlib#date#Parse()| + tlib#date#SecondsSince1970 ............. |tlib#date#SecondsSince1970()| + tlib#date#Shift ........................ |tlib#date#Shift()| + tlib#type#IsNumber ..................... |tlib#type#IsNumber()| + tlib#type#IsString ..................... |tlib#type#IsString()| + tlib#type#IsFuncref .................... |tlib#type#IsFuncref()| + tlib#type#IsList ....................... |tlib#type#IsList()| + tlib#type#IsDictionary ................. |tlib#type#IsDictionary()| + tlib#type#Is ........................... |tlib#type#Is()| + tlib#type#Are .......................... |tlib#type#Are()| + tlib#type#Has .......................... |tlib#type#Has()| + tlib#type#Have ......................... |tlib#type#Have()| + tlib#Filter_fuzzy#New .................. |tlib#Filter_fuzzy#New()| + tlib#assert#Enable ..................... |tlib#assert#Enable()| + tlib#assert#Disable .................... |tlib#assert#Disable()| + tlib#assert#Assert ..................... |tlib#assert#Assert()| + tlib#assert#Map ........................ |tlib#assert#Map()| + tlib#assert#All ........................ |tlib#assert#All()| + tlib#textobjects#StandardParagraph ..... |standard-paragraph| + tlib#textobjects#Init .................. |tlib#textobjects#Init()| + v_sp ................................... |v_sp| + o_sp ................................... |o_sp| + tlib#arg#Get ........................... |tlib#arg#Get()| + tlib#arg#Let ........................... |tlib#arg#Let()| + tlib#arg#StringAsKeyArgs ............... |tlib#arg#StringAsKeyArgs()| + tlib#arg#StringAsKeyArgsEqual .......... |tlib#arg#StringAsKeyArgsEqual()| + tlib#arg#GetOpts ....................... |tlib#arg#GetOpts()| + tlib#arg#Ex ............................ |tlib#arg#Ex()| + tlib#fixes#Winpos ...................... |tlib#fixes#Winpos()| + g:tlib#dir#sep ......................... |g:tlib#dir#sep| + tlib#dir#CanonicName ................... |tlib#dir#CanonicName()| + tlib#dir#NativeName .................... |tlib#dir#NativeName()| + tlib#dir#PlainName ..................... |tlib#dir#PlainName()| + tlib#dir#Ensure ........................ |tlib#dir#Ensure()| + tlib#dir#MyRuntime ..................... |tlib#dir#MyRuntime()| + tlib#dir#CD ............................ |tlib#dir#CD()| + tlib#dir#Push .......................... |tlib#dir#Push()| + tlib#dir#Pop ........................... |tlib#dir#Pop()| + g:tlib#hash#use_crc32 .................. |g:tlib#hash#use_crc32| + g:tlib#hash#use_adler32 ................ |g:tlib#hash#use_adler32| + tlib#hash#CRC32B ....................... |tlib#hash#CRC32B()| + tlib#hash#CRC32B_ruby .................. |tlib#hash#CRC32B_ruby()| + tlib#hash#CRC32B_vim ................... |tlib#hash#CRC32B_vim()| + tlib#hash#Adler32 ...................... |tlib#hash#Adler32()| + tlib#hash#Adler32_vim .................. |tlib#hash#Adler32_vim()| + tlib#hash#Adler32_tlib ................. |tlib#hash#Adler32_tlib()| + tlib#win#Set ........................... |tlib#win#Set()| + tlib#win#GetLayout ..................... |tlib#win#GetLayout()| + tlib#win#SetLayout ..................... |tlib#win#SetLayout()| + tlib#win#List .......................... |tlib#win#List()| + tlib#win#Width ......................... |tlib#win#Width()| + tlib#win#WinDo ......................... |tlib#win#WinDo()| + tlib#comments#Comments ................. |tlib#comments#Comments()| + tlib#grep#Do ........................... |tlib#grep#Do()| + tlib#grep#LocList ...................... |tlib#grep#LocList()| + tlib#grep#QuickFixList ................. |tlib#grep#QuickFixList()| + tlib#grep#List ......................... |tlib#grep#List()| + tlib#qfl#FormatQFLE .................... |tlib#qfl#FormatQFLE()| + tlib#qfl#QfeFilename ................... |tlib#qfl#QfeFilename()| + tlib#qfl#InitListBuffer ................ |tlib#qfl#InitListBuffer()| + tlib#qfl#SetSyntax ..................... |tlib#qfl#SetSyntax()| + tlib#qfl#Balloon ....................... |tlib#qfl#Balloon()| + tlib#qfl#AgentEditQFE .................. |tlib#qfl#AgentEditQFE()| + tlib#qfl#AgentPreviewQFE ............... |tlib#qfl#AgentPreviewQFE()| + tlib#qfl#AgentGotoQFE .................. |tlib#qfl#AgentGotoQFE()| + tlib#qfl#AgentWithSelected ............. |tlib#qfl#AgentWithSelected()| + tlib#qfl#RunCmdOnSelected .............. |tlib#qfl#RunCmdOnSelected()| + tlib#qfl#AgentSplitBuffer .............. |tlib#qfl#AgentSplitBuffer()| + tlib#qfl#AgentTabBuffer ................ |tlib#qfl#AgentTabBuffer()| + tlib#qfl#AgentVSplitBuffer ............. |tlib#qfl#AgentVSplitBuffer()| + tlib#qfl#AgentEditLine ................. |tlib#qfl#AgentEditLine()| + tlib#qfl#EditLine ...................... |tlib#qfl#EditLine()| + tlib#qfl#SetFollowCursor ............... |tlib#qfl#SetFollowCursor()| + tlib#qfl#QflList ....................... |tlib#qfl#QflList()| + tlib#qfl#Browse ........................ |tlib#qfl#Browse()| + tlib#Filter_cnf#New .................... |tlib#Filter_cnf#New()| + prototype.Pretty + tlib#Object#New ........................ |tlib#Object#New()| + prototype.New + prototype.Inherit + prototype.Extend + prototype.IsA + prototype.IsRelated + prototype.RespondTo + prototype.Super + tlib#Object#Methods .................... |tlib#Object#Methods()| + g:tlib_viewline_position ............... |g:tlib_viewline_position| + tlib#buffer#EnableMRU .................. |tlib#buffer#EnableMRU()| + tlib#buffer#DisableMRU ................. |tlib#buffer#DisableMRU()| + tlib#buffer#Set ........................ |tlib#buffer#Set()| + tlib#buffer#Eval ....................... |tlib#buffer#Eval()| + tlib#buffer#GetList .................... |tlib#buffer#GetList()| + tlib#buffer#ViewLine ................... |tlib#buffer#ViewLine()| + tlib#buffer#HighlightLine .............. |tlib#buffer#HighlightLine()| + tlib#buffer#DeleteRange ................ |tlib#buffer#DeleteRange()| + tlib#buffer#ReplaceRange ............... |tlib#buffer#ReplaceRange()| + tlib#buffer#ScratchStart ............... |tlib#buffer#ScratchStart()| + tlib#buffer#ScratchEnd ................. |tlib#buffer#ScratchEnd()| + tlib#buffer#BufDo ...................... |tlib#buffer#BufDo()| + tlib#buffer#InsertText ................. |tlib#buffer#InsertText()| + tlib#buffer#InsertText0 ................ |tlib#buffer#InsertText0()| + tlib#buffer#CurrentByte ................ |tlib#buffer#CurrentByte()| + tlib#buffer#KeepCursorPosition ......... |tlib#buffer#KeepCursorPosition()| + tlib#hook#Run .......................... |tlib#hook#Run()| + tlib#string#RemoveBackslashes .......... |tlib#string#RemoveBackslashes()| + tlib#string#Chomp ...................... |tlib#string#Chomp()| + tlib#string#Format ..................... |tlib#string#Format()| + tlib#string#Printf1 .................... |tlib#string#Printf1()| + tlib#string#TrimLeft ................... |tlib#string#TrimLeft()| + tlib#string#TrimRight .................. |tlib#string#TrimRight()| + tlib#string#Strip ...................... |tlib#string#Strip()| + tlib#string#Count ...................... |tlib#string#Count()| + tlib#string#SplitCommaList ............. |tlib#string#SplitCommaList()| + + +======================================================================== +plugin/02tlib.vim~ + + *:TLet* +:TLet VAR = VALUE + Set a variable only if it doesn't already exist. + EXAMPLES: > + TLet foo = 1 + TLet foo = 2 + echo foo + => 1 +< + + *:TScratch* +:TScratch + Open a scratch buffer (a buffer without a file). + TScratch ... use split window + TScratch! ... use the whole frame + This command takes an (inner) dictionary as optional argument. + EXAMPLES: > + TScratch 'scratch': '__FOO__' + => Open a scratch buffer named __FOO__ +< + + *:TVarArg* +:TVarArg VAR1, [VAR2, DEFAULT2] ... + A convenience wrapper for |tlib#arg#Let|. + EXAMPLES: > + function! Foo(...) + TVarArg ['a', 1], 'b' + echo 'a='. a + echo 'b='. b + endf +< + + *:TBrowseOutput* +:TBrowseOutput COMMAND + Ever wondered how to efficiently browse the output of a command + without redirecting it to a file? This command takes a command as + argument and presents the output via |tlib#input#List()| so that you + can easily search for a keyword (e.g. the name of a variable or + function) and the like. + + If you press enter, the selected line will be copied to the command + line. Press ESC to cancel browsing. + + EXAMPLES: > + TBrowseOutput 20verb TeaseTheCulprit +< + + *:TBrowseScriptnames* +:TBrowseScriptnames + List all sourced script names (the output of ':scriptnames'). + + When you press enter, the selected script will be opened in the current + window. Press ESC to cancel. + + EXAMPLES: > + TBrowseScriptnames +< + + *:Tlibtrace* +:Tlibtrace GUARD, VAR1, VAR2... + Do nothing unless |tlib#trace#Enable()| was called. + + When |:Tlibtraceset| or |tlib#trace#Enable()| were called: + + If GUARD is a number that evaluates to true or if it is a string that + matches a |regexp|, which was added using Tlibtrace! (with '!'), + display the values of VAR1, VAR2 ... + + *:Tlibtraceset* +:Tlibtraceset + :Tlibtraceset +RX1, -RX2... + If |tlib#trace#Enable()| was called: With the optional , users + can add and remove GUARDs (actually a |regexp|) that should be traced. + + *:Tlibassert* +:Tlibtrace ASSERTION + + +======================================================================== +test/tlib.vim~ + + *Add()* +Add(a,b) + List + + *TestGetArg()* +TestGetArg(...) + Optional arguments + + *TestGetArg1()* +TestGetArg1(...) + + *TestArgs()* +TestArgs(...) + + *TestArgs1()* +TestArgs1(...) + + *TestArgs2()* +TestArgs2(...) + + *TestArgs3()* +TestArgs3(...) + + +======================================================================== +autoload/tlib.vim~ + + *g:tlib#debug* +g:tlib#debug + + +======================================================================== +autoload/tlib/notify.vim~ + + *tlib#notify#Echo()* +tlib#notify#Echo(text, ?style='') + Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' + in order to prevent |press-enter| messages. + + *tlib#notify#TrimMessage()* +tlib#notify#TrimMessage(message) + Contributed by Erik Falor: + If the line containing the message is too long, echoing it will cause + a 'Hit ENTER' prompt to appear. This function cleans up the line so + that does not happen. + The echoed line is too long if it is wider than the width of the + window, minus cmdline space taken up by the ruler and showcmd + features. + + +======================================================================== +autoload/tlib/trace.vim~ + + *g:tlib#trace#backtrace* +g:tlib#trace#backtrace (default: 2) + The length of the backtrace that should be included in + |tlib#trace#Print()|. + + *g:tlib#trace#printf* +g:tlib#trace#printf (default: 'echom %s') + The command used for printing traces from |tlib#trace#Print()|. + + *tlib#trace#PrintToFile()* +tlib#trace#PrintToFile(filename) + Set |g:tlib#trace#printf| to make |tlib#trace#Print()| print to + `filename`. + + *tlib#trace#Set()* +tlib#trace#Set(vars) + Set the tracing |regexp|. See |:Tlibtrace|. + This will also call |tlib#trace#Enable()|. + + Examples: + call tlib#trace#Set(["+foo", "-bar"]) + call tlib#trace#Set("+foo,-bar") + + *tlib#trace#Backtrace()* +tlib#trace#Backtrace(caller) + + *tlib#trace#Print()* +tlib#trace#Print(caller, vars, values) + Print the values of vars. The first value is a "guard" (see + |:Tlibtrace|). + + *tlib#trace#Enable()* +tlib#trace#Enable() + Enable tracing via |:Tlibtrace|. + + *tlib#trace#Disable()* +tlib#trace#Disable() + Disable tracing via |:Tlibtrace|. + + +======================================================================== +autoload/tlib/dictionary.vim~ + + *tlib#dictionary#Rev()* +tlib#dictionary#Rev(dict) + + +======================================================================== +autoload/tlib/persistent.vim~ + + *g:tlib_persistent* +g:tlib_persistent (default: '') + The directory for persistent data files. If empty, use + |tlib#dir#MyRuntime|.'/share'. + + *tlib#persistent#Dir()* +tlib#persistent#Dir(?mode = 'bg') + Return the full directory name for persistent data files. + + *tlib#persistent#Filename()* +tlib#persistent#Filename(type, ?file=%, ?mkdir=0) + + *tlib#persistent#Get()* +tlib#persistent#Get(...) + + *tlib#persistent#MTime()* +tlib#persistent#MTime(cfile) + + *tlib#persistent#Value()* +tlib#persistent#Value(...) + + *tlib#persistent#Save()* +tlib#persistent#Save(cfile, dictionary) + + +======================================================================== +autoload/tlib/vim.vim~ + + *g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_maximize (default: 'x') + The alt-key for maximizing the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#simalt_restore* +g:tlib#vim#simalt_restore (default: 'r') + The alt-key for restoring the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#use_vimtweak* +g:tlib#vim#use_vimtweak (default: 0) + If true, use the vimtweak.dll for windows. This will enable + tlib to remove the caption for fullscreen windows. + + *tlib#vim#Maximize()* +tlib#vim#Maximize(fullscreen) + Maximize the window. + You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't + work for you. + + *tlib#vim#RestoreWindow()* +tlib#vim#RestoreWindow() + Restore the original vimsize after having called |tlib#vim#Maximize()|. + + *g:tlib#vim#use_wmctrl* +g:tlib#vim#use_wmctrl (default: executable('wmctrl')) + If true, use wmctrl for X windows to make a window + maximized/fullscreen. + + This is the preferred method for maximizing windows under X + windows. Some window managers have problem coping with the + default method of setting 'lines' and 'columns' to a large + value. + + *tlib#vim#CopyFunction()* +tlib#vim##CopyFunction(old, new, overwrite=0) + + +======================================================================== +autoload/tlib/progressbar.vim~ + + *tlib#progressbar#Init()* +tlib#progressbar#Init(max, ...) + EXAMPLE: > + call tlib#progressbar#Init(20) + try + for i in range(20) + call tlib#progressbar#Display(i) + call DoSomethingThatTakesSomeTime(i) + endfor + finally + call tlib#progressbar#Restore() + endtry +< + + *tlib#progressbar#Display()* +tlib#progressbar#Display(value, ...) + + *tlib#progressbar#Restore()* +tlib#progressbar#Restore() + + +======================================================================== +autoload/tlib/eval.vim~ + + *tlib#eval#FormatValue()* +tlib#eval#FormatValue(value, ...) + + *tlib#eval#Extend()* +tlib#eval#Extend(a, b, ...) + + +======================================================================== +autoload/tlib/list.vim~ + + *tlib#list#Inject()* +tlib#list#Inject(list, initial_value, funcref) + EXAMPLES: > + echo tlib#list#Inject([1,2,3], 0, function('Add') + => 6 +< + + *tlib#list#Compact()* +tlib#list#Compact(list) + EXAMPLES: > + tlib#list#Compact([0,1,2,3,[], {}, ""]) + => [1,2,3] +< + + *tlib#list#Flatten()* +tlib#list#Flatten(list) + EXAMPLES: > + tlib#list#Flatten([0,[1,2,[3,""]]]) + => [0,1,2,3,""] +< + + *tlib#list#FindAll()* +tlib#list#FindAll(list, filter, ?process_expr="") + Basically the same as filter() + + EXAMPLES: > + tlib#list#FindAll([1,2,3], 'v:val >= 2') + => [2, 3] +< + + *tlib#list#Find()* +tlib#list#Find(list, filter, ?default="", ?process_expr="") + + EXAMPLES: > + tlib#list#Find([1,2,3], 'v:val >= 2') + => 2 +< + + *tlib#list#Any()* +tlib#list#Any(list, expr) + EXAMPLES: > + tlib#list#Any([1,2,3], 'v:val >= 2') + => 1 +< + + *tlib#list#All()* +tlib#list#All(list, expr) + EXAMPLES: > + tlib#list#All([1,2,3], 'v:val >= 2') + => 0 +< + + *tlib#list#Remove()* +tlib#list#Remove(list, element) + EXAMPLES: > + tlib#list#Remove([1,2,1,2], 2) + => [1,1,2] +< + + *tlib#list#RemoveAll()* +tlib#list#RemoveAll(list, element) + EXAMPLES: > + tlib#list#RemoveAll([1,2,1,2], 2) + => [1,1] +< + + *tlib#list#Zip()* +tlib#list#Zip(lists, ?default='') + EXAMPLES: > + tlib#list#Zip([[1,2,3], [4,5,6]]) + => [[1,4], [2,5], [3,6]] +< + + *tlib#list#Uniq()* +tlib#list#Uniq(list, ...) + + *tlib#list#ToDictionary()* +tlib#list#ToDictionary(list, default, ...) + + +======================================================================== +autoload/tlib/cmd.vim~ + + *tlib#cmd#OutputAsList()* +tlib#cmd#OutputAsList(command) + + *tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutput(command) + See |:TBrowseOutput|. + + *tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#BrowseOutputWithCallback(callback, command) + Execute COMMAND and present its output in a |tlib#input#List()|; + when a line is selected, execute the function named as the CALLBACK + and pass in that line as an argument. + + The CALLBACK function gives you an opportunity to massage the COMMAND output + and possibly act on it in a meaningful way. For example, if COMMAND listed + all URIs found in the current buffer, CALLBACK could validate and then open + the selected URI in the system's default browser. + + This function is meant to be a tool to help compose the implementations of + powerful commands that use |tlib#input#List()| as a common interface. See + |TBrowseScriptnames| as an example. + + EXAMPLES: > + call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') +< + + *tlib#cmd#DefaultBrowseOutput()* +tlib#cmd#DefaultBrowseOutput(cmd) + + *tlib#cmd#ParseScriptname()* +tlib#cmd#ParseScriptname(line) + + *tlib#cmd#TBrowseScriptnames()* +tlib#cmd#TBrowseScriptnames() + + *tlib#cmd#UseVertical()* +tlib#cmd#UseVertical(?rx='') + Look at the history whether the command was called with vertical. If + an rx is provided check first if the last entry in the history matches + this rx. + + *tlib#cmd#Time()* +tlib#cmd#Time(cmd) + Print the time in seconds or milliseconds (if your version of VIM + has |+reltime|) a command takes. + + *tlib#cmd#Capture()* +tlib#cmd#Capture(cmd) + + +======================================================================== +autoload/tlib/syntax.vim~ + + *tlib#syntax#Collect()* +tlib#syntax#Collect() + + *tlib#syntax#Names()* +tlib#syntax#Names(?rx='') + + +======================================================================== +autoload/tlib/balloon.vim~ + + *tlib#balloon#Register()* +tlib#balloon#Register(expr) + + *tlib#balloon#Remove()* +tlib#balloon#Remove(expr) + + *tlib#balloon#Expr()* +tlib#balloon#Expr() + + *tlib#balloon#Expand()* +tlib#balloon#Expand(expr) + + +======================================================================== +autoload/tlib/vcs.vim~ + + *g:tlib#vcs#def* +g:tlib#vcs#def {...} + A dictionarie of supported VCS (currently: git, hg, svn, bzr). + + *g:tlib#vcs#executables* +g:tlib#vcs#executables {...} + A dictionary of custom executables for VCS commands. If the value is + empty, support for that VCS will be removed. If no key is present, it + is assumed that the VCS "type" is the name of the executable. + + *g:tlib#vcs#check* +g:tlib#vcs#check (default: has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s') + If non-empty, use it as a format string to check whether a VCS is + installed on your computer. + + *tlib#vcs#Executable()* +tlib#vcs#Executable(type) + + *tlib#vcs#FindVCS()* +tlib#vcs#FindVCS(filename) + + *tlib#vcs#Ls()* +tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) + Return the files under VCS. + + *tlib#vcs#Diff()* +tlib#vcs#Diff(filename, ?vcs=[type, dir]) + Return the diff for "filename" + + *tlib#vcs#GitLsPostprocess()* +tlib#vcs#GitLsPostprocess(filename) + + +======================================================================== +autoload/tlib/char.vim~ + + *tlib#char#Get()* +tlib#char#Get(?timeout=0) + Get a character. + + EXAMPLES: > + echo tlib#char#Get() + echo tlib#char#Get(5) +< + + *tlib#char#IsAvailable()* +tlib#char#IsAvailable() + + *tlib#char#GetWithTimeout()* +tlib#char#GetWithTimeout(timeout, ...) + + +======================================================================== +autoload/tlib/Filter_glob.vim~ + + *g:tlib#Filter_glob#seq* +g:tlib#Filter_glob#seq (default: '*') + A character that should be expanded to '\.\{-}'. + + *g:tlib#Filter_glob#char* +g:tlib#Filter_glob#char (default: '?') + A character that should be expanded to '\.\?'. + + *tlib#Filter_glob#New()* +tlib#Filter_glob#New(...) + The same as |tlib#Filter_cnf#New()| but a a customizable character + |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and + |g:tlib#Filter_glob#char| is expanded to '\.'. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + +======================================================================== +autoload/tlib/scratch.vim~ + + *g:tlib_scratch_pos* +g:tlib_scratch_pos (default: 'botright') + Scratch window position. By default the list window is opened on the + bottom. Set this variable to 'topleft' or '' to change this behaviour. + See |tlib#input#List()|. + + *g:tlib#scratch#hidden* +g:tlib#scratch#hidden (default: 'hide') + If you want the scratch buffer to be fully removed, you might want to + set this variable to 'wipe'. + See also https://github.com/tomtom/tlib_vim/pull/16 + + *tlib#scratch#UseScratch()* +tlib#scratch#UseScratch(?keyargs={}) + Display a scratch buffer (a buffer with no file). See :TScratch for an + example. + Return the scratch buffer's number. + Values for keyargs: + scratch_split ... 1: split, 0: window, -1: tab + + *tlib#scratch#CloseScratch()* +tlib#scratch#CloseScratch(keyargs, ...) + Close a scratch buffer as defined in keyargs (usually a World). + Return 1 if the scratch buffer is closed (or if it already was + closed). + + +======================================================================== +autoload/tlib/autocmdgroup.vim~ + + *tlib#autocmdgroup#Init()* +tlib#autocmdgroup#Init() + + +======================================================================== +autoload/tlib/cache.vim~ + + *g:tlib_cache* +g:tlib_cache (default: '') + The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. + You might want to delete old files from this directory from time to + time with a command like: > + find ~/vimfiles/cache/ -atime +31 -type f -print -delete +< + + *g:tlib#cache#purge_days* +g:tlib#cache#purge_days (default: 31) + |tlib#cache#Purge()|: Remove cache files older than N days. + + *g:tlib#cache#purge_every_days* +g:tlib#cache#purge_every_days (default: 31) + Purge the cache every N days. Disable automatic purging by setting + this value to a negative value. + + *g:tlib#cache#script_encoding* +g:tlib#cache#script_encoding (default: &enc) + The encoding used for the purge-cache script. + Default: 'enc' + + *g:tlib#cache#run_script* +g:tlib#cache#run_script (default: 1) + Whether to run the directory removal script: + 0 ... No + 1 ... Query user + 2 ... Yes + + *g:tlib#cache#verbosity* +g:tlib#cache#verbosity (default: 1) + Verbosity level: + 0 ... Be quiet + 1 ... Display informative message + 2 ... Display detailed messages + + *g:tlib#cache#dont_purge* +g:tlib#cache#dont_purge (default: ['[\/]\.last_purge$']) + A list of regexps that are matched against partial filenames of the + cached files. If a regexp matches, the file won't be removed by + |tlib#cache#Purge()|. + + *g:tlib#cache#max_filename* +g:tlib#cache#max_filename (default: 200) + If the cache filename is longer than N characters, use + |pathshorten()|. + + *tlib#cache#Dir()* +tlib#cache#Dir(?mode = 'bg') + The default cache directory. + + *tlib#cache#Filename()* +tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') + + *tlib#cache#Save()* +tlib#cache#Save(cfile, dictionary, ...) + + *tlib#cache#MTime()* +tlib#cache#MTime(cfile) + + *tlib#cache#Get()* +tlib#cache#Get(cfile, ...) + + *tlib#cache#Value()* +tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) + Get a cached value from cfile. If it is outdated (compared to ftime) + or does not exist, create it calling a generator function. + + *tlib#cache#MaybePurge()* +tlib#cache#MaybePurge() + Call |tlib#cache#Purge()| if the last purge was done before + |g:tlib#cache#purge_every_days|. + + *tlib#cache#Purge()* +tlib#cache#Purge() + Delete old files. + + *tlib#cache#ListFilesInCache()* +tlib#cache#ListFilesInCache(...) + + +======================================================================== +autoload/tlib/normal.vim~ + + *tlib#normal#WithRegister()* +tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') + Execute a normal command while maintaining all registers. + + +======================================================================== +autoload/tlib/time.vim~ + + *tlib#time#MSecs()* +tlib#time#MSecs() + + *tlib#time#Now()* +tlib#time#Now() + + *tlib#time#FormatNow()* +tlib#time#FormatNow() + + *tlib#time#Diff()* +tlib#time#Diff(a, b, ...) + + *tlib#time#DiffMSecs()* +tlib#time#DiffMSecs(a, b, ...) + + +======================================================================== +autoload/tlib/var.vim~ + + *tlib#var#Let()* +tlib#var#Let(name, val) + Define a variable called NAME if yet undefined. + You can also use the :TLLet command. + + EXAMPLES: > + exec tlib#var#Let('g:foo', 1) + TLet g:foo = 1 +< + + *tlib#var#EGet()* +tlib#var#EGet(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo eval(tlib#var#EGet('foo', 'vg')) => 1 + echo eval(tlib#var#EGet('foo', 'bg')) => 2 + echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +< + + *tlib#var#Get()* +tlib#var#Get(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo tlib#var#Get('foo', 'bg') => 1 + echo tlib#var#Get('foo', 'bg') => 2 + echo tlib#var#Get('foo', 'wbg') => 3 +< + + *tlib#var#List()* +tlib#var#List(rx, ?prefix='') + Get a list of variables matching rx. + EXAMPLE: + echo tlib#var#List('tlib_', 'g:') + + +======================================================================== +autoload/tlib/agent.vim~ +Various agents for use as key handlers in tlib#input#List() + + *g:tlib_scroll_lines* +g:tlib_scroll_lines (default: 10) + Number of items to move when pressing in the input list window. + + *tlib#agent#Exit()* +tlib#agent#Exit(world, selected) + + *tlib#agent#CopyItems()* +tlib#agent#CopyItems(world, selected) + + *tlib#agent#PageUp()* +tlib#agent#PageUp(world, selected) + + *tlib#agent#PageDown()* +tlib#agent#PageDown(world, selected) + + *tlib#agent#Home()* +tlib#agent#Home(world, selected) + + *tlib#agent#End()* +tlib#agent#End(world, selected) + + *tlib#agent#Up()* +tlib#agent#Up(world, selected, ...) + + *tlib#agent#Down()* +tlib#agent#Down(world, selected, ...) + + *tlib#agent#UpN()* +tlib#agent#UpN(world, selected) + + *tlib#agent#DownN()* +tlib#agent#DownN(world, selected) + + *tlib#agent#ShiftLeft()* +tlib#agent#ShiftLeft(world, selected) + + *tlib#agent#ShiftRight()* +tlib#agent#ShiftRight(world, selected) + + *tlib#agent#Reset()* +tlib#agent#Reset(world, selected) + + *tlib#agent#ToggleRestrictView()* +tlib#agent#ToggleRestrictView(world, selected) + + *tlib#agent#RestrictView()* +tlib#agent#RestrictView(world, selected) + + *tlib#agent#UnrestrictView()* +tlib#agent#UnrestrictView(world, selected) + + *tlib#agent#Input()* +tlib#agent#Input(world, selected) + + *tlib#agent#SuspendToParentWindow()* +tlib#agent#SuspendToParentWindow(world, selected) + Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the + original position in the parent window. + + *tlib#agent#Suspend()* +tlib#agent#Suspend(world, selected) + Suspend lets you temporarily leave the input loop of + |tlib#input#List|. You can resume editing the list by pressing , + . , or in the suspended window. + and will immediatly select the item under the cursor. + < will select the item but the window will remain opened. + + *tlib#agent#Help()* +tlib#agent#Help(world, selected) + + *tlib#agent#OR()* +tlib#agent#OR(world, selected) + + *tlib#agent#AND()* +tlib#agent#AND(world, selected) + + *tlib#agent#ReduceFilter()* +tlib#agent#ReduceFilter(world, selected) + + *tlib#agent#PopFilter()* +tlib#agent#PopFilter(world, selected) + + *tlib#agent#Debug()* +tlib#agent#Debug(world, selected) + + *tlib#agent#Select()* +tlib#agent#Select(world, selected) + + *tlib#agent#SelectUp()* +tlib#agent#SelectUp(world, selected) + + *tlib#agent#SelectDown()* +tlib#agent#SelectDown(world, selected) + + *tlib#agent#SelectAll()* +tlib#agent#SelectAll(world, selected) + + *tlib#agent#ToggleStickyList()* +tlib#agent#ToggleStickyList(world, selected) + + *tlib#agent#EditItem()* +tlib#agent#EditItem(world, selected) + + *tlib#agent#NewItem()* +tlib#agent#NewItem(world, selected) + Insert a new item below the current one. + + *tlib#agent#DeleteItems()* +tlib#agent#DeleteItems(world, selected) + + *tlib#agent#Cut()* +tlib#agent#Cut(world, selected) + + *tlib#agent#Copy()* +tlib#agent#Copy(world, selected) + + *tlib#agent#Paste()* +tlib#agent#Paste(world, selected) + + *tlib#agent#EditReturnValue()* +tlib#agent#EditReturnValue(world, rv) + + *tlib#agent#ViewFile()* +tlib#agent#ViewFile(world, selected) + + *tlib#agent#EditFile()* +tlib#agent#EditFile(world, selected) + + *tlib#agent#EditFileInSplit()* +tlib#agent#EditFileInSplit(world, selected) + + *tlib#agent#EditFileInVSplit()* +tlib#agent#EditFileInVSplit(world, selected) + + *tlib#agent#EditFileInTab()* +tlib#agent#EditFileInTab(world, selected) + + *tlib#agent#ToggleScrollbind()* +tlib#agent#ToggleScrollbind(world, selected) + + *tlib#agent#ShowInfo()* +tlib#agent#ShowInfo(world, selected) + + *tlib#agent#PreviewLine()* +tlib#agent#PreviewLine(world, selected) + + *tlib#agent#GotoLine()* +tlib#agent#GotoLine(world, selected) + If not called from the scratch, we assume/guess that we don't have to + suspend the input-evaluation loop. + + *tlib#agent#DoAtLine()* +tlib#agent#DoAtLine(world, selected) + + *tlib#agent#Wildcard()* +tlib#agent#Wildcard(world, selected) + + *tlib#agent#Null()* +tlib#agent#Null(world, selected) + + *tlib#agent#ExecAgentByName()* +tlib#agent#ExecAgentByName(world, selected) + + *tlib#agent#CompleteAgentNames()* +tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) + + *tlib#agent#Complete()* +tlib#agent#Complete(world, selected) + + +======================================================================== +autoload/tlib/bitwise.vim~ + + *tlib#bitwise#Num2Bits()* +tlib#bitwise#Num2Bits(num) + + *tlib#bitwise#Bits2Num()* +tlib#bitwise#Bits2Num(bits, ...) + + *tlib#bitwise#AND()* +tlib#bitwise#AND(num1, num2, ...) + + *tlib#bitwise#OR()* +tlib#bitwise#OR(num1, num2, ...) + + *tlib#bitwise#XOR()* +tlib#bitwise#XOR(num1, num2, ...) + + *tlib#bitwise#ShiftRight()* +tlib#bitwise#ShiftRight(bits, n) + + *tlib#bitwise#ShiftLeft()* +tlib#bitwise#ShiftLeft(bits, n) + + *tlib#bitwise#Add()* +tlib#bitwise#Add(num1, num2, ...) + + *tlib#bitwise#Sub()* +tlib#bitwise#Sub(num1, num2, ...) + + +======================================================================== +autoload/tlib/url.vim~ + + *tlib#url#Decode()* +tlib#url#Decode(url) + Decode an encoded URL. + + *tlib#url#DecodeChar()* +tlib#url#DecodeChar(char) + Decode a single character. + + *tlib#url#EncodeChar()* +tlib#url#EncodeChar(char) + Encode a single character. + + *tlib#url#Encode()* +tlib#url#Encode(url, ...) + Encode an URL. + + +======================================================================== +autoload/tlib/signs.vim~ + + *tlib#signs#ClearAll()* +tlib#signs#ClearAll(sign) + Clear all signs with name SIGN. + + *tlib#signs#ClearBuffer()* +tlib#signs#ClearBuffer(sign, bufnr) + Clear all signs with name SIGN in buffer BUFNR. + + *tlib#signs#Mark()* +tlib#signs#Mark(sign, list) + Add signs for all locations in LIST. LIST must adhere with the + quickfix list format (see |getqflist()|; only the fields lnum and + bufnr are required). + + list:: a quickfix or location list + sign:: a sign defined with |:sign-define| + + +======================================================================== +autoload/tlib/rx.vim~ + + *tlib#rx#Escape()* +tlib#rx#Escape(text, ?magic='m') + magic can be one of: m, M, v, V + See :help 'magic' + + *tlib#rx#EscapeReplace()* +tlib#rx#EscapeReplace(text, ?magic='m') + Escape return |sub-replace-special|. + + *tlib#rx#Suffixes()* +tlib#rx#Suffixes(...) + + *tlib#rx#LooksLikeRegexp()* +tlib#rx#LooksLikeRegexp(text) + + +======================================================================== +autoload/tlib/tag.vim~ + + *g:tlib_tags_extra* +g:tlib_tags_extra (default: '') + Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. + + *g:tlib_tag_substitute* +g:tlib_tag_substitute + Filter the tag description through |substitute()| for these filetypes. + This applies only if the tag cmd field (see |taglist()|) is used. + + *tlib#tag#Retrieve()* +tlib#tag#Retrieve(rx, ?extra_tags=0) + Get all tags matching rx. Basically, this function simply calls + |taglist()|, but when extra_tags is true, the list of the tag files + (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. + + Example use: + If you want to include tags for, eg, JDK, normal tags use can become + slow. You could proceed as follows: + 1. Create a tags file for the JDK sources. When creating the tags + file, make sure to include inheritance information and the like + (command-line options like --fields=+iaSm --extra=+q should be ok). + In this example, we want tags only for public methods (there are + most likely better ways to do this): > + ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src + head -n 6 tags > tags0 + grep access:public tags >> tags0 +< 2. Make 'tags' include project specific tags files. In + ~/vimfiles/after/ftplugin/java.vim insert: > + let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +< 3. When this function is invoked as > + echo tlib#tag#Retrieve('print') +< it will return only project-local tags. If it is invoked as > + echo tlib#tag#Retrieve('print', 1) +< tags from the JDK will be included. + + *tlib#tag#Collect()* +tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) + Retrieve tags that meet the constraints (a dictionnary of fields and + regexp, with the exception of the kind field which is a list of chars). + For the use of the optional use_extra argument see + |tlib#tag#Retrieve()|. + + *tlib#tag#Format()* +tlib#tag#Format(tag) + + +======================================================================== +autoload/tlib/map.vim~ + + *tlib#map#PumAccept()* +tlib#map#PumAccept(key) + If |pumvisible()| is true, return "\". Otherwise return a:key. + For use in maps like: > + imap tlib#map#PumAccept("\") +< + + +======================================================================== +autoload/tlib/Filter_cnfd.vim~ + + *tlib#Filter_cnfd#New()* +tlib#Filter_cnfd#New(...) + The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. + As a consequence, patterns cannot match dots. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + +======================================================================== +autoload/tlib/input.vim~ +Input-related, select from a list etc. + + *g:tlib#input#sortprefs_threshold* +g:tlib#input#sortprefs_threshold (default: 200) + If a list is bigger than this value, don't try to be smart when + selecting an item. Be slightly faster instead. + See |tlib#input#List()|. + + *g:tlib#input#livesearch_threshold* +g:tlib#input#livesearch_threshold (default: 1000) + If a list contains more items, |tlib#input#List()| does not perform an + incremental "live search" but uses |input()| to query the user for a + filter. This is useful on slower machines or with very long lists. + + *g:tlib#input#filter_mode* +g:tlib#input#filter_mode (default: 'glob') + Determine how |tlib#input#List()| and related functions work. + Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: + glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, + |g:tlib#Filter_glob#char|) are interpreted as glob-like + |wildcards| (this is the default method) + - Examples: + - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match + "far". + - Otherwise it is a derivate of the cnf method (see below). + - See also |tlib#Filter_glob#New()|. + cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is + expanded to "\.\{-}" + - A period character (".") acts as a wildcard as if ".\{-}" (see + |/\{-|) were entered. + - Examples: + - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match + "far". + - Otherwise it is a derivate of the cnf method (see below). + - See also |tlib#Filter_cnfd#New()|. + cnf .... Match substrings + - A blank creates an AND conjunction, i.e. the next pattern has to + match too. + - A pipe character ("|") creates an OR conjunction, either this or + the next next pattern has to match. + - Patterns are very 'nomagic' |regexp| with a |\V| prefix. + - A pattern starting with "-" makes the filter exclude items + matching that pattern. + - Examples: + - "foo bar" matches items that contain the strings "foo" AND + "bar". + - "foo|bar boo|far" matches items that contain either ("foo" OR + "bar") AND ("boo" OR "far"). + - See also |tlib#Filter_cnf#New()|. + seq .... Match sequences of characters + - |tlib#Filter_seq#New()| + fuzzy .. Match fuzzy character sequences + - |tlib#Filter_fuzzy#New()| + + *g:tlib#input#higroup* +g:tlib#input#higroup (default: 'IncSearch') + The highlight group to use for showing matches in the input list + window. + See |tlib#input#List()|. + + *g:tlib_pick_last_item* +g:tlib_pick_last_item (default: 1) + When 1, automatically select the last remaining item only if the list + had only one item to begin with. + When 2, automatically select a last remaining item after applying + any filters. + See |tlib#input#List()|. + + +Keys for |tlib#input#List|~ + + *g:tlib#input#and* +g:tlib#input#and (default: ' ') + + *g:tlib#input#or* +g:tlib#input#or (default: '|') + + *g:tlib#input#not* +g:tlib#input#not (default: '-') + + *g:tlib#input#numeric_chars* +g:tlib#input#numeric_chars + When editing a list with |tlib#input#List|, typing these numeric chars + (as returned by getchar()) will select an item based on its index, not + based on its name. I.e. in the default setting, typing a "4" will + select the fourth item, not the item called "4". + In order to make keys 0-9 filter the items in the list and make + select an item by its index, remove the keys 48 to 57 from + this dictionary. + Format: [KEY] = BASE ... the number is calculated as KEY - BASE. + + *g:tlib#input#keyagents_InputList_s* +g:tlib#input#keyagents_InputList_s + The default key bindings for single-item-select list views. + + This variable is best customized via the variable + g:tlib_extend_keyagents_InputList_s. If you want to use , + to move the cursor up and down, add these two lines to your |vimrc| + file: + + let g:tlib_extend_keyagents_InputList_s = { + \ 10: 'tlib#agent#Down', + \ 11: 'tlib#agent#Up' + \ } + + *g:tlib#input#keyagents_InputList_m* +g:tlib#input#keyagents_InputList_m + + *g:tlib#input#handlers_EditList* +g:tlib#input#handlers_EditList + + *g:tlib#input#user_shortcuts* +g:tlib#input#user_shortcuts (default: {}) + A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to + customize keyboard shortcuts in the list view. + + *g:tlib#input#use_popup* +g:tlib#input#use_popup (default: has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32'))) + If true, define a popup menu for |tlib#input#List()| and related + functions. + + *g:tlib#input#format_filename* +g:tlib#input#format_filename (default: 'l') + How to format filenames: + l ... Show basenames on the left side, separated from the + directory names + r ... Show basenames on the right side + + *g:tlib#input#filename_padding_r* +g:tlib#input#filename_padding_r (default: '&co / 10') + If g:tlib#input#format_filename == 'r', how much space should be kept + free on the right side. + + *g:tlib#input#filename_max_width* +g:tlib#input#filename_max_width (default: '&co / 2') + If g:tlib#input#format_filename == 'l', an expression that + |eval()|uates to the maximum display width of filenames. + + *tlib#input#List()* +tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) + Select a single or multiple items from a list. Return either the list + of selected elements or its indexes. + + By default, typing numbers will select an item by its index. See + |g:tlib#input#numeric_chars| to find out how to change this. + + The item is automatically selected if the numbers typed equals the + number of digits of the list length. I.e. if a list contains 20 items, + typing 1 will first highlight item 1 but it won't select/use it + because 1 is an ambiguous input in this context. If you press enter, + the first item will be selected. If you press another digit (e.g. 0), + item 10 will be selected. Another way to select item 1 would be to + type 01. If the list contains only 9 items, typing 1 would select the + first item right away. + + type can be: + s ... Return one selected element + si ... Return the index of the selected element + m ... Return a list of selected elements + mi ... Return a list of indexes + + Several pattern matching styles are supported. See + |g:tlib#input#filter_mode|. + + Users can type to complete the current filter with the longest + match. + + EXAMPLES: > + echo tlib#input#List('s', 'Select one item', [100,200,300]) + echo tlib#input#List('si', 'Select one item', [100,200,300]) + echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) + echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) + +< See ../samples/tlib/input/tlib_input_list.vim (move the cursor over + the filename and press gf) for a more elaborated example. + + *tlib#input#ListD()* +tlib#input#ListD(dict) + A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from + dict. + + *tlib#input#ListW()* +tlib#input#ListW(world, ?command='') + The second argument (command) is meant for internal use only. + The same as |tlib#input#List| but the arguments are packed into world + (an instance of tlib#World as returned by |tlib#World#New|). + + *tlib#input#EditList()* +tlib#input#EditList(query, list, ?timeout=0) + Edit a list. + + EXAMPLES: > + echo tlib#input#EditList('Edit:', [100,200,300]) +< + + *tlib#input#Resume()* +tlib#input#Resume(name, pick, bufnr) + + *tlib#input#CommandSelect()* +tlib#input#CommandSelect(command, ?keyargs={}) + Take a command, view the output, and let the user select an item from + its output. + + EXAMPLE: > + command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') + command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +< + + *tlib#input#Edit()* +tlib#input#Edit(name, value, callback, ?cb_args=[]) + + Edit a value (asynchronously) in a scratch buffer. Use name for + identification. Call callback when done (or on cancel). + In the scratch buffer: + Press or to enter the new value, c to cancel + editing. + EXAMPLES: > + fun! FooContinue(success, text) + if a:success + let b:var = a:text + endif + endf + call tlib#input#Edit('foo', b:var, 'FooContinue') +< + + *tlib#input#Dialog()* +tlib#input#Dialog(text, options, default) + + +======================================================================== +autoload/tlib/number.vim~ + + *tlib#number#ConvertBase()* +tlib#number#ConvertBase(num, base, ...) + + +======================================================================== +autoload/tlib/file.vim~ + + *g:tlib#file#drop* +g:tlib#file#drop (default: has('gui')) + If true, use |:drop| to edit loaded buffers (only available with GUI). + + *g:tlib#file#use_tabs* +g:tlib#file#use_tabs (default: 0) + + *g:tlib#file#edit_cmds* +g:tlib#file#edit_cmds (default: g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {}) + + *g:tlib#file#absolute_filename_rx* +g:tlib#file#absolute_filename_rx (default: '^\~\?[\/]') + + *tlib#file#Split()* +tlib#file#Split(filename) + EXAMPLES: > + tlib#file#Split('foo/bar/filename.txt') + => ['foo', 'bar', 'filename.txt'] +< + + *tlib#file#Join()* +tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) + EXAMPLES: > + tlib#file#Join(['foo', 'bar', 'filename.txt']) + => 'foo/bar/filename.txt' +< + + *tlib#file#Relative()* +tlib#file#Relative(filename, basedir) + EXAMPLES: > + tlib#file#Relative('foo/bar/filename.txt', 'foo') + => 'bar/filename.txt' +< + + *tlib#file#Absolute()* +tlib#file#Absolute(filename, ...) + + *tlib#file#Canonic()* +tlib#file#Canonic(filename, ...) + + *tlib#file#With()* +tlib#file#With(fcmd, bcmd, files, ?world={}) + + *tlib#file#Edit()* +tlib#file#Edit(fileid) + Return 0 if the file isn't readable/doesn't exist. + Otherwise return 1. + + *tlib#file#Glob()* +tlib#file#Glob(pattern) + + *tlib#file#Globpath()* +tlib#file#Globpath(path, pattern) + + +======================================================================== +autoload/tlib/sys.vim~ + + *g:tlib#sys#special_protocols* +g:tlib#sys#special_protocols (default: ['https\?', 'nntp', 'mailto']) + A list of |regexp|s matching protocol names that should be handled + by |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#special_suffixes* +g:tlib#sys#special_suffixes (default: ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif']) + A list of |regexp|s matching suffixes that should be handled by + |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_rx* +g:tlib#sys#system_rx (default: printf('\V\%(\^\%(%s\):\|.\%(%s\)\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|'))) + Open links matching this |regexp| with |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_browser* +g:tlib#sys#system_browser (default: ...) + Open files in the system browser. + + *g:tlib#sys#windows* +g:tlib#sys#windows (default: &shell !~ 'sh' && (has('win16') || has('win32') || has('win64'))) + + *g:tlib#sys#null* +g:tlib#sys#null (default: g:tlib#sys#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : '')) + + *tlib#sys#IsCygwinBin()* +tlib#sys#IsCygwinBin(cmd) + + *tlib#sys#IsExecutable()* +tlib#sys#IsExecutable(cmd, ...) + + *g:tlib#sys#check_cygpath* +g:tlib#sys#check_cygpath (default: g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1)) + If true, check whether we have to convert a path via cyppath -- + see |tlib#sys#MaybeUseCygpath| + + *g:tlib#sys#cygwin_path_rx* +g:tlib#sys#cygwin_path_rx (default: '/cygwin/') + If a full windows filename (with slashes instead of backslashes) + matches this |regexp|, it is assumed to be a cygwin executable. + + *g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_expr (default: '"bash -c ''". escape(%s, "''\\") ."''"') + For cygwin binaries, convert command calls using this vim + expression. + + *tlib#sys#GetCmd()* +tlib#sys#GetCmd(cmd) + + *tlib#sys#MaybeUseCygpath()* +tlib#sys#MaybeUseCygpath(cmd) + If cmd seems to be a cygwin executable, use cygpath to convert + filenames. This assumes that cygwin's which command returns full + filenames for non-cygwin executables. + + *tlib#sys#ConvertPath()* +tlib#sys#ConvertPath(converter, filename) + + *tlib#sys#FileArgs()* +tlib#sys#FileArgs(cmd, files) + + *tlib#sys#IsSpecial()* +tlib#sys#IsSpecial(filename) + Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it + is a special file that should not be opened in vim. + + *tlib#sys#Open()* +tlib#sys#Open(filename) + Open filename with the default OS application (see + |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. + Returns 1 if successful or 0 otherwise. + + *tlib#sys#SystemInDir()* +tlib#sys#SystemInDir(dir, expr, ?input='') + + +======================================================================== +autoload/tlib/paragraph.vim~ + + *tlib#paragraph#GetMetric()* +tlib#paragraph#GetMetric() + Return an object describing a |paragraph|. + + *tlib#paragraph#Move()* +tlib#paragraph#Move(direction, count) + This function can be used with the tinymode plugin to move around + paragraphs. + + Example configuration: > + + call tinymode#EnterMap("para_move", "gp") + call tinymode#ModeMsg("para_move", "Move paragraph: j/k") + call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") + call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") + call tinymode#ModeArg("para_move", "owncount", 1) +< + + +======================================================================== +autoload/tlib/World.vim~ +A prototype used by |tlib#input#List|. +Inherits from |tlib#Object#New|. + + *g:tlib_inputlist_pct* +g:tlib_inputlist_pct (default: 50) + Size of the input list window (in percent) from the main size (of &lines). + See |tlib#input#List()|. + + *g:tlib_inputlist_width_filename* +g:tlib_inputlist_width_filename (default: '&co / 3') + Size of filename columns when listing filenames. + See |tlib#input#List()|. + + *g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_filename_indicators (default: 0) + If true, |tlib#input#List()| will show some indicators about the + status of a filename (e.g. buflisted(), bufloaded() etc.). + This is disabled by default because vim checks also for the file on + disk when doing this. + + *g:tlib_inputlist_shortmessage* +g:tlib_inputlist_shortmessage (default: 0) + If not null, display only a short info about the filter. + + *tlib#World#New()* +tlib#World#New(...) + +prototype.PrintLines + +prototype.Suspend + + +======================================================================== +autoload/tlib/loclist.vim~ + + *tlib#loclist#Browse()* +tlib#loclist#Browse(...) + + +======================================================================== +autoload/tlib/tab.vim~ + + *tlib#tab#BufMap()* +tlib#tab#BufMap() + Return a dictionary of bufnumbers => [[tabpage, winnr] ...] + + *tlib#tab#TabWinNr()* +tlib#tab#TabWinNr(buffer) + Find a buffer's window at some tab page. + + *tlib#tab#Set()* +tlib#tab#Set(tabnr) + + +======================================================================== +autoload/tlib/date.vim~ + + *tlib#date#IsDate()* +tlib#date#IsDate(text) + + *tlib#date#Format()* +tlib#date#Format(secs1970) + + *tlib#date#DiffInDays()* +tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) + + *tlib#date#Parse()* +tlib#date#Parse(date, ?allow_zero=0) "{{{3 + + *tlib#date#SecondsSince1970()* +tlib#date#SecondsSince1970(date, ...) + tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) + + *tlib#date#Shift()* +tlib#date#Shift(date, shift) + + +======================================================================== +autoload/tlib/type.vim~ + + *tlib#type#IsNumber()* +tlib#type#IsNumber(expr) + + *tlib#type#IsString()* +tlib#type#IsString(expr) + + *tlib#type#IsFuncref()* +tlib#type#IsFuncref(expr) + + *tlib#type#IsList()* +tlib#type#IsList(expr) + + *tlib#type#IsDictionary()* +tlib#type#IsDictionary(expr) + + *tlib#type#Is()* +tlib#type#Is(val, type) + + *tlib#type#Are()* +tlib#type#Are(vals, type) + + *tlib#type#Has()* +tlib#type#Has(val, lst) + + *tlib#type#Have()* +tlib#type#Have(vals, lst) + + +======================================================================== +autoload/tlib/Filter_fuzzy.vim~ + + *tlib#Filter_fuzzy#New()* +tlib#Filter_fuzzy#New(...) + Support for "fuzzy" pattern matching in |tlib#input#List()|. + Patterns are interpreted as if characters were connected with '.\{-}'. + + In "fuzzy" mode, the pretty printing of filenames is disabled. + + +======================================================================== +autoload/tlib/assert.vim~ + + *tlib#assert#Enable()* +tlib#assert#Enable() + Enable tracing via |:Tlibassert|. + + *tlib#assert#Disable()* +tlib#assert#Disable() + Disable tracing via |:Tlibassert|. + + *tlib#assert#Assert()* +tlib#assert#Assert(caller, check, vals) + + *tlib#assert#Map()* +tlib#assert#Map(vals, expr) + + *tlib#assert#All()* +tlib#assert#All(vals) + + +======================================================================== +autoload/tlib/textobjects.vim~ + + *standard-paragraph* +tlib#textobjects#StandardParagraph() + Select a "Standard Paragraph", i.e. a text block followed by blank + lines. Other than |ap|, the last paragraph in a document is handled + just the same. + + The |text-object| can be accessed as "sp". Example: > + + vsp ... select the current standard paragraph + +< Return 1, if the paragraph is the last one in the document. + + *tlib#textobjects#Init()* +tlib#textobjects#Init() + + *v_sp* +v_sp ... :call tlib#textobjects#StandardParagraph() + sp ... Standard paragraph (for use as |text-objects|). + + *o_sp* +o_sp ... :normal Vsp + + +======================================================================== +autoload/tlib/arg.vim~ + + *tlib#arg#Get()* +tlib#arg#Get(n, var, ?default="", ?test='') + Set a positional argument from a variable argument list. + See tlib#string#RemoveBackslashes() for an example. + + *tlib#arg#Let()* +tlib#arg#Let(list, ?default='') + Set a positional arguments from a variable argument list. + See tlib#input#List() for an example. + + *tlib#arg#StringAsKeyArgs()* +tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':', ?booleans=0) + + *tlib#arg#StringAsKeyArgsEqual()* +tlib#arg#StringAsKeyArgsEqual(string) + + *tlib#arg#GetOpts()* +tlib#arg#GetOpts(args, ?def={}) + Convert a list of strings of command-line arguments into a dictonary. + + The main use case is to pass [], i.e. the command-line + arguments of a command as list, from a command definition to this + function. + + Example: + ['-h'] + => If def contains a 'help' key, invoke |:help| on its value. + + ['-ab', '--foo', '--bar=BAR', 'bla', bla'] + => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} + + ['-ab', '--', '--foo', '--bar=BAR'] + => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} + + *tlib#arg#Ex()* +tlib#arg#Ex(arg, ?chars='%#! ') + Escape some characters in a string. + + Use |fnamescape()| if available. + + EXAMPLES: > + exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +< + + +======================================================================== +autoload/tlib/fixes.vim~ + + *tlib#fixes#Winpos()* +tlib#fixes#Winpos() + + +======================================================================== +autoload/tlib/dir.vim~ + + *g:tlib#dir#sep* +g:tlib#dir#sep (default: exists('+shellslash') && !&shellslash ? '\' : '/') + TLet g:tlib#dir#sep = '/' + + *tlib#dir#CanonicName()* +tlib#dir#CanonicName(dirname) + EXAMPLES: > + tlib#dir#CanonicName('foo/bar') + => 'foo/bar/' +< + + *tlib#dir#NativeName()* +tlib#dir#NativeName(dirname) + EXAMPLES: > + tlib#dir#NativeName('foo/bar/') + On Windows: + => 'foo\bar\' + On Linux: + => 'foo/bar/' +< + + *tlib#dir#PlainName()* +tlib#dir#PlainName(dirname) + EXAMPLES: > + tlib#dir#PlainName('foo/bar/') + => 'foo/bar' +< + + *tlib#dir#Ensure()* +tlib#dir#Ensure(dir) + Create a directory if it doesn't already exist. + + *tlib#dir#MyRuntime()* +tlib#dir#MyRuntime() + Return the first directory in &rtp. + + *tlib#dir#CD()* +tlib#dir#CD(dir, ?locally=0) + + *tlib#dir#Push()* +tlib#dir#Push(dir, ?locally=0) + + *tlib#dir#Pop()* +tlib#dir#Pop() + + +======================================================================== +autoload/tlib/hash.vim~ + + *g:tlib#hash#use_crc32* +g:tlib#hash#use_crc32 (default: '') + + *g:tlib#hash#use_adler32* +g:tlib#hash#use_adler32 (default: '') + + *tlib#hash#CRC32B()* +tlib#hash#CRC32B(chars) + + *tlib#hash#CRC32B_ruby()* +tlib#hash#CRC32B_ruby(chars) + + *tlib#hash#CRC32B_vim()* +tlib#hash#CRC32B_vim(chars) + + *tlib#hash#Adler32()* +tlib#hash#Adler32(chars) + + *tlib#hash#Adler32_vim()* +tlib#hash#Adler32_vim(chars) + + *tlib#hash#Adler32_tlib()* +tlib#hash#Adler32_tlib(chars) + + +======================================================================== +autoload/tlib/win.vim~ + + *tlib#win#Set()* +tlib#win#Set(winnr) + Return vim code to jump back to the original window. + + *tlib#win#GetLayout()* +tlib#win#GetLayout(?save_view=0) + + *tlib#win#SetLayout()* +tlib#win#SetLayout(layout) + + *tlib#win#List()* +tlib#win#List() + + *tlib#win#Width()* +tlib#win#Width(wnr) + + *tlib#win#WinDo()* +tlib#win#WinDo(ex) + + +======================================================================== +autoload/tlib/comments.vim~ + + *tlib#comments#Comments()* +tlib#comments#Comments(...) + function! tlib#comments#Comments(?rx='') + + +======================================================================== +autoload/tlib/grep.vim~ + + *tlib#grep#Do()* +tlib#grep#Do(cmd, rx, files) + + *tlib#grep#LocList()* +tlib#grep#LocList(rx, files) + + *tlib#grep#QuickFixList()* +tlib#grep#QuickFixList(rx, files) + + *tlib#grep#List()* +tlib#grep#List(rx, files) + + +======================================================================== +autoload/tlib/qfl.vim~ + + *tlib#qfl#FormatQFLE()* +tlib#qfl#FormatQFLE(qfe) + + *tlib#qfl#QfeFilename()* +tlib#qfl#QfeFilename(qfe) + + *tlib#qfl#InitListBuffer()* +tlib#qfl#InitListBuffer(world) + + *tlib#qfl#SetSyntax()* +tlib#qfl#SetSyntax() + + *tlib#qfl#Balloon()* +tlib#qfl#Balloon() + + *tlib#qfl#AgentEditQFE()* +tlib#qfl#AgentEditQFE(world, selected, ...) + + *tlib#qfl#AgentPreviewQFE()* +tlib#qfl#AgentPreviewQFE(world, selected) + + *tlib#qfl#AgentGotoQFE()* +tlib#qfl#AgentGotoQFE(world, selected) + + *tlib#qfl#AgentWithSelected()* +tlib#qfl#AgentWithSelected(world, selected, ...) + + *tlib#qfl#RunCmdOnSelected()* +tlib#qfl#RunCmdOnSelected(world, selected, cmd, ...) + + *tlib#qfl#AgentSplitBuffer()* +tlib#qfl#AgentSplitBuffer(world, selected) + + *tlib#qfl#AgentTabBuffer()* +tlib#qfl#AgentTabBuffer(world, selected) + + *tlib#qfl#AgentVSplitBuffer()* +tlib#qfl#AgentVSplitBuffer(world, selected) + + *tlib#qfl#AgentEditLine()* +tlib#qfl#AgentEditLine(world, selected) + + *tlib#qfl#EditLine()* +tlib#qfl#EditLine(lnum) + + *tlib#qfl#SetFollowCursor()* +tlib#qfl#SetFollowCursor(world, selected) + + *tlib#qfl#QflList()* +tlib#qfl#QflList(list, ...) + + *tlib#qfl#Browse()* +tlib#qfl#Browse(...) + + +======================================================================== +autoload/tlib/Filter_cnf.vim~ + + *tlib#Filter_cnf#New()* +tlib#Filter_cnf#New(...) + The search pattern for |tlib#input#List()| is in conjunctive normal + form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... + The pattern is a '/\V' very no-'/magic' regexp pattern. + + Pressing joins two patterns with AND. + Pressing | joins two patterns with OR. + I.e. In order to get "lala AND (foo OR bar)", you type + "lala foo|bar". + + This is also the base class for other filters. + +prototype.Pretty + + +======================================================================== +autoload/tlib/Object.vim~ +Provides a prototype plus some OO-like methods. + + *tlib#Object#New()* +tlib#Object#New(?fields={}) + This function creates a prototype that provides some kind of + inheritance mechanism and a way to call parent/super methods. + + The usage demonstrated in the following example works best when every + class/prototype is defined in a file of its own. + + The reason for why there is a dedicated constructor function is that + this layout facilitates the use of templates and that methods are + hidden from the user. Other solutions are possible. + + EXAMPLES: > + let s:prototype = tlib#Object#New({ + \ '_class': ['FooBar'], + \ 'foo': 1, + \ 'bar': 2, + \ }) + " Constructor + function! FooBar(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object + endf + function! s:prototype.babble() { + echo "I think, therefore I am ". (self.foo * self.bar) ." months old." + } + +< This could now be used like this: > + let myfoo = FooBar({'foo': 3}) + call myfoo.babble() + => I think, therefore I am 6 months old. + echo myfoo.IsA('FooBar') + => 1 + echo myfoo.IsA('object') + => 1 + echo myfoo.IsA('Foo') + => 0 + echo myfoo.RespondTo('babble') + => 1 + echo myfoo.RespondTo('speak') + => 0 +< + +prototype.New + +prototype.Inherit + +prototype.Extend + +prototype.IsA + +prototype.IsRelated + +prototype.RespondTo + +prototype.Super + + *tlib#Object#Methods()* +tlib#Object#Methods(object, ...) + + +======================================================================== +autoload/tlib/buffer.vim~ + + *g:tlib_viewline_position* +g:tlib_viewline_position (default: 'zz') + Where to display the line when using |tlib#buffer#ViewLine|. + For possible values for position see |scroll-cursor|. + + *tlib#buffer#EnableMRU()* +tlib#buffer#EnableMRU() + + *tlib#buffer#DisableMRU()* +tlib#buffer#DisableMRU() + + *tlib#buffer#Set()* +tlib#buffer#Set(buffer) + Set the buffer to buffer and return a command as string that can be + evaluated by |:execute| in order to restore the original view. + + *tlib#buffer#Eval()* +tlib#buffer#Eval(buffer, code) + Evaluate CODE in BUFFER. + + EXAMPLES: > + call tlib#buffer#Eval('foo.txt', 'echo b:bar') +< + + *tlib#buffer#GetList()* +tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') + Possible values for the "order" argument: + bufnr :: Default behaviour + mru :: Sort buffers according to most recent use + basename :: Sort by the file's basename (last component) + + NOTE: MRU order works on second invocation only. If you want to always + use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. + + *tlib#buffer#ViewLine()* +tlib#buffer#ViewLine(line, ?position='z') + line is either a number or a string that begins with a number. + For possible values for position see |scroll-cursor|. + See also |g:tlib_viewline_position|. + + *tlib#buffer#HighlightLine()* +tlib#buffer#HighlightLine(...) + + *tlib#buffer#DeleteRange()* +tlib#buffer#DeleteRange(line1, line2) + Delete the lines in the current buffer. Wrapper for |:delete|. + + *tlib#buffer#ReplaceRange()* +tlib#buffer#ReplaceRange(line1, line2, lines) + Replace a range of lines. + + *tlib#buffer#ScratchStart()* +tlib#buffer#ScratchStart() + Initialize some scratch area at the bottom of the current buffer. + + *tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchEnd() + Remove the in-buffer scratch area. + + *tlib#buffer#BufDo()* +tlib#buffer#BufDo(exec) + Run exec on all buffers via bufdo and return to the original buffer. + + *tlib#buffer#InsertText()* +tlib#buffer#InsertText(text, keyargs) + Keyargs: + 'shift': 0|N + 'col': col('.')|N + 'lineno': line('.')|N + 'indent': 0|1 + 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) + Insert text (a string) in the buffer. + + *tlib#buffer#InsertText0()* +tlib#buffer#InsertText0(text, ...) + + *tlib#buffer#CurrentByte()* +tlib#buffer#CurrentByte() + + *tlib#buffer#KeepCursorPosition()* +tlib#buffer#KeepCursorPosition(cmd) + Evaluate cmd while maintaining the cursor position and jump registers. + + +======================================================================== +autoload/tlib/hook.vim~ + + *tlib#hook#Run()* +tlib#hook#Run(hook, ?dict={}) + Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. + + +======================================================================== +autoload/tlib/string.vim~ + + *tlib#string#RemoveBackslashes()* +tlib#string#RemoveBackslashes(text, ?chars=' ') + Remove backslashes from text (but only in front of the characters in + chars). + + *tlib#string#Chomp()* +tlib#string#Chomp(string, ?max=0) + + *tlib#string#Format()* +tlib#string#Format(template, dict) + + *tlib#string#Printf1()* +tlib#string#Printf1(format, string) + This function deviates from |printf()| in certain ways. + Additional items: + %{rx} ... insert escaped regexp + %{fuzzyrx} ... insert typo-tolerant regexp + + *tlib#string#TrimLeft()* +tlib#string#TrimLeft(string) + + *tlib#string#TrimRight()* +tlib#string#TrimRight(string) + + *tlib#string#Strip()* +tlib#string#Strip(string) + + *tlib#string#Count()* +tlib#string#Count(string, rx) + + *tlib#string#SplitCommaList()* +tlib#string#SplitCommaList(text, ...) + + + +vim:tw=78:fo=w2croql:isk=!-~,^*,^|,^":ts=8:ft=help:norl: diff --git a/sources_non_forked/tlib/plugin/02tlib.vim b/sources_non_forked/tlib/plugin/02tlib.vim new file mode 100644 index 00000000..cc2c3ca0 --- /dev/null +++ b/sources_non_forked/tlib/plugin/02tlib.vim @@ -0,0 +1,102 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Created: 2007-04-10. +" @Last Change: 2015-11-23. +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 808 +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" GetLatestVimScripts: 1863 1 tlib.vim +" tlib.vim -- Some utility functions + +if &cp || exists("g:loaded_tlib") + finish +endif +if v:version < 700 "{{{2 + echoerr "tlib requires Vim >= 7" + finish +endif +let g:loaded_tlib = 117 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: :TLet VAR = VALUE +" Set a variable only if it doesn't already exist. +" EXAMPLES: > +" TLet foo = 1 +" TLet foo = 2 +" echo foo +" => 1 +command! -nargs=+ TLet if !exists(matchstr(, '^[^=[:space:]]\+')) | exec 'let '. | endif + + +" Open a scratch buffer (a buffer without a file). +" TScratch ... use split window +" TScratch! ... use the whole frame +" This command takes an (inner) dictionary as optional argument. +" EXAMPLES: > +" TScratch 'scratch': '__FOO__' +" => Open a scratch buffer named __FOO__ +command! -bar -nargs=* -bang TScratch call tlib#scratch#UseScratch({'scratch_split': empty(''), }) + + +" :display: :TVarArg VAR1, [VAR2, DEFAULT2] ... +" A convenience wrapper for |tlib#arg#Let|. +" EXAMPLES: > +" function! Foo(...) +" TVarArg ['a', 1], 'b' +" echo 'a='. a +" echo 'b='. b +" endf +command! -nargs=+ TVarArg exec tlib#arg#Let([]) + + +" :display: :TBrowseOutput COMMAND +" Ever wondered how to efficiently browse the output of a command +" without redirecting it to a file? This command takes a command as +" argument and presents the output via |tlib#input#List()| so that you +" can easily search for a keyword (e.g. the name of a variable or +" function) and the like. +" +" If you press enter, the selected line will be copied to the command +" line. Press ESC to cancel browsing. +" +" EXAMPLES: > +" TBrowseOutput 20verb TeaseTheCulprit +command! -nargs=1 -complete=command TBrowseOutput call tlib#cmd#BrowseOutput() + + +" :display: :TBrowseScriptnames +" List all sourced script names (the output of ':scriptnames'). +" +" When you press enter, the selected script will be opened in the current +" window. Press ESC to cancel. +" +" EXAMPLES: > +" TBrowseScriptnames +command! -nargs=0 -complete=command TBrowseScriptnames call tlib#cmd#TBrowseScriptnames() + + +" :display: :Tlibtrace GUARD, VAR1, VAR2... +" Do nothing unless |tlib#trace#Enable()| was called. +" +" When |:Tlibtraceset| or |tlib#trace#Enable()| were called: +" +" If GUARD is a number that evaluates to true or if it is a string that +" matches a |regexp|, which was added using Tlibtrace! (with '!'), +" display the values of VAR1, VAR2 ... +command! -nargs=+ -bang -bar Tlibtrace : + + +" :Tlibtraceset +RX1, -RX2... +" If |tlib#trace#Enable()| was called: With the optional , users +" can add and remove GUARDs (actually a |regexp|) that should be traced. +command! -nargs=+ -bang -bar Tlibtraceset call tlib#trace#Set() + + +" :display: :Tlibtrace ASSERTION +command! -nargs=+ -bang -bar Tlibassert : + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/test/tlib.vim b/sources_non_forked/tlib/test/tlib.vim new file mode 100644 index 00000000..2277d361 --- /dev/null +++ b/sources_non_forked/tlib/test/tlib.vim @@ -0,0 +1,219 @@ +" tLib.vim +" @Author: Thomas Link (mailto:micathom AT gmail com?subject=vim-tLib) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2006-12-17. +" @Last Change: 2008-11-23. +" @Revision: 129 + +if !exists("loaded_tassert") + echoerr 'tAssert (vimscript #1730) is required' +endif + + +TAssertBegin! "tlib" + + +" List {{{2 +fun! Add(a,b) + return a:a + a:b +endf +TAssert IsEqual(tlib#list#Inject([], 0, function('Add')), 0) +TAssert IsEqual(tlib#list#Inject([1,2,3], 0, function('Add')), 6) +delfunction Add + +TAssert IsEqual(tlib#list#Compact([]), []) +TAssert IsEqual(tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3]) + +TAssert IsEqual(tlib#list#Flatten([]), []) +TAssert IsEqual(tlib#list#Flatten([1,2,3]), [1,2,3]) +TAssert IsEqual(tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3]) +TAssert IsEqual(tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""]) + +TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3]) +TAssert IsEqual(tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30]) + +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2'), 2) +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20) +TAssert IsEqual(tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10) + +TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 2'), 1) +TAssert IsEqual(tlib#list#Any([1,2,3], 'v:val >= 5'), 0) + +TAssert IsEqual(tlib#list#All([1,2,3], 'v:val < 5'), 1) +TAssert IsEqual(tlib#list#All([1,2,3], 'v:val >= 2'), 0) + +TAssert IsEqual(tlib#list#Remove([1,2,1,2], 2), [1,1,2]) +TAssert IsEqual(tlib#list#RemoveAll([1,2,1,2], 2), [1,1]) + +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]]) +TAssert IsEqual(tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]]) + + +" Vars {{{2 +let g:foo = 1 +let g:bar = 2 +let b:bar = 3 +let s:bar = 4 + +TAssert IsEqual(tlib#var#Get('bar', 'bg'), 3) +TAssert IsEqual(tlib#var#Get('bar', 'g'), 2) +TAssert IsEqual(tlib#var#Get('foo', 'bg'), 1) +TAssert IsEqual(tlib#var#Get('foo', 'g'), 1) +TAssert IsEqual(tlib#var#Get('none', 'l'), '') + +TAssert IsEqual(eval(tlib#var#EGet('bar', 'bg')), 3) +TAssert IsEqual(eval(tlib#var#EGet('bar', 'g')), 2) +" TAssert IsEqual(eval(tlib#var#EGet('bar', 'sg')), 4) +TAssert IsEqual(eval(tlib#var#EGet('foo', 'bg')), 1) +TAssert IsEqual(eval(tlib#var#EGet('foo', 'g')), 1) +TAssert IsEqual(eval(tlib#var#EGet('none', 'l')), '') + +unlet g:foo +unlet g:bar +unlet b:bar + + + +" Filenames {{{2 +TAssert IsEqual(tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt']) +TAssert IsEqual(tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt']) +TAssert IsEqual(tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt']) + +TAssert IsEqual(tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt') + +TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt') +TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt') +TAssert IsEqual(tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt') + + + +" Prototype-based programming {{{2 +let test = tlib#Test#New() +TAssert test.IsA('Test') +TAssert !test.IsA('foo') +TAssert test.RespondTo('RespondTo') +TAssert !test.RespondTo('RespondToNothing') +let test1 = tlib#Test#New() +TAssert test.IsRelated(test1) +let testworld = tlib#World#New() +TAssert !test.IsRelated(testworld) + +let testc = tlib#TestChild#New() +TAssert IsEqual(testc.Dummy(), 'TestChild.vim') +TAssert IsEqual(testc.Super('Dummy', []), 'Test.vim') + + + +" Optional arguments {{{2 +function! TestGetArg(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1) + return foo +endf + +function! TestGetArg1(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1, '!= ""') + return foo +endf + +TAssert IsEqual(TestGetArg(), 1) +TAssert IsEqual(TestGetArg(''), '') +TAssert IsEqual(TestGetArg(2), 2) +TAssert IsEqual(TestGetArg1(), 1) +TAssert IsEqual(TestGetArg1(''), 1) +TAssert IsEqual(TestGetArg1(2), 2) + +function! TestArgs(...) "{{{3 + exec tlib#arg#Let([['foo', "o"], ['bar', 2]]) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs(), 'oo') +TAssert IsEqual(TestArgs('a'), 'aa') +TAssert IsEqual(TestArgs('a', 3), 'aaa') + +function! TestArgs1(...) "{{{3 + exec tlib#arg#Let(['foo', ['bar', 2]]) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs1(), '') +TAssert IsEqual(TestArgs1('a'), 'aa') +TAssert IsEqual(TestArgs1('a', 3), 'aaa') + +function! TestArgs2(...) "{{{3 + exec tlib#arg#Let(['foo', 'bar'], 1) + return repeat(foo, bar) +endf +TAssert IsEqual(TestArgs2(), '1') +TAssert IsEqual(TestArgs2('a'), 'a') +TAssert IsEqual(TestArgs2('a', 3), 'aaa') + +function! TestArgs3(...) + TVarArg ['a', 1], 'b' + return a . b +endf +TAssert IsEqual(TestArgs3(), '1') +TAssert IsEqual(TestArgs3('a'), 'a') +TAssert IsEqual(TestArgs3('a', 3), 'a3') + +delfunction TestGetArg +delfunction TestGetArg1 +delfunction TestArgs +delfunction TestArgs1 +delfunction TestArgs2 +delfunction TestArgs3 + + + +" Strings {{{2 +TAssert IsString(tlib#string#RemoveBackslashes('foo bar')) +TAssert IsEqual(tlib#string#RemoveBackslashes('foo bar'), 'foo bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar') +TAssert IsEqual(tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar') + + + +" Regexp {{{2 +for c in split('^$.*+\()|{}[]~', '\zs') + let s = printf('%sfoo%sbar%s', c, c, c) + TAssert (s =~ '\m^'. tlib#rx#Escape(s, 'm') .'$') + TAssert (s =~ '\M^'. tlib#rx#Escape(s, 'M') .'$') + TAssert (s =~ '\v^'. tlib#rx#Escape(s, 'v') .'$') + TAssert (s =~ '\V\^'. tlib#rx#Escape(s, 'V') .'\$') +endfor + + +" Encode, decode +TAssert IsEqual(tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar') +TAssert IsEqual(tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.') + +TAssert IsEqual(tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar') +TAssert IsEqual(tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.') + +TAssertEnd test test1 testc testworld + + +TAssert IsEqual(tlib#string#Count("fooo", "o"), 3) +TAssert IsEqual(tlib#string#Count("***", "\\*"), 3) +TAssert IsEqual(tlib#string#Count("***foo", "\\*"), 3) +TAssert IsEqual(tlib#string#Count("foo***", "\\*"), 3) + + +finish "{{{1 + + +" Input {{{2 +echo tlib#input#List('s', 'Test', ['barfoobar', 'barFoobar']) +echo tlib#input#List('s', 'Test', ['barfoobar', 'bar foo bar', 'barFoobar']) +echo tlib#input#List('s', 'Test', ['barfoobar', 'bar1Foo1bar', 'barFoobar']) +echo tlib#input#EditList('Test', ['bar1', 'bar2', 'bar3', 'foo1', 'foo2', 'foo3']) + + diff --git a/sources_non_forked/vim-abolish/.gitignore b/sources_non_forked/vim-abolish/.gitignore new file mode 100644 index 00000000..0a56e3fc --- /dev/null +++ b/sources_non_forked/vim-abolish/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_non_forked/vim-abolish/CONTRIBUTING.markdown b/sources_non_forked/vim-abolish/CONTRIBUTING.markdown new file mode 100644 index 00000000..b3f00951 --- /dev/null +++ b/sources_non_forked/vim-abolish/CONTRIBUTING.markdown @@ -0,0 +1 @@ +See the [contribution guidelines for pathogen.vim](https://github.com/tpope/vim-pathogen/blob/master/CONTRIBUTING.markdown). diff --git a/sources_non_forked/vim-abolish/README.markdown b/sources_non_forked/vim-abolish/README.markdown new file mode 100644 index 00000000..e8dd0d03 --- /dev/null +++ b/sources_non_forked/vim-abolish/README.markdown @@ -0,0 +1,149 @@ +# abolish.vim + +I sat on this plugin for 3 years before releasing it, primarily +because it's so gosh darn hard to explain. It's three superficially +unrelated plugins in one that share a common theme: working with +variants of a word. + +## Abbreviation + +I know how to spell "separate". I know how to spell "desperate". My +fingers, however, have trouble distinguishing between the two, and I +invariably have a 50 percent chance of typing "seperate" or "desparate" +each time one of these comes up. At first, I tried abbreviations: + + :iabbrev seperate separate + :iabbrev desparate desperate + +But this falls short at the beginning of a sentence. + + :iabbrev Seperate Separate + :iabbrev Desparate Desperate + +To be really thorough, we need uppercase too! + + :iabbrev SEPERATE SEPARATE + :iabbrev DESPARATE DESPERATE + +Oh, but consider the noun form, and the adverb form! + + :iabbrev seperation separation + :iabbrev desparation desperation + :iabbrev seperately separately + :iabbrev desparately desperately + :iabbrev Seperation separation + :iabbrev Desparation Desperation + :iabbrev Seperately Separately + :iabbrev Desparately Desperately + :iabbrev SEPERATION SEPARATION + :iabbrev DESPARATION DESPERATION + :iabbrev SEPERATELY SEPARATELY + :iabbrev DESPARATELY DESPERATELY + +Wait, there's also "separates", "separated", "separating", +"separations", "separator"... + +Abolish.vim provides a simpler way. The following one command produces +48 abbreviations including all of the above. + + :Abolish {despa,sepe}rat{e,es,ed,ing,ely,ion,ions,or} {despe,sepa}rat{} + +My current configuration has 25 Abolish commands that create hundreds of +corrections my fingers refuse to learn. + +## Substitution + +One time I had an application with a domain model called +"facility" that needed to be renamed to "building". So, a simple +search and replace, right? + + :%s/facility/building/g + +Oh, but the case variants! + + :%s/Facility/Building/g + :%s/FACILITY/BUILDING/g + +Wait, the plural is more than "s" so we need to get that too! + + :%s/facilities/buildings/g + :%s/Facilities/Buildings/g + :%s/FACILITIES/BUILDINGS/g + +Abolish.vim has your back. One command to do all six, and you can +repeat it with `&` too! + + :%Subvert/facilit{y,ies}/building{,s}/g + +From a conceptual level, one way to think about how this substitution +works is to imagine that in the braces you are declaring the +requirements for turning that word from singular to plural. In +the facility example, the same base letters in both the singular +and plural form of the word are `facilit` To turn "facility" to a +plural word you must change the `y` to `ies` so you specify +`{y,ies}` in the braces. + +To convert the word "building" from singular to plural, again +look at the common letters between the singular and plural forms: +`building`. In this case you do not need to remove any letter +from building to turn it into plural form and you need to +add an `s` so the braces should be `{,s}`. + +A few more examples: + +Address to Reference + + :Subvert/address{,es}/reference{,s}/g + +Blog to Post (you can just do this with a regular :s also) + + :Subvert/blog{,s}/post{,s}/g + +Child to Adult + + :Subvert/child{,ren}/adult{,s}/g + +Be amazed as it correctly turns the word children into the word adults! + +Die to Spinner + + :Subvert/di{e,ce}/spinner{,s}/g + +You can abbreviate it as `:S`, and it accepts the full range of flags +including things like `c` (confirm). + +There's also a variant for searching and a variant for grepping. + +## Coercion + +Want to turn `fooBar` into `foo_bar`? Press `crs` (coerce to +snake\_case). MixedCase (`crm`), camelCase (`crc`), snake\_case +(`crs`), UPPER\_CASE (`cru`), dash-case (`cr-`), dot.case (`cr.`), +space case (`cr`), and Title Case (`crt`) are all just 3 +keystrokes away. + +## Installation + +If you don't have a preferred installation method, I recommend +installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and +then simply copy and paste: + + cd ~/.vim/bundle + git clone git://github.com/tpope/vim-abolish.git + +Once help tags have been generated, you can view the manual with +`:help abolish`. + +## Self-Promotion + +Like abolish.vim? Follow the repository on +[GitHub](https://github.com/tpope/vim-abolish) and vote for it on +[vim.org](http://www.vim.org/scripts/script.php?script_id=1545). And if +you're feeling especially charitable, follow [tpope](http://tpo.pe/) on +[Twitter](http://twitter.com/tpope) and +[GitHub](https://github.com/tpope). + +## License + +Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. +See `:help license`. diff --git a/sources_non_forked/vim-abolish/doc/abolish.txt b/sources_non_forked/vim-abolish/doc/abolish.txt new file mode 100644 index 00000000..91f24da9 --- /dev/null +++ b/sources_non_forked/vim-abolish/doc/abolish.txt @@ -0,0 +1,181 @@ +*abolish.txt* Language friendly searches, substitutions, and abbreviations + +Author: Tim Pope +License: Same terms as Vim itself (see |license|) + +This plugin is only available if 'compatible' is not set. + +INTRODUCTION *abolish* *:Abolish* *:Subvert* + +Abolish lets you quickly find, substitute, and abbreviate several variations +of a word at once. By default, three case variants (foo, Foo, and FOO) are +operated on by every command. + +Two commands are provided. :Abolish is the most general interface. +:Subvert provides an alternative, more concise syntax for searching and +substituting. +> + :Abolish [options] {abbreviation} {replacement} + :Abolish -delete [options] {abbreviation} + + :Abolish -search [options] {pattern} + :Subvert/{pattern}[/flags] + :Abolish!-search [options] {pattern} + :Subvert?{pattern}[?flags] + + :Abolish -search [options] {pattern} {grep-arguments} + :Subvert /{pattern}/[flags] {grep-options} + :Abolish!-search [options] {pattern} {grep-arguments} + :Subvert!/{pattern}/[flags] {grep-options} + + :[range]Abolish -substitute [options] {pattern} {replacement} + :[range]Subvert/{pattern}/{replacement}[/flags] +< + *:S* +In addition to the :Subvert command, a :S synonym is provided if not +already defined. This will be used in examples below. + +PATTERNS *abolish-patterns* + +Patterns can include brace pairs that contain comma separated alternatives: + + box{,es} => box, boxes, Box, Boxes, BOX, BOXES + +For commands with a replacement, corresponding brace pairs are used in both +halves. If the replacement should be identical to the pattern, an empty +brace pair may be used. If fewer replacements are given than were given in +the pattern, they are looped. That is, {a,b} on the replacement side is the +same as {a,b,a,b,a,b,...} repeated indefinitely. + +The following replaces several different misspellings of "necessary": +> + :%S/{,un}nec{ce,ces,e}sar{y,ily}/{}nec{es}sar{}/g +< +ABBREVIATING *abolish-abbrev* + +By default :Abolish creates abbreviations, which replace words automatically +as you type. This is good for words you frequently misspell, or as +shortcuts for longer words. Since these are just Vim abbreviations, only +whole words will match. +> + :Abolish anomol{y,ies} anomal{} + :Abolish {,in}consistant{,ly} {}consistent{} + :Abolish Tqbf The quick, brown fox jumps over the lazy dog +< +Accepts the following options: + + -buffer: buffer local + -cmdline: work in command line in addition to insert mode + +A good place to define abbreviations is "after/plugin/abolish.vim", +relative to ~\vimfiles on Windows and ~/.vim everywhere else. + +With a bang (:Abolish!) the abbreviation is also appended to the file in +g:abolish_save_file. The default is "after/plugin/abolish.vim", relative +to the install directory. + +Abbreviations can be removed with :Abolish -delete: +> + Abolish -delete -buffer -cmdline anomol{y,ies} +< +SEARCHING *abolish-search* + +The -search command does a search in a manner similar to / key. +search. After searching, you can use |n| and |N| as you would with a normal +search. + +The following will search for box, Box, and BOX: +> + :Abolish -search box +< +When given a single word to operate on, :Subvert defaults to doing a +search as well: +> + :S/box/ +< +This one searches for box, boxes, boxed, boxing, Box, Boxes, Boxed, Boxing, +BOX, BOXES, BOXED, and BOXING: +> + :S/box{,es,ed,ing}/ +< +The following syntaxes search in reverse. +> + :Abolish! -search box + :S?box? +< +Flags can be given with the -flags= option to :Abolish, or by appending them +after the separator to :Subvert. The flags trigger the following behaviors: + + I: Disable case variations (box, Box, BOX) + v: Match inside variable names (match my_box, myBox, but not mybox) + w: Match whole words (like surrounding with \< and \>) + +A |search-offset| may follow the flags. +> + :Abolish -search -flags=avs+1 box + :S?box{,es,ed,ing}?we +< +GREPPING *abolish-grep* + +Grepping works similar to searching, and is invoked when additional options +are given. These options are passed directly to the :grep command. +> + :Abolish -search box{,es} + :S /box{,es}/ * + :S /box/aw *.txt *.html +< +The slash delimiters must both be present if used with :Subvert. They may +both be omitted if no flags are used. + +Both an external grepprg and vimgrep (via grepprg=internal) are supported. +With an external grep, the "v" flag behaves less intelligently, due to the +lack of look ahead and look behind support in grep regexps. + +SUBSTITUTING *abolish-substitute* + +Giving a range switches :Subvert into substitute mode. This command will +change box -> bag, boxes -> bags, Box -> Bag, Boxes -> Bags, BOX -> BAG, +BOXES -> BAGS across the entire document: +> + :%Abolish -substitute -flags=g box{,es} bag{,s} + :%S/box{,es}/bag{,s}/g +< +The "c", "e", "g", and "n" flags can be used from the substitute command +|:s_flags|, along with the "a", "I", "v", and "w" flags from searching. + +COERCION *abolish-coercion* *cr* + +Abolish's case mutating algorithms can be applied to the word under the cursor +using the cr mapping (mnemonic: CoeRce) followed by one of the following +characters: + + c: camelCase + m: MixedCase + _: snake_case + s: snake_case + u: SNAKE_UPPERCASE + U: SNAKE_UPPERCASE + -: dash-case (not usually reversible; see |abolish-coercion-reversible|) + k: kebab-case (not usually reversible; see |abolish-coercion-reversible|) + .: dot.case (not usually reversible; see |abolish-coercion-reversible|) + : space case (not usually reversible; see |abolish-coercion-reversible|) + t: Title Case (not usually reversible; see |abolish-coercion-reversible|) + +For example, cru on a lowercase word is a slightly easier to type equivalent +to gUiw. + +COERCION REVERSIBILITY *abolish-coercion-reversible* + +Some separators, such as "-" and ".", are listed as "not usually reversible". +The reason is that these are not "keyword characters", so vim (and +abolish.vim) will treat them as breaking a word. + +For example: "key_word" is a single keyword. The dash-case version, +"key-word", is treated as two keywords, "key" and "word". + +This behaviour is governed by the 'iskeyword' option. If a separator appears +in 'iskeyword', the corresponding coercion will be reversible. For instance, +dash-case is reversible in 'lisp' files, and dot-case is reversible in R +files. + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-abolish/plugin/abolish.vim b/sources_non_forked/vim-abolish/plugin/abolish.vim new file mode 100644 index 00000000..e2486c11 --- /dev/null +++ b/sources_non_forked/vim-abolish/plugin/abolish.vim @@ -0,0 +1,631 @@ +" abolish.vim - Language friendly searches, substitutions, and abbreviations +" Maintainer: Tim Pope +" Version: 1.1 +" GetLatestVimScripts: 1545 1 :AutoInstall: abolish.vim + +" Initialization {{{1 + +if exists("g:loaded_abolish") || &cp || v:version < 700 + finish +endif +let g:loaded_abolish = 1 + +if !exists("g:abolish_save_file") + if isdirectory(expand("~/.vim")) + let g:abolish_save_file = expand("~/.vim/after/plugin/abolish.vim") + elseif isdirectory(expand("~/vimfiles")) || has("win32") + let g:abolish_save_file = expand("~/vimfiles/after/plugin/abolish.vim") + else + let g:abolish_save_file = expand("~/.vim/after/plugin/abolish.vim") + endif +endif + +" }}}1 +" Utility functions {{{1 + +function! s:function(name) + return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) +endfunction + +function! s:send(self,func,...) + if type(a:func) == type('') || type(a:func) == type(0) + let Func = get(a:self,a:func,'') + else + let Func = a:func + endif + let s = type(a:self) == type({}) ? a:self : {} + if type(Func) == type(function('tr')) + return call(Func,a:000,s) + elseif type(Func) == type({}) && has_key(Func,'apply') + return call(Func.apply,a:000,Func) + elseif type(Func) == type({}) && has_key(Func,'call') + return call(Func.call,a:000,s) + elseif type(Func) == type('') && Func == '' && has_key(s,'function missing') + return call('s:send',[s,'function missing',a:func] + a:000) + else + return Func + endif +endfunction + +let s:object = {} +function! s:object.clone(...) + let sub = deepcopy(self) + return a:0 ? extend(sub,a:1) : sub +endfunction + +if !exists("g:Abolish") + let Abolish = {} +endif +call extend(Abolish, s:object, 'force') +call extend(Abolish, {'Coercions': {}}, 'keep') + +function! s:throw(msg) + let v:errmsg = a:msg + throw "Abolish: ".a:msg +endfunction + +function! s:words() + let words = [] + let lnum = line('w0') + while lnum <= line('w$') + let line = getline(lnum) + let col = 0 + while match(line,'\<\k\k\+\>',col) != -1 + let words += [matchstr(line,'\<\k\k\+\>',col)] + let col = matchend(line,'\<\k\k\+\>',col) + endwhile + let lnum += 1 + endwhile + return words +endfunction + +function! s:extractopts(list,opts) + let i = 0 + while i < len(a:list) + if a:list[i] =~ '^-[^=]' && has_key(a:opts,matchstr(a:list[i],'-\zs[^=]*')) + let key = matchstr(a:list[i],'-\zs[^=]*') + let value = matchstr(a:list[i],'=\zs.*') + if type(get(a:opts,key)) == type([]) + let a:opts[key] += [value] + elseif type(get(a:opts,key)) == type(0) + let a:opts[key] = 1 + else + let a:opts[key] = value + endif + else + let i += 1 + continue + endif + call remove(a:list,i) + endwhile + return a:opts +endfunction + +" }}}1 +" Dictionary creation {{{1 + +function! s:mixedcase(word) + return substitute(s:camelcase(a:word),'^.','\u&','') +endfunction + +function! s:camelcase(word) + let word = substitute(a:word, '-', '_', 'g') + if word !~# '_' && word =~# '\l' + return substitute(word,'^.','\l&','') + else + return substitute(word,'\C\(_\)\=\(.\)','\=submatch(1)==""?tolower(submatch(2)) : toupper(submatch(2))','g') + endif +endfunction + +function! s:snakecase(word) + let word = substitute(a:word,'::','/','g') + let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g') + let word = substitute(word,'\(\l\|\d\)\(\u\)','\1_\2','g') + let word = substitute(word,'[.-]','_','g') + let word = tolower(word) + return word +endfunction + +function! s:uppercase(word) + return toupper(s:snakecase(a:word)) +endfunction + +function! s:dashcase(word) + return substitute(s:snakecase(a:word),'_','-','g') +endfunction + +function! s:spacecase(word) + return substitute(s:snakecase(a:word),'_',' ','g') +endfunction + +function! s:dotcase(word) + return substitute(s:snakecase(a:word),'_','.','g') +endfunction + +function! s:titlecase(word) + return substitute(s:spacecase(a:word), '\(\<\w\)','\=toupper(submatch(1))','g') +endfunction + +call extend(Abolish, { + \ 'camelcase': s:function('s:camelcase'), + \ 'mixedcase': s:function('s:mixedcase'), + \ 'snakecase': s:function('s:snakecase'), + \ 'uppercase': s:function('s:uppercase'), + \ 'dashcase': s:function('s:dashcase'), + \ 'dotcase': s:function('s:dotcase'), + \ 'spacecase': s:function('s:spacecase'), + \ 'titlecase': s:function('s:titlecase') + \ }, 'keep') + +function! s:create_dictionary(lhs,rhs,opts) + let dictionary = {} + let i = 0 + let expanded = s:expand_braces({a:lhs : a:rhs}) + for [lhs,rhs] in items(expanded) + if get(a:opts,'case',1) + let dictionary[s:mixedcase(lhs)] = s:mixedcase(rhs) + let dictionary[tolower(lhs)] = tolower(rhs) + let dictionary[toupper(lhs)] = toupper(rhs) + endif + let dictionary[lhs] = rhs + endfor + let i += 1 + return dictionary +endfunction + +function! s:expand_braces(dict) + let new_dict = {} + for [key,val] in items(a:dict) + if key =~ '{.*}' + let redo = 1 + let [all,kbefore,kmiddle,kafter;crap] = matchlist(key,'\(.\{-\}\){\(.\{-\}\)}\(.*\)') + let [all,vbefore,vmiddle,vafter;crap] = matchlist(val,'\(.\{-\}\){\(.\{-\}\)}\(.*\)') + ["","","",""] + if all == "" + let [vbefore,vmiddle,vafter] = [val, ",", ""] + endif + let targets = split(kmiddle,',',1) + let replacements = split(vmiddle,',',1) + if replacements == [""] + let replacements = targets + endif + for i in range(0,len(targets)-1) + let new_dict[kbefore.targets[i].kafter] = vbefore.replacements[i%len(replacements)].vafter + endfor + else + let new_dict[key] = val + endif + endfor + if exists("redo") + return s:expand_braces(new_dict) + else + return new_dict + endif +endfunction + +" }}}1 +" Abolish Dispatcher {{{1 + +function! s:SubComplete(A,L,P) + if a:A =~ '^[/?]\k\+$' + let char = strpart(a:A,0,1) + return join(map(s:words(),'char . v:val'),"\n") + elseif a:A =~# '^\k\+$' + return join(s:words(),"\n") + endif +endfunction + +function! s:Complete(A,L,P) + let g:L = a:L + " Vim bug: :Abolish - calls this function with a:A equal to 0 + if a:A =~# '^[^/?-]' && type(a:A) != type(0) + return join(s:words(),"\n") + elseif a:L =~# '^\w\+\s\+\%(-\w*\)\=$' + return "-search\n-substitute\n-delete\n-buffer\n-cmdline\n" + elseif a:L =~# ' -\%(search\|substitute\)\>' + return "-flags=" + else + return "-buffer\n-cmdline" + endif +endfunction + +let s:commands = {} +let s:commands.abstract = s:object.clone() + +function! s:commands.abstract.dispatch(bang,line1,line2,count,args) + return self.clone().go(a:bang,a:line1,a:line2,a:count,a:args) +endfunction + +function! s:commands.abstract.go(bang,line1,line2,count,args) + let self.bang = a:bang + let self.line1 = a:line1 + let self.line2 = a:line2 + let self.count = a:count + return self.process(a:bang,a:line1,a:line2,a:count,a:args) +endfunction + +function! s:dispatcher(bang,line1,line2,count,args) + let i = 0 + let args = copy(a:args) + let command = s:commands.abbrev + while i < len(args) + if args[i] =~# '^-\w\+$' && has_key(s:commands,matchstr(args[i],'-\zs.*')) + let command = s:commands[matchstr(args[i],'-\zs.*')] + call remove(args,i) + break + endif + let i += 1 + endwhile + try + return command.dispatch(a:bang,a:line1,a:line2,a:count,args) + catch /^Abolish: / + echohl ErrorMsg + echo v:errmsg + echohl NONE + return "" + endtry +endfunction + +" }}}1 +" Subvert Dispatcher {{{1 + +function! s:subvert_dispatcher(bang,line1,line2,count,args) + try + return s:parse_subvert(a:bang,a:line1,a:line2,a:count,a:args) + catch /^Subvert: / + echohl ErrorMsg + echo v:errmsg + echohl NONE + return "" + endtry +endfunction + +function! s:parse_subvert(bang,line1,line2,count,args) + if a:args =~ '^\%(\w\|$\)' + let args = (a:bang ? "!" : "").a:args + else + let args = a:args + endif + let separator = matchstr(args,'^.') + let split = split(args,separator,1)[1:] + if a:count || split == [""] + return s:parse_substitute(a:bang,a:line1,a:line2,a:count,split) + elseif len(split) == 1 + return s:find_command(separator,"",split[0]) + elseif len(split) == 2 && split[1] =~# '^[A-Za-z]*n[A-Za-z]*$' + return s:parse_substitute(a:bang,a:line1,a:line2,a:count,[split[0],"",split[1]]) + elseif len(split) == 2 && split[1] =~# '^[A-Za-z]*\%([+-]\d\+\)\=$' + return s:find_command(separator,split[1],split[0]) + elseif len(split) >= 2 && split[1] =~# '^[A-Za-z]* ' + let flags = matchstr(split[1],'^[A-Za-z]*') + let rest = matchstr(join(split[1:],separator),' \zs.*') + return s:grep_command(rest,a:bang,flags,split[0]) + elseif len(split) >= 2 && separator == ' ' + return s:grep_command(join(split[1:],' '),a:bang,"",split[0]) + else + return s:parse_substitute(a:bang,a:line1,a:line2,a:count,split) + endif +endfunction + +function! s:normalize_options(flags) + if type(a:flags) == type({}) + let opts = a:flags + let flags = get(a:flags,"flags","") + else + let opts = {} + let flags = a:flags + endif + let g:op1 = copy(opts) + if flags =~# 'w' + let opts.boundaries = 2 + elseif flags =~# 'v' + let opts.boundaries = 1 + elseif !has_key(opts,'boundaries') + let opts.boundaries = 0 + endif + let opts.case = (flags !~# 'I' ? get(opts,'case',1) : 0) + let opts.flags = substitute(flags,'\C[avIiw]','','g') + let g:op2 = copy(opts) + return opts +endfunction + +" }}}1 +" Searching {{{1 + +function! s:subesc(pattern) + return substitute(a:pattern,'[][\\/.*+?~%()&]','\\&','g') +endfunction + +function! s:sort(a,b) + if a:a ==? a:b + return a:a == a:b ? 0 : a:a > a:b ? 1 : -1 + elseif strlen(a:a) == strlen(a:b) + return a:a >? a:b ? 1 : -1 + else + return strlen(a:a) < strlen(a:b) ? 1 : -1 + endif +endfunction + +function! s:pattern(dict,boundaries) + if a:boundaries == 2 + let a = '<' + let b = '>' + elseif a:boundaries + let a = '%(<|_@<=|[[:lower:]]@<=[[:upper:]]@=)' + let b = '%(>|_@=|[[:lower:]]@<=[[:upper:]]@=)' + else + let a = '' + let b = '' + endif + return '\v\C'.a.'%('.join(map(sort(keys(a:dict),function('s:sort')),'s:subesc(v:val)'),'|').')'.b +endfunction + +function! s:egrep_pattern(dict,boundaries) + if a:boundaries == 2 + let a = '\<' + let b = '\>' + elseif a:boundaries + let a = '(\<\|_)' + let b = '(\>\|_\|[[:upper:]][[:lower:]])' + else + let a = '' + let b = '' + endif + return a.'('.join(map(sort(keys(a:dict),function('s:sort')),'s:subesc(v:val)'),'\|').')'.b +endfunction + +function! s:c() + call histdel('search',-1) + return "" +endfunction + +function! s:find_command(cmd,flags,word) + let opts = s:normalize_options(a:flags) + let dict = s:create_dictionary(a:word,"",opts) + " This is tricky. If we use :/pattern, the search drops us at the + " beginning of the line, and we can't use position flags (e.g., /foo/e). + " If we use :norm /pattern, we leave ourselves vulnerable to "press enter" + " prompts (even with :silent). + let cmd = (a:cmd =~ '[?!]' ? '?' : '/') + let @/ = s:pattern(dict,opts.boundaries) + if opts.flags == "" || !search(@/,'n') + return "norm! ".cmd."\" + elseif opts.flags =~ ';[/?]\@!' + call s:throw("E386: Expected '?' or '/' after ';'") + else + return "exe 'norm! ".cmd.cmd.opts.flags."\'|call histdel('search',-1)" + return "" + endif +endfunction + +function! s:grep_command(args,bang,flags,word) + let opts = s:normalize_options(a:flags) + let dict = s:create_dictionary(a:word,"",opts) + if &grepprg == "internal" + let lhs = "'".s:pattern(dict,opts.boundaries)."'" + else + let lhs = "-E '".s:egrep_pattern(dict,opts.boundaries)."'" + endif + return "grep".(a:bang ? "!" : "")." ".lhs." ".a:args +endfunction + +let s:commands.search = s:commands.abstract.clone() +let s:commands.search.options = {"word": 0, "variable": 0, "flags": ""} + +function! s:commands.search.process(bang,line1,line2,count,args) + call s:extractopts(a:args,self.options) + if self.options.word + let self.options.flags .= "w" + elseif self.options.variable + let self.options.flags .= "v" + endif + let opts = s:normalize_options(self.options) + if len(a:args) > 1 + return s:grep_command(join(a:args[1:]," "),a:bang,opts,a:args[0]) + elseif len(a:args) == 1 + return s:find_command(a:bang ? "!" : " ",opts,a:args[0]) + else + call s:throw("E471: Argument required") + endif +endfunction + +" }}}1 +" Substitution {{{1 + +function! Abolished() + return get(g:abolish_last_dict,submatch(0),submatch(0)) +endfunction + +function! s:substitute_command(cmd,bad,good,flags) + let opts = s:normalize_options(a:flags) + let dict = s:create_dictionary(a:bad,a:good,opts) + let lhs = s:pattern(dict,opts.boundaries) + let g:abolish_last_dict = dict + return a:cmd.'/'.lhs.'/\=Abolished()'."/".opts.flags +endfunction + +function! s:parse_substitute(bang,line1,line2,count,args) + if get(a:args,0,'') =~ '^[/?'']' + let separator = matchstr(a:args[0],'^.') + let args = split(join(a:args,' '),separator,1) + call remove(args,0) + else + let args = a:args + endif + if len(args) < 2 + call s:throw("E471: Argument required") + elseif len(args) > 3 + call s:throw("E488: Trailing characters") + endif + let [bad,good,flags] = (args + [""])[0:2] + if a:count == 0 + let cmd = "substitute" + else + let cmd = a:line1.",".a:line2."substitute" + endif + return s:substitute_command(cmd,bad,good,flags) +endfunction + +let s:commands.substitute = s:commands.abstract.clone() +let s:commands.substitute.options = {"word": 0, "variable": 0, "flags": "g"} + +function! s:commands.substitute.process(bang,line1,line2,count,args) + call s:extractopts(a:args,self.options) + if self.options.word + let self.options.flags .= "w" + elseif self.options.variable + let self.options.flags .= "v" + endif + let opts = s:normalize_options(self.options) + if len(a:args) <= 1 + call s:throw("E471: Argument required") + else + let good = join(a:args[1:],"") + let cmd = a:bang ? "." : "%" + return s:substitute_command(cmd,a:args[0],good,self.options) + endif +endfunction + +" }}}1 +" Abbreviations {{{1 + +function! s:badgood(args) + let words = filter(copy(a:args),'v:val !~ "^-"') + call filter(a:args,'v:val =~ "^-"') + if empty(words) + call s:throw("E471: Argument required") + elseif !empty(a:args) + call s:throw("Unknown argument: ".a:args[0]) + endif + let [bad; words] = words + return [bad, join(words," ")] +endfunction + +function! s:abbreviate_from_dict(cmd,dict) + for [lhs,rhs] in items(a:dict) + exe a:cmd lhs rhs + endfor +endfunction + +let s:commands.abbrev = s:commands.abstract.clone() +let s:commands.abbrev.options = {"buffer":0,"cmdline":0,"delete":0} +function! s:commands.abbrev.process(bang,line1,line2,count,args) + let args = copy(a:args) + call s:extractopts(a:args,self.options) + if self.options.delete + let cmd = "unabbrev" + let good = "" + else + let cmd = "noreabbrev" + endif + if !self.options.cmdline + let cmd = "i" . cmd + endif + if self.options.delete + let cmd = "silent! ".cmd + endif + if self.options.buffer + let cmd = cmd . " " + endif + let [bad, good] = s:badgood(a:args) + if substitute(bad,'{.\{-\}.}','','g') !~ '^\k\+$' + call s:throw("E474: Invalid argument (not a keyword: ".string(bad).")") + endif + if !self.options.delete && good == "" + call s:throw("E471: Argument required".a:args[0]) + endif + let dict = s:create_dictionary(bad,good,self.options) + call s:abbreviate_from_dict(cmd,dict) + if a:bang + let i = 0 + let str = "Abolish ".join(args," ") + let file = g:abolish_save_file + if !isdirectory(fnamemodify(file,':h')) + call mkdir(fnamemodify(file,':h'),'p') + endif + + if filereadable(file) + let old = readfile(file) + else + let old = ["\" Exit if :Abolish isn't available.","if !exists(':Abolish')"," finish","endif",""] + endif + call writefile(old + [str],file) + endif + return "" +endfunction + +let s:commands.delete = s:commands.abbrev.clone() +let s:commands.delete.options.delete = 1 + +" }}}1 +" Maps {{{1 + +function! s:unknown_coercion(letter,word) + return a:word +endfunction + +call extend(Abolish.Coercions, { + \ 'c': Abolish.camelcase, + \ 'm': Abolish.mixedcase, + \ 's': Abolish.snakecase, + \ '_': Abolish.snakecase, + \ 'u': Abolish.uppercase, + \ 'U': Abolish.uppercase, + \ '-': Abolish.dashcase, + \ 'k': Abolish.dashcase, + \ '.': Abolish.dotcase, + \ ' ': Abolish.spacecase, + \ 't': Abolish.titlecase, + \ "function missing": s:function("s:unknown_coercion") + \}, "keep") + +function! s:coerce(transformation) + let clipboard = &clipboard + try + set clipboard= + let regbody = getreg('"') + let regtype = getregtype('"') + let c = v:count1 + while c > 0 + let c -= 1 + norm! yiw + let word = @@ + let @@ = s:send(g:Abolish.Coercions,a:transformation,word) + if !exists('begin') + let begin = getpos("'[") + endif + if word !=# @@ + let changed = 1 + norm! viwpw + else + norm! w + endif + endwhile + call setreg('"',regbody,regtype) + call setpos("'[",begin) + call setpos(".",begin) + if exists("changed") + silent! call repeat#set("\Coerce".a:transformation) + endif + finally + let &clipboard = clipboard + endtry +endfunction + +nnoremap Coerce :call coerce(nr2char(getchar())) + +" }}}1 + +if !exists("g:abolish_no_mappings") || ! g:abolish_no_mappings + nmap cr Coerce +endif + +command! -nargs=+ -bang -bar -range=0 -complete=custom,s:Complete Abolish + \ :exec s:dispatcher(0,,,,[]) +command! -nargs=1 -bang -bar -range=0 -complete=custom,s:SubComplete Subvert + \ :exec s:subvert_dispatcher(0,,,,) +if exists(':S') != 2 + command -nargs=1 -bang -bar -range=0 -complete=custom,s:SubComplete S + \ :exec s:subvert_dispatcher(0,,,,) +endif + +" vim:set ft=vim sw=2 sts=2: diff --git a/sources_non_forked/vim-addon-mw-utils/.gitignore b/sources_non_forked/vim-addon-mw-utils/.gitignore new file mode 100644 index 00000000..926ccaaf --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/buf_utils.vim b/sources_non_forked/vim-addon-mw-utils/autoload/buf_utils.vim new file mode 100644 index 00000000..d14d404b --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/buf_utils.vim @@ -0,0 +1,24 @@ +" buf_identifier is either a buf_nr or a filename +" If any window shows the buffer move to the buffer +" If not show it in current window (by c-w s c^ you can always +" reshow the last buffer +" +" Example: buf_utils#GotoBuf("/tmp/tfile.txt", {'create': 1}) +" returns: The command which was used to switch to the buffer +fun! buf_utils#GotoBuf(buf_identifier, opts) + let buf_nr = bufnr(a:buf_identifier) + if buf_nr == -1 && ( get(a:opts, 'create', 0) || has_key(a:opts, 'create_cmd')) + exec get(a:opts,'create_cmd','e').' '.fnameescape(a:buf_identifier) + return "e" + else + let win_nr = bufwinnr(buf_nr) + if win_nr == -1 + exec 'b '.buf_nr + return "b" + else + exec win_nr.'wincmd w' + return "w" + endif + wincmd w" + endif +endf diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/cached_file_contents.vim b/sources_non_forked/vim-addon-mw-utils/autoload/cached_file_contents.vim new file mode 100644 index 00000000..3fc3ce46 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/cached_file_contents.vim @@ -0,0 +1,104 @@ +" cached_file_contents.vim +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2010-01-03. +" @Revision: 0.3.0 + +"exec vam#DefineAndBind('s:c','g:cache_dir_options','{}') +if !exists('g:cache_dir_options') | let g:cache_dir_options = {} | endif | let s:c = g:cache_dir_options + +let s:c['cache_dir'] = get(s:c, 'cache_dir', expand('$HOME').'/.vim-cache') +let s:c['scanned_files'] = get(s:c, 'scanned_files', {}) +let s:scanned_files = s:c['scanned_files'] + + +let s:define_cache_file = "let this_dir = s:c['cache_dir'].'/cached-file-contents' | let cache_file = expand(this_dir.'/'.substitute(string([func_as_string, a:file]),'[[\\]{}:/\\,''\"# ]\\+','_','g'))" + +" read a file, run function to extract contents and cache the result returned +" by that function in memory. Optionally the result can be cached on disk as +" because VimL can be slow! +" +" file : the file to be read +" func: { 'func': function which will be called by funcref#Call +" , 'version' : if this version changes cache will be invalidate automatically +" , 'ftime_check': optional, default 1. if set to 0 cache isn't updated when file changes and file is in cache +" } +" +" default: what to return if file doesn't exist +" think twice about adding lines. This function is called many times. +function! cached_file_contents#CachedFileContents(file, func, ...) abort + let ignore_ftime = a:0 > 0 ? a:1 : 0 + " using string for default so that is evaluated when needed only + let use_file_cache = get(a:func, 'use_file_cache', 0) + + " simple kind of normalization. necessary when using file caching + " this seems to be slower: + " let file = fnamemodify(a:file, ':p') " simple kind of normalization. necessary when using file caching + " / = assume its an absolute path + " let file = a:file[0] == '/' ? a:file : expand(a:file, ':p') + let file = a:file[0] == '/' ? a:file : fnamemodify(a:file, ':p') " simple kind of normalization. necessary when using file caching + let func_as_string = string(a:func['func']) + + if (!has_key(s:scanned_files, func_as_string)) + let s:scanned_files[func_as_string] = {} + endif + let dict = s:scanned_files[func_as_string] + if use_file_cache && !has_key(dict, a:file) + exec s:define_cache_file + if filereadable(cache_file) + let dict[file] = eval(readfile(cache_file,'b')[0]) + endif + endif + if has_key(dict, a:file) + let d = dict[a:file] + if use_file_cache + \ && (ignore_ftime || getftime(a:file) <= d['ftime']) + \ && d['version'] == a:func['version'] + return dict[a:file]['scan_result'] + endif + endif + let scan_result = funcref#Call(a:func['func'], [a:file] ) + let dict[a:file] = {"ftime": getftime(a:file), 'version': a:func['version'], "scan_result": scan_result } + if use_file_cache + if !exists('cache_file') | exec s:define_cache_file | endif + if !isdirectory(this_dir) | call mkdir(this_dir,'p',0700) | endif + call writefile([string(dict[a:file])], cache_file) + endif + return scan_result +endfunction + +fun! cached_file_contents#ClearScanCache() + let s:c['scanned_files'] = {} + + " Don't run rm -fr. Ask user to run it. It cache_dir may have been set to + " $HOME ! (should nevere be the case but who knows + echoe "run manually in your shell: rm -fr ".shellescape(s:c['cache_dir'])."/*" +endf + +fun! cached_file_contents#Test() + + " usually you use a global option so that the function can be reused + let my_interpreting_func = {'func' : funcref#Function('return len(readfile(ARGS[0]))'), 'version': 2, 'use_file_cache':1} + let my_interpreting_func2 = {'func' : funcref#Function('return ARGS[0]') , 'version': 2, 'use_file_cache':1} + + let tmp = tempname() + call writefile(['some text','2nd line'], tmp) + + let r = [ cached_file_contents#CachedFileContents(tmp, my_interpreting_func) + \ , cached_file_contents#CachedFileContents(tmp, my_interpreting_func2) ] + if r != [2, tmp] + throw "test failed 1, got ".string(r) + endif + unlet r + + sleep 3 + + " now let's change contents + call writefile(['some text','2nd line','3rd line'], tmp) + + let r = cached_file_contents#CachedFileContents(tmp, my_interpreting_func) + if 3 != r + throw "test failed 2, got ".string(r) + endif + + echo "test passed" +endf diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/env_reload.vim b/sources_non_forked/vim-addon-mw-utils/autoload/env_reload.vim new file mode 100644 index 00000000..d8af33ae --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/env_reload.vim @@ -0,0 +1,12 @@ +" in sh/bash you can type export to get a list of environment variables +" This function assigns those env vars to Vim. +" Does not delete env vars yet +" Example: env_reload#ReloadEnv(system("sh -c 'export'") +fun! env_reload#ReloadEnv(bash_export_command_output) + for i in split(a:bash_export_command_output,"\n") + let m = matchlist(i, 'export \([^=]\+\)="\(.*\)"') + if empty(m) | continue | endif + " don't care about quoted values right now. + exec 'let $'.m[1].'='.string(m[2]) + endfor +endf diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/funcref.vim b/sources_non_forked/vim-addon-mw-utils/autoload/funcref.vim new file mode 100644 index 00000000..20eec54a --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/funcref.vim @@ -0,0 +1,95 @@ +" funcref.vim +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2010-01-03. +" @Revision: 0.1.0 + +" documentation see doc/funcref.txt + +" usage: +" funcref#Function("filename#Function") +" optionally pass arguments: +" funcref#Function("filename#Function",{'args': [2]}) +" optionally define self: +" funcref#Function("filename#Function",{'self': object}) +function! funcref#Function(name,...) + let d = a:0 > 0 ? a:1 : {} + let d['faked_function_reference'] = a:name + return d +endfunction + +" args : same as used for call(f,[args], self) +" f must be either +" - a string which can be evaled (use "return 'value'" to return a value) +" - a Vim function reference created by function('..') +" - a faked function reference created by funcref#Function(..) +" +" the last "self" argument can be overriden by the function reference +" You can pass arguments in a closure like style +function! funcref#Call(...) + let args = copy(a:000) + + " add parameters: + if (len(args) < 2) + call add(args, []) + endif + + + let isDict = type(args[0]) == type({}) + + " prepend parameters which were passed by faked function reference: + if isDict && has_key(args[0], 'args') + let args[1] = args[0]['args']+args[1] + endif + + " always pass self. this way you can call functions from dictionaries not + " refering to self + if (len(args) < 3) + call add(args, {}) + endif + + " the funcref overrides self: + if isDict && has_key(args[0], 'self') + let args[2] = args[0]['self'] + endif + + if type(a:1) == 2 + " funcref: function must have been laoded + return call(function('call'), args) + elseif isDict && has_key(args[0], 'faked_function_reference') + let Fun = args[0]['faked_function_reference'] + if type(Fun) == type('') + \ && (Fun[:len('return ')-1] == 'return ' + \ || Fun[:len('call ')-1] == 'call ' + \ || Fun[:len('if ')-1] == 'if ' + \ || Fun[:len('let ')-1] == 'let ' + \ || Fun[:len('echo ')-1] == 'echo ' + \ || Fun[:len('exec ')-1] == 'exec ' + \ || Fun[:len('debug ')-1] == 'debug ') + " it doesn't make sense to list all vim commands here + " So if you want to execute another action consider using + " funcref#Function('exec '.string('aw')) or such + + " function is a String, call exec + let ARGS = args[1] + let SELF = args[2] + exec Fun + else + " pseudo function, let's load it.. + if type(Fun) == 1 + if !exists('*'.Fun) + " lazily load function + let file = substitute(substitute(Fun,'#[^#]*$','',''),'#','/','g') + exec 'runtime /autoload/'.file.'.vim' + endif + let Fun2 = function(Fun) + else + let Fun2 = Fun + endif + let args[0] = Fun + return call(function('call'), args) + endif + else + " no function, return the value + return args[0] + endif +endfunction diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/glob.vim b/sources_non_forked/vim-addon-mw-utils/autoload/glob.vim new file mode 100644 index 00000000..9a0f79a2 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/glob.vim @@ -0,0 +1,27 @@ +exec vam#DefineAndBind('s:c','g:glob_like', '{}') + +" ignore vcs stuff, Don't think you want those.. +let s:c['regex_ignore_directory'] = '\<\%([_.]darcs\|\.git\|.svn\|.hg\|.cvs\|.bzr\)\>' +let s:c['glob_cache'] = get(s:c, 'glob_cache', {}) +let s:glob_cache = s:c['glob_cache'] + +fun! glob#Glob(pattern, ...) + let pattern = a:pattern + if pattern[0] == '~' + let pattern = $HOME.pattern[1:] + endif + let opts = a:0 > 0 ? a:1 : {} + " never cache current directory. You're very likely to edit files in it. + + let c = getcwd() + let cachable = get(opts, 'cachable', 0) && pattern[:len(c)-1] != c + if cachable && has_key(s:glob_cache, pattern) + return s:glob_cache[pattern] + endif + + " FIXME: don't recurse into \.git directory (thus reimplement glob in vimL!) + let r = filter(split(glob(pattern),"\n"),'v:val !~ '.string(s:c['regex_ignore_directory'])) + if cachable | let s:glob_cache[pattern] = r | endif + return r +endf + diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim new file mode 100644 index 00000000..6fd3f044 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim @@ -0,0 +1,42 @@ + +" TODO refactor: create glob function +" noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"\\.git\\\\.hg\\node_modules\\\\.pyc" ) +" noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"default" ) +function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern) + if a:exclude_pattern == "default" + let exclude_pattern = '\.git\|\.hg\|node_modules\|\.pyc' + else + let exclude_pattern = a:exclude_pattern + endif + + " let files = split(glob(a:glob),"\n") + let g = a:glob + let replace = {'**': '.*','*': '[^/\]*','.': '\.'} + let g = substitute(g, '\(\*\*\|\*\|\.\)', '\='.string(replace).'[submatch(1)]','g') + + let exclude = exclude_pattern == '' ? '' : ' | grep -v -e '.shellescape(exclude_pattern) + + let cmd = 'find | grep -e '.shellescape(g).exclude + let files = split(system(cmd),"\n") + " for nom in a:excludes + " call filter(files,nom) + " endfor + if len(files) > 1000 + echoe "more than ".2000." files - would be too slow. Open the file in another way" + else + if empty(files) + echoe "no file found" + elseif len(files) == 1 + exec 'e '.fnameescape(files[0]) + else + let g:abc=7 + call tovl#ui#filter_list#ListView({ + \ 'number' : 1, + \ 'selectByIdOrFilter' : 1, + \ 'Continuation' : funcref#Function('exec "e ".fnameescape(ARGS[0])'), + \ 'items' : files, + \ 'cmds' : ['wincmd J'] + \ }) + endif + endif +endfunction diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/tiny_cmd.vim b/sources_non_forked/vim-addon-mw-utils/autoload/tiny_cmd.vim new file mode 100644 index 00000000..052bbe04 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/tiny_cmd.vim @@ -0,0 +1,19 @@ +" vim suffers: + +exec vam#DefineAndBind('s:c','g:vim_tiny_cmd', '{}') + +fun! tiny_cmd#Put(a) + let new = get(s:c,'next',0) +1 + let s:c['next'] = new + let s:c[new] = a:a + return new +endf + +fun! tiny_cmd#Get(nr) + return s:c[a:nr] +endf + +" Get and remove item +fun! tiny_cmd#Pop(nr) + let r = s:c[a:nr] | unlet s:c[a:nr] | return r +endf diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim b/sources_non_forked/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim new file mode 100644 index 00000000..217dca11 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim @@ -0,0 +1,103 @@ +" old code + +augroup TOVLWrite +augroup end + +" =========== scratch buffer ========================================= +" a scratch buffer is a temporary buffer where the user can enter some text +" It can be used to get commit messages, edit configuration options and so on + +function! tovl#scratch_buffer#KeepIntactLineNr() + let i = 0 + while getline(i)!= b:keepIntact && i < line('$') + let i = i+1 + endwhile + if i > line('$') + return -1 + else + return i + endif +endfunction + +" opens a buffer and runs an action when the buffer is written +" keys: +" name : the name of the buffer +" onWrite : will be called on write +" onWrite is responsible for setlocal nomodified to indicate that +" saving has been successful +" help : callback returning additional information lines +" getContent : callback returning lines +" cmds : extra commands to be run (optional) +" (maybe you prefer adding them the default way afer the +" ScratchBuffer call. They'll be rerun on GetContents +" sp_cmd : the command to use to create the new buffer. Defaults to :e +" buftype : ... +" modifiable : 1 / 0 defaults to 1 +function! tovl#scratch_buffer#ScratchBuffer(opts) + let a:opts['name'] = get(a:opts,'name', 'strach_buffer_without_name') + exec get(a:opts, 'sp_cmd', 'e').' '.escape(a:opts['name'],' ') + let b:settings = a:opts + let b:settings['modifiable'] = get(a:opts,'modifiable', 1) + setlocal buftype=acwrite + command! -buffer -nargs=0 Help call tovl#scratch_buffer#Help() + + " setup write notification + au TOVLWrite BufWriteCmd call tovl#scratch_buffer#Write() + + if has_key(a:opts,'getContent') + command! -buffer -nargs=0 GetContents call tovl#scratch_buffer#GetContents() + GetContents + if !b:settings['modifiable'] + setlocal nomodifiable + endif + endif + "let u=&undolevels + "setlocal undolevels=-1 + "exec 'setlocal undolevels='.u + + " mark buffer as not modified + setlocal nomodified + + au BufReadCmd GetContents + + " run addittional commands + for cmd in get(a:opts,'cmds',[]) + exec cmd + endfor + silent echo get(a:opts,'echo_help', "type :Help for help") +endfunction + +" =========== utility functions ====================================== + +function! tovl#scratch_buffer#Write() + if has_key(b:settings, 'onWrite') + call funcref#Call(b:settings['onWrite']) + else + echo "don't know how to write. Option hasn't been passed" + endif +endfunction + +function! tovl#scratch_buffer#GetContents() + setlocal modifiable + " empty buffer + %g!//d + call append(0, funcref#Call(b:settings['getContent'])) + if !b:settings['modifiable'] + setlocal nomodifiable + endif + for cmd in get(b:settings,'cmds',[]) + exec cmd + endfor +endfunction + +function! tovl#scratch_buffer#Help() + let help = ["use :e! to reload contents, ZZ or :w(q) to write and quit" + \ ,"" + \ ,"Help for this scratch buffer:" + \ ,"=======================================================","",""] + \ + funcref#Call(get(b:settings, 'help', [])) + call tovl#scratch_buffer#ScratchBuffer({ + \ 'name' : "return Help of ".b:settings['name'], + \ 'getContent' : help + \ }) +endfunction diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim b/sources_non_forked/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim new file mode 100644 index 00000000..74b2ab49 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim @@ -0,0 +1,473 @@ +" OLD CODE ! +" I should contribute the multiple filter feature to tlib + +" filter list displays a list of items +" you can white / black filter them by regular expressions (similar to the +" tlib TToC command +" However you can edit the filters afterwards and select the cols which should +" be shown + +fun! tovl#ui#filter_list#ListTest() + call tovl#ui#filter_list#ListView({ + \ 'aligned' : 1, + \ 'Continuation' : funcref#Function('echo string(ARGS[0])'), + \ 'items' : [ {"aa" : "a\nAAAAAAAAAAA", 'bb' : "bbbbbbbbbbbbb\nB" }, + \ {"aa" : "2a\n2AAAAAAAAAAAA", "bb" : "2 bbbbbbbbbbbbb\n2B"}, + \ {"aa" : "XXX", "bb" : "YY"} ], + \ }) + +endfun + +fun! s:Intersection(a, b) + return filter(copy(a:a), 'index(a:b, v:val) >= 0') +endf + +fun! tovl#ui#filter_list#ListTestGotoLineCurrentBuf() + let nr=1 + let lines = [] + for l in getline(0,line('$')) + call add(lines, {'nr': nr, 'line' :l}) + let nr = nr +1 + endfor + call tovl#ui#filter_list#ListView({ + \ 'aligned' : 0, + \ 'keys' : ['nr','line'], + \ 'number' : 1, + \ 'selectByIdOrFilter' : 1, + \ 'Continuation' : funcref#Function('exec ARGS[0]["nr"]'), + \ 'items' : lines, + \ }) +endfun + +" opens a new filtered list +" keys of opts parameters: +" Continuation: This function will be called with the selected items +" items: { key : (string or dict) } +" items willl be modified. use copy(youritems) as argument to prevent +" this. An item is either a string or a dict +" (eg {'file' : .., 'line': ... , 'msg' : .. ) +" keys: list of keys to be shown (optional) +" filter: list of inital filters which must be applied +" contains [ { filter: .. , keep : .. }, ] see FilterItems() below +" aligned: default 0 +" sp_cmd: the command to be used to create the new buffer (default ':e') +" init : 0 / 1 (default 1): wether to show the view right now +" number: 0 /1 (default 1): number items ? +" selectByIdOrFilter: 1: start in getchar() loop so that the user can select +" the item even faster +" auto: only do this if all items fit on screen +" (recommend) +" cmds: extra cmds to be run +" cursorAt : at which item to put the cursor? +" +" If you don't like the default view you can override UpdateDisplay +" +" Usage examples of this list control: +" - db results +" - replacement of the quickfix window +" - select a buffer etc +fun! tovl#ui#filter_list#ListView(opts) + " ActivateAddons theonevimlib + let d = {} + let d.items = a:opts.items + let d.cursorAt = get(a:opts, 'cursorAt', 0) + let d.aligned = get(a:opts, 'aligned', 0) + let d.sep = ' ' + let d.filter = get(a:opts, 'filter', []) + " using sp because of bd! (FIXME) + let d.sp_cmd = get(a:opts, 'sp_cmd', 'sp') + let d.allKeys = {} + let d.closeOnContinuation = get(a:opts,'closeOnContinuation',1) + " don't recommend OnSingleMatch, use OnSingleMatchCR instead + let d.continueOnSingleMatch = get(a:opts, 'continueOnSingleMatch',0) + let d.continueOnSingleMatchCR = get(a:opts, 'continueOnSingleMatchCR',1) + let d.selectByIdOrFilter = get(a:opts, 'selectByIdOrFilter', 0) + let d.linesToItems = {} + let d.number = get(a:opts, 'number', 1) + let d.cmds = get(a:opts, 'cmds', []) + let d.syn_cmds = get(a:opts, 'syn_cmds', []) + + if has_key(a:opts,'keys') | let d.keys = a:opts.keys | endif + if has_key(a:opts,'Continuation') | let d.Continuation = a:opts.Continuation | endif + + " cache already filtered items in case we want to view really long results + " contains [ { filter : { regex: .. , keep : .. } , items : .. , cursorAt :}, + " { filter : { ... } , items: .. , cursorAt : } + let d.cached = [] + " id of buffer + let d.buffer = -1 + let d.modeText = '' + + fun d.HelpText() + return [ "you've entered the the help of the powerful filtered view buffer", + \ "", + \ "type f to start filtering items by regex", + \ "type F to start dropping items by regex", + \ "k / K will ask you for the key to apply the filter to first", + \ "apply the filter by and press again to select item", + \ "", + \ "use :ShowAppliedFilters to list active filters", + \ "use :ToggleAlignment to toggle alignment", + \ "", + \ "TODO: Implement sorting, implement interface to change keys (displayed columns)" + \ ] + endfun + + " create new scratch buffer + " preprocess items calculating line count and maxwidth for all items + fun d.NewBufferAndInit() + let self.bufferId = bufnr(bufname('%')) + for idx in range(0,len(self.items)-1) + if type(self.items[idx]) != 4 + " no dict yet, make it one + let self.items[idx] = {'string_line' : self.items[idx]} + endif + let new = {} + for [k,v] in items(self.items[idx]) + let lines = split(v,"\n") + let self.items[idx][k] = { 'text' : v, 'rows' : len(lines), 'cols' : max(map(copy(lines),'len(v:val)')), 'lines' : lines } + let self.allKeys[k] = 1 + unlet k v + endfor + endfor + call tovl#scratch_buffer#ScratchBuffer({ + \ 'help' : funcref#Function(self.HelpText,{ 'self' : self }), + \ 'sp_cmd' : self.sp_cmd, + \ 'cmds' : self.cmds + \ }) + " I assume we have some kind of formatting anyway. Thus breaking lines is bad! + set nowrap + setlocal cursorline + let b:filtered_view = self + command! -buffer -nargs=0 ToggleAlignment call b:filtered_view.ToggleAlignment() + command! -buffer -nargs=0 ShowAppliedFilters call b:filtered_view.ShowAppliedFilters() + command! -buffer -nargs=0 RemoveFilters call b:filtered_view.RemoveFilters() + noremap f :call b:filtered_view.FilterFromKeyboard(1,'') + " noremap f :call b:filtered_view.FilterFromKeyboard(1) + noremap F :call b:filtered_view.FilterFromKeyboard(0,'') + if has_key(self,'Continuation') + nnoremap :call b:filtered_view.Continue() + endif + "noremap k + "noremap K + + let [items, cursorAt] = self.FilteredItems() + " len(items) is an approximation because one item can have multiple + " lines.. However adding the lines first to check takes too much time + if self.selectByIdOrFilter == 1 || (self.selectByIdOrFilter == 'auto' && winheight('%') > len(items) ) + call self.SelectByIdOrFilter() + else + " user should choose how to proceed + call self.UpdateDisplay() + endif + endfun + + " user interface + fun d.ToggleAlignment() + let self.aligned = !self.aligned + call self.UpdateDisplay() + endfun + fun d.ShowAppliedFilters() + for i in self.filter | echo string(i) | endfor + endfun + fun d.RemoveFilters() + let self.filter = [] + call self.UpdateDisplay() + endfun + fun d.Continue() + let item = self.CurrentItem() + call self.DoContinue(item) + endfun + fun d.DoContinue(v) + if self.closeOnContinuation | bw! | endif + call funcref#Call(self.Continuation,[a:v]) + endfun + + fun d.MapToOriginal(v) + if has_key(a:v, 'string_line') + return a:v.string_line.text + else + let d = {} + for [k,v] in items(a:v) + let d[k] = v.text + unlet k v + endfor + return d + endif + endfun + + fun d.CurrentItem() + let idx=line('.')-len(self.headerLines) + while idx >= 0 + if has_key(self.linesToItems, idx) + return self.MapToOriginal(self.FilteredItems()[0][self.linesToItems[idx]]) + else + let idx = idx -1 + endif + endwhile + throw "internal error, couldn't determine selected item!" + endfun + + " updates the filter cache and returns the final filtered items + fun d.FilteredItems() + " update cache + let idx = 0 + let [items, cursorAt] = [self.items, self.cursorAt] + for idx in range(0, len(self.filter)-1) + if idx +1 > len(self.cached) || self.cached[idx]['filter'] != self.filter[idx] + let self.cached = self.cached[:idx-1] + let [items, cursorAt] = self.FilterItem(copy(items), self.filter[idx], cursorAt) + call add(self.cached, { 'cursorAt' : cursorAt, 'items' : items, 'filter' : self.filter[idx]}) + else + let ci = self.cached[idx] + let [items, cursorAt] = [ci['items'], ci['cursorAt']] + endif + endfor + return [items, cursorAt] + endfun + + " calling this will return a set of lines which are expected to be the new + " buffer contents. The self.linesToItems dict is updated + fun d.UpdateDisplay() + + if empty(self.filter) + let self.statusline= 'no filter applied, :Help for help' + else + let self.statusline = len(self.filter).' '.string(self.filter[-1]) + endif + + let self.linesToItems = {} + let [items, cursorAt] = self.FilteredItems() + "let num_width = printf('%.0f', trunc(log10(len(items))+1)) + let num_width = 4 + if self.aligned + " get column width.. (probably will not work with unicde characters.. I + " don't have a better solution) + let maxlens={} + for i in items + for [k,v] in items(i) + if get(maxlens,k,0) < v.cols + let maxlens[k] = v.cols + endif + endfor + endfor + endif + + " format lines + let self.headerLines = [self.modeText] + let lines = copy(self.headerLines) + let lines_count = 0 + if self.number + let fmt_startA = '%'.num_width.'s)' + let fmt_startB = '%'.num_width.'s' + else + let fmt_startA = '' | let fmt_startB = '' + endif + let cursorAtLine = 1 " sane default + for idx in range(0,len(items)-1) + let self.linesToItems[lines_count + 1] = idx + let i = items[idx] + let keys = has_key(self,'keys') + \ ? s:Intersection(self.keys, keys(i)) + \ : keys(i) + let fmt = '' + let args = [i] + let cols = [] + for k in keys + let fmt .= self.sep.'%-'.(self.aligned ? maxlens[k] : i[k]['cols']).'s' + call add(cols, i[k]) + endfor + for row in range(0, max([1] + map(copy(cols),'v:val["rows"]'))-1) + let fmt_args = row == 0 ? [fmt_startA.fmt] : [fmt_startB.fmt] + if self.number + call add(fmt_args, row == 0 ? idx : '') + endif + for c in cols + call add(fmt_args, c.rows <= row ? '' : c.lines[row]) + endfor + call add(lines, call('printf', fmt_args)) + let lines_count += 1 + endfor + if idx == cursorAt + let cursorAtLine = lines_count + endif + endfor + " update stauts line to show last applied filter + " disabled cause it causes trouble on :wincmd w + " setlocal statusline=%!b:filtered_view.statusline + + " syntax + syn clear + for s in self.syn_cmds | exec s | endfor + let id = 0 + " highlight filter regex in buffer as well + let syn_ids = [ 'Underlined', 'Todo', 'Error', 'Type', 'Statement' ] + for f in self.filter + if !f.keep || !has_key(f, 'regex') | continue | endif + if f.regex != '' + try + exec 'syn match '.syn_ids[id % len(syn_ids)].' '.string(f.regex) + catch /.*/ + " ignore errors such as \ without following characters. Thus just + " ignore and wait for the next character + endtry + endif + let id = id +1 + endfor + if len(lines) > winheight('%') + call extend(lines, self.headerLines) + endif + normal ggdG + call append(0, lines) + " place cursor + exec (cursorAtLine+1) + " move cursor into the middle of the window + normal zz + endf + + " filter = keys : + " filter = string to be executed containing Val + " keep = 1 keep on match + " = 0 drop on match + " key (optional) + " cursorAt: at which item to put the cursor + " if that item is deleted it will be placed at the item above + " optional: key of dict if dict + fun d.FilterItem(items, filter, cursorAt) + let filter = 'Val =~ '.string(a:filter.regex) + let keep = a:filter.keep + let cursorAt = a:cursorAt + + for idx in reverse(range(0, len(a:items)-1)) + let i = a:items[idx] + if has_key(a:filter,'key') + let key = a:filter.key + if has_key(i, key) + " key given, only filter by this column + let Val = i[key]['text'] + exec 'let any = '.filter + else + let any = 0 + endif + else + let any = 0 + " no key given, try all + for x in values(i) + let Val = x['text'] + exec 'let any = '.filter + if any | break | endif + endfor + endif + if any != keep + call remove(a:items, idx) + if idx <= cursorAt + let cursorAt = cursorAt -1 + endif + endif + endfor + return [a:items, cursorAt] + endfun + + " if the user enters a number select by index else start filtering.. + fun d.SelectByIdOrFilter() + let idx='' + let items = self.FilteredItems()[0] + try + let self.modeText = '[0-9]* : select by index| : escape getchar() loop, any char: start filtering' + call self.UpdateDisplay() | redraw + while 1 + let c=getchar() + if index([13,10],c) >= 0 + return self.DoContinue(self.MapToOriginal(items[idx])) + elseif index([27], c) >=0 + " esc, abort + return + else + if type(c) == 0 + let c = nr2char(c) + endif + if c == "\" || index(map(range(0,10),'v:val.""'),c) >= 0 + if c == "\" + let idx = idx[:-2] + else + let idx .= c + endif + if idx < len(items) && idx.'0' > len(items) || idx == 0 && len(items) < 10 + " only match + return self.DoContinue(self.MapToOriginal(items[idx])) + endif + else + return self.FilterFromKeyboard(1,c) + endif + endif + endwhile + finally + let self.modeText = '' + endtry + endfun + + " gets a regular expresion filter by keybaord and updates the display while + " you're typing. The regex ist shown in the statusline + fun d.FilterFromKeyboard(keep, start, ...) + let self.modeText = 'press ESC to exit getchar() loop' + call self.UpdateDisplay() | redraw + + try + let key_text = a:0 > 0 ? 'key : '.a:1 : '' + let filter_bak = self.filter + let filter = copy(self.filter) + let start = a:start + let filter_new = '' + while 1 + if start != '' + " use c= last char to force updating display etc + let filter_new = start[:-2] + let c = start[-1:] + let start = '' + else + let c=getchar() + endif + if index([13,10],c) >= 0 + " c-j or return, accept new filter + let items = self.FilteredItems() + if len(items) == 1 && has_key(self, 'Continuation') && self.continueOnSingleMatchCR + call self.DoContinue(self.MapToOriginal(items[0])) + endif + return + elseif index([27], c) >=0 + " esc, abort + let self.filter = filter_bak + call self.UpdateDisplay() + return + else + if type(c) == 0 + let c = nr2char(c) + endif + if c == "\" + let filter_new = filter_new[:-2] + else + let filter_new .= c + endif + let d = {'keep' : a:keep, 'regex' : filter_new } + if a:0 > 0 + let d['key'] = a:1 + endif + let self.filter = copy(filter_bak) + call add(self.filter, d) + let items = self.FilteredItems() + if len(items) == 1 && has_key(self, 'Continuation') && self.continueOnSingleMatch + call self.DoContinue(self.MapToOriginal(items[0])) + return + endif + call self.UpdateDisplay() | redraw + endif + endwhile + finally + let self.modeText = '' + endtry + endfun + + if get(a:opts,'init',1) + call d.NewBufferAndInit() + endif +endfun diff --git a/sources_non_forked/vim-addon-mw-utils/doc/cached_file_contents.txt b/sources_non_forked/vim-addon-mw-utils/doc/cached_file_contents.txt new file mode 100644 index 00000000..a47a8cf8 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/doc/cached_file_contents.txt @@ -0,0 +1,7 @@ +*cached_file_contents* read contents of a file then cache extracted data + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + + see cached_file_contents#Test() diff --git a/sources_non_forked/vim-addon-mw-utils/doc/funcref.txt b/sources_non_forked/vim-addon-mw-utils/doc/funcref.txt new file mode 100644 index 00000000..cb366d0e --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/doc/funcref.txt @@ -0,0 +1,35 @@ +*funcref* create lazier function references. Pass arguments to create closure + like function calls + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + +Use *funcref#Function* to create a special dict called +*faked-function-reference* which can be called by *funcref#Call* +> + { 'faked_function_reference': 'file#FuncName' } +< passing some arguments and / or self: > + { 'faked_function_reference': 'MyFunc', 'args': [1,2], 'self' : { a object ] } +< You can also create lambda like functions which will be evaled: > + { 'faked_function_reference': 'return ARGS[1]' } + +REASONS ~ + Creating a Vim funcref pointing to an autoload function will make Vim source + that file. This is not lazy enough. (Seems to be no longer true? Has this changed?) + + A Vim function reference neither allows attaching arguments nor self. + + Don't care about case of variables. Normally when using Vim function + references you have to use variable names starting with an upper case letter + (E704) + +Example: ~ +> + let f = funcref#Function('return ARGS[0].ARGS[1].SELF["key"]',{'args':[3], 'self':{'key': 'value'} }) + echo funcref#Call(f, [2]) + " prints "32value" + + echo funcref#Call('no value') +< + echo funcref#Call(f, [2]) diff --git a/sources_non_forked/vim-addon-mw-utils/doc/tiny_cmd.txt b/sources_non_forked/vim-addon-mw-utils/doc/tiny_cmd.txt new file mode 100644 index 00000000..bc6e0028 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/doc/tiny_cmd.txt @@ -0,0 +1,18 @@ +*tiny-cmd* make long commands short so that they hopefully no longer trigger "press Enter .. [ok]" + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + +Problem: > + exec 'map :silent! let g:g="'.repeat('foobar ',200).'"' +Now run the mapping by pressing and you notice what I'm talking about + +Solution (Example): + + +Example usage: > + let nr = tiny_cmd#Put('let g:g="'.repeat('foobar ',200).'"') + exec 'map :exec tiny_cmd#Get('.nr.')' +< +Use Pop instead of Get if you use this command once only diff --git a/sources_non_forked/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt b/sources_non_forked/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt new file mode 100644 index 00000000..0b20bb38 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt @@ -0,0 +1,9 @@ +{ + "name" : "vim-addon-mw-utils", + "version" : "0.0", + "author" : "Marc Weber ", + "maintainer" : "Marc Weber ", + "repository" : {"type": "git", "url": "git://github.com/MarcWeber/vim-addon-manager-known-repositories.git"}, + "dependencies" : {}, + "description" : "various utils such as caching interpreted contents of files or advanced glob like things" +} diff --git a/sources_non_forked/vim-bundle-mako/README.md b/sources_non_forked/vim-bundle-mako/README.md new file mode 100644 index 00000000..037e44e4 --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/README.md @@ -0,0 +1,22 @@ +This project is a colleciton of vim scripts that relate to the Mako templating +engine for python. Most of thse are not at all written by me, just packaged +here from the vim-script site. The purpose is to make them easy to use with +pathogen.vim. + +Useful configuration variables: + +* `g:mako_detect_lang_from_ext`: when set to 1 (the default), the ftdetect + script will attempt to figure out the "outer" filetype of the file by + stripping the ".mako" extension (eg: index.html.mako will be treated as HTML, + while script.cpp.mako will be treated as C++). Set to 0 to prevent this + detection. +* `g:mako_default_outer_lang`: if ftdetect cannot detect the "outer" filetype of + the file, this sets the default filetype used. If not set, defaults to "html". + +About mako: http://www.makotemplates.org/ + +Externally sourced scripts: + +* [indent/mako.vim](http://www.vim.org/scripts/script.php?script_id=2663) 0.4 by Scott Torborg +* [syntax/mako.vim](http://www.vim.org/scripts/script.php?script_id=1858) 0.6.1 by Armin Ronacher + diff --git a/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim b/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim new file mode 100644 index 00000000..3051a431 --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim @@ -0,0 +1,11 @@ +if !exists("g:mako_detect_lang_from_ext") + let g:mako_detect_lang_from_ext = 1 +endif +if g:mako_detect_lang_from_ext + au BufNewFile *.*.mako execute "do BufNewFile filetypedetect " . expand(":r") | let b:mako_outer_lang = &filetype + " it's important to get this before any of the normal BufRead autocmds execute + " for this file, otherwise a mako tag at the start of the file can cause the + " filetype to be set to mason + au BufReadPre *.*.mako execute "do BufRead filetypedetect " . expand(":r") | let b:mako_outer_lang = &filetype +endif +au BufRead,BufNewFile *.mako set filetype=mako diff --git a/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim b/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim new file mode 100644 index 00000000..41be4705 --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim @@ -0,0 +1,11 @@ +" Vim filetype plugin file +" Language: Mako +" Maintainer: Randy Stauner +" Last Change: 2014-02-07 +" Version: 0.1 + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setlocal comments=:## +setlocal commentstring=##%s diff --git a/sources_non_forked/vim-bundle-mako/indent/mako.vim b/sources_non_forked/vim-bundle-mako/indent/mako.vim new file mode 100644 index 00000000..4433cc4a --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/indent/mako.vim @@ -0,0 +1,355 @@ +" Vim indent file +" Language: Mako +" Author: Scott Torborg +" Version: 0.4 +" License: Do What The Fuck You Want To Public License (WTFPL) +" +" --------------------------------------------------------------------------- +" +" 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. +" +" --------------------------------------------------------------------------- +" +" This script does more useful indenting for Mako HTML templates. It indents +" inside of control blocks, defs, etc. Note that this indenting style will +" sacrifice readability of the output text for the sake of readability of the +" template. +" +" We'll use HTML indenting globally, python inside <% %> blocks. Inspired by +" the excellent PHP + HTML indentation files such as php.vim by Pim Snel. +" +" Changelog: +" 0.4 - 5 March 2010 +" - Added license information +" 0.3 - 15 September 2009 +" - Added explicit indenting for ## comments, fixed unindenting count, +" thanks to Mike Lewis (@MikeRLewis) for this +" 0.2 - 15 June 2009 +" - Fixed issue where opening and closing mako tags on the same line +" would cause incorrect indenting +" 0.1 - 06 June 2009 +" - Initial public release of mako indent file + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal nosmartindent +setlocal noautoindent +setlocal nocindent +setlocal nolisp +setlocal expandtab +setlocal softtabstop=2 +setlocal shiftwidth=2 + +setlocal indentexpr=GetMakoIndent() +setlocal indentkeys+=*,<>>,,end,: + +" Only define the function once. +if exists("*GetMakoIndent") + finish +endif + +if exists('g:html_indent_tags') + unlet g:html_indent_tags +endif + +function IsInsidePythonBlock(startline) + " Loop until we get a line that's either <% or %> + let lnum = a:startline + while getline(lnum) !~ '\(%>\|<%\)$' && lnum > 0 + let lnum = lnum - 1 + endwhile + + " lnum points to the last control. If it's a <% then we're inside an + " embedded python block, otherwise we're not. + return getline(lnum) =~ '<%$' +endfunction + +function GetMakoIndent() + " Find a non-empty line above the current line + let lnum = prevnonblank(v:lnum - 1) + + " Hit the start of the file, use zero indent. + if lnum == 0 + return 0 + endif + + let line = getline(lnum) " last line + let cline = getline(v:lnum) " current line + let pline = getline(lnum - 1) " previous to last line + let ind = indent(lnum) + if line =~ '^\s*##' + return indent(lnum) + end + + let restore_ic=&ic + let &ic=1 " ignore case + + let ind = HtmlIndentSum(lnum, -1) + let ind = HtmlIndentSum(lnum, -1) + let ind = ind + HtmlIndentSum(v:lnum, 0) + + let &ic=restore_ic + + let ind = indent(lnum) + (&sw * ind) + + " Indent after %anything: or <%anything NOT ending in /> + if line =~ '^\s*%.*:\s*$' + let ind = ind + &sw + endif + + " Unindent before %end* or $' + let scanlnum = lnum + " Scan backwards until we find the beginning of this python block. + while getline(scanlnum) !~ '<%$' && scanlnum > 0 + let scanlnum = scanlnum - 1 + endwhile + let ind = indent(scanlnum) + endif + + " If we're inside a python block and the previous line ends in a colon, + " indent. + if IsInsidePythonBlock(lnum - 1) + " Indent after : + if line =~ '\:$' + let ind = ind + &sw + endif + endif + + return ind +endfunction + + +" [-- helper function to assemble tag list --] +fun! HtmlIndentPush(tag) + if exists('g:html_indent_tags') + let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag + else + let g:html_indent_tags = a:tag + endif +endfun + +fun! MakoIndentPush(tag) + if exists('g:mako_indent_tags') + let g:mako_indent_tags = g:mako_indent_tags.'\|'.a:tag + else + let g:mako_indent_tags = a:tag + endif +endfun + +" [-- --] +call HtmlIndentPush('a') +call HtmlIndentPush('abbr') +call HtmlIndentPush('acronym') +call HtmlIndentPush('address') +call HtmlIndentPush('b') +call HtmlIndentPush('bdo') +call HtmlIndentPush('big') +call HtmlIndentPush('blockquote') +call HtmlIndentPush('button') +call HtmlIndentPush('caption') +call HtmlIndentPush('center') +call HtmlIndentPush('cite') +call HtmlIndentPush('code') +call HtmlIndentPush('colgroup') +call HtmlIndentPush('del') +call HtmlIndentPush('dfn') +call HtmlIndentPush('dir') +call HtmlIndentPush('div') +call HtmlIndentPush('dl') +call HtmlIndentPush('em') +call HtmlIndentPush('fieldset') +call HtmlIndentPush('font') +call HtmlIndentPush('form') +call HtmlIndentPush('frameset') +call HtmlIndentPush('h1') +call HtmlIndentPush('h2') +call HtmlIndentPush('h3') +call HtmlIndentPush('h4') +call HtmlIndentPush('h5') +call HtmlIndentPush('h6') +call HtmlIndentPush('i') +call HtmlIndentPush('iframe') +call HtmlIndentPush('ins') +call HtmlIndentPush('kbd') +call HtmlIndentPush('label') +call HtmlIndentPush('legend') +call HtmlIndentPush('map') +call HtmlIndentPush('menu') +call HtmlIndentPush('noframes') +call HtmlIndentPush('noscript') +call HtmlIndentPush('object') +call HtmlIndentPush('ol') +call HtmlIndentPush('optgroup') +call HtmlIndentPush('pre') +call HtmlIndentPush('q') +call HtmlIndentPush('s') +call HtmlIndentPush('samp') +call HtmlIndentPush('script') +call HtmlIndentPush('select') +call HtmlIndentPush('small') +call HtmlIndentPush('span') +call HtmlIndentPush('strong') +call HtmlIndentPush('style') +call HtmlIndentPush('sub') +call HtmlIndentPush('sup') +call HtmlIndentPush('table') +call HtmlIndentPush('textarea') +call HtmlIndentPush('title') +call HtmlIndentPush('tt') +call HtmlIndentPush('u') +call HtmlIndentPush('ul') +call HtmlIndentPush('var') + +" For some reason the default HTML indentation script doesn't consider these +" elements to be worthy of indentation. +call HtmlIndentPush('p') +call HtmlIndentPush('dt') +call HtmlIndentPush('dd') + + +" [-- --] +if !exists('g:html_indent_strict') + call HtmlIndentPush('body') + call HtmlIndentPush('head') + call HtmlIndentPush('html') + call HtmlIndentPush('tbody') +endif + + +" [-- --] +if !exists('g:html_indent_strict_table') + call HtmlIndentPush('th') + call HtmlIndentPush('td') + call HtmlIndentPush('tr') + call HtmlIndentPush('tfoot') + call HtmlIndentPush('thead') +endif + +" [-- --] +call MakoIndentPush('%def') +call MakoIndentPush('%block') +call MakoIndentPush('%call') +call MakoIndentPush('%doc') +call MakoIndentPush('%text') +call MakoIndentPush('%.\+:.\+') + +delfun HtmlIndentPush +delfun MakoIndentPush + +set cpo-=C + +" [-- get number of regex matches in a string --] +fun! MatchCount(expr, pat) + let mpos = 0 + let mcount = 0 + let expr = a:expr + while (mpos > -1) + let mend = matchend(expr, a:pat) + if mend > -1 + let mcount = mcount + 1 + endif + if mend == mpos + let mpos = mpos + 1 + else + let mpos = mend + endif + let expr = strpart(expr, mpos) + endwhile + return mcount +endfun + +" [-- count indent-increasing tags of line a:lnum --] +fun! HtmlIndentOpen(lnum) + let s = substitute('x'.getline(a:lnum), + \ '.\{-}\(\(<\)\('.g:html_indent_tags.'\)\>\)', "\1", 'g') + let s = substitute(s, "[^\1].*$", '', '') + return strlen(s) +endfun + +" [-- count indent-decreasing tags of line a:lnum --] +fun! HtmlIndentClose(lnum) + let s = substitute('x'.getline(a:lnum), + \ '.\{-}\(\(<\)/\('.g:html_indent_tags.'\)\>>\)', "\1", 'g') + let s = substitute(s, "[^\1].*$", '', '') + return strlen(s) +endfun + +" [-- count indent-increasing mako tags of line a:lnum --] +fun! MakoIndentOpen(lnum) + let s = substitute('x'.getline(a:lnum), + \ '.\{-}\(\(<\)\('.g:mako_indent_tags.'\)\>\)', "\1", 'g') + let s = substitute(s, "[^\1].*$", '', '') + return strlen(s) +endfun + +" [-- count indent-decreasing mako tags of line a:lnum --] +fun! MakoIndentClose(lnum) + let mcount = MatchCount(getline(a:lnum), '') + let mcount = mcount + MatchCount(getline(a:lnum), '<\('.g:mako_indent_tags.'\)[^>]*/>') + return mcount +endfun + +" [-- count indent-increasing '{' of (java|css) line a:lnum --] +fun! HtmlIndentOpenAlt(lnum) + return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g')) +endfun + +" [-- count indent-decreasing '}' of (java|css) line a:lnum --] +fun! HtmlIndentCloseAlt(lnum) + return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g')) +endfun + +" [-- return the sum of indents respecting the syntax of a:lnum --] +fun! HtmlIndentSum(lnum, style) + let open = HtmlIndentOpen(a:lnum) + MakoIndentOpen(a:lnum) + let close = HtmlIndentClose(a:lnum) + MakoIndentClose(a:lnum) + if a:style == match(getline(a:lnum), '^\s*HtmlIndentOpenAlt(a:lnum) - HtmlIndentCloseAlt(a:lnum) + endif + endif + return 0 +endfun + +" vim: set ts=4 sw=4: diff --git a/sources_non_forked/vim-bundle-mako/syntax/mako.vim b/sources_non_forked/vim-bundle-mako/syntax/mako.vim new file mode 100644 index 00000000..83736995 --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/syntax/mako.vim @@ -0,0 +1,103 @@ +" Vim syntax file +" Language: Mako +" Maintainer: Armin Ronacher +" URL: http://lucumr.pocoo.org/ +" Last Change: 2013-05-01 +" Version: 0.6.1+ +" +" Thanks to Brine Rue who noticed a bug in the +" delimiter handling. +" +" Known Limitations +" the <%text> block does not have correct attributes + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +if !exists("b:mako_outer_lang") + if exists("g:mako_default_outer_lang") + let b:mako_outer_lang = g:mako_default_outer_lang + else + let b:mako_outer_lang = "html" + endif +endif +if !exists("main_syntax") + let main_syntax = b:mako_outer_lang +endif + +"Source the outer syntax file +execute "ru! syntax/" . b:mako_outer_lang . ".vim" +if exists("b:current_syntax") + unlet b:current_syntax +endif + +if b:mako_outer_lang == "html" + " tell html.vim what syntax groups should take precedence (see :help html.vim) + syn cluster htmlPreproc add=makoLine,makoVariable,makoTag,makoDocComment,makoDefEnd,makoText,makoDelim,makoEnd,makoComment,makoEscape +endif + +"Put the python syntax file in @pythonTop +syn include @pythonTop syntax/python.vim + +" End keywords +syn keyword makoEnd contained endfor endwhile endif endtry enddef + +" Block rules +syn region makoLine matchgroup=makoDelim start=#^\s*%# end=#$# keepend contains=@pythonTop,makoEnd +syn region makoBlock matchgroup=makoDelim start=#<%!\?# end=#%># keepend contains=@pythonTop,makoEnd + +" Variables +syn region makoNested start="{" end="}" transparent display contained contains=makoNested,@pythonTop +syn region makoVariable matchgroup=makoDelim start=#\${# end=#}# contains=makoNested,@pythonTop + +" Comments +syn region makoComment start="^\s*##" end="$" +syn region makoDocComment matchgroup=makoDelim start="<%doc>" end="" keepend + +" Literal Blocks +syn region makoText matchgroup=makoDelim start="<%text[^>]*>" end="" + +" Attribute Sublexing +syn match makoAttributeKey containedin=makoTag contained "[a-zA-Z_][a-zA-Z0-9_]*=" +syn region makoAttributeValue containedin=makoTag contained start=/"/ skip=/\\"/ end=/"/ +syn region makoAttributeValue containedin=MakoTag contained start=/'/ skip=/\\'/ end=/'/ + +" Tags +syn region makoTag matchgroup=makoDelim start="<%\(def\|call\|page\|include\|namespace\|inherit\|block\|[a-zA-Z_][a-zA-Z0-9_]*:[a-zA-Z_][a-zA-Z0-9_]*\)\>" end="/\?>" +syn match makoDelim "" + +syn region makoJavaScript matchgroup=makoDelim start=+<%block .*js.*>+ keepend end=++ contains=@htmlJavaScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc,makoLine,makoBlock,makoVariable +syn region makoCssStyle matchgroup=makoDelim start=+<%block .*css.*>+ keepend end=++ contains=@htmlCss,htmlTag,htmlEndTag,htmlCssStyleComment,@htmlPreproc,makoLine,makoBlock,makoVariable + +" Newline Escapes +syn match makoEscape /\\$/ + +" Default highlighting links +if version >= 508 || !exists("did_mako_syn_inits") + if version < 508 + let did_mako_syn_inits = 1 + com -nargs=+ HiLink hi link + else + com -nargs=+ HiLink hi def link + endif + + HiLink makoDocComment makoComment + HiLink makoDefEnd makoDelim + + HiLink makoAttributeKey Type + HiLink makoAttributeValue String + HiLink makoText Normal + HiLink makoDelim Preproc + HiLink makoEnd Keyword + HiLink makoComment Comment + HiLink makoEscape Special + + delc HiLink +endif + +let b:current_syntax = b:mako_outer_lang diff --git a/sources_non_forked/vim-coffee-script/.gitignore b/sources_non_forked/vim-coffee-script/.gitignore new file mode 100644 index 00000000..1ff7b050 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/.gitignore @@ -0,0 +1,4 @@ +.*.sw[a-z] +.*.un~ +doc/tags + diff --git a/sources_non_forked/vim-coffee-script/Copying.md b/sources_non_forked/vim-coffee-script/Copying.md new file mode 100644 index 00000000..9520fb91 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Copying.md @@ -0,0 +1,54 @@ +All files except: + +ftdetect/vim-literate-coffeescript.vim +indent/litcoffee.vim +syntax/litcoffee.vim +test/test.coffee.md +test/test.litcoffee +test/test.png + +Issued under WTFPL: + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2010 to 2014 Mick Koch + + 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. + + +These files issed under this license: + +ftdetect/vim-literate-coffeescript.vim +indent/litcoffee.vim +syntax/litcoffee.vim +test/test.coffee.md +test/test.litcoffee +test/test.png + +Copyright (c) 2013 Michael Smith + +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/vim-coffee-script/Makefile b/sources_non_forked/vim-coffee-script/Makefile new file mode 100644 index 00000000..e6ef4092 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Makefile @@ -0,0 +1,25 @@ +REF = HEAD +VERSION = $(shell git describe --always $(REF)) + +ARCHIVE = vim-coffee-script-$(VERSION).zip +ARCHIVE_DIRS = after autoload compiler doc ftdetect ftplugin indent syntax + +# Don't do anything by default. +all: + +# Make vim.org zipball. +archive: + git archive $(REF) -o $(ARCHIVE) -- $(ARCHIVE_DIRS) + +# Remove zipball. +clean: + -rm -f $(ARCHIVE) + +# Build the list of syntaxes for @coffeeAll. +coffeeAll: + @grep -E 'syn (match|region)' syntax/coffee.vim |\ + grep -v 'contained' |\ + awk '{print $$3}' |\ + uniq + +.PHONY: all archive clean hash coffeeAll diff --git a/sources_non_forked/vim-coffee-script/News.md b/sources_non_forked/vim-coffee-script/News.md new file mode 100644 index 00000000..9f3f1390 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/News.md @@ -0,0 +1,22 @@ +### Version 003 (October 10, 2014) + +Almost 3 years' worth of fixes and (hopefully) improvements. + +### Version 002 (December 5, 2011) + +Added binary numbers (0b0101) and fixed some bugs (#9, #62, #63, #65). + +### Version 001 (October 18, 2011) + +Removed deprecated `coffee_folding` option, added `coffee_compile_vert` option, +split out compiler, fixed indentation and syntax bugs, and added Haml support +and omnicompletion. + + - The coffee compiler is now a proper vim compiler that can be loaded with + `:compiler coffee`. + - The `coffee_compile_vert` option can now be set to split the CoffeeCompile + buffer vertically by default. + - CoffeeScript is now highlighted inside the `:coffeescript` filter in Haml. + - Omnicompletion (`:help compl-omni`) now uses JavaScript's dictionary to + complete words. + - We now have a fancy version number. diff --git a/sources_non_forked/vim-coffee-script/Readme.md b/sources_non_forked/vim-coffee-script/Readme.md new file mode 100644 index 00000000..053a71b8 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Readme.md @@ -0,0 +1,591 @@ +This project adds [CoffeeScript] support to vim. It covers syntax, indenting, +compiling, and more. + +![Screenshot](http://i.imgur.com/j1BhpZQ.png) + +[CoffeeScript]: http://coffeescript.org/ + +## Table of Contents + +- Installation + - [Requirements](#requirements) + - [Install using Pathogen](#install-using-pathogen) + - [Install using Vundle](#install-using-vundle) + - [Install from a Zip File](#install-from-a-zip-file) +- Coffee Commands + - [Compile to JavaScript](#compile-to-javascript) + - [Compile CoffeeScript Snippets](#coffeecompile-compile-coffeescript-snippets) + - [Live Preview Compiling](#coffeewatch-live-preview-compiling) + - [Run CoffeeScript Snippets](#coffeerun-run-coffeescript-snippets) + - [Lint your CoffeeScript](#coffeelint-lint-your-coffeescript) +- Extras + - [Literate CoffeeScript](#literate-coffeescript) + - [CoffeeScript in HTML](#coffeescript-in-html) + - [CoffeeScript in Haml](#coffeescript-in-haml) +- Configuration + - [Custom Autocmds](#custom-autocmds) + - [Configuration Variables](#configuration-variables) + - [Configure Syntax Highlighting](#configure-syntax-highlighting) + - [Tune Vim for CoffeeScript](#tune-vim-for-coffeescript) + +## Requirements + + - vim 7.4 or later + - coffee 1.2.0 or later + +## Install using Pathogen + +This project uses rolling releases based on git commits, so pathogen is a +natural fit for it. If you're already using pathogen, you can skip to step 4. + +1. Install [pathogen.vim] into `~/.vim/autoload/` (see [pathogen's + readme][install-pathogen] for more information.) + +[pathogen.vim]: http://www.vim.org/scripts/script.php?script_id=2332 +[install-pathogen]: https://github.com/tpope/vim-pathogen#installation + +2. Enable pathogen in your vimrc. Here's a bare-minimum vimrc that enables + all the features of `vim-coffee-script`: + + ```vim + call pathogen#infect() + syntax enable + filetype plugin indent on + ``` + + If you already have a vimrc built up, just make sure it contains these calls, + in this order. + +3. Create the directory `~/.vim/bundle/`: + + mkdir ~/.vim/bundle + +4. Clone the `vim-coffee-script` repo into `~/.vim/bundle/`: + + git clone https://github.com/kchmck/vim-coffee-script.git ~/.vim/bundle/vim-coffee-script/ + +Updating takes two steps: + +1. Change into `~/.vim/bundle/vim-coffee-script/`: + + cd ~/.vim/bundle/vim-coffee-script + +2. Pull in the latest changes: + + git pull + +## Install using Vundle + +1. [Install Vundle] into `~/.vim/bundle/`. + +[Install Vundle]: https://github.com/gmarik/vundle#quick-start + +2. Configure your vimrc for Vundle. Here's a bare-minimum vimrc that enables all + the features of `vim-coffee-script`: + + + ```vim + set nocompatible + filetype off + + set rtp+=~/.vim/bundle/vundle/ + call vundle#rc() + + Plugin 'kchmck/vim-coffee-script' + + syntax enable + filetype plugin indent on + ``` + + If you're adding Vundle to a built-up vimrc, just make sure all these calls + are in there and that they occur in this order. + +3. Open vim and run `:PluginInstall`. + +To update, open vim and run `:PluginInstall!` (notice the bang!) + +## Install from a Zip File + +1. Download the latest zip file from [vim.org][zip]. + +2. Extract the archive into `~/.vim/`: + + unzip -od ~/.vim/ ARCHIVE.zip + + This should create the files `~/.vim/autoload/coffee.vim`, + `~/.vim/compiler/coffee.vim`, etc. + +You can update the plugin using the same steps. + +[zip]: http://www.vim.org/scripts/script.php?script_id=3590 + +## Compile to JavaScript + +A `coffee` wrapper for use with `:make` is enabled automatically for coffee +files if no other compiler is loaded. To enable it manually, run + + :compiler coffee + +The `:make` command is then configured to use the `coffee` compiler and +recognize its errors. I've included a quick reference here but be sure to check +out [`:help :make`][make] for a full reference of the command. + + ![make](http://i.imgur.com/scUXmxR.png) + + ![make Result](http://i.imgur.com/eGIjEdn.png) + +[make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make_makeprg + +Consider the full signature of a `:make` call as + + :[silent] make[!] [COFFEE-OPTIONS]... + +By default `:make` shows all compiler output and jumps to the first line +reported as an error. Compiler output can be hidden with a leading `:silent`: + + :silent make + +Line-jumping can be turned off by adding a bang: + + :make! + +`COFFEE-OPTIONS` given to `:make` are passed along to `coffee` (see also +[`coffee_make_options`](#coffee_make_options)): + + :make --bare --output /some/dir + +See the [full table of options](http://coffeescript.org/#usage) for a +list of all the options that `coffee` recognizes. + +*Configuration*: [`coffee_compiler`](#coffee_compiler), +[`coffee_make_options`](#coffee_make_options) + +#### The quickfix window + +Compiler errors are added to the [quickfix] list by `:make`, but the quickfix +window isn't automatically shown. The [`:cwindow`][cwindow] command will pop up +the quickfix window if there are any errors: + + :make + :cwindow + +This is usually the desired behavior, so you may want to add an autocmd to your +vimrc to do this automatically: + + autocmd QuickFixCmdPost * nested cwindow | redraw! + +The `redraw!` command is needed to fix a redrawing quirk in terminal vim, but +can removed for gVim. + +[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix +[cwindow]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:cwindow + +#### Recompile on write + +To recompile a file when it's written, add a `BufWritePost` autocmd to your +vimrc: + + autocmd BufWritePost *.coffee silent make! + +#### Cake and Cakefiles + +A `cake` compiler is also available with the call + + :compiler cake + +You can then use `:make` as above to run your Cakefile and capture any `coffee` +errors: + + :silent make build + +It runs within the current directory, so make sure you're in the directory of +your Cakefile before calling it. + +*Configuration*: [`coffee_cake`](#coffee_cake), +[`coffee_cake_options`](#coffee_cake_options) + +## CoffeeCompile: Compile CoffeeScript Snippets + +CoffeeCompile shows how the current file or a snippet of CoffeeScript is +compiled to JavaScript. + + :[RANGE] CoffeeCompile [vert[ical]] [WINDOW-SIZE] + +Calling `:CoffeeCompile` without a range compiles the whole file: + + ![CoffeeCompile](http://i.imgur.com/0zFG0l0.png) + + ![CoffeeCompile Result](http://i.imgur.com/bpiAxaa.png) + +Calling it with a range, like in visual mode, compiles only the selected snippet +of CoffeeScript: + + ![CoffeeCompile Snippet](http://i.imgur.com/x3OT3Ay.png) + + ![Compiled Snippet](http://i.imgur.com/J02j4T8.png) + +Each file gets its own CoffeeCompile buffer, and the same buffer is used for all +future calls of `:CoffeeCompile` on that file. It can be quickly closed by +hitting `q` in normal mode. + +Using `vert` opens the CoffeeCompile buffer vertically instead of horizontally +(see also [`coffee_compile_vert`](#coffee_compile_vert)): + + :CoffeeCompile vert + +By default the CoffeeCompile buffer splits the source buffer in half, but this +can be overridden by passing in a `WINDOW-SIZE`: + + :CoffeeCompile 4 + +*Configuration*: [`coffee_compiler`](#coffee_compiler`), +[`coffee_compile_vert`](#coffee_compile_vert) + +#### Quick syntax checking + +If compiling a snippet results in a compiler error, CoffeeCompile adds that +error to the [quickfix] list. + +[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix + + ![Syntax Checking](http://i.imgur.com/RC8accF.png) + + ![Syntax Checking Result](http://i.imgur.com/gi1ON75.png) + +You can use this to quickly check the syntax of a snippet. + +## CoffeeWatch: Live Preview Compiling + +CoffeeWatch emulates using the Try CoffeeScript preview box on the [CoffeeScript +homepage][CoffeeScript]. + + ![CoffeeWatch](http://i.imgur.com/TRHdIMG.png) + + ![CoffeeWatch Result](http://i.imgur.com/rJbOeeS.png) + +CoffeeWatch takes the same options as CoffeeCompile: + + :CoffeeWatch [vert[ical]] [WINDOW-SIZE] + +After a source buffer is watched, leaving insert mode or saving the file fires +off a recompile of the CoffeeScript: + + ![Insert Mode](http://i.imgur.com/SBVcf4k.png) + + ![Recompile](http://i.imgur.com/pbPMog7.png) + +You can force recompilation by calling `:CoffeeWatch`. + +To get synchronized scrolling of the source buffer and CoffeeWatch buffer, set +[`'scrollbind'`](http://vimdoc.sourceforge.net/htmldoc/options.html#'scrollbind') +on each: + + :setl scrollbind + +*Configuration*: [`coffee_compiler`](#coffee_compiler), +[`coffee_watch_vert`](#coffee_watch_vert) + +## CoffeeRun: Run CoffeeScript Snippets + +CoffeeRun compiles the current file or selected snippet and runs the resulting +JavaScript. + + ![CoffeeRun](http://i.imgur.com/YSkHUuQ.png) + + ![CoffeeRun Output](http://i.imgur.com/wZQbggN.png) + +The command has two forms: + + :CoffeeRun [PROGRAM-OPTIONS]... + +This form applies when no `RANGE` is given or when the given range is `1,$` +(first line to last line). It allows passing `PROGRAM-OPTIONS` to your compiled +program. The filename is passed directly to `coffee` so you must save the file +for your changes to take effect. + + :RANGE CoffeeRun [COFFEE-OPTIONS]... + +This form applies with all other ranges. It compiles and runs the lines within +the given `RANGE` and any extra `COFFEE-OPTIONS` are passed to `coffee`. + +*Configuration*: [`coffee_compiler`](#coffee_compiler), +[`coffee_run_vert`](#coffee_run_vert) + +## CoffeeLint: Lint your CoffeeScript + +CoffeeLint runs [coffeelint](http://www.coffeelint.org/) (version 1.4.0 or later +required) on the current file and adds any issues to the [quickfix] list. + + ![CoffeeLint](http://i.imgur.com/UN8Nr5N.png) + + ![CoffeeLint Result](http://i.imgur.com/9hSIj3W.png) + + :[RANGE] CoffeeLint[!] [COFFEELINT-OPTIONS]... [ | cwindow] + +If a `RANGE` is given, only those lines are piped to `coffeelint`. Options given +in `COFFEELINT-OPTIONS` are passed to `coffeelint` (see also +[`coffee_lint_options`](#coffee_lint_options)): + + :CoffeeLint -f lint.json + +It behaves very similar to `:make`, described [above](#compile-to-javascript). + + :CoffeeLint! | cwindow + +*Configuration*: [`coffee_linter`](#coffee_linter), +[`coffee_lint_options`](#coffee_lint_options) + +## Literate CoffeeScript + +Literate CoffeeScript syntax and indent support is now built in! The `Coffee` +commands detect when they're running on a litcoffee file and pass the +`--literate` flag to their respective tools. + +Literate CoffeeScript syntax and indent support was written by @mintplant +(Michael Smith). A standalone repo +[exists](https://github.com/jwhitley/vim-literate-coffeescript), but you'll +need to copy the `ftplugin/litcoffee.vim` file or set up an autocmd to get the +`Coffee` commands to be automatically loaded for litcoffee files. + +## CoffeeScript in HTML + +CoffeeScript is highlighted and indented within + +```html + +``` + +blocks in html files. + +## CoffeeScript in Haml + +CoffeeScript is highlighted within the `:coffeescript` filter in haml files: + +```haml +:coffeescript + console.log "hullo" +``` + +At this time, coffee indenting doesn't work in these blocks. + +## Custom Autocmds + +You can [define commands][autocmd-explain] to be ran automatically on these +custom events. + +In all cases, the name of the command running the event (`CoffeeCompile`, +`CoffeeWatch`, or `CoffeeRun`) is matched by the [`{pat}`][autocmd] argument. +You can match all commands with a `*` or only specific commands by separating +them with a comma: `CoffeeCompile,CoffeeWatch`. + +[autocmd-explain]: http://vimdoc.sourceforge.net/htmldoc/usr_40.html#40.3 +[autocmd]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:autocmd + +#### CoffeeBufNew + +CoffeeBufNew is ran when a new scratch buffer is created. It's called from the +new buffer, so it can be used to do additional set up. + +```vim +augroup CoffeeBufNew + autocmd User * set wrap +augroup END +``` + +*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun + +#### CoffeeBufUpdate + +CoffeeBufUpdate is ran when a scratch buffer is updated with output from +`coffee`. It's called from the scratch buffer, so it can be used to alter the +compiled output. + +```vim +" Switch back to the source buffer after updating. +augroup CoffeeBufUpdate + autocmd User CoffeeCompile,CoffeeRun exec bufwinnr(b:coffee_src_buf) 'wincmd w' +augroup END +``` + +For example, to strip off the "Generated by" comment on the first line, put this +in your vimrc: + +```vim +function! s:RemoveGeneratedBy() + " If there was an error compiling, there's no comment to remove. + if v:shell_error + return + endif + + " Save cursor position. + let pos = getpos('.') + + " Remove first line. + set modifiable + 1 delete _ + set nomodifiable + + " Restore cursor position. + call setpos('.', pos) +endfunction + +augroup CoffeeBufUpdate + autocmd User CoffeeCompile,CoffeeWatch call s:RemoveGeneratedBy() +augroup END +``` + +*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun + +## Configuration Variables + +This is the full list of configuration variables available, with example +settings and default values. Use these in your vimrc to control the default +behavior. + +#### coffee\_indent\_keep\_current + +By default, the indent function matches the indent of the previous line if it +doesn't find a reason to indent or outdent. To change this behavior so it +instead keeps the [current indent of the cursor][98], use + + let coffee_indent_keep_current = 1 + +[98]: https://github.com/kchmck/vim-coffee-script/pull/98 + +*Default*: `unlet coffee_indent_keep_current` + +Note that if you change this after a coffee file has been loaded, you'll have to +reload the indent script for the change to take effect: + + unlet b:did_indent | runtime indent/coffee.vim + +#### coffee\_compiler + +Path to the `coffee` executable used by the `Coffee` commands: + + let coffee_compiler = '/usr/bin/coffee' + +*Default*: `'coffee'` (search `$PATH` for executable) + +#### coffee\_make\_options + +Options to pass to `coffee` with `:make`: + + let coffee_make_options = '--bare' + +*Default*: `''` (nothing) + +Note that `coffee_make_options` is embedded into `'makeprg'`, so `:compiler +coffee` must be ran after changing `coffee_make_options` for the changes to take +effect. + +#### coffee\_cake + +Path to the `cake` executable: + + let coffee_cake = '/opt/bin/cake' + +*Default*: `'cake'` (search `$PATH` for executable) + +#### coffee\_cake\_options + +Options to pass to `cake` with `:make`: + + let coffee_cake_options = 'build' + +*Default*: `''` (nothing) + +#### coffee\_linter + +Path to the `coffeelint` executable: + + let coffee_linter = '/opt/bin/coffeelint' + +*Default*: `'coffeelint'` (search `$PATH` for executable) + +#### coffee\_lint\_options + +Options to pass to `coffeelint`: + + let coffee_lint_options = '-f lint.json' + +*Default*: `''` (nothing) + +#### coffee\_compile\_vert + +Open the CoffeeCompile buffer with a vertical split instead of a horizontal +one: + + let coffee_compile_vert = 1 + +*Default*: `unlet coffee_compile_vert` + +#### coffee\_watch\_vert + +Open the CoffeeWatch buffer with a vertical split instead of a horizontal +one: + + let coffee_watch_vert = 1 + +*Default*: `unlet coffee_watch_vert` + +#### coffee\_run\_vert + +Open the CoffeeRun buffer with a vertical split instead of a horizontal +one: + + let coffee_run_vert = 1 + +*Default*: `unlet coffee_run_vert` + +## Configure Syntax Highlighting + +Add these lines to your vimrc to disable the relevant syntax group. + +#### Disable trailing whitespace error + +Trailing whitespace is highlighted as an error by default. This can be disabled +with: + + hi link coffeeSpaceError NONE + +#### Disable trailing semicolon error + +Trailing semicolons are considered an error (for help transitioning from +JavaScript.) This can be disabled with: + + hi link coffeeSemicolonError NONE + +#### Disable reserved words error + +Reserved words like `function` and `var` are highlighted as an error where +they're not allowed in CoffeeScript. This can be disabled with: + + hi link coffeeReservedError NONE + +## Tune Vim for CoffeeScript + +Changing these core settings can make vim more CoffeeScript friendly. + +#### Fold by indentation + +Folding by indentation works well for CoffeeScript functions and classes: + + ![Folding](http://i.imgur.com/gDgUBdO.png) + +To fold by indentation in CoffeeScript files, add this line to your vimrc: + + autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable + +With this, folding is disabled by default but can be quickly toggled per-file +by hitting `zi`. To enable folding by default, remove `nofoldenable`: + + autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent + +#### Two-space indentation + +To get standard two-space indentation in CoffeeScript files, add this line to +your vimrc: + + autocmd BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab diff --git a/sources_non_forked/vim-coffee-script/Thanks.md b/sources_non_forked/vim-coffee-script/Thanks.md new file mode 100644 index 00000000..8ddcf23f --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Thanks.md @@ -0,0 +1,44 @@ +Thanks to all bug reporters, and special thanks to those who have contributed +code: + + Brian Egan (brianegan): + Initial compiling support + + Ches Martin (ches): + Initial vim docs + + Chris Hoffman (cehoffman): + Add new keywoards from, to, and do + Highlight the - in negative integers + Add here regex highlighting, increase fold level for here docs + + David Wilhelm (bigfish): + CoffeeRun command + + Jay Adkisson (jayferd): + Support for eco templates + + Karl Guertin (grayrest) + Cakefiles are coffeescript + + Maciej Konieczny (narfdotpl): + Fix funny typo + + Matt Sacks (mattsa): + Javascript omni-completion + coffee_compile_vert option + + Nick Stenning (nickstenning): + Fold by indentation for coffeescript + + Simon Lipp (sloonz): + Trailing spaces are not error on lines containing only spaces + + Stéphan Kochen (stephank): + Initial HTML CoffeeScript highlighting + + Sven Felix Oberquelle (Svelix): + Haml CoffeeScript highlighting + + Wei Dai (clvv): + Fix the use of Vim built-in make command. diff --git a/sources_non_forked/vim-coffee-script/Todo.md b/sources_non_forked/vim-coffee-script/Todo.md new file mode 100644 index 00000000..3d4ffaa8 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Todo.md @@ -0,0 +1 @@ +- Don't highlight bad operator combinations diff --git a/sources_non_forked/vim-coffee-script/after/indent/html.vim b/sources_non_forked/vim-coffee-script/after/indent/html.vim new file mode 100644 index 00000000..0823e689 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/after/indent/html.vim @@ -0,0 +1,33 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +" Load the coffee and html indent functions. +silent! unlet b:did_indent +runtime indent/coffee.vim +let s:coffeeIndentExpr = &l:indentexpr + +" Load html last so it can overwrite coffee settings. +silent! unlet b:did_indent +runtime indent/html.vim +let s:htmlIndentExpr = &l:indentexpr + +" Inject our wrapper indent function. +setlocal indentexpr=GetCoffeeHtmlIndent(v:lnum) + +function! GetCoffeeHtmlIndent(curlinenum) + " See if we're inside a coffeescript block. + let scriptlnum = searchpair('', 'bWn') + let prevlnum = prevnonblank(a:curlinenum) + + " If we're in the script block and the previous line isn't the script tag + " itself, use coffee indenting. + if scriptlnum && scriptlnum != prevlnum + exec 'return ' s:coffeeIndentExpr + endif + + " Otherwise use html indenting. + exec 'return ' s:htmlIndentExpr +endfunction diff --git a/sources_non_forked/vim-coffee-script/after/syntax/haml.vim b/sources_non_forked/vim-coffee-script/after/syntax/haml.vim new file mode 100644 index 00000000..3e186cdc --- /dev/null +++ b/sources_non_forked/vim-coffee-script/after/syntax/haml.vim @@ -0,0 +1,23 @@ +" Language: CoffeeScript +" Maintainer: Sven Felix Oberquelle +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + + +if exists('b:current_syntax') + let s:current_syntax_save = b:current_syntax +endif + +" Inherit coffee from html so coffeeComment isn't redefined and given higher +" priority than hamlInterpolation. +syn cluster hamlCoffeescript contains=@htmlCoffeeScript +syn region hamlCoffeescriptFilter matchgroup=hamlFilter +\ start="^\z(\s*\):coffee\z(script\)\?\s*$" +\ end="^\%(\z1 \| *$\)\@!" +\ contains=@hamlCoffeeScript,hamlInterpolation +\ keepend + +if exists('s:current_syntax_save') + let b:current_syntax = s:current_syntax_save + unlet s:current_syntax_save +endif diff --git a/sources_non_forked/vim-coffee-script/after/syntax/html.vim b/sources_non_forked/vim-coffee-script/after/syntax/html.vim new file mode 100644 index 00000000..a78ba88d --- /dev/null +++ b/sources_non_forked/vim-coffee-script/after/syntax/html.vim @@ -0,0 +1,20 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +if exists('b:current_syntax') + let s:current_syntax_save = b:current_syntax +endif + +" Syntax highlighting for text/coffeescript script tags +syn include @htmlCoffeeScript syntax/coffee.vim +syn region coffeeScript start=##me=s-1 keepend +\ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc +\ containedin=htmlHead + +if exists('s:current_syntax_save') + let b:current_syntax = s:current_syntax_save + unlet s:current_syntax_save +endif diff --git a/sources_non_forked/vim-coffee-script/autoload/coffee.vim b/sources_non_forked/vim-coffee-script/autoload/coffee.vim new file mode 100644 index 00000000..8d727951 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/autoload/coffee.vim @@ -0,0 +1,54 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +" Set up some common global/buffer variables. +function! coffee#CoffeeSetUpVariables() + " Path to coffee executable + if !exists('g:coffee_compiler') + let g:coffee_compiler = 'coffee' + endif + + " Options passed to coffee with make + if !exists('g:coffee_make_options') + let g:coffee_make_options = '' + endif + + " Path to cake executable + if !exists('g:coffee_cake') + let g:coffee_cake = 'cake' + endif + + " Extra options passed to cake + if !exists('g:coffee_cake_options') + let g:coffee_cake_options = '' + endif + + " Path to coffeelint executable + if !exists('g:coffee_linter') + let g:coffee_linter = 'coffeelint' + endif + + " Options passed to CoffeeLint + if !exists('g:coffee_lint_options') + let g:coffee_lint_options = '' + endif + + " Pass the litcoffee flag to tools in this buffer if a litcoffee file is open. + " Let the variable be overwritten so it can be updated if a different filetype + " is set. + if &filetype == 'litcoffee' + let b:coffee_litcoffee = '--literate' + else + let b:coffee_litcoffee = '' + endif +endfunction + +function! coffee#CoffeeSetUpErrorFormat() + CompilerSet errorformat=Error:\ In\ %f\\,\ %m\ on\ line\ %l, + \Error:\ In\ %f\\,\ Parse\ error\ on\ line\ %l:\ %m, + \SyntaxError:\ In\ %f\\,\ %m, + \%f:%l:%c:\ error:\ %m, + \%-G%.%# +endfunction diff --git a/sources_non_forked/vim-coffee-script/compiler/cake.vim b/sources_non_forked/vim-coffee-script/compiler/cake.vim new file mode 100644 index 00000000..b49638e7 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/compiler/cake.vim @@ -0,0 +1,15 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +if exists('current_compiler') + finish +endif + +let current_compiler = 'cake' +call coffee#CoffeeSetUpVariables() + +exec 'CompilerSet makeprg=' . escape(g:coffee_cake . ' ' . +\ g:coffee_cake_options . ' $*', ' ') +call coffee#CoffeeSetUpErrorFormat() diff --git a/sources_non_forked/vim-coffee-script/compiler/coffee.vim b/sources_non_forked/vim-coffee-script/compiler/coffee.vim new file mode 100644 index 00000000..5a914578 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/compiler/coffee.vim @@ -0,0 +1,82 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +" All this is needed to support compiling filenames with spaces, quotes, and +" such. The filename is escaped and embedded into the `makeprg` setting. +" +" Because of this, `makeprg` must be updated on every file rename. And because +" of that, `CompilerSet` can't be used because it doesn't exist when the +" rename autocmd is ran. So, we have to do some checks to see whether `compiler` +" was called locally or globally, and respect that in the rest of the script. + +if exists('current_compiler') + finish +endif + +let current_compiler = 'coffee' +call coffee#CoffeeSetUpVariables() + +" Pattern to check if coffee is the compiler +let s:pat = '^' . current_compiler + +" Get a `makeprg` for the current filename. +function! s:GetMakePrg() + return g:coffee_compiler . + \ ' -c' . + \ ' ' . b:coffee_litcoffee . + \ ' ' . g:coffee_make_options . + \ ' $*' . + \ ' ' . fnameescape(expand('%')) +endfunction + +" Set `makeprg` and return 1 if coffee is still the compiler, else return 0. +function! s:SetMakePrg() + if &l:makeprg =~ s:pat + let &l:makeprg = s:GetMakePrg() + elseif &g:makeprg =~ s:pat + let &g:makeprg = s:GetMakePrg() + else + return 0 + endif + + return 1 +endfunction + +" Set a dummy compiler so we can check whether to set locally or globally. +exec 'CompilerSet makeprg=' . current_compiler +" Then actually set the compiler. +call s:SetMakePrg() +call coffee#CoffeeSetUpErrorFormat() + +function! s:CoffeeMakeDeprecated(bang, args) + echoerr 'CoffeeMake is deprecated! Please use :make instead, its behavior ' . + \ 'is identical.' + sleep 5 + exec 'make' . a:bang a:args +endfunction + +" Compile the current file. +command! -bang -bar -nargs=* CoffeeMake +\ call s:CoffeeMakeDeprecated(, ) + +" Set `makeprg` on rename since we embed the filename in the setting. +augroup CoffeeUpdateMakePrg + autocmd! + + " Update `makeprg` if coffee is still the compiler, else stop running this + " function. + function! s:UpdateMakePrg() + if !s:SetMakePrg() + autocmd! CoffeeUpdateMakePrg + endif + endfunction + + " Set autocmd locally if compiler was set locally. + if &l:makeprg =~ s:pat + autocmd BufWritePre,BufFilePost call s:UpdateMakePrg() + else + autocmd BufWritePre,BufFilePost call s:UpdateMakePrg() + endif +augroup END diff --git a/sources_non_forked/vim-coffee-script/doc/coffee-script.txt b/sources_non_forked/vim-coffee-script/doc/coffee-script.txt new file mode 100644 index 00000000..1b43cf3a --- /dev/null +++ b/sources_non_forked/vim-coffee-script/doc/coffee-script.txt @@ -0,0 +1,4 @@ +Please see the project readme for up-to-date docs: +https://github.com/kchmck/vim-coffee-script + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim b/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim new file mode 100644 index 00000000..e6c4d698 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim @@ -0,0 +1,17 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +autocmd BufNewFile,BufRead *.coffee set filetype=coffee +autocmd BufNewFile,BufRead *Cakefile set filetype=coffee +autocmd BufNewFile,BufRead *.coffeekup,*.ck set filetype=coffee +autocmd BufNewFile,BufRead *._coffee set filetype=coffee + +function! s:DetectCoffee() + if getline(1) =~ '^#!.*\' + set filetype=coffee + endif +endfunction + +autocmd BufNewFile,BufRead * call s:DetectCoffee() diff --git a/sources_non_forked/vim-coffee-script/ftdetect/vim-literate-coffeescript.vim b/sources_non_forked/vim-coffee-script/ftdetect/vim-literate-coffeescript.vim new file mode 100644 index 00000000..7f666246 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/ftdetect/vim-literate-coffeescript.vim @@ -0,0 +1,8 @@ +" Language: Literate CoffeeScript +" Maintainer: Michael Smith +" URL: https://github.com/mintplant/vim-literate-coffeescript +" License: MIT + +autocmd BufNewFile,BufRead *.litcoffee set filetype=litcoffee +autocmd BufNewFile,BufRead *.coffee.md set filetype=litcoffee + diff --git a/sources_non_forked/vim-coffee-script/ftplugin/coffee.vim b/sources_non_forked/vim-coffee-script/ftplugin/coffee.vim new file mode 100644 index 00000000..3f9cd771 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/ftplugin/coffee.vim @@ -0,0 +1,405 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +if exists('b:did_ftplugin') + finish +endif + +let b:did_ftplugin = 1 +call coffee#CoffeeSetUpVariables() + +setlocal formatoptions-=t formatoptions+=croql +setlocal comments=:# commentstring=#\ %s +setlocal omnifunc=javascriptcomplete#CompleteJS +setlocal suffixesadd+=.coffee + +" Create custom augroups. +augroup CoffeeBufUpdate | augroup END +augroup CoffeeBufNew | augroup END + +" Enable coffee compiler if a compiler isn't set already. +if !len(&l:makeprg) + compiler coffee +endif + +" Switch to the window for buf. +function! s:SwitchWindow(buf) + exec bufwinnr(a:buf) 'wincmd w' +endfunction + +" Create a new scratch buffer and return the bufnr of it. After the function +" returns, vim remains in the scratch buffer so more set up can be done. +function! s:ScratchBufBuild(src, vert, size) + if a:size <= 0 + if a:vert + let size = winwidth(bufwinnr(a:src)) / 2 + else + let size = winheight(bufwinnr(a:src)) / 2 + endif + endif + + if a:vert + vertical belowright new + exec 'vertical resize' size + else + belowright new + exec 'resize' size + endif + + setlocal bufhidden=wipe buftype=nofile nobuflisted noswapfile nomodifiable + nnoremap q :hide + + return bufnr('%') +endfunction + +" Replace buffer contents with text and delete the last empty line. +function! s:ScratchBufUpdate(buf, text) + " Move to the scratch buffer. + call s:SwitchWindow(a:buf) + + " Double check we're in the scratch buffer before overwriting. + if bufnr('%') != a:buf + throw 'unable to change to scratch buffer' + endif + + setlocal modifiable + silent exec '% delete _' + silent put! =a:text + silent exec '$ delete _' + setlocal nomodifiable +endfunction + +" Parse the output of coffee into a qflist entry for src buffer. +function! s:ParseCoffeeError(output, src, startline) + " Coffee error is always on first line? + let match = matchlist(a:output, + \ '^\(\f\+\|\[stdin\]\):\(\d\):\(\d\): error: \(.\{-}\)' . "\n") + + if !len(match) + return + endif + + " Consider the line number from coffee as relative and add it to the beginning + " line number of the range the command was called on, then subtract one for + " zero-based relativity. + call setqflist([{'bufnr': a:src, 'lnum': a:startline + str2nr(match[2]) - 1, + \ 'type': 'E', 'col': str2nr(match[3]), 'text': match[4]}], 'r') +endfunction + +" Reset source buffer variables. +function! s:CoffeeCompileResetVars() + " Variables defined in source buffer: + " b:coffee_compile_buf: bufnr of output buffer + " Variables defined in output buffer: + " b:coffee_src_buf: bufnr of source buffer + " b:coffee_compile_pos: previous cursor position in output buffer + + let b:coffee_compile_buf = -1 +endfunction + +function! s:CoffeeWatchResetVars() + " Variables defined in source buffer: + " b:coffee_watch_buf: bufnr of output buffer + " Variables defined in output buffer: + " b:coffee_src_buf: bufnr of source buffer + " b:coffee_watch_pos: previous cursor position in output buffer + + let b:coffee_watch_buf = -1 +endfunction + +function! s:CoffeeRunResetVars() + " Variables defined in CoffeeRun source buffer: + " b:coffee_run_buf: bufnr of output buffer + " Variables defined in CoffeeRun output buffer: + " b:coffee_src_buf: bufnr of source buffer + " b:coffee_run_pos: previous cursor position in output buffer + + let b:coffee_run_buf = -1 +endfunction + +" Clean things up in the source buffers. +function! s:CoffeeCompileClose() + " Switch to the source buffer if not already in it. + silent! call s:SwitchWindow(b:coffee_src_buf) + call s:CoffeeCompileResetVars() +endfunction + +function! s:CoffeeWatchClose() + silent! call s:SwitchWindow(b:coffee_src_buf) + silent! autocmd! CoffeeAuWatch * + call s:CoffeeWatchResetVars() +endfunction + +function! s:CoffeeRunClose() + silent! call s:SwitchWindow(b:coffee_src_buf) + call s:CoffeeRunResetVars() +endfunction + +" Compile the lines between startline and endline and put the result into buf. +function! s:CoffeeCompileToBuf(buf, startline, endline) + let src = bufnr('%') + let input = join(getline(a:startline, a:endline), "\n") + + " Coffee doesn't like empty input. + if !len(input) + " Function should still return within output buffer. + call s:SwitchWindow(a:buf) + return + endif + + " Pipe lines into coffee. + let output = system(g:coffee_compiler . + \ ' -scb' . + \ ' ' . b:coffee_litcoffee . + \ ' 2>&1', input) + + " Paste output into output buffer. + call s:ScratchBufUpdate(a:buf, output) + + " Highlight as JavaScript if there were no compile errors. + if v:shell_error + call s:ParseCoffeeError(output, src, a:startline) + setlocal filetype= + else + " Clear the quickfix list. + call setqflist([], 'r') + setlocal filetype=javascript + endif +endfunction + +" Peek at compiled CoffeeScript in a scratch buffer. We handle ranges like this +" to prevent the cursor from being moved (and its position saved) before the +" function is called. +function! s:CoffeeCompile(startline, endline, args) + if a:args =~ '\' + echoerr 'CoffeeCompile watch is deprecated! Please use CoffeeWatch instead' + sleep 5 + call s:CoffeeWatch(a:args) + return + endif + + " Switch to the source buffer if not already in it. + silent! call s:SwitchWindow(b:coffee_src_buf) + + " Bail if not in source buffer. + if !exists('b:coffee_compile_buf') + return + endif + + " Build the output buffer if it doesn't exist. + if bufwinnr(b:coffee_compile_buf) == -1 + let src = bufnr('%') + + let vert = exists('g:coffee_compile_vert') || a:args =~ '\' + let size = str2nr(matchstr(a:args, '\<\d\+\>')) + + " Build the output buffer and save the source bufnr. + let buf = s:ScratchBufBuild(src, vert, size) + let b:coffee_src_buf = src + + " Set the buffer name. + exec 'silent! file [CoffeeCompile ' . src . ']' + + " Clean up the source buffer when the output buffer is closed. + autocmd BufWipeout call s:CoffeeCompileClose() + " Save the cursor when leaving the output buffer. + autocmd BufLeave let b:coffee_compile_pos = getpos('.') + + " Run user-defined commands on new buffer. + silent doautocmd CoffeeBufNew User CoffeeCompile + + " Switch back to the source buffer and save the output bufnr. This also + " triggers BufLeave above. + call s:SwitchWindow(src) + let b:coffee_compile_buf = buf + endif + + " Fill the scratch buffer. + call s:CoffeeCompileToBuf(b:coffee_compile_buf, a:startline, a:endline) + " Reset cursor to previous position. + call setpos('.', b:coffee_compile_pos) + + " Run any user-defined commands on the scratch buffer. + silent doautocmd CoffeeBufUpdate User CoffeeCompile +endfunction + +" Update the scratch buffer and switch back to the source buffer. +function! s:CoffeeWatchUpdate() + call s:CoffeeCompileToBuf(b:coffee_watch_buf, 1, '$') + call setpos('.', b:coffee_watch_pos) + silent doautocmd CoffeeBufUpdate User CoffeeWatch + call s:SwitchWindow(b:coffee_src_buf) +endfunction + +" Continually compile a source buffer. +function! s:CoffeeWatch(args) + silent! call s:SwitchWindow(b:coffee_src_buf) + + if !exists('b:coffee_watch_buf') + return + endif + + if bufwinnr(b:coffee_watch_buf) == -1 + let src = bufnr('%') + + let vert = exists('g:coffee_watch_vert') || a:args =~ '\' + let size = str2nr(matchstr(a:args, '\<\d\+\>')) + + let buf = s:ScratchBufBuild(src, vert, size) + let b:coffee_src_buf = src + + exec 'silent! file [CoffeeWatch ' . src . ']' + + autocmd BufWipeout call s:CoffeeWatchClose() + autocmd BufLeave let b:coffee_watch_pos = getpos('.') + + silent doautocmd CoffeeBufNew User CoffeeWatch + + call s:SwitchWindow(src) + let b:coffee_watch_buf = buf + endif + + " Make sure only one watch autocmd is defined on this buffer. + silent! autocmd! CoffeeAuWatch * + + augroup CoffeeAuWatch + autocmd InsertLeave call s:CoffeeWatchUpdate() + autocmd BufWritePost call s:CoffeeWatchUpdate() + augroup END + + call s:CoffeeWatchUpdate() +endfunction + +" Run a snippet of CoffeeScript between startline and endline. +function! s:CoffeeRun(startline, endline, args) + silent! call s:SwitchWindow(b:coffee_src_buf) + + if !exists('b:coffee_run_buf') + return + endif + + if bufwinnr(b:coffee_run_buf) == -1 + let src = bufnr('%') + + let buf = s:ScratchBufBuild(src, exists('g:coffee_run_vert'), 0) + let b:coffee_src_buf = src + + exec 'silent! file [CoffeeRun ' . src . ']' + + autocmd BufWipeout call s:CoffeeRunClose() + autocmd BufLeave let b:coffee_run_pos = getpos('.') + + silent doautocmd CoffeeBufNew User CoffeeRun + + call s:SwitchWindow(src) + let b:coffee_run_buf = buf + endif + + if a:startline == 1 && a:endline == line('$') + let output = system(g:coffee_compiler . + \ ' ' . b:coffee_litcoffee . + \ ' ' . fnameescape(expand('%')) . + \ ' ' . a:args) + else + let input = join(getline(a:startline, a:endline), "\n") + + if !len(input) + return + endif + + let output = system(g:coffee_compiler . + \ ' -s' . + \ ' ' . b:coffee_litcoffee . + \ ' ' . a:args, input) + endif + + call s:ScratchBufUpdate(b:coffee_run_buf, output) + call setpos('.', b:coffee_run_pos) + + silent doautocmd CoffeeBufUpdate User CoffeeRun +endfunction + +" Run coffeelint on a file, and add any errors between startline and endline +" to the quickfix list. +function! s:CoffeeLint(startline, endline, bang, args) + let input = join(getline(a:startline, a:endline), "\n") + + if !len(input) + return + endif + + let output = system(g:coffee_linter . + \ ' -s --reporter csv' . + \ ' ' . b:coffee_litcoffee . + \ ' ' . g:coffee_lint_options . + \ ' ' . a:args . + \ ' 2>&1', input) + + " Convert output into an array and strip off the csv header. + let lines = split(output, "\n")[1:] + let buf = bufnr('%') + let qflist = [] + + for line in lines + let match = matchlist(line, '^stdin,\(\d\+\),\d*,\(error\|warn\),\(.\+\)$') + + " Ignore unmatched lines. + if !len(match) + continue + endif + + " The 'type' will result in either 'E' or 'W'. + call add(qflist, {'bufnr': buf, 'lnum': a:startline + str2nr(match[1]) - 1, + \ 'type': toupper(match[2][0]), 'text': match[3]}) + endfor + + " Replace the quicklist with our items. + call setqflist(qflist, 'r') + + " If not given a bang, jump to first error. + if !len(a:bang) + silent! cc 1 + endif +endfunction + +" Complete arguments for Coffee* commands. +function! s:CoffeeComplete(cmd, cmdline, cursor) + let args = ['vertical'] + + " If no partial command, return all possibilities. + if !len(a:cmd) + return args + endif + + let pat = '^' . a:cmd + + for arg in args + if arg =~ pat + return [arg] + endif + endfor +endfunction + +" Set initial state variables if they don't exist +if !exists('b:coffee_compile_buf') + call s:CoffeeCompileResetVars() +endif + +if !exists('b:coffee_watch_buf') + call s:CoffeeWatchResetVars() +endif + +if !exists('b:coffee_run_buf') + call s:CoffeeRunResetVars() +endif + +command! -buffer -range=% -bar -nargs=* -complete=customlist,s:CoffeeComplete +\ CoffeeCompile call s:CoffeeCompile(, , ) +command! -buffer -bar -nargs=* -complete=customlist,s:CoffeeComplete +\ CoffeeWatch call s:CoffeeWatch() +command! -buffer -range=% -bar -nargs=* CoffeeRun +\ call s:CoffeeRun(, , ) +command! -buffer -range=% -bang -bar -nargs=* CoffeeLint +\ call s:CoffeeLint(, , , ) diff --git a/sources_non_forked/vim-coffee-script/ftplugin/litcoffee.vim b/sources_non_forked/vim-coffee-script/ftplugin/litcoffee.vim new file mode 100644 index 00000000..febc730c --- /dev/null +++ b/sources_non_forked/vim-coffee-script/ftplugin/litcoffee.vim @@ -0,0 +1 @@ +runtime ftplugin/coffee.vim diff --git a/sources_non_forked/vim-coffee-script/indent/coffee.vim b/sources_non_forked/vim-coffee-script/indent/coffee.vim new file mode 100644 index 00000000..4f4570a8 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/indent/coffee.vim @@ -0,0 +1,428 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +if exists('b:did_indent') + finish +endif + +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetCoffeeIndent(v:lnum) +" Make sure GetCoffeeIndent is run when these are typed so they can be +" indented or outdented. +setlocal indentkeys+=0],0),0.,=else,=when,=catch,=finally + +" If no indenting or outdenting is needed, either keep the indent of the cursor +" (use autoindent) or match the indent of the previous line. +if exists('g:coffee_indent_keep_current') + let s:DEFAULT_LEVEL = '-1' +else + let s:DEFAULT_LEVEL = 'indent(prevnlnum)' +endif + +" Only define the function once. +if exists('*GetCoffeeIndent') + finish +endif + +" Keywords that begin a block +let s:BEGIN_BLOCK_KEYWORD = '\C^\%(if\|unless\|else\|for\|while\|until\|' +\ . 'loop\|switch\|when\|try\|catch\|finally\|' +\ . 'class\)\>\%(\s*:\)\@!' + +" An expression that uses the result of a statement +let s:COMPOUND_EXPRESSION = '\C\%([^-]-\|[^+]+\|[^/]/\|[:=*%&|^<>]\)\s*' +\ . '\%(if\|unless\|for\|while\|until\|loop\|switch\|' +\ . 'try\|class\)\>' + +" Combine the two above +let s:BEGIN_BLOCK = s:BEGIN_BLOCK_KEYWORD . '\|' . s:COMPOUND_EXPRESSION + +" Operators that begin a block but also count as a continuation +let s:BEGIN_BLOCK_OP = '[([{:=]$' + +" Begins a function block +let s:FUNCTION = '[-=]>$' + +" Operators that continue a line onto the next line +let s:CONTINUATION_OP = '\C\%(\<\%(is\|isnt\|and\|or\)\>\|' +\ . '[^-]-\|[^+]+\|[^-=]>\|[^.]\.\|[<*/%&|^,]\)$' + +" Ancestor operators that prevent continuation indenting +let s:CONTINUATION = s:CONTINUATION_OP . '\|' . s:BEGIN_BLOCK_OP + +" A closing bracket by itself on a line followed by a continuation +let s:BRACKET_CONTINUATION = '^\s*[}\])]\s*' . s:CONTINUATION_OP + +" A continuation dot access +let s:DOT_ACCESS = '^\.' + +" Keywords that break out of a block +let s:BREAK_BLOCK_OP = '\C^\%(return\|break\|continue\|throw\)\>' + +" A condition attached to the end of a statement +let s:POSTFIX_CONDITION = '\C\S\s\+\zs\<\%(if\|unless\|when\|while\|until\)\>' + +" A then contained in brackets +let s:CONTAINED_THEN = '\C[(\[].\{-}\.\{-\}[)\]]' + +" An else with a condition attached +let s:ELSE_COND = '\C^\s*else\s\+\<\%(if\|unless\)\>' + +" A single-line else statement (without a condition attached) +let s:SINGLE_LINE_ELSE = '\C^else\s\+\%(\<\%(if\|unless\)\>\)\@!' + +" Pairs of starting and ending keywords, with an initial pattern to match +let s:KEYWORD_PAIRS = [ +\ ['\C^else\>', '\C\<\%(if\|unless\|when\|else\s\+\%(if\|unless\)\)\>', +\ '\C\'], +\ ['\C^catch\>', '\C\', '\C\'], +\ ['\C^finally\>', '\C\', '\C\'] +\] + +" Pairs of starting and ending brackets +let s:BRACKET_PAIRS = {']': '\[', '}': '{', ')': '('} + +" Max lines to look back for a match +let s:MAX_LOOKBACK = 50 + +" Syntax names for strings +let s:SYNTAX_STRING = 'coffee\%(String\|AssignString\|Embed\|Regex\|Heregex\|' +\ . 'Heredoc\)' + +" Syntax names for comments +let s:SYNTAX_COMMENT = 'coffee\%(Comment\|BlockComment\|HeregexComment\)' + +" Syntax names for strings and comments +let s:SYNTAX_STRING_COMMENT = s:SYNTAX_STRING . '\|' . s:SYNTAX_COMMENT + +" Compatibility code for shiftwidth() as recommended by the docs, but modified +" so there isn't as much of a penalty if shiftwidth() exists. +if exists('*shiftwidth') + let s:ShiftWidth = function('shiftwidth') +else + function! s:ShiftWidth() + return &shiftwidth + endfunction +endif + +" Get the linked syntax name of a character. +function! s:SyntaxName(lnum, col) + return synIDattr(synID(a:lnum, a:col, 1), 'name') +endfunction + +" Check if a character is in a comment. +function! s:IsComment(lnum, col) + return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_COMMENT +endfunction + +" Check if a character is in a string. +function! s:IsString(lnum, col) + return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_STRING +endfunction + +" Check if a character is in a comment or string. +function! s:IsCommentOrString(lnum, col) + return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_STRING_COMMENT +endfunction + +" Search a line for a regex until one is found outside a string or comment. +function! s:SearchCode(lnum, regex) + " Start at the first column and look for an initial match (including at the + " cursor.) + call cursor(a:lnum, 1) + let pos = search(a:regex, 'c', a:lnum) + + while pos + if !s:IsCommentOrString(a:lnum, col('.')) + return 1 + endif + + " Move to the match and continue searching (don't accept matches at the + " cursor.) + let pos = search(a:regex, '', a:lnum) + endwhile + + return 0 +endfunction + +" Search for the nearest previous line that isn't a comment. +function! s:GetPrevNormalLine(startlnum) + let curlnum = a:startlnum + + while curlnum + let curlnum = prevnonblank(curlnum - 1) + + " Return the line if the first non-whitespace character isn't a comment. + if !s:IsComment(curlnum, indent(curlnum) + 1) + return curlnum + endif + endwhile + + return 0 +endfunction + +function! s:SearchPair(startlnum, lookback, skip, open, close) + " Go to the first column so a:close will be matched even if it's at the + " beginning of the line. + call cursor(a:startlnum, 1) + return searchpair(a:open, '', a:close, 'bnW', a:skip, max([1, a:lookback])) +endfunction + +" Skip if a match +" - is in a string or comment +" - is a single-line statement that isn't immediately +" adjacent +" - has a postfix condition and isn't an else statement or compound +" expression +function! s:ShouldSkip(startlnum, lnum, col) + return s:IsCommentOrString(a:lnum, a:col) || + \ s:SearchCode(a:lnum, '\C\') && a:startlnum - a:lnum > 1 || + \ s:SearchCode(a:lnum, s:POSTFIX_CONDITION) && + \ getline(a:lnum) !~ s:ELSE_COND && + \ !s:SearchCode(a:lnum, s:COMPOUND_EXPRESSION) +endfunction + +" Search for the nearest and farthest match for a keyword pair. +function! s:SearchMatchingKeyword(startlnum, open, close) + let skip = 's:ShouldSkip(' . a:startlnum . ", line('.'), line('.'))" + + " Search for the nearest match. + let nearestlnum = s:SearchPair(a:startlnum, a:startlnum - s:MAX_LOOKBACK, + \ skip, a:open, a:close) + + if !nearestlnum + return [] + endif + + " Find the nearest previous line with indent less than or equal to startlnum. + let ind = indent(a:startlnum) + let lookback = s:GetPrevNormalLine(a:startlnum) + + while lookback && indent(lookback) > ind + let lookback = s:GetPrevNormalLine(lookback) + endwhile + + " Search for the farthest match. If there are no other matches, then the + " nearest match is also the farthest one. + let matchlnum = nearestlnum + + while matchlnum + let lnum = matchlnum + let matchlnum = s:SearchPair(matchlnum, lookback, skip, a:open, a:close) + endwhile + + return [nearestlnum, lnum] +endfunction + +" Strip a line of a trailing comment and surrounding whitespace. +function! s:GetTrimmedLine(lnum) + " Try to find a comment starting at the first column. + call cursor(a:lnum, 1) + let pos = search('#', 'c', a:lnum) + + " Keep searching until a comment is found or search returns 0. + while pos + if s:IsComment(a:lnum, col('.')) + break + endif + + let pos = search('#', '', a:lnum) + endwhile + + if !pos + " No comment was found so use the whole line. + let line = getline(a:lnum) + else + " Subtract 1 to get to the column before the comment and another 1 for + " column indexing -> zero-based indexing. + let line = getline(a:lnum)[:col('.') - 2] + endif + + return substitute(substitute(line, '^\s\+', '', ''), + \ '\s\+$', '', '') +endfunction + +" Get the indent policy when no special rules are used. +function! s:GetDefaultPolicy(curlnum) + " Check whether equalprg is being ran on existing lines. + if strlen(getline(a:curlnum)) == indent(a:curlnum) + " If not indenting an existing line, use the default policy. + return s:DEFAULT_LEVEL + else + " Otherwise let autoindent determine what to do with an existing line. + return '-1' + endif +endfunction + +function! GetCoffeeIndent(curlnum) + " Get the previous non-blank line (may be a comment.) + let prevlnum = prevnonblank(a:curlnum - 1) + + " Bail if there's no code before. + if !prevlnum + return -1 + endif + + " Bail if inside a multiline string. + if s:IsString(a:curlnum, 1) + let prevnlnum = prevlnum + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + " Get the code part of the current line. + let curline = s:GetTrimmedLine(a:curlnum) + " Get the previous non-comment line. + let prevnlnum = s:GetPrevNormalLine(a:curlnum) + + " Check if the current line is the closing bracket in a bracket pair. + if has_key(s:BRACKET_PAIRS, curline[0]) + " Search for a matching opening bracket. + let matchlnum = s:SearchPair(a:curlnum, a:curlnum - s:MAX_LOOKBACK, + \ "s:IsCommentOrString(line('.'), col('.'))", + \ s:BRACKET_PAIRS[curline[0]], curline[0]) + + if matchlnum + " Match the indent of the opening bracket. + return indent(matchlnum) + else + " No opening bracket found (bad syntax), so bail. + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + + " Check if the current line is the closing keyword in a keyword pair. + for pair in s:KEYWORD_PAIRS + if curline =~ pair[0] + " Find the nearest and farthest matches within the same indent level. + let matches = s:SearchMatchingKeyword(a:curlnum, pair[1], pair[2]) + + if len(matches) + " Don't force indenting/outdenting as long as line is already lined up + " with a valid match + return max([min([indent(a:curlnum), indent(matches[0])]), + \ indent(matches[1])]) + else + " No starting keyword found (bad syntax), so bail. + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + endfor + + " Check if the current line is a `when` and not the first in a switch block. + if curline =~ '\C^when\>' && !s:SearchCode(prevnlnum, '\C\') + " Look back for a `when`. + while prevnlnum + if getline(prevnlnum) =~ '\C^\s*when\>' + " Indent to match the found `when`, but don't force indenting (for when + " indenting nested switch blocks.) + return min([indent(a:curlnum), indent(prevnlnum)]) + endif + + let prevnlnum = s:GetPrevNormalLine(prevnlnum) + endwhile + + " No matching `when` found (bad syntax), so bail. + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + " If the previous line is a comment, use its indentation, but don't force + " indenting. + if prevlnum != prevnlnum + return min([indent(a:curlnum), indent(prevlnum)]) + endif + + let prevline = s:GetTrimmedLine(prevnlnum) + + " Always indent after these operators. + if prevline =~ s:BEGIN_BLOCK_OP + return indent(prevnlnum) + s:ShiftWidth() + endif + + " Indent if the previous line starts a function block, but don't force + " indenting if the line is non-blank (for empty function bodies.) + if prevline =~ s:FUNCTION + if strlen(getline(a:curlnum)) > indent(a:curlnum) + return min([indent(prevnlnum) + s:ShiftWidth(), indent(a:curlnum)]) + else + return indent(prevnlnum) + s:ShiftWidth() + endif + endif + + " Check if continuation indenting is needed. If the line ends in a slash, make + " sure it isn't a regex. + if prevline =~ s:CONTINUATION_OP && + \ !(prevline =~ '/$' && s:IsString(prevnlnum, col([prevnlnum, '$']) - 1)) + " Don't indent if the continuation follows a closing bracket. + if prevline =~ s:BRACKET_CONTINUATION + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + let prevprevnlnum = s:GetPrevNormalLine(prevnlnum) + + " Don't indent if not the first continuation. + if prevprevnlnum && s:GetTrimmedLine(prevprevnlnum) =~ s:CONTINUATION + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + " Continuation indenting seems to vary between programmers, so if the line + " is non-blank, don't override the indentation + if strlen(getline(a:curlnum)) > indent(a:curlnum) + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + " Otherwise indent a level. + return indent(prevnlnum) + s:ShiftWidth() + endif + + " Check if the previous line starts with a keyword that begins a block. + if prevline =~ s:BEGIN_BLOCK + " Indent if the current line doesn't start with `then` and the previous line + " isn't a single-line statement. + if curline !~ '\C^\' && !s:SearchCode(prevnlnum, '\C\') && + \ prevline !~ s:SINGLE_LINE_ELSE + return indent(prevnlnum) + s:ShiftWidth() + else + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + + " Indent a dot access if it's the first. + if curline =~ s:DOT_ACCESS + if prevline !~ s:DOT_ACCESS + return indent(prevnlnum) + s:ShiftWidth() + else + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + + " Outdent if a keyword breaks out of a block as long as it doesn't have a + " postfix condition (and the postfix condition isn't a single-line statement.) + if prevline =~ s:BREAK_BLOCK_OP + if !s:SearchCode(prevnlnum, s:POSTFIX_CONDITION) || + \ s:SearchCode(prevnlnum, '\C\') && + \ !s:SearchCode(prevnlnum, s:CONTAINED_THEN) + " Don't force indenting. + return min([indent(a:curlnum), indent(prevnlnum) - s:ShiftWidth()]) + else + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + + " Check if inside brackets. + let matchlnum = s:SearchPair(a:curlnum, a:curlnum - s:MAX_LOOKBACK, + \ "s:IsCommentOrString(line('.'), col('.'))", + \ '\[\|(\|{', '\]\|)\|}') + + " If inside brackets, indent relative to the brackets, but don't outdent an + " already indented line. + if matchlnum + return max([indent(a:curlnum), indent(matchlnum) + s:ShiftWidth()]) + endif + + " No special rules applied, so use the default policy. + exec 'return' s:GetDefaultPolicy(a:curlnum) +endfunction diff --git a/sources_non_forked/vim-coffee-script/indent/litcoffee.vim b/sources_non_forked/vim-coffee-script/indent/litcoffee.vim new file mode 100644 index 00000000..599cbea8 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/indent/litcoffee.vim @@ -0,0 +1,22 @@ +if exists('b:did_indent') + finish +endif + +runtime! indent/coffee.vim + +let b:did_indent = 1 + +setlocal indentexpr=GetLitCoffeeIndent() + +if exists('*GetLitCoffeeIndent') + finish +endif + +function GetLitCoffeeIndent() + if searchpair('^ \|\t', '', '$', 'bWnm') > 0 + return GetCoffeeIndent(v:lnum) + else + return -1 + endif +endfunc + diff --git a/sources_non_forked/vim-coffee-script/syntax/coffee.vim b/sources_non_forked/vim-coffee-script/syntax/coffee.vim new file mode 100644 index 00000000..bd8de587 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/syntax/coffee.vim @@ -0,0 +1,221 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +" Bail if our syntax is already loaded. +if exists('b:current_syntax') && b:current_syntax == 'coffee' + finish +endif + +" Include JavaScript for coffeeEmbed. +syn include @coffeeJS syntax/javascript.vim +silent! unlet b:current_syntax + +" Highlight long strings. +syntax sync fromstart + +" These are `matches` instead of `keywords` because vim's highlighting +" priority for keywords is higher than matches. This causes keywords to be +" highlighted inside matches, even if a match says it shouldn't contain them -- +" like with coffeeAssign and coffeeDot. +syn match coffeeStatement /\<\%(return\|break\|continue\|throw\)\>/ display +hi def link coffeeStatement Statement + +syn match coffeeRepeat /\<\%(for\|while\|until\|loop\)\>/ display +hi def link coffeeRepeat Repeat + +syn match coffeeConditional /\<\%(if\|else\|unless\|switch\|when\|then\)\>/ +\ display +hi def link coffeeConditional Conditional + +syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display +hi def link coffeeException Exception + +syn match coffeeKeyword /\<\%(new\|in\|of\|from\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\|default\|await\)\>/ +\ display +" The `own` keyword is only a keyword after `for`. +syn match coffeeKeyword /\/ contained containedin=coffeeRepeat +\ display +hi def link coffeeKeyword Keyword + +syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display +hi def link coffeeOperator Operator + +" The first case matches symbol operators only if they have an operand before. +syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.]\{-1,}\|[-=]>\|--\|++\|:/ +\ display +syn match coffeeExtendedOp /\<\%(and\|or\)=/ display +hi def link coffeeExtendedOp coffeeOperator + +" This is separate from `coffeeExtendedOp` to help differentiate commas from +" dots. +syn match coffeeSpecialOp /[,;]/ display +hi def link coffeeSpecialOp SpecialChar + +syn match coffeeBoolean /\<\%(true\|on\|yes\|false\|off\|no\)\>/ display +hi def link coffeeBoolean Boolean + +syn match coffeeGlobal /\<\%(null\|undefined\)\>/ display +hi def link coffeeGlobal Type + +" A special variable +syn match coffeeSpecialVar /\<\%(this\|prototype\|arguments\)\>/ display +hi def link coffeeSpecialVar Special + +" An @-variable +syn match coffeeSpecialIdent /@\%(\%(\I\|\$\)\%(\i\|\$\)*\)\?/ display +hi def link coffeeSpecialIdent Identifier + +" A class-like name that starts with a capital letter +syn match coffeeObject /\<\u\w*\>/ display +hi def link coffeeObject Structure + +" A constant-like name in SCREAMING_CAPS +syn match coffeeConstant /\<\u[A-Z0-9_]\+\>/ display +hi def link coffeeConstant Constant + +" A variable name +syn cluster coffeeIdentifier contains=coffeeSpecialVar,coffeeSpecialIdent, +\ coffeeObject,coffeeConstant + +" A non-interpolated string +syn cluster coffeeBasicString contains=@Spell,coffeeEscape +" An interpolated string +syn cluster coffeeInterpString contains=@coffeeBasicString,coffeeInterp + +" Regular strings +syn region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/ +\ contains=@coffeeInterpString +syn region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/ +\ contains=@coffeeBasicString +hi def link coffeeString String + +" A integer, including a leading plus or minus +syn match coffeeNumber /\%(\i\|\$\)\@/ display +syn match coffeeNumber /\<0[bB][01]\+\>/ display +syn match coffeeNumber /\<0[oO][0-7]\+\>/ display +syn match coffeeNumber /\<\%(Infinity\|NaN\)\>/ display +hi def link coffeeNumber Number + +" A floating-point number, including a leading plus or minus +syn match coffeeFloat /\%(\i\|\$\)\@/ +\ display +hi def link coffeeReservedError Error + +" A normal object assignment +syn match coffeeObjAssign /@\?\%(\I\|\$\)\%(\i\|\$\)*\s*\ze::\@!/ contains=@coffeeIdentifier display +hi def link coffeeObjAssign Identifier + +syn keyword coffeeTodo TODO FIXME XXX contained +hi def link coffeeTodo Todo + +syn match coffeeComment /#.*/ contains=@Spell,coffeeTodo +hi def link coffeeComment Comment + +syn region coffeeBlockComment start=/####\@!/ end=/###/ +\ contains=@Spell,coffeeTodo +hi def link coffeeBlockComment coffeeComment + +" A comment in a heregex +syn region coffeeHeregexComment start=/#/ end=/\ze\/\/\/\|$/ contained +\ contains=@Spell,coffeeTodo +hi def link coffeeHeregexComment coffeeComment + +" Embedded JavaScript +syn region coffeeEmbed matchgroup=coffeeEmbedDelim +\ start=/`/ skip=/\\\\\|\\`/ end=/`/ keepend +\ contains=@coffeeJS +hi def link coffeeEmbedDelim Delimiter + +syn region coffeeInterp matchgroup=coffeeInterpDelim start=/#{/ end=/}/ contained +\ contains=@coffeeAll +hi def link coffeeInterpDelim PreProc + +" A string escape sequence +syn match coffeeEscape /\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\./ contained display +hi def link coffeeEscape SpecialChar + +" A regex -- must not follow a parenthesis, number, or identifier, and must not +" be followed by a number +syn region coffeeRegex start=#\%(\%()\|\%(\i\|\$\)\@ +" URL: https://github.com/mintplant/vim-literate-coffeescript +" License: MIT + +if exists('b:current_syntax') && b:current_syntax == 'litcoffee' + finish +endif + +syn include @markdown syntax/markdown.vim +syn include @coffee syntax/coffee.vim + +" Partition the file into notCoffee and inlineCoffee. Each line will match +" exactly one of these regions. notCoffee matches with a zero-width +" look-behind. +syn region notCoffee start='^\%( \|\t\)\@> #{ == { { { } } } == } << " +" >> #{ == { abc: { def: 42 } } == } << " diff --git a/sources_non_forked/vim-coffee-script/test/test-ops.coffee b/sources_non_forked/vim-coffee-script/test/test-ops.coffee new file mode 100644 index 00000000..54be8dba --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test-ops.coffee @@ -0,0 +1,90 @@ +# Various operators +abc instanceof def +typeof abc +delete abc +abc::def + +abc + def +abc - def +abc * def +abc / def +abc % def +abc & def +abc | def +abc ^ def +abc >> def +abc << def +abc >>> def +abc ? def +abc && def +abc and def +abc || def +abc or def + +abc += def +abc -= def +abc *= def +abc /= def +abc %= def +abc &= def +abc |= def +abc ^= def +abc >>= def +abc <<= def +abc >>>= def +abc ?= def +abc &&= def +abc ||= def + +abc and= def +abc or= def + +abc.def.ghi +abc?.def?.ghi + +abc < def +abc > def +abc = def +abc == def +abc != def +abc <= def +abc >= def + +abc++ +abc-- +++abc +--abc + +# Nested operators +abc[def] = ghi +abc[def[ghi: jkl]] = 42 +@abc[def] = ghi + +abc["#{def = 42}"] = 42 +abc["#{def.ghi = 42}"] = 42 +abc["#{def[ghi] = 42}"] = 42 +abc["#{def['ghi']}"] = 42 + +# Object assignments +abc = + def: 123 + DEF: 123 + @def: 123 + Def: 123 + 'def': 123 + 42: 123 + +# Operators shouldn't be highlighted +vector= +wand= + +abc+++ +abc--- +abc ** def +abc &&& def +abc ^^ def +abc ===== def +abc <==== def +abc >==== def +abc +== def +abc =^= def diff --git a/sources_non_forked/vim-coffee-script/test/test-reserved.coffee b/sources_non_forked/vim-coffee-script/test/test-reserved.coffee new file mode 100644 index 00000000..b841760c --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test-reserved.coffee @@ -0,0 +1,27 @@ +# Should be an error +function = 42 +var = 42 + +# Shouldn't be an error +abc.with = 42 +function: 42 +var: 42 + +# Keywords shouldn't be highlighted +abc.function +abc.do +abc.break +abc.true + +abc::function +abc::do +abc::break +abc::true + +abc:: function +abc. function + +# Numbers should be highlighted +def.42 +def .42 +def::42 diff --git a/sources_non_forked/vim-coffee-script/test/test.coffee.md b/sources_non_forked/vim-coffee-script/test/test.coffee.md new file mode 100644 index 00000000..62b99b7d --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test.coffee.md @@ -0,0 +1,117 @@ +The **Scope** class regulates lexical scoping within CoffeeScript. As you +generate code, you create a tree of scopes in the same shape as the nested +function bodies. Each scope knows about the variables declared within it, +and has a reference to its parent enclosing scope. In this way, we know which +variables are new and need to be declared with `var`, and which are shared +with external scopes. + +Import the helpers we plan to use. + + {extend, last} = require './helpers' + + exports.Scope = class Scope + +The `root` is the top-level **Scope** object for a given file. + + @root: null + +Initialize a scope with its parent, for lookups up the chain, +as well as a reference to the **Block** node it belongs to, which is +where it should declare its variables, and a reference to the function that +it belongs to. + + constructor: (@parent, @expressions, @method) -> + @variables = [{name: 'arguments', type: 'arguments'}] + @positions = {} + Scope.root = this unless @parent + +Adds a new variable or overrides an existing one. + + add: (name, type, immediate) -> + return @parent.add name, type, immediate if @shared and not immediate + if Object::hasOwnProperty.call @positions, name + @variables[@positions[name]].type = type + else + @positions[name] = @variables.push({name, type}) - 1 + +When `super` is called, we need to find the name of the current method we're +in, so that we know how to invoke the same method of the parent class. This +can get complicated if super is being called from an inner function. +`namedMethod` will walk up the scope tree until it either finds the first +function object that has a name filled in, or bottoms out. + + namedMethod: -> + return @method if @method.name or !@parent + @parent.namedMethod() + +Look up a variable name in lexical scope, and declare it if it does not +already exist. + + find: (name) -> + return yes if @check name + @add name, 'var' + no + +Reserve a variable name as originating from a function parameter for this +scope. No `var` required for internal references. + + parameter: (name) -> + return if @shared and @parent.check name, yes + @add name, 'param' + +Just check to see if a variable has already been declared, without reserving, +walks up to the root scope. + + check: (name) -> + !!(@type(name) or @parent?.check(name)) + +Generate a temporary variable name at the given index. + + temporary: (name, index) -> + if name.length > 1 + '_' + name + if index > 1 then index - 1 else '' + else + '_' + (index + parseInt name, 36).toString(36).replace /\d/g, 'a' + +Gets the type of a variable. + + type: (name) -> + return v.type for v in @variables when v.name is name + null + +If we need to store an intermediate result, find an available name for a +compiler-generated variable. `_var`, `_var2`, and so on... + + freeVariable: (name, reserve=true) -> + index = 0 + index++ while @check((temp = @temporary name, index)) + @add temp, 'var', yes if reserve + temp + +Ensure that an assignment is made at the top of this scope +(or at the top-level scope, if requested). + + assign: (name, value) -> + @add name, {value, assigned: yes}, yes + @hasAssignments = yes + +Does this scope have any declared variables? + + hasDeclarations: -> + !!@declaredVariables().length + +Return the list of variables first declared in this scope. + + declaredVariables: -> + realVars = [] + tempVars = [] + for v in @variables when v.type is 'var' + (if v.name.charAt(0) is '_' then tempVars else realVars).push v.name + realVars.sort().concat tempVars.sort() + +Return the list of assignments that are supposed to be made at the top +of this scope. + + assignedVariables: -> + "#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned + diff --git a/sources_non_forked/vim-coffee-script/test/test.haml b/sources_non_forked/vim-coffee-script/test/test.haml new file mode 100644 index 00000000..ae19fba5 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test.haml @@ -0,0 +1,3 @@ +:coffeescript + class Hello + # test diff --git a/sources_non_forked/vim-coffee-script/test/test.html b/sources_non_forked/vim-coffee-script/test/test.html new file mode 100644 index 00000000..0da7b62d --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test.html @@ -0,0 +1,17 @@ + + + + + diff --git a/sources_non_forked/vim-coffee-script/test/test.litcoffee b/sources_non_forked/vim-coffee-script/test/test.litcoffee new file mode 100644 index 00000000..62b99b7d --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test.litcoffee @@ -0,0 +1,117 @@ +The **Scope** class regulates lexical scoping within CoffeeScript. As you +generate code, you create a tree of scopes in the same shape as the nested +function bodies. Each scope knows about the variables declared within it, +and has a reference to its parent enclosing scope. In this way, we know which +variables are new and need to be declared with `var`, and which are shared +with external scopes. + +Import the helpers we plan to use. + + {extend, last} = require './helpers' + + exports.Scope = class Scope + +The `root` is the top-level **Scope** object for a given file. + + @root: null + +Initialize a scope with its parent, for lookups up the chain, +as well as a reference to the **Block** node it belongs to, which is +where it should declare its variables, and a reference to the function that +it belongs to. + + constructor: (@parent, @expressions, @method) -> + @variables = [{name: 'arguments', type: 'arguments'}] + @positions = {} + Scope.root = this unless @parent + +Adds a new variable or overrides an existing one. + + add: (name, type, immediate) -> + return @parent.add name, type, immediate if @shared and not immediate + if Object::hasOwnProperty.call @positions, name + @variables[@positions[name]].type = type + else + @positions[name] = @variables.push({name, type}) - 1 + +When `super` is called, we need to find the name of the current method we're +in, so that we know how to invoke the same method of the parent class. This +can get complicated if super is being called from an inner function. +`namedMethod` will walk up the scope tree until it either finds the first +function object that has a name filled in, or bottoms out. + + namedMethod: -> + return @method if @method.name or !@parent + @parent.namedMethod() + +Look up a variable name in lexical scope, and declare it if it does not +already exist. + + find: (name) -> + return yes if @check name + @add name, 'var' + no + +Reserve a variable name as originating from a function parameter for this +scope. No `var` required for internal references. + + parameter: (name) -> + return if @shared and @parent.check name, yes + @add name, 'param' + +Just check to see if a variable has already been declared, without reserving, +walks up to the root scope. + + check: (name) -> + !!(@type(name) or @parent?.check(name)) + +Generate a temporary variable name at the given index. + + temporary: (name, index) -> + if name.length > 1 + '_' + name + if index > 1 then index - 1 else '' + else + '_' + (index + parseInt name, 36).toString(36).replace /\d/g, 'a' + +Gets the type of a variable. + + type: (name) -> + return v.type for v in @variables when v.name is name + null + +If we need to store an intermediate result, find an available name for a +compiler-generated variable. `_var`, `_var2`, and so on... + + freeVariable: (name, reserve=true) -> + index = 0 + index++ while @check((temp = @temporary name, index)) + @add temp, 'var', yes if reserve + temp + +Ensure that an assignment is made at the top of this scope +(or at the top-level scope, if requested). + + assign: (name, value) -> + @add name, {value, assigned: yes}, yes + @hasAssignments = yes + +Does this scope have any declared variables? + + hasDeclarations: -> + !!@declaredVariables().length + +Return the list of variables first declared in this scope. + + declaredVariables: -> + realVars = [] + tempVars = [] + for v in @variables when v.type is 'var' + (if v.name.charAt(0) is '_' then tempVars else realVars).push v.name + realVars.sort().concat tempVars.sort() + +Return the list of assignments that are supposed to be made at the top +of this scope. + + assignedVariables: -> + "#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned + diff --git a/sources_non_forked/vim-colors-solarized/README.mkd b/sources_non_forked/vim-colors-solarized/README.mkd new file mode 100644 index 00000000..a163b029 --- /dev/null +++ b/sources_non_forked/vim-colors-solarized/README.mkd @@ -0,0 +1,267 @@ +--- +Title: Solarized Colorscheme for Vim +Description: Precision colors for machines and people +Author: Ethan Schoonover +Colors: light yellow +Created: 2011 Mar 15 +Modified: 2011 Apr 16 + +--- + +Solarized Colorscheme for Vim +============================= + +Developed by Ethan Schoonover + +Visit the [Solarized homepage] +------------------------------ + +See the [Solarized homepage] for screenshots, +details and colorscheme versions for Vim, Mutt, popular terminal emulators and +other applications. + +Screenshots +----------- + +![solarized dark](https://github.com/altercation/solarized/raw/master/img/solarized-vim.png) + +Downloads +--------- + +If you have come across this colorscheme via the [Vim-only repository] on +github, or the [vim.org script] page see the link above to the Solarized +homepage or visit the main [Solarized repository]. + +The [Vim-only repository] is kept in sync with the main [Solarized repository] +and is for installation convenience only (with [Pathogen] or [Vundle], for +instance). Issues, bug reports, changelogs are centralized at the main +[Solarized repository]. + +[Solarized homepage]: http://ethanschoonover.com/solarized +[Solarized repository]: https://github.com/altercation/solarized +[Vim-only repository]: https://github.com/altercation/vim-colors-solarized +[vimorg-script]: http://vim.org/script +[Pathogen]: https://github.com/tpope/vim-pathogen +[Vundle]: https://github.com/gmarik/vundle + +Installation +------------ + +### Option 1: Manual installation + +1. Move `solarized.vim` to your `.vim/colors` directory. After downloading the + vim script or package: + + $ cd vim-colors-solarized/colors + $ mv solarized.vim ~/.vim/colors/ + +### Option 2: Pathogen installation ***(recommended)*** + +1. Download and install Tim Pope's [Pathogen]. + +2. Next, move or clone the `vim-colors-solarized` directory so that it is + a subdirectory of the `.vim/bundle` directory. + + a. **Clone:** + + $ cd ~/.vim/bundle + $ git clone git://github.com/altercation/vim-colors-solarized.git + + b. **Move:** + + In the parent directory of vim-colors-solarized: + + $ mv vim-colors-solarized ~/.vim/bundle/ + +### Modify .vimrc + +After either Option 1 or Option 2 above, put the following two lines in your +.vimrc: + + syntax enable + set background=dark + colorscheme solarized + +or, for the light background mode of Solarized: + + syntax enable + set background=light + colorscheme solarized + +I like to have a different background in GUI and terminal modes, so I can use +the following if-then. However, I find vim's background autodetection to be +pretty good and, at least with MacVim, I can leave this background value +assignment out entirely and get the same results. + + if has('gui_running') + set background=light + else + set background=dark + endif + +See the [Solarized homepage] for screenshots which will help you +select either the light or dark background. + +### IMPORTANT NOTE FOR TERMINAL USERS: + +If you are going to use Solarized in Terminal mode (i.e. not in a GUI version +like gvim or macvim), **please please please** consider setting your terminal +emulator's colorscheme to used the Solarized palette. I've included palettes +for some popular terminal emulator as well as Xdefaults in the official +Solarized download available from [Solarized homepage]. If you use +Solarized *without* these colors, Solarized will need to be told to degrade its +colorscheme to a set compatible with the limited 256 terminal palette (whereas +by using the terminal's 16 ansi color values, you can set the correct, specific +values for the Solarized palette). + +If you do use the custom terminal colors, solarized.vim should work out of the +box for you. If you are using a terminal emulator that supports 256 colors and +don't want to use the custom Solarized terminal colors, you will need to use +the degraded 256 colorscheme. To do so, simply add the following line *before* +the `colorschem solarized` line: + + let g:solarized_termcolors=256 + +Again, I recommend just changing your terminal colors to Solarized values +either manually or via one of the many terminal schemes available for import. + +Advanced Configuration +---------------------- + +Solarized will work out of the box with just the two lines specified above but +does include several other options that can be set in your .vimrc file. + +Set these in your vimrc file prior to calling the colorscheme. +" + option name default optional + ------------------------------------------------ + g:solarized_termcolors= 16 | 256 + g:solarized_termtrans = 0 | 1 + g:solarized_degrade = 0 | 1 + g:solarized_bold = 1 | 0 + g:solarized_underline = 1 | 0 + g:solarized_italic = 1 | 0 + g:solarized_contrast = "normal"| "high" or "low" + g:solarized_visibility= "normal"| "high" or "low" + ------------------------------------------------ + +### Option Details + +* g:solarized_termcolors + + This is set to *16* by default, meaning that Solarized will attempt to use + the standard 16 colors of your terminal emulator. You will need to set + those colors to the correct Solarized values either manually or by + importing one of the many colorscheme available for popular terminal + emulators and Xdefaults. + +* g:solarized_termtrans + + If you use a terminal emulator with a transparent background and Solarized + isn't displaying the background color transparently, set this to 1 and + Solarized will use the default (transparent) background of the terminal + emulator. *urxvt* required this in my testing; iTerm2 did not. + + Note that on Mac OS X Terminal.app, solarized_termtrans is set to 1 by + default as this is almost always the best option. The only exception to + this is if the working terminfo file supports 256 colors (xterm-256color). + +* g:solarized_degrade + + For test purposes only; forces Solarized to use the 256 degraded color mode + to test the approximate color values for accuracy. + +* g:solarized_bold | g:solarized_underline | g:solarized_italic + + If you wish to stop Solarized from displaying bold, underlined or + italicized typefaces, simply assign a zero value to the appropriate + variable, for example: `let g:solarized_italic=0` + +* g:solarized_contrast + + Stick with normal! It's been carefully tested. Setting this option to high + or low does use the same Solarized palette but simply shifts some values up + or down in order to expand or compress the tonal range displayed. + +* g:solarized_visibility + + Special characters such as trailing whitespace, tabs, newlines, when + displayed using `:set list` can be set to one of three levels depending on + your needs. Default value is `normal` with `high` and `low` options. + +Toggle Background Function +-------------------------- + +Solarized comes with a Toggle Background plugin that by default will map to + if that mapping is available. If it is not available you will need to +either map the function manually or change your current mapping to +something else. + +To set your own mapping in your .vimrc file, simply add the following line to +support normal, insert and visual mode usage, changing the "" value to the +key or key combination you wish to use: + + call togglebg#map("") + +Note that you'll want to use a single function key or equivalent if you want +the plugin to work in all modes (normal, insert, visual). + +Code Notes +---------- + +Use folding to view the `solarized.vim` script with `foldmethod=marker` turned +on. + +I have attempted to modularize the creation of Vim colorschemes in this script +and, while it could be refactored further, it should be a good foundation for +the creation of any color scheme. By simply changing the sixteen values in the +GUI section and testing in gvim (or mvim) you can rapidly prototype new +colorschemes without diving into the weeds of line-item editing each syntax +highlight declaration. + +The Values +---------- + +L\*a\*b values are canonical (White D65, Reference D50), other values are +matched in sRGB space. + + SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B sRGB HSB + --------- ------- ---- ------- ----------- ---------- ----------- ----------- + base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21 + base02 #073642 0/4 black 235 #262626 20 -12 -12 7 54 66 192 90 26 + base01 #586e75 10/7 brgreen 240 #4e4e4e 45 -07 -07 88 110 117 194 25 46 + base00 #657b83 11/7 bryellow 241 #585858 50 -07 -07 101 123 131 195 23 51 + base0 #839496 12/6 brblue 244 #808080 60 -06 -03 131 148 150 186 13 59 + base1 #93a1a1 14/4 brcyan 245 #8a8a8a 65 -05 -02 147 161 161 180 9 63 + base2 #eee8d5 7/7 white 254 #d7d7af 92 -00 10 238 232 213 44 11 93 + base3 #fdf6e3 15/7 brwhite 230 #ffffd7 97 00 10 253 246 227 44 10 99 + yellow #b58900 3/3 yellow 136 #af8700 60 10 65 181 137 0 45 100 71 + orange #cb4b16 9/3 brred 166 #d75f00 50 50 55 203 75 22 18 89 80 + red #dc322f 1/1 red 160 #d70000 50 65 45 220 50 47 1 79 86 + magenta #d33682 5/5 magenta 125 #af005f 50 65 -05 211 54 130 331 74 83 + violet #6c71c4 13/5 brmagenta 61 #5f5faf 50 15 -45 108 113 196 237 45 77 + blue #268bd2 4/4 blue 33 #0087ff 55 -10 -45 38 139 210 205 82 82 + cyan #2aa198 6/6 cyan 37 #00afaf 60 -35 -05 42 161 152 175 74 63 + green #859900 2/2 green 64 #5f8700 60 -20 65 133 153 0 68 100 60 + +License +------- +Copyright (c) 2011 Ethan Schoonover + +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/vim-colors-solarized/autoload/togglebg.vim b/sources_non_forked/vim-colors-solarized/autoload/togglebg.vim new file mode 100644 index 00000000..108511fe --- /dev/null +++ b/sources_non_forked/vim-colors-solarized/autoload/togglebg.vim @@ -0,0 +1,55 @@ +" Toggle Background +" Modified: 2011 Apr 29 +" Maintainer: Ethan Schoonover +" License: OSI approved MIT license + +if exists("g:loaded_togglebg") + finish +endif +let g:loaded_togglebg = 1 + +" noremap is a bit misleading here if you are unused to vim mapping. +" in fact, there is remapping, but only of script locally defined remaps, in +" this case TogBG. The +endsnippet + +snippet scriptsrc "HTML +endsnippet + +snippet select "Select Box" w + +endsnippet + +snippet small "" w +$1 +endsnippet + +snippet span "" w +${0:${VISUAL}} +endsnippet + +snippet span# " with ID & class" w +${0:${VISUAL}} +endsnippet + +snippet span. " with class" w +${0:${VISUAL}} +endsnippet + +snippet strong "" w +$1 +endsnippet + +snippet style "HTML +endsnippet + +snippet sub "" w +$1 +endsnippet + +snippet sup "" w +$1 +endsnippet + +snippet table "HTML " w +
+ ${0:${VISUAL}} +
+endsnippet + +snippet tbody "" +$1 +endsnippet + +snippet td "table cell" w +${0:${VISUAL}} +endsnippet + +snippet template "