From cf3eea13fb3eee4cade22febdddfb8e29447a5ec Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Sun, 7 Jul 2013 17:25:47 -0400 Subject: [PATCH] Bunch of changes inspired by r00k --- .gitmodules | 33 - .vim/bundle/ag | 1 - .vim/bundle/cctrlp.vim | 1 - .vim/bundle/gist-vim | 1 - .vim/bundle/vim-bundler | 1 - .vim/bundle/vim-colors-solarized | 1 - .vim/bundle/vim-colorscheme-elrodeo | 1 - .vim/bundle/vim-fugitive | 1 - .vim/bundle/vim-monokai | 1 - .vim/bundle/vim-obsession | 1 - .vim/bundle/vim-rails | 1 - .vim/bundle/webapi-vim | 1 - .zsh/lib/completion.zsh | 72 - .zsh/tools/check_for_upgrade.sh | 46 - .zsh/tools/install.sh | 39 - .zsh/tools/require_tool.sh | 161 - .zsh/tools/theme_chooser.sh | 96 - .zsh/tools/uninstall.sh | 20 - .zsh/tools/upgrade.sh | 19 - Rakefile | 42 + .gitconfig => gitconfig | 3 +- .githelpers => githelpers | 0 gitignore | 8 + .../iterm_mike.itermcolors | 0 setup_notes.txt => notes/setup.txt | 0 .pryrc => pryrc | 0 scripts/{ => ruby}/features | 0 scripts/ruby/rails/spec_helper.rb | 43 + scripts/ruby/rails/spec_helper_lite.rb | 53 + .../{ => ruby/rails}/tmux-rails-template.sh | 0 scripts/{ => ruby}/test | 0 .tmux.conf => tmux.conf | 0 vim/.netrwhist | 3 + {.vim => vim}/autoload/pathogen.vim | 0 vim/bundle/ag/.gitignore | 2 + vim/bundle/ag/README.md | 74 + vim/bundle/ag/Rakefile | 3 + vim/bundle/ag/autoload/ag.vim | 101 + vim/bundle/ag/doc/ag.txt | 80 + vim/bundle/ag/plugin/ag.vim | 9 + vim/bundle/cctrlp.vim/.gitignore | 6 + vim/bundle/cctrlp.vim/autoload/ctrlp.vim | 2110 ++++++++ .../cctrlp.vim/autoload/ctrlp/bookmarkdir.vim | 140 + .../cctrlp.vim/autoload/ctrlp/buffertag.vim | 261 + .../cctrlp.vim/autoload/ctrlp/changes.vim | 95 + vim/bundle/cctrlp.vim/autoload/ctrlp/dir.vim | 93 + vim/bundle/cctrlp.vim/autoload/ctrlp/line.vim | 62 + .../cctrlp.vim/autoload/ctrlp/mixed.vim | 83 + .../cctrlp.vim/autoload/ctrlp/mrufiles.vim | 129 + .../cctrlp.vim/autoload/ctrlp/quickfix.vim | 59 + .../cctrlp.vim/autoload/ctrlp/rtscript.vim | 59 + vim/bundle/cctrlp.vim/autoload/ctrlp/tag.vim | 125 + vim/bundle/cctrlp.vim/autoload/ctrlp/undo.vim | 154 + .../cctrlp.vim/autoload/ctrlp/utils.vim | 120 + vim/bundle/cctrlp.vim/doc/ctrlp.txt | 1395 +++++ vim/bundle/cctrlp.vim/plugin/ctrlp.vim | 69 + vim/bundle/cctrlp.vim/readme.md | 86 + vim/bundle/gist-vim/Makefile | 11 + vim/bundle/gist-vim/README.mkd | 224 + vim/bundle/gist-vim/autoload/gist.vim | 919 ++++ vim/bundle/gist-vim/doc/gist-vim.txt | 279 + vim/bundle/gist-vim/doc/tags | 9 + vim/bundle/gist-vim/gist.vim.vimup | 297 ++ vim/bundle/gist-vim/plugin/gist.vim | 16 + vim/bundle/vim-bundler/.gitignore | 1 + vim/bundle/vim-bundler/CONTRIBUTING.markdown | 2 + vim/bundle/vim-bundler/README.markdown | 55 + vim/bundle/vim-bundler/compiler/bundler.vim | 26 + vim/bundle/vim-bundler/doc/bundler.txt | 68 + vim/bundle/vim-bundler/plugin/bundler.vim | 581 +++ vim/bundle/vim-colors-solarized/README.mkd | 267 + .../autoload/togglebg.vim | 55 + .../vim-colors-solarized/bitmaps/togglebg.png | Bin 0 -> 1674 bytes .../vim-colors-solarized/colors/solarized.vim | 1117 ++++ .../vim-colors-solarized/doc/solarized.txt | 254 + vim/bundle/vim-colors-solarized/doc/tags | 27 + vim/bundle/vim-colorscheme-elrodeo/README.md | 15 + .../colors/elrodeo.vim | 63 + .../vim-colorscheme-elrodeo/screenshot.png | Bin 0 -> 76962 bytes vim/bundle/vim-fugitive/.gitignore | 1 + vim/bundle/vim-fugitive/README.markdown | 150 + vim/bundle/vim-fugitive/doc/fugitive.txt | 313 ++ vim/bundle/vim-fugitive/plugin/fugitive.vim | 2532 +++++++++ vim/bundle/vim-monokai/README.md | 7 + vim/bundle/vim-monokai/colors/Monokai.vim | 107 + vim/bundle/vim-obsession/.gitignore | 1 + .../vim-obsession/CONTRIBUTING.markdown | 1 + vim/bundle/vim-obsession/README.markdown | 47 + vim/bundle/vim-obsession/doc/obsession.txt | 27 + vim/bundle/vim-obsession/plugin/obsession.vim | 71 + vim/bundle/vim-rails/.gitignore | 3 + vim/bundle/vim-rails/CONTRIBUTING.markdown | 16 + vim/bundle/vim-rails/README.markdown | 135 + vim/bundle/vim-rails/autoload/rails.vim | 4550 +++++++++++++++++ vim/bundle/vim-rails/doc/rails.txt | 930 ++++ vim/bundle/vim-rails/plugin/rails.vim | 128 + vim/bundle/webapi-vim/.gitignore | 1 + vim/bundle/webapi-vim/Makefile | 11 + vim/bundle/webapi-vim/README | 34 + .../webapi-vim/autoload/webapi/atom.vim | 226 + .../webapi-vim/autoload/webapi/base64.vim | 140 + vim/bundle/webapi-vim/autoload/webapi/bit.vim | 56 + .../webapi-vim/autoload/webapi/feed.vim | 53 + .../webapi-vim/autoload/webapi/hmac.vim | 166 + .../webapi-vim/autoload/webapi/html.vim | 74 + .../webapi-vim/autoload/webapi/http.vim | 251 + .../webapi-vim/autoload/webapi/json.vim | 135 + .../webapi-vim/autoload/webapi/jsonrpc.vim | 73 + .../webapi-vim/autoload/webapi/metaweblog.vim | 46 + .../webapi-vim/autoload/webapi/oauth.vim | 162 + .../webapi-vim/autoload/webapi/sha1.vim | 746 +++ .../webapi-vim/autoload/webapi/soap.vim | 118 + vim/bundle/webapi-vim/autoload/webapi/ucs.vim | 56 + vim/bundle/webapi-vim/autoload/webapi/xml.vim | 320 ++ .../webapi-vim/autoload/webapi/xmlrpc.vim | 259 + vim/bundle/webapi-vim/doc/webapi-html.txt | 47 + vim/bundle/webapi-vim/doc/webapi-http.txt | 53 + vim/bundle/webapi-vim/doc/webapi-json.txt | 29 + vim/bundle/webapi-vim/doc/webapi-xml.txt | 47 + vim/bundle/webapi-vim/example/gistview.vim | 43 + vim/bundle/webapi-vim/example/google-buzz.vim | 40 + vim/bundle/webapi-vim/example/hatenadiary.vim | 27 + vim/bundle/webapi-vim/example/jugem.vim | 24 + vim/bundle/webapi-vim/example/livedoor.vim | 15 + vim/bundle/webapi-vim/example/rss.vim | 4 + vim/bundle/webapi-vim/example/twitter.vim | 29 + vim/bundle/webapi-vim/example/weather.vim | 3 + vim/bundle/webapi-vim/webapi.vim.vimup | 31 + vim/ftdetect/markdown.vim | 2 + vim/snippets/markdown.snippets | 43 + vim/syntax/markdown.vim | 110 + .vimrc => vimrc | 0 zlogin | 5 + zprofile | 1 + zsh/aliases | 125 + {.zsh => zsh}/func/prompt_grb_setup | 4 +- {.zsh => zsh}/func/prompt_wunjo_setup | 0 {.zsh => zsh}/func/zgitinit | 0 zsh/functions | 47 + zshenv | 2 + .zshrc => zshrc | 64 +- 141 files changed, 22472 insertions(+), 519 deletions(-) delete mode 100644 .gitmodules delete mode 160000 .vim/bundle/ag delete mode 160000 .vim/bundle/cctrlp.vim delete mode 160000 .vim/bundle/gist-vim delete mode 160000 .vim/bundle/vim-bundler delete mode 160000 .vim/bundle/vim-colors-solarized delete mode 160000 .vim/bundle/vim-colorscheme-elrodeo delete mode 160000 .vim/bundle/vim-fugitive delete mode 160000 .vim/bundle/vim-monokai delete mode 160000 .vim/bundle/vim-obsession delete mode 160000 .vim/bundle/vim-rails delete mode 160000 .vim/bundle/webapi-vim delete mode 100644 .zsh/lib/completion.zsh delete mode 100644 .zsh/tools/check_for_upgrade.sh delete mode 100755 .zsh/tools/install.sh delete mode 100755 .zsh/tools/require_tool.sh delete mode 100755 .zsh/tools/theme_chooser.sh delete mode 100644 .zsh/tools/uninstall.sh delete mode 100644 .zsh/tools/upgrade.sh create mode 100644 Rakefile rename .gitconfig => gitconfig (97%) rename .githelpers => githelpers (100%) create mode 100644 gitignore rename iterm_mike.itermcolors => iterm/iterm_mike.itermcolors (100%) rename setup_notes.txt => notes/setup.txt (100%) rename .pryrc => pryrc (100%) rename scripts/{ => ruby}/features (100%) create mode 100644 scripts/ruby/rails/spec_helper.rb create mode 100644 scripts/ruby/rails/spec_helper_lite.rb rename scripts/{ => ruby/rails}/tmux-rails-template.sh (100%) rename scripts/{ => ruby}/test (100%) rename .tmux.conf => tmux.conf (100%) create mode 100644 vim/.netrwhist rename {.vim => vim}/autoload/pathogen.vim (100%) create mode 100644 vim/bundle/ag/.gitignore create mode 100644 vim/bundle/ag/README.md create mode 100644 vim/bundle/ag/Rakefile create mode 100644 vim/bundle/ag/autoload/ag.vim create mode 100644 vim/bundle/ag/doc/ag.txt create mode 100644 vim/bundle/ag/plugin/ag.vim create mode 100644 vim/bundle/cctrlp.vim/.gitignore create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/bookmarkdir.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/buffertag.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/changes.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/dir.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/line.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/mixed.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/mrufiles.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/quickfix.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/rtscript.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/tag.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/undo.vim create mode 100644 vim/bundle/cctrlp.vim/autoload/ctrlp/utils.vim create mode 100644 vim/bundle/cctrlp.vim/doc/ctrlp.txt create mode 100644 vim/bundle/cctrlp.vim/plugin/ctrlp.vim create mode 100644 vim/bundle/cctrlp.vim/readme.md create mode 100644 vim/bundle/gist-vim/Makefile create mode 100644 vim/bundle/gist-vim/README.mkd create mode 100644 vim/bundle/gist-vim/autoload/gist.vim create mode 100644 vim/bundle/gist-vim/doc/gist-vim.txt create mode 100644 vim/bundle/gist-vim/doc/tags create mode 100644 vim/bundle/gist-vim/gist.vim.vimup create mode 100644 vim/bundle/gist-vim/plugin/gist.vim create mode 100644 vim/bundle/vim-bundler/.gitignore create mode 100644 vim/bundle/vim-bundler/CONTRIBUTING.markdown create mode 100644 vim/bundle/vim-bundler/README.markdown create mode 100644 vim/bundle/vim-bundler/compiler/bundler.vim create mode 100644 vim/bundle/vim-bundler/doc/bundler.txt create mode 100644 vim/bundle/vim-bundler/plugin/bundler.vim create mode 100644 vim/bundle/vim-colors-solarized/README.mkd create mode 100644 vim/bundle/vim-colors-solarized/autoload/togglebg.vim create mode 100644 vim/bundle/vim-colors-solarized/bitmaps/togglebg.png create mode 100644 vim/bundle/vim-colors-solarized/colors/solarized.vim create mode 100644 vim/bundle/vim-colors-solarized/doc/solarized.txt create mode 100644 vim/bundle/vim-colors-solarized/doc/tags create mode 100644 vim/bundle/vim-colorscheme-elrodeo/README.md create mode 100644 vim/bundle/vim-colorscheme-elrodeo/colors/elrodeo.vim create mode 100644 vim/bundle/vim-colorscheme-elrodeo/screenshot.png create mode 100644 vim/bundle/vim-fugitive/.gitignore create mode 100644 vim/bundle/vim-fugitive/README.markdown create mode 100644 vim/bundle/vim-fugitive/doc/fugitive.txt create mode 100644 vim/bundle/vim-fugitive/plugin/fugitive.vim create mode 100644 vim/bundle/vim-monokai/README.md create mode 100644 vim/bundle/vim-monokai/colors/Monokai.vim create mode 100644 vim/bundle/vim-obsession/.gitignore create mode 100644 vim/bundle/vim-obsession/CONTRIBUTING.markdown create mode 100644 vim/bundle/vim-obsession/README.markdown create mode 100644 vim/bundle/vim-obsession/doc/obsession.txt create mode 100644 vim/bundle/vim-obsession/plugin/obsession.vim create mode 100644 vim/bundle/vim-rails/.gitignore create mode 100644 vim/bundle/vim-rails/CONTRIBUTING.markdown create mode 100644 vim/bundle/vim-rails/README.markdown create mode 100644 vim/bundle/vim-rails/autoload/rails.vim create mode 100644 vim/bundle/vim-rails/doc/rails.txt create mode 100644 vim/bundle/vim-rails/plugin/rails.vim create mode 100644 vim/bundle/webapi-vim/.gitignore create mode 100644 vim/bundle/webapi-vim/Makefile create mode 100644 vim/bundle/webapi-vim/README create mode 100644 vim/bundle/webapi-vim/autoload/webapi/atom.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/base64.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/bit.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/feed.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/hmac.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/html.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/http.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/json.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/jsonrpc.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/metaweblog.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/oauth.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/sha1.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/soap.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/ucs.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/xml.vim create mode 100644 vim/bundle/webapi-vim/autoload/webapi/xmlrpc.vim create mode 100644 vim/bundle/webapi-vim/doc/webapi-html.txt create mode 100644 vim/bundle/webapi-vim/doc/webapi-http.txt create mode 100644 vim/bundle/webapi-vim/doc/webapi-json.txt create mode 100644 vim/bundle/webapi-vim/doc/webapi-xml.txt create mode 100644 vim/bundle/webapi-vim/example/gistview.vim create mode 100644 vim/bundle/webapi-vim/example/google-buzz.vim create mode 100644 vim/bundle/webapi-vim/example/hatenadiary.vim create mode 100644 vim/bundle/webapi-vim/example/jugem.vim create mode 100644 vim/bundle/webapi-vim/example/livedoor.vim create mode 100644 vim/bundle/webapi-vim/example/rss.vim create mode 100644 vim/bundle/webapi-vim/example/twitter.vim create mode 100644 vim/bundle/webapi-vim/example/weather.vim create mode 100644 vim/bundle/webapi-vim/webapi.vim.vimup create mode 100644 vim/ftdetect/markdown.vim create mode 100644 vim/snippets/markdown.snippets create mode 100644 vim/syntax/markdown.vim rename .vimrc => vimrc (100%) create mode 100644 zlogin create mode 100644 zprofile create mode 100644 zsh/aliases rename {.zsh => zsh}/func/prompt_grb_setup (98%) rename {.zsh => zsh}/func/prompt_wunjo_setup (100%) rename {.zsh => zsh}/func/zgitinit (100%) create mode 100644 zsh/functions create mode 100644 zshenv rename .zshrc => zshrc (51%) diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 467829f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,33 +0,0 @@ -[submodule ".vim/bundle/vim-fugitive"] - path = .vim/bundle/vim-fugitive - url = git://github.com/tpope/vim-fugitive.git -[submodule ".vim/bundle/vim-colors-solarized"] - path = .vim/bundle/vim-colors-solarized - url = https://github.com/altercation/vim-colors-solarized -[submodule ".vim/bundle/vim-colorscheme-elrodeo"] - path = .vim/bundle/vim-colorscheme-elrodeo - url = git://github.com/chmllr/vim-colorscheme-elrodeo.git -[submodule ".vim/bundle/cctrlp.vim"] - path = .vim/bundle/cctrlp.vim - url = https://github.com/kien/ctrlp.vim.git -[submodule ".vim/bundle/vim-monokai"] - path = .vim/bundle/vim-monokai - url = git://github.com/sickill/vim-monokai.git -[submodule ".vim/bundle/vim-obsession"] - path = .vim/bundle/vim-obsession - url = git://github.com/tpope/vim-obsession.git -[submodule ".vim/bundle/ag"] - path = .vim/bundle/ag - url = https://github.com/rking/ag.vim -[submodule ".vim/bundle/webapi-vim"] - path = .vim/bundle/webapi-vim - url = git@github.com:mattn/webapi-vim.git -[submodule ".vim/bundle/gist-vim"] - path = .vim/bundle/gist-vim - url = git@github.com:mattn/gist-vim.git -[submodule ".vim/bundle/vim-rails"] - path = .vim/bundle/vim-rails - url = git://github.com/tpope/vim-rails.git -[submodule ".vim/bundle/vim-bundler"] - path = .vim/bundle/vim-bundler - url = git://github.com/tpope/vim-bundler.git diff --git a/.vim/bundle/ag b/.vim/bundle/ag deleted file mode 160000 index f013434..0000000 --- a/.vim/bundle/ag +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f0134343434bc30a77d3ad2ca19d7e2f0a137461 diff --git a/.vim/bundle/cctrlp.vim b/.vim/bundle/cctrlp.vim deleted file mode 160000 index 7251d9d..0000000 --- a/.vim/bundle/cctrlp.vim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7251d9dce85e45b41dab00d7d7032713847ed5ea diff --git a/.vim/bundle/gist-vim b/.vim/bundle/gist-vim deleted file mode 160000 index 385140f..0000000 --- a/.vim/bundle/gist-vim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 385140f2ff6065efccf32d58e52b25ae9952c677 diff --git a/.vim/bundle/vim-bundler b/.vim/bundle/vim-bundler deleted file mode 160000 index 94fdfe4..0000000 --- a/.vim/bundle/vim-bundler +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 94fdfe47d6f9e5f6d0406e03c021c24a539c9a76 diff --git a/.vim/bundle/vim-colors-solarized b/.vim/bundle/vim-colors-solarized deleted file mode 160000 index 528a59f..0000000 --- a/.vim/bundle/vim-colors-solarized +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 528a59f26d12278698bb946f8fb82a63711eec21 diff --git a/.vim/bundle/vim-colorscheme-elrodeo b/.vim/bundle/vim-colorscheme-elrodeo deleted file mode 160000 index 01a2355..0000000 --- a/.vim/bundle/vim-colorscheme-elrodeo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 01a23559bbbb1f28ff13fa2f11dbe66c356ee8b4 diff --git a/.vim/bundle/vim-fugitive b/.vim/bundle/vim-fugitive deleted file mode 160000 index 003f38c..0000000 --- a/.vim/bundle/vim-fugitive +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 003f38c6a4d8e3d527e4e1dfeab6fdf05c8ff149 diff --git a/.vim/bundle/vim-monokai b/.vim/bundle/vim-monokai deleted file mode 160000 index 496ac90..0000000 --- a/.vim/bundle/vim-monokai +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 496ac9039f016fda75d7787a28abfba5481f7347 diff --git a/.vim/bundle/vim-obsession b/.vim/bundle/vim-obsession deleted file mode 160000 index d342229..0000000 --- a/.vim/bundle/vim-obsession +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d342229cc1fa5ed442179269b8358b4c42b52300 diff --git a/.vim/bundle/vim-rails b/.vim/bundle/vim-rails deleted file mode 160000 index 74f407e..0000000 --- a/.vim/bundle/vim-rails +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 74f407e2f8d02dc6ff39ed370a25731d723e5cef diff --git a/.vim/bundle/webapi-vim b/.vim/bundle/webapi-vim deleted file mode 160000 index 5731da5..0000000 --- a/.vim/bundle/webapi-vim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5731da5c074c1a86ed05d28f6f510347ff3f8d15 diff --git a/.zsh/lib/completion.zsh b/.zsh/lib/completion.zsh deleted file mode 100644 index f31e101..0000000 --- a/.zsh/lib/completion.zsh +++ /dev/null @@ -1,72 +0,0 @@ -# fixme - the load process here seems a bit bizarre - -unsetopt menu_complete # do not autoselect the first completion entry -unsetopt flowcontrol -setopt auto_menu # show completion menu on succesive tab press -setopt complete_in_word -setopt always_to_end - -WORDCHARS='' - -zmodload -i zsh/complist - -## case-insensitive (all),partial-word and then substring completion -if [ "x$CASE_SENSITIVE" = "xtrue" ]; then - zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - unset CASE_SENSITIVE -else - zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' -fi - -zstyle ':completion:*' list-colors '' - -# should this be in keybindings? -bindkey -M menuselect '^o' accept-and-infer-next-history - -zstyle ':completion:*:*:*:*:*' menu select -zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" - -# disable named-directories autocompletion -zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories -cdpath=(.) - -# use /etc/hosts and known_hosts for hostname completion -[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$( ~/.zsh-update -} - -function _upgrade_zsh() { - /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh - # update the zsh file - _update_zsh_update -} - -if [ -f ~/.zsh-update ] -then - . ~/.zsh-update - - if [[ -z "$LAST_EPOCH" ]]; then - _update_zsh_update && return 0; - fi - - epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt 13 ] - then - if [ "$DISABLE_UPDATE_PROMPT" = "true" ] - then - _upgrade_zsh - else - echo "[Oh My Zsh] Would you like to check for updates?" - echo "Type Y to update oh-my-zsh: \c" - read line - if [ "$line" = Y ] || [ "$line" = y ]; then - _upgrade_zsh - else - _update_zsh_update - fi - fi - fi -else - # create the zsh file - _update_zsh_update -fi - diff --git a/.zsh/tools/install.sh b/.zsh/tools/install.sh deleted file mode 100755 index b080be3..0000000 --- a/.zsh/tools/install.sh +++ /dev/null @@ -1,39 +0,0 @@ -if [ -d ~/.oh-my-zsh ] -then - echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove ~/.oh-my-zsh if you want to install" - exit -fi - -echo "\033[0;34mCloning Oh My Zsh...\033[0m" -hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh || { - echo "git not installed" - exit -} - -echo "\033[0;34mLooking for an existing zsh config...\033[0m" -if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] -then - echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m"; - cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh; - rm ~/.zshrc; -fi - -echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" -cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc - -echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" -echo "export PATH=$PATH" >> ~/.zshrc - -echo "\033[0;34mTime to change your default shell to zsh!\033[0m" -chsh -s `which zsh` - -echo "\033[0;32m"' __ __ '"\033[0m" -echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" -echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" -echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" -echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" -echo "\033[0;32m"' /____/ '"\033[0m" - -echo "\n\n \033[0;32m....is now installed.\033[0m" -/usr/bin/env zsh -source ~/.zshrc diff --git a/.zsh/tools/require_tool.sh b/.zsh/tools/require_tool.sh deleted file mode 100755 index 1fa77f7..0000000 --- a/.zsh/tools/require_tool.sh +++ /dev/null @@ -1,161 +0,0 @@ -__require_tool_version_compare () -{ - ( - # Locally ignore failures, otherwise we'll exit whenever $1 and $2 - # are not equal! - set +e - -awk_strverscmp=' - # Use only awk features that work with 7th edition Unix awk (1978). - # My, what an old awk you have, Mr. Solaris! - END { - while (length(v1) || length(v2)) { - # Set d1 to be the next thing to compare from v1, and likewise for d2. - # Normally this is a single character, but if v1 and v2 contain digits, - # compare them as integers and fractions as strverscmp does. - if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) { - # Split v1 and v2 into their leading digit string components d1 and d2, - # and advance v1 and v2 past the leading digit strings. - for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue - for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue - d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1) - d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1) - if (d1 ~ /^0/) { - if (d2 ~ /^0/) { - # Compare two fractions. - while (d1 ~ /^0/ && d2 ~ /^0/) { - d1 = substr(d1, 2); len1-- - d2 = substr(d2, 2); len2-- - } - if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) { - # The two components differ in length, and the common prefix - # contains only leading zeros. Consider the longer to be less. - d1 = -len1 - d2 = -len2 - } else { - # Otherwise, compare as strings. - d1 = "x" d1 - d2 = "x" d2 - } - } else { - # A fraction is less than an integer. - exit 1 - } - } else { - if (d2 ~ /^0/) { - # An integer is greater than a fraction. - exit 2 - } else { - # Compare two integers. - d1 += 0 - d2 += 0 - } - } - } else { - # The normal case, without worrying about digits. - if (v1 == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 = substr(v1,2) } - if (v2 == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 = substr(v2,2) } - } - if (d1 < d2) exit 1 - if (d1 > d2) exit 2 - } - } -' - awk "$awk_strverscmp" v1="$1" v2="$2" /dev/null - case $? in - 1) echo '<';; - 0) echo '=';; - 2) echo '>';; - esac - ) -} - - -__require_tool_fatal () -{ - echo $@ >/dev/stderr - return 1 -} - -# Usage: require_tool program version -# Returns: 0 if $1 version if greater equals than $2, 1 otherwise. -# In case of error, message is written on error output. -# -# Example: require_tool gcc 4.6 -# Use GCC environment variable if defined instead of lookup for the tool -# in the environment. -require_tool () -{ - envvar_name=$(echo $1 | tr '[:lower:]' '[:upper:]') - tool=$(printenv $envvar_name || echo $1) - local version=$($tool --version 2>/dev/null| \ - sed -n 's/.*[^0-9.]\([0-9]*\.[0-9.]*\).*/\1/p;q') - if test x"$version" = x ; then - echo "$tool is required" >/dev/stderr - return 1 - fi - case $(__require_tool_version_compare "$2" "$version") in - '>') - echo "$1 $2 or better is required: this is $tool $version" >/dev/stderr - return 1 - ;; - esac -} - -usage() { - cat < /dev/null ; then - echo "Already in favlist" - else - echo $THEME_NAME >> $FAVLIST - echo "Saved to favlist" - fi - -} - -function theme_chooser() { - for THEME in $(ls $THEMES_DIR); do - echo - theme_preview $THEME - echo - if [[ -z $1 ]]; then - noyes "Do you want to add it to your favourite list ($FAVLIST)?" || \ - insert_favlist $THEME_NAME - echo - fi - done -} - -while getopts ":lhs" Option -do - case $Option in - l ) list_themes ;; - s ) theme_chooser 0 ;; - h ) usage ;; - * ) usage ;; # Default. - esac -done - -if [[ -z $Option ]]; then - if [[ -z $1 ]]; then - banner - echo - theme_chooser - else - theme_preview $1".zsh-theme" - fi -fi diff --git a/.zsh/tools/uninstall.sh b/.zsh/tools/uninstall.sh deleted file mode 100644 index 8ff5833..0000000 --- a/.zsh/tools/uninstall.sh +++ /dev/null @@ -1,20 +0,0 @@ -echo "Removing ~/.oh-my-zsh" -if [[ -d ~/.oh-my-zsh ]] -then - rm -rf ~/.oh-my-zsh -fi - -echo "Looking for an existing zsh config..." -if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ] -then - echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh"; - rm ~/.zshrc; - cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc; - source ~/.zshrc; -else - echo "Switching back to bash" - chsh -s /bin/bash - source /etc/profile -fi - -echo "Thanks for trying out Oh My Zsh. It's been uninstalled." \ No newline at end of file diff --git a/.zsh/tools/upgrade.sh b/.zsh/tools/upgrade.sh deleted file mode 100644 index b2a1c06..0000000 --- a/.zsh/tools/upgrade.sh +++ /dev/null @@ -1,19 +0,0 @@ -current_path=`pwd` -printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh" -cd $ZSH - -if git pull origin master -then - printf '\033[0;32m%s\033[0m\n' ' __ __ ' - printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' - printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' - printf '\033[0;32m%s\033[0m\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' - printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' - printf '\033[0;32m%s\033[0m\n' ' /____/ ' - printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.' - printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest, be sure to follow Oh My Zsh on twitter: ' 'http://twitter.com/ohmyzsh' -else - printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' -fi - -cd "$current_path" \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..3fdba4b --- /dev/null +++ b/Rakefile @@ -0,0 +1,42 @@ +require 'rake' + +desc "install the dot files into user's home directory" +task :install do + replace_all = false + Dir['*'].each do |file| + next if %w[Rakefile README notes fonts iterm id_dsa.pub .git .gitignore].include? file + + if File.exist?(File.join(ENV['HOME'], ".#{file}")) + if replace_all + replace_file(file) + else + print "overwrite ~/.#{file}? [ynaq] " + case $stdin.gets.chomp + when 'a' + replace_all = true + replace_file(file) + when 'y' + replace_file(file) + when 'q' + exit + else + puts "skipping ~/.#{file}" + end + end + else + link_file(file) + end + end + + system %Q{mkdir ~/.tmp} +end + +def replace_file(file) + system %Q{rm "$HOME/.#{file}"} + link_file(file) +end + +def link_file(file) + puts "linking ~/.#{file}" + system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"} +end diff --git a/.gitconfig b/gitconfig similarity index 97% rename from .gitconfig rename to gitconfig index c37bd7b..b23c8fe 100644 --- a/.gitconfig +++ b/gitconfig @@ -40,7 +40,7 @@ sp = stash pop sd = stash drop sa = stash apply - st = status -s -b + st = status ci = commit cp = cherry-pick co = checkout @@ -57,6 +57,7 @@ ff = merge --ff-only pff = pull --ff-only noff = merge --no-ff + theirs = merge -Xtheirs la = !git ll --all ll = "!source ~/.githelpers && pretty_git_log" div = divergence diff --git a/.githelpers b/githelpers similarity index 100% rename from .githelpers rename to githelpers diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..3e7e6b1 --- /dev/null +++ b/gitignore @@ -0,0 +1,8 @@ +.DS_Store +.svn +*~ +tags +log/ +db/*.sqlite3 +.netrwhist +project-notes.txt diff --git a/iterm_mike.itermcolors b/iterm/iterm_mike.itermcolors similarity index 100% rename from iterm_mike.itermcolors rename to iterm/iterm_mike.itermcolors diff --git a/setup_notes.txt b/notes/setup.txt similarity index 100% rename from setup_notes.txt rename to notes/setup.txt diff --git a/.pryrc b/pryrc similarity index 100% rename from .pryrc rename to pryrc diff --git a/scripts/features b/scripts/ruby/features similarity index 100% rename from scripts/features rename to scripts/ruby/features diff --git a/scripts/ruby/rails/spec_helper.rb b/scripts/ruby/rails/spec_helper.rb new file mode 100644 index 0000000..c601023 --- /dev/null +++ b/scripts/ruby/rails/spec_helper.rb @@ -0,0 +1,43 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'rspec/autorun' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +RSpec.configure do |config| + # ## Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + #config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = "random" + + config.before(:each) do + clean_mongodb + Resque.reset! + end + + def clean_mongodb + Mongoid::Sessions.default.collections.select {|c| c.name !~ /system/}.each {|c| c.find.remove_all} + end + + # TODO add additional functionality defined in test_helper as it is needed. e.g. + # factory_girl +end + diff --git a/scripts/ruby/rails/spec_helper_lite.rb b/scripts/ruby/rails/spec_helper_lite.rb new file mode 100644 index 0000000..d52134a --- /dev/null +++ b/scripts/ruby/rails/spec_helper_lite.rb @@ -0,0 +1,53 @@ +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +$LOAD_PATH.unshift(File.dirname(__FILE__)) + +require 'rspec' +require 'mongoid' +require 'pry' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +require 'support/mongoid' + +# NOTE: make sure to change this for other projects +Mongoid::Config.connect_to('campusperks_test') + +RSpec.configure do |config| + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = "random" + + config.before(:each) do + clean_mongodb + end + + def clean_mongodb + Mongoid::Sessions.default.collections.select {|c| c.name !~ /system/}.each {|c| c.find.remove_all} + end +end + +# Stubs out a module so that Rails doesn't have to be loaded when testing classes that +# make use of Rails functionality in production. +# +# An example usage: +# +# require_relative '../spec_helper_lite' +# stub_module 'ActiveModel::Conversion' +# stub_module 'ActiveModel::Naming' +# +# describe Post do +# ... +# end +# +def stub_module(full_name) + full_name.to_s.split(/::/).reduce(Object) do|context, name| + begin + context.const_get(name) + rescue NameError + context.const_set(name, Module.new) + end + end +end + diff --git a/scripts/tmux-rails-template.sh b/scripts/ruby/rails/tmux-rails-template.sh similarity index 100% rename from scripts/tmux-rails-template.sh rename to scripts/ruby/rails/tmux-rails-template.sh diff --git a/scripts/test b/scripts/ruby/test similarity index 100% rename from scripts/test rename to scripts/ruby/test diff --git a/.tmux.conf b/tmux.conf similarity index 100% rename from .tmux.conf rename to tmux.conf diff --git a/vim/.netrwhist b/vim/.netrwhist new file mode 100644 index 0000000..122c18d --- /dev/null +++ b/vim/.netrwhist @@ -0,0 +1,3 @@ +let g:netrw_dirhistmax =10 +let g:netrw_dirhist_cnt =1 +let g:netrw_dirhist_1='/Users/sauron/code/projects/dotfiles/zsh/func' diff --git a/.vim/autoload/pathogen.vim b/vim/autoload/pathogen.vim similarity index 100% rename from .vim/autoload/pathogen.vim rename to vim/autoload/pathogen.vim diff --git a/vim/bundle/ag/.gitignore b/vim/bundle/ag/.gitignore new file mode 100644 index 0000000..e350ecc --- /dev/null +++ b/vim/bundle/ag/.gitignore @@ -0,0 +1,2 @@ +tags +ag-vim.tgz diff --git a/vim/bundle/ag/README.md b/vim/bundle/ag/README.md new file mode 100644 index 0000000..f4ee2c6 --- /dev/null +++ b/vim/bundle/ag/README.md @@ -0,0 +1,74 @@ +# ag.vim # + +This plugin is a front for ag, A.K.A. +[the_silver_searcher](https://github.com/ggreer/the_silver_searcher). Ag can +be used as a replacement for 153% of the uses of `ack`. This plugin will allow +you to run ag from vim, and shows the results in a split window. + +## Installation ## + +### The Silver Searcher + +You have to first install [ag](https://github.com/ggreer/the_silver_searcher), itself. On Mac+Homebrew, Gentoo Linux, several others, there's package named `the_silver_searcher`, but if your OS/distro don't have one, the GitHub repo installs fine: + +```sh +git clone https://github.com/ggreer/the_silver_searcher ag && cd ag && ./build.sh && sudo make install +``` + +* Then, if you're using [pathogen](https://github.com/tpope/vim-pathogen): + +```sh +cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && vim +HelpTags +``` + +* Or, if you're using [Vundle](https://github.com/gmarik/vundle): + +```sh +echo "Bundle 'rking/ag.vim'" >> ~/.vimrc && vim +BundleInstall +``` + +### Configuation + +You can specify a custom ag name and path in your .vimrc like so: + + let g:agprg=" --column" + +## Usage ## + + :Ag [options] {pattern} [{directory}] + +Search recursively in {directory} (which defaults to the current directory) for the {pattern}. + +Files containing the search term will be listed in the split window, along with +the line number of the occurrence, once for each occurrence. [Enter] on a line +in this window will open the file, and place the cursor on the matching line. + +Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ag`, `:AgAdd`, `:LAg`, and `:LAgAdd` respectively. (See `doc/ag.txt`, or install and `:h Ag` for more information.) + +### Gotchas ### + +Some characters have special meaning, and need to be escaped your search pattern. For instance, '#'. You have to escape it like this `:Ag '\\\#define foo'` to search for `#define foo`. (From [blueyed in issue #5](https://github.com/mileszs/ack.vim/issues/5).) + +Sometimes `git grep` is even faster, though in my experience it's not noticably so. + +### Keyboard Shortcuts ### + +In the quickfix window, you can use: + + o to open (same as enter) + go to preview file (open but maintain focus on ag.vim results) + t to open in new tab + T to open in new tab silently + h to open in horizontal split + H to open in horizontal split silently + v to open in vertical split + gv to open in vertical split silently + q to close the quickfix window + +### Acknowledgements + +This Vim plugin is derived (and by derived, I mean copied, almost entirely) +from [milesz's ack.vim](https://github.com/mileszs/ack.vim), which I also +recommend installing since you might be in a situation where you have ack but +not ag, and don't want to stop to install ag. Also, ack supports `--type`, and +a few other features. diff --git a/vim/bundle/ag/Rakefile b/vim/bundle/ag/Rakefile new file mode 100644 index 0000000..e6bb6da --- /dev/null +++ b/vim/bundle/ag/Rakefile @@ -0,0 +1,3 @@ +task :tgz do + sh 'cd ..; tar czvf ag/ag-vim.tgz ag/{plugin,autoload,doc}' +end diff --git a/vim/bundle/ag/autoload/ag.vim b/vim/bundle/ag/autoload/ag.vim new file mode 100644 index 0000000..686d598 --- /dev/null +++ b/vim/bundle/ag/autoload/ag.vim @@ -0,0 +1,101 @@ +" NOTE: You must, of course, install ag / the_silver_searcher + +" Location of the ag utility +if !exists("g:agprg") + let g:agprg="ag --column" +endif + +if !exists("g:ag_apply_qmappings") + let g:ag_apply_qmappings = !exists("g:ag_qhandler") +endif + +if !exists("g:ag_apply_lmappings") + let g:ag_apply_lmappings = !exists("g:ag_lhandler") +endif + +if !exists("g:ag_qhandler") + let g:ag_qhandler="botright copen" +endif + +if !exists("g:ag_lhandler") + let g:ag_lhandler="botright lopen" +endif + +function! ag#Ag(cmd, args) + " If no pattern is provided, search for the word under the cursor + if empty(a:args) + let l:grepargs = expand("") + else + let l:grepargs = a:args . join(a:000, ' ') + end + + " Format, used to manage column jump + if a:cmd =~# '-g$' + let g:agformat="%f" + else + let g:agformat="%f:%l:%c:%m" + end + + let grepprg_bak=&grepprg + let grepformat_bak=&grepformat + try + let &grepprg=g:agprg + let &grepformat=g:agformat + silent execute a:cmd . " " . escape(l:grepargs, '|') + finally + let &grepprg=grepprg_bak + let &grepformat=grepformat_bak + endtry + + if a:cmd =~# '^l' + exe g:ag_lhandler + let l:apply_mappings = g:ag_apply_lmappings + else + exe g:ag_qhandler + let l:apply_mappings = g:ag_apply_qmappings + endif + + " If highlighting is on, highlight the search keyword. + if exists("g:aghighlight") + let @/=a:args + set hlsearch + end + + redraw! + + if l:apply_mappings + exec "nnoremap q :ccl" + exec "nnoremap t T" + exec "nnoremap T TgT" + exec "nnoremap o " + exec "nnoremap go " + exec "nnoremap h K" + exec "nnoremap H Kb" + exec "nnoremap v HbJt" + exec "nnoremap gv HbJ" + echom "ag.vim keys: q=quit /t/h/v=enter/tab/split/vsplit go/T/H/gv=preview versions of same" + endif +endfunction + +function! ag#AgFromSearch(cmd, args) + let search = getreg('/') + " translate vim regular expression to perl regular expression. + let search = substitute(search,'\(\\<\|\\>\)','\\b','g') + call ag#Ag(a:cmd, '"' . search .'" '. a:args) +endfunction + +function! ag#GetDocLocations() + let dp = '' + for p in split(&rtp,',') + let p = p.'/doc/' + if isdirectory(p) + let dp = p.'*.txt '.dp + endif + endfor + return dp +endfunction + +function! ag#AgHelp(cmd,args) + let args = a:args.' '.ag#GetDocLocations() + call ag#Ag(a:cmd,args) +endfunction diff --git a/vim/bundle/ag/doc/ag.txt b/vim/bundle/ag/doc/ag.txt new file mode 100644 index 0000000..f8c30cc --- /dev/null +++ b/vim/bundle/ag/doc/ag.txt @@ -0,0 +1,80 @@ +*ag.txt* Plugin that integrates ag with Vim + +============================================================================== +INTRODUCTION *ag* + +This plugin is a front for the_silver_searcher: ag. Ag can be used as a +replacement for ack. This plugin will allow you to run ag from vim, and +shows the results in a split window. + +:Ag[!] [options] {pattern} [{directory}] *:Ag* + + Search recursively in {directory} (which defaults to the current + directory) for the {pattern}. Behaves just like the |:grep| command, but + will open the |Quickfix| window for you. If [!] is not given the first + error is jumped to. + +:AgAdd [options] {pattern} [{directory}] *:AgAdd* + + Just like |:Ag|, but instead of making a new list, the matches are + appended to the current |quickfix| list. + +:AgFromSearch [{directory}] *:AgFromSearch* + + Just like |:Ag| but the pattern is from previous search. + +:LAg [options] {pattern} [{directory}] *:LAg* + + Just like |:Ag| but instead of the |quickfix| list, matches are placed in + the current |location-list|. + +:LAgAdd [options] {pattern} [{directory}] *:LAgAdd* + + Just like |:AgAdd| but instead of the |quickfix| list, matches are added + to the current |location-list| + +:AgFile [options] {pattern} [{directory}] *:AgFile* + + Search recursively in {directory} (which defaults to the current + directory) for filenames matching the {pattern}. Behaves just like the + |:grep| command, but will open the |Quickfix| window for you. + +:AgHelp[!] [options] {pattern} *:AgHelp* + + Search vim documentation files for the {pattern}. Behaves just like the + |:Ag| command, but searches only vim documentation .txt files + +:LAgHelp [options] {pattern} *:LAgHelp* + + Just like |:AgHelp| but instead of the |quickfix| list, matches are placed + in the current |location-list|. + +Files containing the search term will be listed in the split window, along +with the line number of the occurrence, once for each occurrence. on +a line in this window will open the file, and place the cursor on the matching +line. + +See http://betterthangrep.com/ for more information. + +============================================================================== +MAPPINGS *ag-mappings* + +The following keyboard shortcuts are available in the quickfix window: + +o open file (same as enter). + +go preview file (open but maintain focus on ag.vim results). + +t open in a new tab. + +T open in new tab silently. + +h open in horizontal split. + +H open in horizontal split silently. + +v open in vertical split. + +gv open in vertical split silently. + +q close the quickfix window. diff --git a/vim/bundle/ag/plugin/ag.vim b/vim/bundle/ag/plugin/ag.vim new file mode 100644 index 0000000..eb5bc22 --- /dev/null +++ b/vim/bundle/ag/plugin/ag.vim @@ -0,0 +1,9 @@ +" NOTE: You must, of course, install ag / the_silver_searcher +command! -bang -nargs=* -complete=file Ag call ag#Ag('grep',) +command! -bang -nargs=* -complete=file AgAdd call ag#Ag('grepadd', ) +command! -bang -nargs=* -complete=file AgFromSearch call ag#AgFromSearch('grep', ) +command! -bang -nargs=* -complete=file LAg call ag#Ag('lgrep', ) +command! -bang -nargs=* -complete=file LAgAdd call ag#Ag('lgrepadd', ) +command! -bang -nargs=* -complete=file AgFile call ag#Ag('grep -g', ) +command! -bang -nargs=* -complete=help AgHelp call ag#AgHelp('grep',) +command! -bang -nargs=* -complete=help LAgHelp call ag#AgHelp('lgrep',) diff --git a/vim/bundle/cctrlp.vim/.gitignore b/vim/bundle/cctrlp.vim/.gitignore new file mode 100644 index 0000000..06fcd83 --- /dev/null +++ b/vim/bundle/cctrlp.vim/.gitignore @@ -0,0 +1,6 @@ +*.markdown +*.zip +note.txt +tags +.hg* +tmp/* diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp.vim new file mode 100644 index 0000000..324ad3a --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp.vim @@ -0,0 +1,2110 @@ +" ============================================================================= +" File: autoload/ctrlp.vim +" Description: Fuzzy file, buffer, mru, tag, etc finder. +" Author: Kien Nguyen +" Version: 1.78 +" ============================================================================= + +" ** Static variables {{{1 +" s:ignore() {{{2 +fu! s:ignore() + let igdirs = [ + \ '\.git', + \ '\.hg', + \ '\.svn', + \ '_darcs', + \ '\.bzr', + \ '\.cdv', + \ '\~\.dep', + \ '\~\.dot', + \ '\~\.nib', + \ '\~\.plst', + \ '\.pc', + \ '_MTN', + \ 'blib', + \ 'CVS', + \ 'RCS', + \ 'SCCS', + \ '_sgbak', + \ 'autom4te\.cache', + \ 'cover_db', + \ '_build', + \ ] + let igfiles = [ + \ '\~$', + \ '#.+#$', + \ '[._].*\.swp$', + \ 'core\.\d+$', + \ '\.exe$', + \ '\.so$', + \ '\.bak$', + \ '\.png$', + \ '\.jpg$', + \ '\.gif$', + \ '\.zip$', + \ '\.rar$', + \ '\.tar\.gz$', + \ ] + retu { + \ 'dir': '\v[\/]('.join(igdirs, '|').')$', + \ 'file': '\v'.join(igfiles, '|'), + \ } +endf +" Script local vars {{{2 +let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = + \ ['g:ctrlp_', 'b:ctrlp_', { + \ 'abbrev': ['s:abbrev', {}], + \ 'arg_map': ['s:argmap', 0], + \ 'buffer_func': ['s:buffunc', {}], + \ 'by_filename': ['s:byfname', 0], + \ 'custom_ignore': ['s:usrign', s:ignore()], + \ 'default_input': ['s:deftxt', 0], + \ 'dont_split': ['s:nosplit', 'netrw'], + \ 'dotfiles': ['s:showhidden', 0], + \ 'extensions': ['s:extensions', []], + \ 'follow_symlinks': ['s:folsym', 0], + \ 'highlight_match': ['s:mathi', [1, 'CtrlPMatch']], + \ 'jump_to_buffer': ['s:jmptobuf', 'Et'], + \ 'key_loop': ['s:keyloop', 0], + \ 'lazy_update': ['s:lazy', 0], + \ 'match_func': ['s:matcher', {}], + \ 'match_window_bottom': ['s:mwbottom', 1], + \ 'match_window_reversed': ['s:mwreverse', 1], + \ 'max_depth': ['s:maxdepth', 40], + \ 'max_files': ['s:maxfiles', 10000], + \ 'max_height': ['s:mxheight', 10], + \ 'max_history': ['s:maxhst', exists('+hi') ? &hi : 20], + \ 'mruf_default_order': ['s:mrudef', 0], + \ 'open_func': ['s:openfunc', {}], + \ 'open_multi': ['s:opmul', '1v'], + \ 'open_new_file': ['s:newfop', 'v'], + \ 'prompt_mappings': ['s:urprtmaps', 0], + \ 'regexp_search': ['s:regexp', 0], + \ 'root_markers': ['s:rmarkers', []], + \ 'split_window': ['s:splitwin', 0], + \ 'status_func': ['s:status', {}], + \ 'tabpage_position': ['s:tabpage', 'ac'], + \ 'use_caching': ['s:caching', 1], + \ 'use_migemo': ['s:migemo', 0], + \ 'user_command': ['s:usrcmd', ''], + \ 'working_path_mode': ['s:pathmode', 'ra'], + \ }, { + \ 'open_multiple_files': 's:opmul', + \ 'regexp': 's:regexp', + \ 'reuse_window': 's:nosplit', + \ 'show_hidden': 's:showhidden', + \ 'switch_buffer': 's:jmptobuf', + \ }, { + \ 'root_markers': 's:rmarkers', + \ 'user_command': 's:usrcmd', + \ 'working_path_mode': 's:pathmode', + \ }] + +" Global options +let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0, + \ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'mouse': 'n', + \ 'gcr': 'a:blinkon0', 'ic': 1, 'lmap': '', 'mousef': 0, 'imd': 1 } + +" Keymaps +let [s:lcmap, s:prtmaps] = ['nn ', { + \ 'PrtBS()': ['', ''], + \ 'PrtDelete()': [''], + \ 'PrtDeleteWord()': [''], + \ 'PrtClear()': [''], + \ 'PrtSelectMove("j")': ['', ''], + \ 'PrtSelectMove("k")': ['', ''], + \ 'PrtSelectMove("t")': ['', ''], + \ 'PrtSelectMove("b")': ['', ''], + \ 'PrtSelectMove("u")': ['', ''], + \ 'PrtSelectMove("d")': ['', ''], + \ 'PrtHistory(-1)': [''], + \ 'PrtHistory(1)': [''], + \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'], + \ 'AcceptSelection("h")': ['', '', ''], + \ 'AcceptSelection("t")': [''], + \ 'AcceptSelection("v")': ['', ''], + \ 'ToggleFocus()': [''], + \ 'ToggleRegex()': [''], + \ 'ToggleByFname()': [''], + \ 'ToggleType(1)': ['', ''], + \ 'ToggleType(-1)': ['', ''], + \ 'PrtExpandDir()': [''], + \ 'PrtInsert("c")': ['', ''], + \ 'PrtInsert()': [''], + \ 'PrtCurStart()': [''], + \ 'PrtCurEnd()': [''], + \ 'PrtCurLeft()': ['', '', ''], + \ 'PrtCurRight()': ['', ''], + \ 'PrtClearCache()': [''], + \ 'PrtDeleteEnt()': [''], + \ 'CreateNewFile()': [''], + \ 'MarkToOpen()': [''], + \ 'OpenMulti()': [''], + \ 'PrtExit()': ['', '', ''], + \ }] + +if !has('gui_running') + cal add(s:prtmaps['PrtBS()'], remove(s:prtmaps['PrtCurLeft()'], 0)) +en + +let s:compare_lim = 3000 + +let s:ficounts = {} + +let s:ccex = s:pref.'clear_cache_on_exit' + +" Regexp +let s:fpats = { + \ '^\(\\|\)\|\(\\|\)$': '\\|', + \ '^\\\(zs\|ze\|<\|>\)': '^\\\(zs\|ze\|<\|>\)', + \ '^\S\*$': '\*', + \ '^\S\\?$': '\\?', + \ } + +" Keypad +let s:kprange = { + \ 'Plus': '+', + \ 'Minus': '-', + \ 'Divide': '/', + \ 'Multiply': '*', + \ 'Point': '.', + \ } + +" Highlight groups +let s:hlgrps = { + \ 'NoEntries': 'Error', + \ 'Mode1': 'Character', + \ 'Mode2': 'LineNr', + \ 'Stats': 'Function', + \ 'Match': 'Identifier', + \ 'PrtBase': 'Comment', + \ 'PrtText': 'Normal', + \ 'PrtCursor': 'Constant', + \ } +" s:opts() {{{2 +fu! s:opts(...) + unl! s:usrign s:usrcmd s:urprtmaps + for each in ['byfname', 'regexp', 'extensions'] | if exists('s:'.each) + let {each} = s:{each} + en | endfo + for [ke, va] in items(s:opts) + let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1] + endfo + unl va + for [ke, va] in items(s:new_opts) + let {va} = {exists(s:pref.ke) ? s:pref.ke : va} + endfo + unl va + for [ke, va] in items(s:lc_opts) + if exists(s:bpref.ke) + unl {va} + let {va} = {s:bpref.ke} + en + endfo + if a:0 && a:1 != {} + unl va + for [ke, va] in items(a:1) + let opke = substitute(ke, '\(\w:\)\?ctrlp_', '', '') + if has_key(s:lc_opts, opke) + let sva = s:lc_opts[opke] + unl {sva} + let {sva} = va + en + endfo + en + for each in ['byfname', 'regexp'] | if exists(each) + let s:{each} = {each} + en | endfo + if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en + let s:maxdepth = min([s:maxdepth, 100]) + let s:mxheight = max([s:mxheight, 1]) + let s:glob = s:showhidden ? '.*\|*' : '*' + let s:igntype = empty(s:usrign) ? -1 : type(s:usrign) + let s:lash = ctrlp#utils#lash() + if s:keyloop + let [s:lazy, s:glbs['imd']] = [0, 0] + en + if s:lazy + cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) }) + en + " Extensions + if !( exists('extensions') && extensions == s:extensions ) + for each in s:extensions + exe 'ru autoload/ctrlp/'.each.'.vim' + endfo + en + " Keymaps + if type(s:urprtmaps) == 4 + cal extend(s:prtmaps, s:urprtmaps) + en +endf +"}}}1 +" * Open & Close {{{1 +fu! s:Open() + cal s:log(1) + cal s:getenv() + cal s:execextvar('enter') + sil! exe 'keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP' + cal s:buffunc(1) + let [s:bufnr, s:winw] = [bufnr('%'), winwidth(0)] + let [s:focus, s:prompt] = [1, ['', '', '']] + abc + if !exists('s:hstry') + let hst = filereadable(s:gethistloc()[1]) ? s:gethistdata() : [''] + let s:hstry = empty(hst) || !s:maxhst ? [''] : hst + en + for [ke, va] in items(s:glbs) | if exists('+'.ke) + sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va) + en | endfo + if s:opmul != '0' && has('signs') + sign define ctrlpmark text=+> texthl=Search + en + cal s:setupblank() +endf + +fu! s:Close() + cal s:buffunc(0) + try | bun! + cat | clo! | endt + cal s:unmarksigns() + for key in keys(s:glbs) | if exists('+'.key) + sil! exe 'let &'.key.' = s:glb_'.key + en | endfo + if exists('s:glb_acd') | let &acd = s:glb_acd | en + let g:ctrlp_lines = [] + if s:winres[1] >= &lines && s:winres[2] == winnr('$') + exe s:winres[0].s:winres[0] + en + unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr + \ s:mrbs s:did_exp + cal ctrlp#recordhist() + cal s:execextvar('exit') + cal s:log(0) + let v:errmsg = s:ermsg + ec +endf +" * Clear caches {{{1 +fu! ctrlp#clr(...) + let [s:matches, g:ctrlp_new{ a:0 ? a:1 : 'cache' }] = [1, 1] +endf + +fu! ctrlp#clra() + let cadir = ctrlp#utils#cachedir() + if isdirectory(cadir) + let cafiles = split(s:glbpath(s:fnesc(cadir, 'g', ','), '**', 1), "\n") + let eval = '!isdirectory(v:val) && fnamemodify(v:val, ":t") !~' + \ . ' ''\v^[.a-z]+$|\.log$''' + sil! cal map(filter(cafiles, eval), 'delete(v:val)') + en + cal ctrlp#clr() +endf + +fu! s:Reset(args) + let opts = has_key(a:args, 'opts') ? [a:args['opts']] : [] + cal call('s:opts', opts) + cal s:autocmds() + cal ctrlp#utils#opts() + cal s:execextvar('opts') +endf +" * Files {{{1 +fu! ctrlp#files() + let cafile = ctrlp#utils#cachefile() + if g:ctrlp_newcache || !filereadable(cafile) || s:nocache(cafile) + let [lscmd, s:initcwd, g:ctrlp_allfiles] = [s:lsCmd(), s:dyncwd, []] + " Get the list of files + if empty(lscmd) + cal s:GlobPath(s:fnesc(s:dyncwd, 'g', ','), 0) + el + sil! cal ctrlp#progress('Indexing...') + try | cal s:UserCmd(lscmd) + cat | retu [] | endt + en + " Remove base directory + cal ctrlp#rmbasedir(g:ctrlp_allfiles) + if len(g:ctrlp_allfiles) <= s:compare_lim + cal sort(g:ctrlp_allfiles, 'ctrlp#complen') + en + cal s:writecache(cafile) + let catime = getftime(cafile) + el + let catime = getftime(cafile) + if !( exists('s:initcwd') && s:initcwd == s:dyncwd ) + \ || get(s:ficounts, s:dyncwd, [0, catime])[1] != catime + let s:initcwd = s:dyncwd + let g:ctrlp_allfiles = ctrlp#utils#readfile(cafile) + en + en + cal extend(s:ficounts, { s:dyncwd : [len(g:ctrlp_allfiles), catime] }) + retu g:ctrlp_allfiles +endf + +fu! s:GlobPath(dirs, depth) + let entries = split(globpath(a:dirs, s:glob), "\n") + let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] + cal extend(g:ctrlp_allfiles, dnf[1]) + if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth + sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1) + cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth) + en +endf + +fu! s:UserCmd(lscmd) + let [path, lscmd] = [s:dyncwd, a:lscmd] + if exists('+ssl') && &ssl + let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')] + en + if has('win32') || has('win64') + let lscmd = substitute(lscmd, '\v(^|&&\s*)\zscd (/d)@!', 'cd /d ', '') + en + let path = exists('*shellescape') ? shellescape(path) : path + let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n") + if exists('+ssl') && exists('ssl') + let &ssl = ssl + cal map(g:ctrlp_allfiles, 'tr(v:val, "\\", "/")') + en + if exists('s:vcscmd') && s:vcscmd + cal map(g:ctrlp_allfiles, 'tr(v:val, "/", "\\")') + en + if type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore'] + if !empty(s:usrign) + let g:ctrlp_allfiles = ctrlp#dirnfile(g:ctrlp_allfiles)[1] + en + if &wig != '' + cal filter(g:ctrlp_allfiles, 'glob(v:val) != ""') + en + en +endf + +fu! s:lsCmd() + let cmd = s:usrcmd + if type(cmd) == 1 + retu cmd + elsei type(cmd) == 3 && len(cmd) >= 2 && cmd[:1] != ['', ''] + if s:findroot(s:dyncwd, cmd[0], 0, 1) == [] + retu len(cmd) == 3 ? cmd[2] : '' + en + let s:vcscmd = s:lash == '\' + retu cmd[1] + elsei type(cmd) == 4 && ( has_key(cmd, 'types') || has_key(cmd, 'fallback') ) + let fndroot = [] + if has_key(cmd, 'types') && cmd['types'] != {} + let [markrs, cmdtypes] = [[], values(cmd['types'])] + for pair in cmdtypes + cal add(markrs, pair[0]) + endfo + let fndroot = s:findroot(s:dyncwd, markrs, 0, 1) + en + if fndroot == [] + retu has_key(cmd, 'fallback') ? cmd['fallback'] : '' + en + for pair in cmdtypes + if pair[0] == fndroot[0] | brea | en + endfo + let s:vcscmd = s:lash == '\' + retu pair[1] + en +endf +" - Buffers {{{1 +fu! ctrlp#buffers(...) + let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))' + \ .' && getbufvar(v:val, "&bl") && strlen(bufname(v:val))'), 's:compmreb') + retu a:0 && a:1 == 'id' ? ids : map(ids, 'fnamemodify(bufname(v:val), ":.")') +endf +" * MatchedItems() {{{1 +fu! s:MatchIt(items, pat, limit, exc) + let [lines, id] = [[], 0] + let pat = + \ s:byfname ? map(split(a:pat, '^[^;]\+\\\@= 0 + cal add(lines, item) + en | cat | brea | endt + if a:limit > 0 && len(lines) >= a:limit | brea | en + endfo + let s:mdata = [s:dyncwd, s:itemtype, s:regexp, s:sublist(a:items, id, -1)] + retu lines +endf + +fu! s:MatchedItems(items, pat, limit) + let exc = exists('s:crfilerel') ? s:crfilerel : '' + let items = s:narrowable() ? s:matched + s:mdata[3] : a:items + if s:matcher != {} + let argms = [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp] + let lines = call(s:matcher['match'], argms) + el + let lines = s:MatchIt(items, a:pat, a:limit, exc) + en + let s:matches = len(lines) + unl! s:did_exp + retu lines +endf + +fu! s:SplitPattern(str) + let str = a:str + if s:migemo && s:regexp && len(str) > 0 && executable('cmigemo') + let str = s:migemo(str) + en + let s:savestr = str + if s:regexp + let pat = s:regexfilter(str) + el + let lst = split(str, '\zs') + if exists('+ssl') && !&ssl + cal map(lst, 'escape(v:val, ''\'')') + en + for each in ['^', '$', '.'] + cal map(lst, 'escape(v:val, each)') + endfo + en + if exists('lst') + let pat = '' + if !empty(lst) + if s:byfname && index(lst, ';') > 0 + let fbar = index(lst, ';') + let lst_1 = s:sublist(lst, 0, fbar - 1) + let lst_2 = len(lst) - 1 > fbar ? s:sublist(lst, fbar + 1, -1) : [''] + let pat = s:buildpat(lst_1).';'.s:buildpat(lst_2) + el + let pat = s:buildpat(lst) + en + en + en + retu escape(pat, '~') +endf +" * BuildPrompt() {{{1 +fu! s:Render(lines, pat) + let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])] + let pat = s:byfname ? split(a:pat, '^[^;]\+\\\@' ).( s:byfname ? 'd' : '>' ).'> ' + let str = escape(s:getinput(), '\') + let lazy = str == '' || exists('s:force') || !has('autocmd') ? 0 : s:lazy + if a:upd && !lazy && ( s:matches || s:regexp || exists('s:did_exp') + \ || str =~ '\(\\\(<\|>\)\|[*|]\)\|\(\\\:\([^:]\|\\:\)*$\)' ) + sil! cal s:Update(str) + en + sil! cal ctrlp#statusline() + " Toggling + let [hiactive, hicursor, base] = s:focus + \ ? ['CtrlPPrtText', 'CtrlPPrtCursor', base] + \ : ['CtrlPPrtBase', 'CtrlPPrtBase', tr(base, '>', '-')] + let hibase = 'CtrlPPrtBase' + " Build it + redr + let prt = copy(s:prompt) + cal map(prt, 'escape(v:val, ''"\'')') + exe 'echoh' hibase '| echon "'.base.'" + \ | echoh' hiactive '| echon "'.prt[0].'" + \ | echoh' hicursor '| echon "'.prt[1].'" + \ | echoh' hiactive '| echon "'.prt[2].'" | echoh None' + " Append the cursor at the end + if empty(prt[1]) && s:focus + exe 'echoh' hibase '| echon "_" | echoh None' + en +endf +" - SetDefTxt() {{{1 +fu! s:SetDefTxt() + if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en + let txt = s:deftxt + if !type(txt) + let txt = txt && !stridx(s:crfpath, s:dyncwd) + \ ? ctrlp#rmbasedir([s:crfpath])[0] : '' + let txt = txt != '' ? txt.s:lash(s:crfpath) : '' + el + let txt = expand(txt, 1) + en + let s:prompt[0] = txt +endf +" ** Prt Actions {{{1 +" Editing {{{2 +fu! s:PrtClear() + if !s:focus | retu | en + unl! s:hstgot + let [s:prompt, s:matches] = [['', '', ''], 1] + cal s:BuildPrompt(1) +endf + +fu! s:PrtAdd(char) + unl! s:hstgot + let s:act_add = 1 + let s:prompt[0] .= a:char + cal s:BuildPrompt(1) + unl s:act_add +endf + +fu! s:PrtBS() + if !s:focus | retu | en + unl! s:hstgot + let [s:prompt[0], s:matches] = [substitute(s:prompt[0], '.$', '', ''), 1] + cal s:BuildPrompt(1) +endf + +fu! s:PrtDelete() + if !s:focus | retu | en + unl! s:hstgot + let [prt, s:matches] = [s:prompt, 1] + let prt[1] = matchstr(prt[2], '^.') + let prt[2] = substitute(prt[2], '^.', '', '') + cal s:BuildPrompt(1) +endf + +fu! s:PrtDeleteWord() + if !s:focus | retu | en + unl! s:hstgot + let [str, s:matches] = [s:prompt[0], 1] + let str = str =~ '\W\w\+$' ? matchstr(str, '^.\+\W\ze\w\+$') + \ : str =~ '\w\W\+$' ? matchstr(str, '^.\+\w\ze\W\+$') + \ : str =~ '\s\+$' ? matchstr(str, '^.*\S\ze\s\+$') + \ : str =~ '\v^(\S+|\s+)$' ? '' : str + let s:prompt[0] = str + cal s:BuildPrompt(1) +endf + +fu! s:PrtInsert(...) + if !s:focus | retu | en + let type = !a:0 ? '' : a:1 + if !a:0 + let type = s:insertstr() + if type == 'cancel' | retu | en + en + if type ==# 'r' + let regcont = s:getregs() + if regcont < 0 | retu | en + en + unl! s:hstgot + let s:act_add = 1 + let s:prompt[0] .= type ==# 'w' ? s:crword + \ : type ==# 'f' ? s:crgfile + \ : type ==# 's' ? s:regisfilter('/') + \ : type ==# 'v' ? s:crvisual + \ : type ==# 'c' ? s:regisfilter('+') + \ : type ==# 'r' ? regcont : '' + cal s:BuildPrompt(1) + unl s:act_add +endf + +fu! s:PrtExpandDir() + if !s:focus | retu | en + let str = s:getinput('c') + if str =~ '\v^\@(cd|lc[hd]?|chd)\s.+' && s:spi + let hasat = split(str, '\v^\@(cd|lc[hd]?|chd)\s*\zs') + let str = get(hasat, 1, '') + en + if str == '' | retu | en + unl! s:hstgot + let s:act_add = 1 + let [base, seed] = s:headntail(str) + let dirs = s:dircompl(base, seed) + if len(dirs) == 1 + let str = dirs[0] + elsei len(dirs) > 1 + let str .= s:findcommon(dirs, str) + en + let s:prompt[0] = exists('hasat') ? hasat[0].str : str + cal s:BuildPrompt(1) + unl s:act_add +endf +" Movement {{{2 +fu! s:PrtCurLeft() + if !s:focus | retu | en + let prt = s:prompt + if !empty(prt[0]) + let s:prompt = [substitute(prt[0], '.$', '', ''), matchstr(prt[0], '.$'), + \ prt[1] . prt[2]] + en + cal s:BuildPrompt(0) +endf + +fu! s:PrtCurRight() + if !s:focus | retu | en + let prt = s:prompt + let s:prompt = [prt[0] . prt[1], matchstr(prt[2], '^.'), + \ substitute(prt[2], '^.', '', '')] + cal s:BuildPrompt(0) +endf + +fu! s:PrtCurStart() + if !s:focus | retu | en + let str = join(s:prompt, '') + let s:prompt = ['', matchstr(str, '^.'), substitute(str, '^.', '', '')] + cal s:BuildPrompt(0) +endf + +fu! s:PrtCurEnd() + if !s:focus | retu | en + let s:prompt = [join(s:prompt, ''), '', ''] + cal s:BuildPrompt(0) +endf + +fu! s:PrtSelectMove(dir) + let wht = winheight(0) + let dirs = {'t': 'gg','b': 'G','j': 'j','k': 'k','u': wht.'k','d': wht.'j'} + exe 'keepj norm!' dirs[a:dir] + if s:nolim != 1 | let s:cline = line('.') | en + if line('$') > winheight(0) | cal s:BuildPrompt(0) | en +endf + +fu! s:PrtSelectJump(char) + let lines = copy(s:lines) + if s:byfname + cal map(lines, 'split(v:val, ''[\/]\ze[^\/]\+$'')[-1]') + en + " Cycle through matches, use s:jmpchr to store last jump + let chr = escape(matchstr(a:char, '^.'), '.~') + let smartcs = &scs && chr =~ '\u' ? '\C' : '' + if match(lines, smartcs.'^'.chr) >= 0 + " If not exists or does but not for the same char + let pos = match(lines, smartcs.'^'.chr) + if !exists('s:jmpchr') || ( exists('s:jmpchr') && s:jmpchr[0] != chr ) + let [jmpln, s:jmpchr] = [pos, [chr, pos]] + elsei exists('s:jmpchr') && s:jmpchr[0] == chr + " Start of lines + if s:jmpchr[1] == -1 | let s:jmpchr[1] = pos | en + let npos = match(lines, smartcs.'^'.chr, s:jmpchr[1] + 1) + let [jmpln, s:jmpchr] = [npos == -1 ? pos : npos, [chr, npos]] + en + exe 'keepj norm!' ( jmpln + 1 ).'G' + if s:nolim != 1 | let s:cline = line('.') | en + if line('$') > winheight(0) | cal s:BuildPrompt(0) | en + en +endf +" Misc {{{2 +fu! s:PrtFocusMap(char) + cal call(( s:focus ? 's:PrtAdd' : 's:PrtSelectJump' ), [a:char]) +endf + +fu! s:PrtClearCache() + if s:itemtype == 0 + cal ctrlp#clr() + elsei s:itemtype > 2 + cal ctrlp#clr(s:statypes[s:itemtype][1]) + en + if s:itemtype == 2 + let g:ctrlp_lines = ctrlp#mrufiles#refresh() + el + cal ctrlp#setlines() + en + let s:force = 1 + cal s:BuildPrompt(1) + unl s:force +endf + +fu! s:PrtDeleteEnt() + if s:itemtype == 2 + cal s:PrtDeleteMRU() + elsei type(s:getextvar('wipe')) == 1 + cal s:delent(s:getextvar('wipe')) + en +endf + +fu! s:PrtDeleteMRU() + if s:itemtype == 2 + cal s:delent('ctrlp#mrufiles#remove') + en +endf + +fu! s:PrtExit() + if !has('autocmd') | cal s:Close() | en + exe ( winnr('$') == 1 ? 'bw!' : 'winc p' ) +endf + +fu! s:PrtHistory(...) + if !s:focus || !s:maxhst | retu | en + let [str, hst, s:matches] = [join(s:prompt, ''), s:hstry, 1] + " Save to history if not saved before + let [hst[0], hslen] = [exists('s:hstgot') ? hst[0] : str, len(hst)] + let idx = exists('s:hisidx') ? s:hisidx + a:1 : a:1 + " Limit idx within 0 and hslen + let idx = idx < 0 ? 0 : idx >= hslen ? hslen > 1 ? hslen - 1 : 0 : idx + let s:prompt = [hst[idx], '', ''] + let [s:hisidx, s:hstgot, s:force] = [idx, 1, 1] + cal s:BuildPrompt(1) + unl s:force +endf +"}}}1 +" * Mappings {{{1 +fu! s:MapNorms() + if exists('s:nmapped') && s:nmapped == s:bufnr | retu | en + let pcmd = "nn \ \ \ :\cal \%s(\"%s\")\" + let cmd = substitute(pcmd, 'k%s', 'char-%d', '') + let pfunc = 'PrtFocusMap' + let ranges = [32, 33, 125, 126] + range(35, 91) + range(93, 123) + for each in [34, 92, 124] + exe printf(cmd, each, pfunc, escape(nr2char(each), '"|\')) + endfo + for each in ranges + exe printf(cmd, each, pfunc, nr2char(each)) + endfo + for each in range(0, 9) + exe printf(pcmd, each, pfunc, each) + endfo + for [ke, va] in items(s:kprange) + exe printf(pcmd, ke, pfunc, va) + endfo + let s:nmapped = s:bufnr +endf + +fu! s:MapSpecs() + if !( exists('s:smapped') && s:smapped == s:bufnr ) + " Correct arrow keys in terminal + if ( has('termresponse') && v:termresponse =~ "\" ) + \ || &term =~? '\vxterm|','\B ','\C ','\D '] + exe s:lcmap.' ['.each + endfo + en + en + for [ke, va] in items(s:prtmaps) | for kp in va + exe s:lcmap kp ':cal '.ke.'' + endfo | endfo + let s:smapped = s:bufnr +endf + +fu! s:KeyLoop() + wh exists('s:init') && s:keyloop + redr + let nr = getchar() + let chr = !type(nr) ? nr2char(nr) : nr + if nr >=# 0x20 + cal s:PrtFocusMap(chr) + el + let cmd = matchstr(maparg(chr), ':\zs.\+\ze$') + exe ( cmd != '' ? cmd : 'norm '.chr ) + en + endw +endf +" * Toggling {{{1 +fu! s:ToggleFocus() + let s:focus = !s:focus + cal s:BuildPrompt(0) +endf + +fu! s:ToggleRegex() + let s:regexp = !s:regexp + cal s:PrtSwitcher() +endf + +fu! s:ToggleByFname() + if s:ispath + let s:byfname = !s:byfname + let s:mfunc = s:mfunc() + cal s:PrtSwitcher() + en +endf + +fu! s:ToggleType(dir) + let max = len(g:ctrlp_ext_vars) + 2 + let next = s:walker(max, s:itemtype, a:dir) + cal ctrlp#syntax() + cal ctrlp#setlines(next) + cal s:PrtSwitcher() +endf + +fu! s:ToggleKeyLoop() + let s:keyloop = !s:keyloop + if exists('+imd') + let &imd = !s:keyloop + en + if s:keyloop + let [&ut, s:lazy] = [0, 0] + cal s:KeyLoop() + elsei has_key(s:glbs, 'ut') + let [&ut, s:lazy] = [s:glbs['ut'], 1] + en +endf + +fu! s:PrtSwitcher() + let [s:force, s:matches] = [1, 1] + cal s:BuildPrompt(1) + unl s:force +endf +" - SetWD() {{{1 +fu! s:SetWD(args) + if has_key(a:args, 'args') && stridx(a:args['args'], '--dir') >= 0 + \ && exists('s:dyncwd') + cal ctrlp#setdir(s:dyncwd) | retu + en + if has_key(a:args, 'dir') && a:args['dir'] != '' + cal ctrlp#setdir(a:args['dir']) | retu + en + let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode + let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()] + if s:crfile =~ '^.\+://' | retu | en + if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 ) + \ || ( !type(pmode) && pmode ) + if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en + cal ctrlp#setdir(s:crfpath) + en + if pmode =~ 'r' || pmode == 2 + let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] + let spath = pmode =~ 'd' ? s:dyncwd : pmode =~ 'w' ? s:cwd : s:crfpath + if type(s:rmarkers) == 3 && !empty(s:rmarkers) + if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu | en + cal filter(markers, 'index(s:rmarkers, v:val) < 0') + en + cal s:findroot(spath, markers, 0, 0) + en +endf +" * AcceptSelection() {{{1 +fu! ctrlp#acceptfile(mode, line, ...) + let [md, filpath] = [a:mode, fnamemodify(a:line, ':p')] + cal s:PrtExit() + let [bufnr, tail] = [bufnr('^'.filpath.'$'), s:tail()] + let j2l = a:0 ? a:1 : matchstr(tail, '^ +\zs\d\+$') + if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0 + \ && !( md == 'e' && bufnr == bufnr('%') ) + let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)] + let buftab = ( s:jmptobuf =~# '[tTVH]' || s:jmptobuf > 1 ) + \ ? s:buftab(bufnr, md) : [0, 0] + en + " Switch to existing buffer or open new one + if exists('jmpb') && bufwinnr > 0 + \ && !( md == 't' && ( s:jmptobuf !~# toupper(md) || buftab[0] ) ) + exe bufwinnr.'winc w' + if j2l | cal ctrlp#j2l(j2l) | en + elsei exists('jmpb') && buftab[0] + \ && !( md =~ '[evh]' && s:jmptobuf !~# toupper(md) ) + exe 'tabn' buftab[0] + exe buftab[1].'winc w' + if j2l | cal ctrlp#j2l(j2l) | en + el + " Determine the command to use + let useb = bufnr > 0 && buflisted(bufnr) && empty(tail) + let cmd = + \ md == 't' || s:splitwin == 1 ? ( useb ? 'tab sb' : 'tabe' ) : + \ md == 'h' || s:splitwin == 2 ? ( useb ? 'sb' : 'new' ) : + \ md == 'v' || s:splitwin == 3 ? ( useb ? 'vert sb' : 'vne' ) : + \ call('ctrlp#normcmd', useb ? ['b', 'bo vert sb'] : ['e']) + " Reset &switchbuf option + let [swb, &swb] = [&swb, ''] + " Open new window/buffer + let [fid, tail] = [( useb ? bufnr : filpath ), ( a:0 ? ' +'.a:1 : tail )] + let args = [cmd, fid, tail, 1, [useb, j2l]] + cal call('s:openfile', args) + let &swb = swb + en +endf + +fu! s:SpecInputs(str) + if a:str =~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*)$' && s:spi + let cwd = s:dyncwd + cal ctrlp#setdir(a:str =~ '^\.\.\.*$' ? + \ '../'.repeat('../', strlen(a:str) - 2) : a:str) + if cwd != s:dyncwd | cal ctrlp#setlines() | en + cal s:PrtClear() + retu 1 + elsei a:str == s:lash && s:spi + cal s:SetWD({ 'mode': 'rd' }) + cal ctrlp#setlines() + cal s:PrtClear() + retu 1 + elsei a:str =~ '^@.\+' && s:spi + retu s:at(a:str) + elsei a:str == '?' + cal s:PrtExit() + let hlpwin = &columns > 159 ? '| vert res 80' : '' + sil! exe 'bo vert h ctrlp-mappings' hlpwin '| norm! 0' + retu 1 + en + retu 0 +endf + +fu! s:AcceptSelection(mode) + if a:mode != 'e' && s:OpenMulti(a:mode) != -1 | retu | en + let str = s:getinput() + if a:mode == 'e' | if s:SpecInputs(str) | retu | en | en + " Get the selected line + let line = ctrlp#getcline() + if a:mode != 'e' && !s:itemtype && line == '' + \ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$' + cal s:CreateNewFile(a:mode) | retu + en + if empty(line) | retu | en + " Do something with it + if s:openfunc != {} && has_key(s:openfunc, s:ctype) + let actfunc = s:openfunc[s:ctype] + el + let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile' : s:getextvar('accept') + en + cal call(actfunc, [a:mode, line]) +endf +" - CreateNewFile() {{{1 +fu! s:CreateNewFile(...) + let [md, str] = ['', s:getinput('n')] + if empty(str) | retu | en + if s:argmap && !a:0 + " Get the extra argument + let md = s:argmaps(md, 1) + if md == 'cancel' | retu | en + en + let str = s:sanstail(str) + let [base, fname] = s:headntail(str) + if fname =~ '^[\/]$' | retu | en + if exists('s:marked') && len(s:marked) + " Use the first marked file's path + let path = fnamemodify(values(s:marked)[0], ':p:h') + let base = path.s:lash(path).base + let str = fnamemodify(base.s:lash.fname, ':.') + en + if base != '' | if isdirectory(ctrlp#utils#mkdir(base)) + let optyp = str | en | el | let optyp = fname + en + if !exists('optyp') | retu | en + let [filpath, tail] = [fnamemodify(optyp, ':p'), s:tail()] + if !stridx(filpath, s:dyncwd) | cal s:insertcache(str) | en + cal s:PrtExit() + let cmd = md == 'r' ? ctrlp#normcmd('e') : + \ s:newfop =~ '1\|t' || ( a:0 && a:1 == 't' ) || md == 't' ? 'tabe' : + \ s:newfop =~ '2\|h' || ( a:0 && a:1 == 'h' ) || md == 'h' ? 'new' : + \ s:newfop =~ '3\|v' || ( a:0 && a:1 == 'v' ) || md == 'v' ? 'vne' : + \ ctrlp#normcmd('e') + cal s:openfile(cmd, filpath, tail, 1) +endf +" * OpenMulti() {{{1 +fu! s:MarkToOpen() + if s:bufnr <= 0 || s:opmul == '0' + \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 ) + retu + en + let line = ctrlp#getcline() + if empty(line) | retu | en + let filpath = s:ispath ? fnamemodify(line, ':p') : line + if exists('s:marked') && s:dictindex(s:marked, filpath) > 0 + " Unmark and remove the file from s:marked + let key = s:dictindex(s:marked, filpath) + cal remove(s:marked, key) + if empty(s:marked) | unl s:marked | en + if has('signs') + exe 'sign unplace' key 'buffer='.s:bufnr + en + el + " Add to s:marked and place a new sign + if exists('s:marked') + let vac = s:vacantdict(s:marked) + let key = empty(vac) ? len(s:marked) + 1 : vac[0] + let s:marked = extend(s:marked, { key : filpath }) + el + let [key, s:marked] = [1, { 1 : filpath }] + en + if has('signs') + exe 'sign place' key 'line='.line('.').' name=ctrlpmark buffer='.s:bufnr + en + en + sil! cal ctrlp#statusline() +endf + +fu! s:OpenMulti(...) + let has_marked = exists('s:marked') + if ( !has_marked && a:0 ) || s:opmul == '0' || !s:ispath + \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 ) + retu -1 + en + " Get the options + let [nr, md] = [matchstr(s:opmul, '\d\+'), matchstr(s:opmul, '[thvi]')] + let [ur, jf] = [s:opmul =~ 'r', s:opmul =~ 'j'] + let md = a:0 ? a:1 : ( md == '' ? 'v' : md ) + let nopt = exists('g:ctrlp_open_multiple_files') + if !has_marked + let line = ctrlp#getcline() + if line == '' | retu | en + let marked = { 1 : fnamemodify(line, ':p') } + let [nr, ur, jf, nopt] = ['1', 0, 0, 1] + en + if ( s:argmap || !has_marked ) && !a:0 + let md = s:argmaps(md, !has_marked ? 2 : 0) + if md == 'c' + cal s:unmarksigns() + unl! s:marked + cal s:BuildPrompt(0) + elsei !has_marked && md =~ '[axd]' + retu s:OpenNoMarks(md, line) + en + if md =~ '\v^c(ancel)?$' | retu | en + let nr = nr == '0' ? ( nopt ? '' : '1' ) : nr + let ur = !has_marked && md == 'r' ? 1 : ur + en + let mkd = values(has_marked ? s:marked : marked) + cal s:sanstail(join(s:prompt, '')) + cal s:PrtExit() + if nr == '0' || md == 'i' + retu map(mkd, "s:openfile('bad', v:val, '', 0)") + en + let tail = s:tail() + let [emptytail, bufnr] = [empty(tail), bufnr('^'.mkd[0].'$')] + let useb = bufnr > 0 && buflisted(bufnr) && emptytail + " Move to a replaceable window + let ncmd = ( useb ? ['b', 'bo vert sb'] : ['e', 'bo vne'] ) + \ + ( ur ? [] : ['ignruw'] ) + let fst = call('ctrlp#normcmd', ncmd) + " Check if the current window has a replaceable buffer + let repabl = !( md == 't' && !ur ) && empty(bufname('%')) && empty(&l:ft) + " Commands for the rest of the files + let [ic, cmds] = [1, { 'v': ['vert sb', 'vne'], 'h': ['sb', 'new'], + \ 't': ['tab sb', 'tabe'] }] + let [swb, &swb] = [&swb, ''] + if md == 't' && ctrlp#tabcount() < tabpagenr() + let s:tabct = ctrlp#tabcount() + en + " Open the files + for va in mkd + let bufnr = bufnr('^'.va.'$') + if bufnr < 0 && getftype(va) == '' | con | en + let useb = bufnr > 0 && buflisted(bufnr) && emptytail + let snd = md != '' && has_key(cmds, md) ? + \ ( useb ? cmds[md][0] : cmds[md][1] ) : ( useb ? 'vert sb' : 'vne' ) + let cmd = ic == 1 && ( !( !ur && fst =~ '^[eb]$' ) || repabl ) ? fst : snd + let conds = [( nr != '' && nr > 1 && nr < ic ) || ( nr == '' && ic > 1 ), + \ nr != '' && nr < ic] + if conds[nopt] + if !buflisted(bufnr) | cal s:openfile('bad', va, '', 0) | en + el + cal s:openfile(cmd, useb ? bufnr : va, tail, ic == 1) + if jf | if ic == 1 + let crpos = [tabpagenr(), winnr()] + el + let crpos[0] += tabpagenr() <= crpos[0] + let crpos[1] += winnr() <= crpos[1] + en | en + let ic += 1 + en + endfo + if jf && exists('crpos') && ic > 2 + exe ( md == 't' ? 'tabn '.crpos[0] : crpos[1].'winc w' ) + en + let &swb = swb + unl! s:tabct +endf + +fu! s:OpenNoMarks(md, line) + if a:md == 'a' + let [s:marked, key] = [{}, 1] + for line in s:lines + let s:marked = extend(s:marked, { key : fnamemodify(line, ':p') }) + let key += 1 + endfo + cal s:remarksigns() + cal s:BuildPrompt(0) + elsei a:md == 'x' + cal call(s:openfunc[s:ctype], [a:md, a:line]) + elsei a:md == 'd' + let dir = fnamemodify(a:line, ':h') + if isdirectory(dir) + cal ctrlp#setdir(dir) + cal ctrlp#switchtype(0) + cal ctrlp#recordhist() + cal s:PrtClear() + en + en +endf +" ** Helper functions {{{1 +" Sorting {{{2 +fu! ctrlp#complen(...) + " By length + let [len1, len2] = [strlen(a:1), strlen(a:2)] + retu len1 == len2 ? 0 : len1 > len2 ? 1 : -1 +endf + +fu! s:compmatlen(...) + " By match length + let mln1 = s:shortest(s:matchlens(a:1, s:compat)) + let mln2 = s:shortest(s:matchlens(a:2, s:compat)) + retu mln1 == mln2 ? 0 : mln1 > mln2 ? 1 : -1 +endf + +fu! s:comptime(...) + " By last modified time + let [time1, time2] = [getftime(a:1), getftime(a:2)] + retu time1 == time2 ? 0 : time1 < time2 ? 1 : -1 +endf + +fu! s:compmreb(...) + " By last entered time (bufnr) + let [id1, id2] = [index(s:mrbs, a:1), index(s:mrbs, a:2)] + retu id1 == id2 ? 0 : id1 > id2 ? 1 : -1 +endf + +fu! s:compmref(...) + " By last entered time (MRU) + let [id1, id2] = [index(g:ctrlp_lines, a:1), index(g:ctrlp_lines, a:2)] + retu id1 == id2 ? 0 : id1 > id2 ? 1 : -1 +endf + +fu! s:comparent(...) + " By same parent dir + if !stridx(s:crfpath, s:dyncwd) + let [as1, as2] = [s:dyncwd.s:lash().a:1, s:dyncwd.s:lash().a:2] + let [loc1, loc2] = [s:getparent(as1), s:getparent(as2)] + if loc1 == s:crfpath && loc2 != s:crfpath | retu -1 | en + if loc2 == s:crfpath && loc1 != s:crfpath | retu 1 | en + retu 0 + en + retu 0 +endf + +fu! s:compfnlen(...) + " By filename length + let len1 = strlen(split(a:1, s:lash)[-1]) + let len2 = strlen(split(a:2, s:lash)[-1]) + retu len1 == len2 ? 0 : len1 > len2 ? 1 : -1 +endf + +fu! s:matchlens(str, pat, ...) + if empty(a:pat) || index(['^', '$'], a:pat) >= 0 | retu {} | en + let st = a:0 ? a:1 : 0 + let lens = a:0 >= 2 ? a:2 : {} + let nr = a:0 >= 3 ? a:3 : 0 + if nr > 20 | retu {} | en + if match(a:str, a:pat, st) >= 0 + let [mst, mnd] = [matchstr(a:str, a:pat, st), matchend(a:str, a:pat, st)] + let lens = extend(lens, { nr : [strlen(mst), mst] }) + let lens = s:matchlens(a:str, a:pat, mnd, lens, nr + 1) + en + retu lens +endf + +fu! s:shortest(lens) + retu min(map(values(a:lens), 'v:val[0]')) +endf + +fu! s:mixedsort(...) + let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)] + if s:ispath + let ms = [] + if s:height < 21 + let ms += [s:compfnlen(a:1, a:2)] + if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en + if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en + en + if s:itemtype =~ '^[12]$' + let ms += [s:compmref(a:1, a:2)] + let cln = cml ? cln : 0 + en + let ms += [cml, 0, 0, 0] + let mp = call('s:multipliers', ms[:3]) + retu cln + ms[0] * mp[0] + ms[1] * mp[1] + ms[2] * mp[2] + ms[3] * mp[3] + en + retu cln + cml * 2 +endf + +fu! s:multipliers(...) + let mp0 = !a:1 ? 0 : 2 + let mp1 = !a:2 ? 0 : 1 + ( !mp0 ? 1 : mp0 ) + let mp2 = !a:3 ? 0 : 1 + ( !( mp0 + mp1 ) ? 1 : ( mp0 + mp1 ) ) + let mp3 = !a:4 ? 0 : 1 + ( !( mp0 + mp1 + mp2 ) ? 1 : ( mp0 + mp1 + mp2 ) ) + retu [mp0, mp1, mp2, mp3] +endf + +fu! s:compval(...) + retu a:1 - a:2 +endf +" Statusline {{{2 +fu! ctrlp#statusline() + if !exists('s:statypes') + let s:statypes = [ + \ ['files', 'fil'], + \ ['buffers', 'buf'], + \ ['mru files', 'mru'], + \ ] + if !empty(g:ctrlp_ext_vars) + cal map(copy(g:ctrlp_ext_vars), + \ 'add(s:statypes, [ v:val["lname"], v:val["sname"] ])') + en + en + let tps = s:statypes + let max = len(tps) - 1 + let nxt = tps[s:walker(max, s:itemtype, 1)][1] + let prv = tps[s:walker(max, s:itemtype, -1)][1] + let s:ctype = tps[s:itemtype][0] + let focus = s:focus ? 'prt' : 'win' + let byfname = s:byfname ? 'file' : 'path' + let marked = s:opmul != '0' ? + \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : '' + if s:status != {} + let args = [focus, byfname, s:regexp, prv, s:ctype, nxt, marked] + let &l:stl = call(s:status['main'], args) + el + let item = '%#CtrlPMode1# '.s:ctype.' %*' + let focus = '%#CtrlPMode2# '.focus.' %*' + let byfname = '%#CtrlPMode1# '.byfname.' %*' + let regex = s:regexp ? '%#CtrlPMode2# regex %*' : '' + let slider = ' <'.prv.'>={'.item.'}=<'.nxt.'>' + let dir = ' %=%<%#CtrlPMode2# %{getcwd()} %*' + let &l:stl = focus.byfname.regex.slider.marked.dir + en +endf + +fu! s:dismrk() + retu has('signs') ? len(s:marked) : + \ '%<'.join(values(map(copy(s:marked), 'split(v:val, "[\\/]")[-1]')), ', ') +endf + +fu! ctrlp#progress(enum, ...) + if has('macunix') || has('mac') | sl 1m | en + let txt = a:0 ? '(press ctrl-c to abort)' : '' + let &l:stl = s:status != {} ? call(s:status['prog'], [a:enum]) + \ : '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*' + redraws +endf +" *** Paths {{{2 +" Line formatting {{{3 +fu! s:formatline(str) + let str = a:str + if s:itemtype == 1 + let bfnr = bufnr('^'.fnamemodify(str, ':p').'$') + let idc = ( bfnr == bufnr('#') ? '#' : '' ) + \ . ( getbufvar(bfnr, '&ma') ? '' : '-' ) + \ . ( getbufvar(bfnr, '&ro') ? '=' : '' ) + \ . ( getbufvar(bfnr, '&mod') ? '+' : '' ) + let str .= idc != '' ? ' '.idc : '' + en + let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str) + retu '> '.( cond ? s:pathshorten(str) : str ) +endf + +fu! s:pathshorten(str) + retu matchstr(a:str, '^.\{9}').'...' + \ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$') +endf +" Directory completion {{{3 +fu! s:dircompl(be, sd) + if a:sd == '' | retu [] | en + let [be, sd] = a:be == '' ? [s:dyncwd, a:sd] : [a:be, a:be.s:lash(a:be).a:sd] + let dirs = ctrlp#rmbasedir(split(globpath(s:fnesc(be, 'g', ','), a:sd.'*/'), "\n")) + cal filter(dirs, '!match(v:val, escape(sd, ''~$.\''))' + \ . ' && v:val !~ ''\v(^|[\/])\.{1,2}[\/]$''') + retu dirs +endf + +fu! s:findcommon(items, seed) + let [items, id, cmn, ic] = [copy(a:items), strlen(a:seed), '', 0] + cal map(items, 'strpart(v:val, id)') + for char in split(items[0], '\zs') + for item in items[1:] + if item[ic] != char | let brk = 1 | brea | en + endfo + if exists('brk') | brea | en + let cmn .= char + let ic += 1 + endfo + retu cmn +endf +" Misc {{{3 +fu! s:headntail(str) + let parts = split(a:str, '[\/]\ze[^\/]\+[\/:]\?$') + retu len(parts) == 1 ? ['', parts[0]] : len(parts) == 2 ? parts : [] +endf + +fu! s:lash(...) + retu ( a:0 ? a:1 : s:dyncwd ) !~ '[\/]$' ? s:lash : '' +endf + +fu! s:ispathitem() + retu s:itemtype < 3 || ( s:itemtype > 2 && s:getextvar('type') == 'path' ) +endf + +fu! ctrlp#dirnfile(entries) + let [items, cwd] = [[[], []], s:dyncwd.s:lash()] + for each in a:entries + let etype = getftype(each) + if s:igntype >= 0 && s:usrign(each, etype) | con | en + if etype == 'dir' + if s:showhidden | if each !~ '[\/]\.\{1,2}$' + cal add(items[0], each) + en | el + cal add(items[0], each) + en + elsei etype == 'link' + if s:folsym + let isfile = !isdirectory(each) + if s:folsym == 2 || !s:samerootsyml(each, isfile, cwd) + cal add(items[isfile], each) + en + en + elsei etype == 'file' + cal add(items[1], each) + en + endfo + retu items +endf + +fu! s:usrign(item, type) + retu s:igntype == 1 ? a:item =~ s:usrign + \ : s:igntype == 4 && has_key(s:usrign, a:type) && s:usrign[a:type] != '' + \ ? a:item =~ s:usrign[a:type] : 0 +endf + +fu! s:samerootsyml(each, isfile, cwd) + let resolve = fnamemodify(resolve(a:each), ':p:h') + let resolve .= s:lash(resolve) + retu !( stridx(resolve, a:cwd) && ( stridx(a:cwd, resolve) || a:isfile ) ) +endf + +fu! ctrlp#rmbasedir(items) + if a:items != [] && !stridx(a:items[0], s:dyncwd) + let idx = strlen(s:dyncwd) + ( s:dyncwd !~ '[\/]$' ) + retu map(a:items, 'strpart(v:val, idx)') + en + retu a:items +endf +" Working directory {{{3 +fu! s:getparent(item) + let parent = substitute(a:item, '[\/][^\/]\+[\/:]\?$', '', '') + if parent == '' || parent !~ '[\/]' + let parent .= s:lash + en + retu parent +endf + +fu! s:findroot(curr, mark, depth, type) + let [depth, fnd] = [a:depth + 1, 0] + if type(a:mark) == 1 + let fnd = s:glbpath(s:fnesc(a:curr, 'g', ','), a:mark, 1) != '' + elsei type(a:mark) == 3 + for markr in a:mark + if s:glbpath(s:fnesc(a:curr, 'g', ','), markr, 1) != '' + let fnd = 1 + brea + en + endfo + en + if fnd + if !a:type | cal ctrlp#setdir(a:curr) | en + retu [exists('markr') ? markr : a:mark, a:curr] + elsei depth > s:maxdepth + cal ctrlp#setdir(s:cwd) + el + let parent = s:getparent(a:curr) + if parent != a:curr + retu s:findroot(parent, a:mark, depth, a:type) + en + en + retu [] +endf + +fu! ctrlp#setdir(path, ...) + let cmd = a:0 ? a:1 : 'lc!' + sil! exe cmd s:fnesc(a:path, 'c') + let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()] +endf +" Fallbacks {{{3 +fu! s:glbpath(...) + retu call('ctrlp#utils#globpath', a:000) +endf + +fu! s:fnesc(...) + retu call('ctrlp#utils#fnesc', a:000) +endf + +fu! ctrlp#setlcdir() + if exists('*haslocaldir') + cal ctrlp#setdir(getcwd(), haslocaldir() ? 'lc!' : 'cd!') + en +endf +" Highlighting {{{2 +fu! ctrlp#syntax() + if ctrlp#nosy() | retu | en + for [ke, va] in items(s:hlgrps) | cal ctrlp#hicheck('CtrlP'.ke, va) | endfo + if !hlexists('CtrlPLinePre') + \ && synIDattr(synIDtrans(hlID('Normal')), 'bg') !~ '^-1$\|^$' + sil! exe 'hi CtrlPLinePre '.( has("gui_running") ? 'gui' : 'cterm' ).'fg=bg' + en + sy match CtrlPNoEntries '^ == NO ENTRIES ==$' + if hlexists('CtrlPLinePre') + sy match CtrlPLinePre '^>' + en +endf + +fu! s:highlight(pat, grp) + if s:matcher != {} | retu | en + cal clearmatches() + if !empty(a:pat) && s:ispath + let pat = s:regexp ? substitute(a:pat, '\\\@ \\zs', 'g') : a:pat + if s:byfname + let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g') + let pat = substitute(pat, '\$\@') + en +endf + +fu! s:dohighlight() + retu s:mathi[0] && exists('*clearmatches') && !ctrlp#nosy() +endf +" Prompt history {{{2 +fu! s:gethistloc() + let utilcadir = ctrlp#utils#cachedir() + let cache_dir = utilcadir.s:lash(utilcadir).'hist' + retu [cache_dir, cache_dir.s:lash(cache_dir).'cache.txt'] +endf + +fu! s:gethistdata() + retu ctrlp#utils#readfile(s:gethistloc()[1]) +endf + +fu! ctrlp#recordhist() + let str = join(s:prompt, '') + if empty(str) || !s:maxhst | retu | en + let hst = s:hstry + if len(hst) > 1 && hst[1] == str | retu | en + cal extend(hst, [str], 1) + if len(hst) > s:maxhst | cal remove(hst, s:maxhst, -1) | en + cal ctrlp#utils#writecache(hst, s:gethistloc()[0], s:gethistloc()[1]) +endf +" Signs {{{2 +fu! s:unmarksigns() + if !s:dosigns() | retu | en + for key in keys(s:marked) + exe 'sign unplace' key 'buffer='.s:bufnr + endfo +endf + +fu! s:remarksigns() + if !s:dosigns() | retu | en + for ic in range(1, len(s:lines)) + let line = s:ispath ? fnamemodify(s:lines[ic - 1], ':p') : s:lines[ic - 1] + let key = s:dictindex(s:marked, line) + if key > 0 + exe 'sign place' key 'line='.ic.' name=ctrlpmark buffer='.s:bufnr + en + endfo +endf + +fu! s:dosigns() + retu exists('s:marked') && s:bufnr > 0 && s:opmul != '0' && has('signs') +endf +" Lists & Dictionaries {{{2 +fu! s:dictindex(dict, expr) + for key in keys(a:dict) + if a:dict[key] == a:expr | retu key | en + endfo + retu -1 +endf + +fu! s:vacantdict(dict) + retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)') +endf + +fu! s:sublist(l, s, e) + retu v:version > 701 ? a:l[(a:s):(a:e)] : s:sublist7071(a:l, a:s, a:e) +endf + +fu! s:sublist7071(l, s, e) + let [newlist, id, ae] = [[], a:s, a:e == -1 ? len(a:l) - 1 : a:e] + wh id <= ae + cal add(newlist, get(a:l, id)) + let id += 1 + endw + retu newlist +endf +" Buffers {{{2 +fu! s:buftab(bufnr, md) + for tabnr in range(1, tabpagenr('$')) + if tabpagenr() == tabnr && a:md == 't' | con | en + let buflist = tabpagebuflist(tabnr) + if index(buflist, a:bufnr) >= 0 + for winnr in range(1, tabpagewinnr(tabnr, '$')) + if buflist[winnr - 1] == a:bufnr | retu [tabnr, winnr] | en + endfo + en + endfo + retu [0, 0] +endf + +fu! s:bufwins(bufnr) + let winns = 0 + for tabnr in range(1, tabpagenr('$')) + let winns += count(tabpagebuflist(tabnr), a:bufnr) + endfo + retu winns +endf + +fu! ctrlp#normcmd(cmd, ...) + if a:0 < 2 && s:nosplit() | retu a:cmd | en + let norwins = filter(range(1, winnr('$')), + \ 'empty(getbufvar(winbufnr(v:val), "&bt"))') + for each in norwins + let bufnr = winbufnr(each) + if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft')) + let fstemp = each | brea + en + endfo + let norwin = empty(norwins) ? 0 : norwins[0] + if norwin + if index(norwins, winnr()) < 0 + exe ( exists('fstemp') ? fstemp : norwin ).'winc w' + en + retu a:cmd + en + retu a:0 ? a:1 : 'bo vne' +endf + +fu! ctrlp#modfilecond(w) + retu &mod && !&hid && &bh != 'hide' && s:bufwins(bufnr('%')) == 1 && !&cf && + \ ( ( !&awa && a:w ) || filewritable(fnamemodify(bufname('%'), ':p')) != 1 ) +endf + +fu! s:nosplit() + retu !empty(s:nosplit) && match([bufname('%'), &l:ft, &l:bt], s:nosplit) >= 0 +endf + +fu! s:setupblank() + setl noswf nonu nobl nowrap nolist nospell nocuc wfh + setl fdc=0 fdl=99 tw=0 bt=nofile bh=unload + if v:version > 702 + setl nornu noudf cc=0 + en +endf + +fu! s:leavepre() + if exists('s:bufnr') && s:bufnr == bufnr('%') | bw! | en + if !( exists(s:ccex) && !{s:ccex} ) + \ && !( has('clientserver') && len(split(serverlist(), "\n")) > 1 ) + cal ctrlp#clra() + en +endf + +fu! s:checkbuf() + if !exists('s:init') && exists('s:bufnr') && s:bufnr > 0 + exe s:bufnr.'bw!' + en +endf + +fu! s:iscmdwin() + let ermsg = v:errmsg + sil! noa winc p + sil! noa winc p + let [v:errmsg, ermsg] = [ermsg, v:errmsg] + retu ermsg =~ '^E11:' +endf +" Arguments {{{2 +fu! s:at(str) + if a:str =~ '\v^\@(cd|lc[hd]?|chd).*' + let str = substitute(a:str, '\v^\@(cd|lc[hd]?|chd)\s*', '', '') + if str == '' | retu 1 | en + let str = str =~ '^%:.\+' ? fnamemodify(s:crfile, str[1:]) : str + let path = fnamemodify(expand(str, 1), ':p') + if isdirectory(path) + if path != s:dyncwd + cal ctrlp#setdir(path) + cal ctrlp#setlines() + en + cal ctrlp#recordhist() + cal s:PrtClear() + en + retu 1 + en + retu 0 +endf + +fu! s:tail() + if exists('s:optail') && !empty('s:optail') + let tailpref = s:optail !~ '^\s*+' ? ' +' : ' ' + retu tailpref.s:optail + en + retu '' +endf + +fu! s:sanstail(str) + let str = s:spi ? + \ substitute(a:str, '^\(@.*$\|\\\\\ze@\|\.\.\zs[.\/]\+$\)', '', 'g') : a:str + let [str, pat] = [substitute(str, '\\\\', '\', 'g'), '\([^:]\|\\:\)*$'] + unl! s:optail + if str =~ '\\\@= 0 + retu char + elsei char =~# "\\v\|\|\|\|\|\" + cal s:BuildPrompt(0) + retu 'cancel' + elsei char =~# "\" && a:args != [] + retu a:args[0] + en + retu call(a:func, a:args) +endf + +fu! s:getregs() + let char = s:textdialog('Insert from register: ') + if char =~# "\\v\|\|\|\|\|\" + cal s:BuildPrompt(0) + retu -1 + elsei char =~# "\" + retu s:getregs() + en + retu s:regisfilter(char) +endf + +fu! s:regisfilter(reg) + retu substitute(getreg(a:reg), "[\t\n]", ' ', 'g') +endf +" Misc {{{2 +fu! s:modevar() + let s:matchtype = s:mtype() + let s:ispath = s:ispathitem() + if !s:ispath | let s:byfname = 0 | en + let s:mfunc = s:mfunc() + let s:nolim = s:getextvar('nolim') + let s:dosort = s:getextvar('sort') + let s:spi = !s:itemtype || s:getextvar('specinput') > 0 +endf + +fu! s:nosort() + retu s:matcher != {} || s:nolim == 1 || ( s:itemtype == 2 && s:mrudef ) + \ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort +endf + +fu! s:narrowable() + retu exists('s:act_add') && exists('s:matched') && s:matched != [] + \ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp] + \ && s:matcher == {} && !exists('s:did_exp') +endf + +fu! s:getinput(...) + let [prt, spi] = [s:prompt, ( a:0 ? a:1 : '' )] + if s:abbrev != {} + let gmd = has_key(s:abbrev, 'gmode') ? s:abbrev['gmode'] : '' + let str = ( gmd =~ 't' && !a:0 ) || spi == 'c' ? prt[0] : join(prt, '') + if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k' + retu join(prt, '') + en + let [pf, rz] = [( s:byfname ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )] + for dict in s:abbrev['abbrevs'] + let dmd = has_key(dict, 'mode') ? dict['mode'] : '' + let pat = escape(dict['pattern'], '~') + if ( dmd == '' || ( dmd =~ pf && dmd =~ rz && !a:0 ) + \ || dmd =~ '['.spi.']' ) && str =~ pat + let [str, s:did_exp] = [join(split(str, pat, 1), dict['expanded']), 1] + en + endfo + if gmd =~ 't' && !a:0 + let prt[0] = str + el + retu str + en + en + retu spi == 'c' ? prt[0] : join(prt, '') +endf + +fu! s:migemo(str) + let [str, rtp] = [a:str, s:fnesc(&rtp, 'g')] + let dict = s:glbpath(rtp, printf("dict/%s/migemo-dict", &enc), 1) + if !len(dict) + let dict = s:glbpath(rtp, "dict/migemo-dict", 1) + en + if len(dict) + let [tokens, str, cmd] = [split(str, '\s'), '', 'cmigemo -v -w %s -d %s'] + for token in tokens + let rtn = system(printf(cmd, shellescape(token), shellescape(dict))) + let str .= !v:shell_error && strlen(rtn) > 0 ? '.*'.rtn : token + endfo + en + retu str +endf + +fu! s:strwidth(str) + retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str) +endf + +fu! ctrlp#j2l(nr) + exe 'norm!' a:nr.'G' + sil! norm! zvzz +endf + +fu! s:maxf(len) + retu s:maxfiles && a:len > s:maxfiles +endf + +fu! s:regexfilter(str) + let str = a:str + for key in keys(s:fpats) | if str =~ key + let str = substitute(str, s:fpats[key], '', 'g') + en | endfo + retu str +endf + +fu! s:walker(m, p, d) + retu a:d >= 0 ? a:p < a:m ? a:p + a:d : 0 : a:p > 0 ? a:p + a:d : a:m +endf + +fu! s:delent(rfunc) + if a:rfunc == '' | retu | en + let [s:force, tbrem] = [1, []] + if exists('s:marked') + let tbrem = values(s:marked) + cal s:unmarksigns() + unl s:marked + en + if tbrem == [] && ( has('dialog_gui') || has('dialog_con') ) && + \ confirm("Wipe all entries?", "&OK\n&Cancel") != 1 + unl s:force + cal s:BuildPrompt(0) + retu + en + let g:ctrlp_lines = call(a:rfunc, [tbrem]) + cal s:BuildPrompt(1) + unl s:force +endf +" Entering & Exiting {{{2 +fu! s:getenv() + let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]] + let [s:crfile, s:crfpath] = [expand('%:p', 1), expand('%:p:h', 1)] + let [s:crword, s:crline] = [expand('', 1), getline('.')] + let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')] + let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()] + let [s:mrbs, s:crgfile] = [ctrlp#mrufiles#bufs(), expand('', 1)] +endf + +fu! s:lastvisual() + let cview = winsaveview() + let [ovreg, ovtype] = [getreg('v'), getregtype('v')] + let [oureg, outype] = [getreg('"'), getregtype('"')] + sil! norm! gv"vy + let selected = s:regisfilter('v') + cal setreg('v', ovreg, ovtype) + cal setreg('"', oureg, outype) + cal winrestview(cview) + retu selected +endf + +fu! s:log(m) + if exists('g:ctrlp_log') && g:ctrlp_log | if a:m + let cadir = ctrlp#utils#cachedir() + sil! exe 'redi! >' cadir.s:lash(cadir).'ctrlp.log' + el + sil! redi END + en | en +endf + +fu! s:buffunc(e) + if a:e && has_key(s:buffunc, 'enter') + cal call(s:buffunc['enter'], []) + elsei !a:e && has_key(s:buffunc, 'exit') + cal call(s:buffunc['exit'], []) + en +endf + +fu! s:openfile(cmd, fid, tail, chkmod, ...) + let cmd = a:cmd + if a:chkmod && cmd =~ '^[eb]$' && ctrlp#modfilecond(!( cmd == 'b' && &aw )) + let cmd = cmd == 'b' ? 'sb' : 'sp' + en + let cmd = cmd =~ '^tab' ? ctrlp#tabcount().cmd : cmd + let j2l = a:0 && a:1[0] ? a:1[1] : 0 + exe cmd.( a:0 && a:1[0] ? '' : a:tail ) s:fnesc(a:fid, 'f') + if j2l + cal ctrlp#j2l(j2l) + en + if !empty(a:tail) + sil! norm! zvzz + en + if cmd != 'bad' + cal ctrlp#setlcdir() + en +endf + +fu! ctrlp#tabcount() + if exists('s:tabct') + let tabct = s:tabct + let s:tabct += 1 + elsei !type(s:tabpage) + let tabct = s:tabpage + elsei type(s:tabpage) == 1 + let tabpos = + \ s:tabpage =~ 'c' ? tabpagenr() : + \ s:tabpage =~ 'f' ? 1 : + \ s:tabpage =~ 'l' ? tabpagenr('$') : + \ tabpagenr() + let tabct = + \ s:tabpage =~ 'a' ? tabpos : + \ s:tabpage =~ 'b' ? tabpos - 1 : + \ tabpos + en + retu tabct < 0 ? 0 : tabct +endf + +fu! s:settype(type) + retu a:type < 0 ? exists('s:itemtype') ? s:itemtype : 0 : a:type +endf +" Matching {{{2 +fu! s:matchfname(item, pat) + let parts = split(a:item, '[\/]\ze[^\/]\+$') + let mfn = match(parts[-1], a:pat[0]) + retu len(a:pat) == 1 ? mfn : len(a:pat) == 2 ? + \ ( mfn >= 0 && ( len(parts) == 2 ? match(parts[0], a:pat[1]) : -1 ) >= 0 + \ ? 0 : -1 ) : -1 + en +endf + +fu! s:matchtabs(item, pat) + retu match(split(a:item, '\t\+')[0], a:pat) +endf + +fu! s:matchtabe(item, pat) + retu match(split(a:item, '\t\+[^\t]\+$')[0], a:pat) +endf + +fu! s:buildpat(lst) + let pat = a:lst[0] + for item in range(1, len(a:lst) - 1) + let pat .= '[^'.a:lst[item - 1].']\{-}'.a:lst[item] + endfo + retu pat +endf + +fu! s:mfunc() + let mfunc = 'match' + if s:byfname && s:ispath + let mfunc = 's:matchfname' + elsei s:itemtype > 2 + let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' } + if has_key(matchtypes, s:matchtype) + let mfunc = matchtypes[s:matchtype] + en + en + retu mfunc +endf + +fu! s:mmode() + let matchmodes = { + \ 'match': 'full-line', + \ 's:matchfname': 'filename-only', + \ 's:matchtabs': 'first-non-tab', + \ 's:matchtabe': 'until-last-tab', + \ } + retu matchmodes[s:mfunc] +endf +" Cache {{{2 +fu! s:writecache(cafile) + if ( g:ctrlp_newcache || !filereadable(a:cafile) ) && !s:nocache() + cal ctrlp#utils#writecache(g:ctrlp_allfiles) + let g:ctrlp_newcache = 0 + en +endf + +fu! s:nocache(...) + if !s:caching + retu 1 + elsei s:caching > 1 + if !( exists(s:ccex) && !{s:ccex} ) || has_key(s:ficounts, s:dyncwd) + retu get(s:ficounts, s:dyncwd, [0, 0])[0] < s:caching + elsei a:0 && filereadable(a:1) + retu len(ctrlp#utils#readfile(a:1)) < s:caching + en + retu 1 + en + retu 0 +endf + +fu! s:insertcache(str) + let [data, g:ctrlp_newcache, str] = [g:ctrlp_allfiles, 1, a:str] + if strlen(str) <= strlen(data[0]) + let pos = 0 + elsei strlen(str) >= strlen(data[-1]) + let pos = len(data) - 1 + el + let pos = 0 + for each in data + if strlen(each) > strlen(str) | brea | en + let pos += 1 + endfo + en + cal insert(data, str, pos) + cal s:writecache(ctrlp#utils#cachefile()) +endf +" Extensions {{{2 +fu! s:mtype() + retu s:itemtype > 2 ? s:getextvar('type') : 'path' +endf + +fu! s:execextvar(key) + if !empty(g:ctrlp_ext_vars) + cal map(filter(copy(g:ctrlp_ext_vars), + \ 'has_key(v:val, a:key)'), 'eval(v:val[a:key])') + en +endf + +fu! s:getextvar(key) + if s:itemtype > 2 + let vars = g:ctrlp_ext_vars[s:itemtype - 3] + retu has_key(vars, a:key) ? vars[a:key] : -1 + en + retu -1 +endf + +fu! ctrlp#getcline() + retu !empty(s:lines) ? s:lines[line('.') - 1] : '' +endf + +fu! ctrlp#getmarkedlist() + retu exists('s:marked') ? values(s:marked) : [] +endf + +fu! ctrlp#exit() + cal s:PrtExit() +endf + +fu! ctrlp#prtclear() + cal s:PrtClear() +endf + +fu! ctrlp#switchtype(id) + cal s:ToggleType(a:id - s:itemtype) +endf + +fu! ctrlp#nosy() + retu !( has('syntax') && exists('g:syntax_on') ) +endf + +fu! ctrlp#hicheck(grp, defgrp) + if !hlexists(a:grp) + exe 'hi link' a:grp a:defgrp + en +endf + +fu! ctrlp#call(func, ...) + cal call(a:func, a:000) +endf +"}}}1 +" * Initialization {{{1 +fu! ctrlp#setlines(...) + if a:0 | let s:itemtype = a:1 | en + cal s:modevar() + let types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()'] + if !empty(g:ctrlp_ext_vars) + cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])') + en + let g:ctrlp_lines = eval(types[s:itemtype]) +endf + +fu! ctrlp#init(type, ...) + if exists('s:init') || s:iscmdwin() | retu | en + let [s:ermsg, v:errmsg] = [v:errmsg, ''] + let [s:matches, s:init] = [1, 1] + cal s:Reset(a:0 ? a:1 : {}) + noa cal s:Open() + cal s:SetWD(a:0 ? a:1 : {}) + cal s:MapNorms() + cal s:MapSpecs() + cal ctrlp#syntax() + cal ctrlp#setlines(s:settype(a:type)) + cal s:SetDefTxt() + cal s:BuildPrompt(1) + if s:keyloop | cal s:KeyLoop() | en +endf +" - Autocmds {{{1 +if has('autocmd') + aug CtrlPAug + au! + au BufEnter ControlP cal s:checkbuf() + au BufLeave ControlP noa cal s:Close() + au VimLeavePre * cal s:leavepre() + aug END +en + +fu! s:autocmds() + if !has('autocmd') | retu | en + if exists('#CtrlPLazy') + au! CtrlPLazy + en + if s:lazy + aug CtrlPLazy + au! + au CursorHold ControlP cal s:ForceUpdate() + aug END + en +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/bookmarkdir.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/bookmarkdir.vim new file mode 100644 index 0000000..7d955b5 --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/bookmarkdir.vim @@ -0,0 +1,140 @@ +" ============================================================================= +" File: autoload/ctrlp/bookmarkdir.vim +" Description: Bookmarked directories extension +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_bookmarkdir') && g:loaded_ctrlp_bookmarkdir + fini +en +let g:loaded_ctrlp_bookmarkdir = 1 + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#bookmarkdir#init()', + \ 'accept': 'ctrlp#bookmarkdir#accept', + \ 'lname': 'bookmarked dirs', + \ 'sname': 'bkd', + \ 'type': 'tabs', + \ 'opmul': 1, + \ 'nolim': 1, + \ 'wipe': 'ctrlp#bookmarkdir#remove', + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) +" Utilities {{{1 +fu! s:getinput(str, ...) + echoh Identifier + cal inputsave() + let input = call('input', a:0 ? [a:str] + a:000 : [a:str]) + cal inputrestore() + echoh None + retu input +endf + +fu! s:cachefile() + if !exists('s:cadir') || !exists('s:cafile') + let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'bkd' + let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt' + en + retu s:cafile +endf + +fu! s:writecache(lines) + cal ctrlp#utils#writecache(a:lines, s:cadir, s:cafile) +endf + +fu! s:getbookmarks() + retu ctrlp#utils#readfile(s:cachefile()) +endf + +fu! s:savebookmark(name, cwd) + let cwds = exists('+ssl') ? [tr(a:cwd, '\', '/'), tr(a:cwd, '/', '\')] : [a:cwd] + let entries = filter(s:getbookmarks(), 'index(cwds, s:parts(v:val)[1]) < 0') + cal s:writecache(insert(entries, a:name.' '.a:cwd)) +endf + +fu! s:setentries() + let time = getftime(s:cachefile()) + if !( exists('s:bookmarks') && time == s:bookmarks[0] ) + let s:bookmarks = [time, s:getbookmarks()] + en +endf + +fu! s:parts(str) + let mlist = matchlist(a:str, '\v([^\t]+)\t(.*)$') + retu mlist != [] ? mlist[1:2] : ['', ''] +endf + +fu! s:process(entries, type) + retu map(a:entries, 's:modify(v:val, a:type)') +endf + +fu! s:modify(entry, type) + let [name, dir] = s:parts(a:entry) + let dir = fnamemodify(dir, a:type) + retu name.' '.( dir == '' ? '.' : dir ) +endf + +fu! s:msg(name, cwd) + redr + echoh Identifier | echon 'Bookmarked ' | echoh Constant + echon a:name.' ' | echoh Directory | echon a:cwd + echoh None +endf + +fu! s:syntax() + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPBookmark', 'Identifier') + cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') + sy match CtrlPBookmark '^> [^\t]\+' contains=CtrlPLinePre + sy match CtrlPTabExtra '\zs\t.*\ze$' + en +endf +" Public {{{1 +fu! ctrlp#bookmarkdir#init() + cal s:setentries() + cal s:syntax() + retu s:process(copy(s:bookmarks[1]), ':.') +endf + +fu! ctrlp#bookmarkdir#accept(mode, str) + let parts = s:parts(s:modify(a:str, ':p')) + cal call('s:savebookmark', parts) + if a:mode =~ 't\|v\|h' + cal ctrlp#exit() + en + cal ctrlp#setdir(parts[1], a:mode =~ 't\|h' ? 'chd!' : 'lc!') + if a:mode == 'e' + cal ctrlp#switchtype(0) + cal ctrlp#recordhist() + cal ctrlp#prtclear() + en +endf + +fu! ctrlp#bookmarkdir#add(dir) + let str = 'Directory to bookmark: ' + let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir') + if cwd == '' | retu | en + let cwd = fnamemodify(cwd, ':p') + let name = s:getinput('Bookmark as: ', cwd) + if name == '' | retu | en + let name = tr(name, ' ', ' ') + cal s:savebookmark(name, cwd) + cal s:msg(name, cwd) +endf + +fu! ctrlp#bookmarkdir#remove(entries) + cal s:process(a:entries, ':p') + cal s:writecache(a:entries == [] ? [] : + \ filter(s:getbookmarks(), 'index(a:entries, v:val) < 0')) + cal s:setentries() + retu s:process(copy(s:bookmarks[1]), ':.') +endf + +fu! ctrlp#bookmarkdir#id() + retu s:id +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/buffertag.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/buffertag.vim new file mode 100644 index 0000000..0a24eef --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/buffertag.vim @@ -0,0 +1,261 @@ +" ============================================================================= +" File: autoload/ctrlp/buffertag.vim +" Description: Buffer Tag extension +" Maintainer: Kien Nguyen +" Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus +" a few lines from taglist.vim by Yegappan Lakshmanan and from +" buffertag.vim by Takeshi Nishida. +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag + fini +en +let g:loaded_ctrlp_buftag = 1 + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#buffertag#init(s:crfile)', + \ 'accept': 'ctrlp#buffertag#accept', + \ 'lname': 'buffer tags', + \ 'sname': 'bft', + \ 'exit': 'ctrlp#buffertag#exit()', + \ 'type': 'tabs', + \ 'opts': 'ctrlp#buffertag#opts()', + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) + +let [s:pref, s:opts] = ['g:ctrlp_buftag_', { + \ 'systemenc': ['s:enc', &enc], + \ 'ctags_bin': ['s:bin', ''], + \ 'types': ['s:usr_types', {}], + \ }] + +let s:bins = [ + \ 'ctags-exuberant', + \ 'exuberant-ctags', + \ 'exctags', + \ '/usr/local/bin/ctags', + \ '/opt/local/bin/ctags', + \ 'ctags', + \ 'ctags.exe', + \ 'tags', + \ ] + +let s:types = { + \ 'asm' : '%sasm%sasm%sdlmt', + \ 'aspperl': '%sasp%sasp%sfsv', + \ 'aspvbs' : '%sasp%sasp%sfsv', + \ 'awk' : '%sawk%sawk%sf', + \ 'beta' : '%sbeta%sbeta%sfsv', + \ 'c' : '%sc%sc%sdgsutvf', + \ 'cpp' : '%sc++%sc++%snvdtcgsuf', + \ 'cs' : '%sc#%sc#%sdtncEgsipm', + \ 'cobol' : '%scobol%scobol%sdfgpPs', + \ 'eiffel' : '%seiffel%seiffel%scf', + \ 'erlang' : '%serlang%serlang%sdrmf', + \ 'expect' : '%stcl%stcl%scfp', + \ 'fortran': '%sfortran%sfortran%spbceiklmntvfs', + \ 'html' : '%shtml%shtml%saf', + \ 'java' : '%sjava%sjava%spcifm', + \ 'javascript': '%sjavascript%sjavascript%sf', + \ 'lisp' : '%slisp%slisp%sf', + \ 'lua' : '%slua%slua%sf', + \ 'make' : '%smake%smake%sm', + \ 'pascal' : '%spascal%spascal%sfp', + \ 'perl' : '%sperl%sperl%sclps', + \ 'php' : '%sphp%sphp%scdvf', + \ 'python' : '%spython%spython%scmf', + \ 'rexx' : '%srexx%srexx%ss', + \ 'ruby' : '%sruby%sruby%scfFm', + \ 'scheme' : '%sscheme%sscheme%ssf', + \ 'sh' : '%ssh%ssh%sf', + \ 'csh' : '%ssh%ssh%sf', + \ 'zsh' : '%ssh%ssh%sf', + \ 'slang' : '%sslang%sslang%snf', + \ 'sml' : '%ssml%ssml%secsrtvf', + \ 'sql' : '%ssql%ssql%scFPrstTvfp', + \ 'tcl' : '%stcl%stcl%scfmp', + \ 'vera' : '%svera%svera%scdefgmpPtTvx', + \ 'verilog': '%sverilog%sverilog%smcPertwpvf', + \ 'vim' : '%svim%svim%savf', + \ 'yacc' : '%syacc%syacc%sl', + \ } + +cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")') + +if executable('jsctags') + cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } }) +en + +fu! ctrlp#buffertag#opts() + for [ke, va] in items(s:opts) + let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1] + endfo + " Ctags bin + if empty(s:bin) + for bin in s:bins | if executable(bin) + let s:bin = bin + brea + en | endfo + el + let s:bin = expand(s:bin, 1) + en + " Types + cal extend(s:types, s:usr_types) +endf +" Utilities {{{1 +fu! s:validfile(fname, ftype) + if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname) + \ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en + retu 0 +endf + +fu! s:exectags(cmd) + if exists('+ssl') + let [ssl, &ssl] = [&ssl, 0] + en + if &sh =~ 'cmd\.exe' + let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c'] + en + let output = system(a:cmd) + if &sh =~ 'cmd\.exe' + let [&sxq, &shcf] = [sxq, shcf] + en + if exists('+ssl') + let &ssl = ssl + en + retu output +endf + +fu! s:exectagsonfile(fname, ftype) + let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype] + if type(s:types[ft]) == 1 + let ags .= s:types[ft] + let bin = s:bin + elsei type(s:types[ft]) == 4 + let ags = s:types[ft]['args'] + let bin = expand(s:types[ft]['bin'], 1) + en + if empty(bin) | retu '' | en + let cmd = s:esctagscmd(bin, ags, a:fname) + if empty(cmd) | retu '' | en + let output = s:exectags(cmd) + if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en + retu output +endf + +fu! s:esctagscmd(bin, args, ...) + if exists('+ssl') + let [ssl, &ssl] = [&ssl, 0] + en + let fname = a:0 ? shellescape(a:1) : '' + let cmd = shellescape(a:bin).' '.a:args.' '.fname + if &sh =~ 'cmd\.exe' + let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g') + en + if exists('+ssl') + let &ssl = ssl + en + if has('iconv') + let last = s:enc != &enc ? s:enc : !empty($LANG) ? $LANG : &enc + let cmd = iconv(cmd, &enc, last) + en + retu cmd +endf + +fu! s:process(fname, ftype) + if !s:validfile(a:fname, a:ftype) | retu [] | endif + let ftime = getftime(a:fname) + if has_key(g:ctrlp_buftags, a:fname) + \ && g:ctrlp_buftags[a:fname]['time'] >= ftime + let lines = g:ctrlp_buftags[a:fname]['lines'] + el + let data = s:exectagsonfile(a:fname, a:ftype) + let [raw, lines] = [split(data, '\n\+'), []] + for line in raw + if line !~# '^!_TAG_' && len(split(line, ';"')) == 2 + let parsed_line = s:parseline(line) + if parsed_line != '' + cal add(lines, parsed_line) + en + en + endfo + let cache = { a:fname : { 'time': ftime, 'lines': lines } } + cal extend(g:ctrlp_buftags, cache) + en + retu lines +endf + +fu! s:parseline(line) + let vals = matchlist(a:line, + \ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)') + if vals == [] | retu '' | en + let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')] + retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3] +endf + +fu! s:syntax() + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPTagKind', 'Title') + cal ctrlp#hicheck('CtrlPBufName', 'Directory') + cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') + sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|' + sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|' + sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind + en +endf + +fu! s:chknearby(pat) + if match(getline('.'), a:pat) < 0 + let [int, forw, maxl] = [1, 1, line('$')] + wh !search(a:pat, 'W'.( forw ? '' : 'b' )) + if !forw + if int > maxl | brea | en + let int += int + en + let forw = !forw + endw + en +endf +" Public {{{1 +fu! ctrlp#buffertag#init(fname) + let bufs = exists('s:btmode') && s:btmode + \ ? filter(ctrlp#buffers(), 'filereadable(v:val)') + \ : [exists('s:bufname') ? s:bufname : a:fname] + let lines = [] + for each in bufs + let bname = fnamemodify(each, ':p') + let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '') + cal extend(lines, s:process(bname, tftype)) + endfo + cal s:syntax() + retu lines +endf + +fu! ctrlp#buffertag#accept(mode, str) + let vals = matchlist(a:str, + \ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$') + let bufnr = str2nr(get(vals, 1)) + if bufnr + cal ctrlp#acceptfile(a:mode, bufname(bufnr)) + exe 'norm!' str2nr(get(vals, 2, line('.'))).'G' + cal s:chknearby('\V\C'.get(vals, 3, '')) + sil! norm! zvzz + en +endf + +fu! ctrlp#buffertag#cmd(mode, ...) + let s:btmode = a:mode + if a:0 && !empty(a:1) + let s:bufname = fnamemodify(a:1, ':p') + en + retu s:id +endf + +fu! ctrlp#buffertag#exit() + unl! s:btmode s:bufname +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/changes.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/changes.vim new file mode 100644 index 0000000..c391aad --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/changes.vim @@ -0,0 +1,95 @@ +" ============================================================================= +" File: autoload/ctrlp/changes.vim +" Description: Change list extension +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes + fini +en +let g:loaded_ctrlp_changes = 1 + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#changes#init(s:bufnr, s:crbufnr)', + \ 'accept': 'ctrlp#changes#accept', + \ 'lname': 'changes', + \ 'sname': 'chs', + \ 'exit': 'ctrlp#changes#exit()', + \ 'type': 'tabe', + \ 'sort': 0, + \ 'nolim': 1, + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) +" Utilities {{{1 +fu! s:changelist(bufnr) + sil! exe 'noa hid b' a:bufnr + redi => result + sil! changes + redi END + retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")') +endf + +fu! s:process(clines, ...) + let [clines, evas] = [[], []] + for each in a:clines + let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$') + if !empty(parts) + if parts[3] == '' | let parts[3] = ' ' | en + cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|') + en + endfo + retu reverse(filter(clines, 'count(clines, v:val) == 1')) +endf + +fu! s:syntax() + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPBufName', 'Directory') + cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') + sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$' + sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName + en +endf +" Public {{{1 +fu! ctrlp#changes#init(original_bufnr, bufnr) + let bufnr = exists('s:bufnr') ? s:bufnr : a:bufnr + let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr] + cal filter(bufs, 'v:val > 0') + let [swb, &swb] = [&swb, ''] + let lines = [] + for each in bufs + let fnamet = fnamemodify(bufname(each), ':t') + cal extend(lines, s:process(s:changelist(each), each, fnamet)) + endfo + sil! exe 'noa hid b' a:original_bufnr + let &swb = swb + cal ctrlp#syntax() + cal s:syntax() + retu lines +endf + +fu! ctrlp#changes#accept(mode, str) + let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$') + let bufnr = str2nr(get(info, 1)) + if bufnr + cal ctrlp#acceptfile(a:mode, bufname(bufnr)) + cal cursor(get(info, 2), get(info, 3)) + sil! norm! zvzz + en +endf + +fu! ctrlp#changes#cmd(mode, ...) + let s:clmode = a:mode + if a:0 && !empty(a:1) + let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$') + en + retu s:id +endf + +fu! ctrlp#changes#exit() + unl! s:clmode s:bufnr +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/dir.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/dir.vim new file mode 100644 index 0000000..2589a0b --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/dir.vim @@ -0,0 +1,93 @@ +" ============================================================================= +" File: autoload/ctrlp/dir.vim +" Description: Directory extension +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir + fini +en +let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0] + +let s:ars = ['s:maxdepth', 's:maxfiles', 's:compare_lim', 's:glob', 's:caching'] + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')', + \ 'accept': 'ctrlp#dir#accept', + \ 'lname': 'dirs', + \ 'sname': 'dir', + \ 'type': 'path', + \ 'specinput': 1, + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) + +let s:dircounts = {} +" Utilities {{{1 +fu! s:globdirs(dirs, depth) + let entries = split(globpath(a:dirs, s:glob), "\n") + let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1] + cal extend(g:ctrlp_alldirs, dirs) + let nr = len(g:ctrlp_alldirs) + if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth + sil! cal ctrlp#progress(nr) + cal map(dirs, 'ctrlp#utils#fnesc(v:val, "g", ",")') + cal s:globdirs(join(dirs, ','), depth) + en +endf + +fu! s:max(len, max) + retu a:max && a:len > a:max +endf + +fu! s:nocache() + retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching ) +endf +" Public {{{1 +fu! ctrlp#dir#init(...) + let s:cwd = getcwd() + for each in range(len(s:ars)) + let {s:ars[each]} = a:{each + 1} + endfo + let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir' + let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir') + if g:ctrlp_newdir || s:nocache() || !filereadable(cafile) + let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []] + cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0) + cal ctrlp#rmbasedir(g:ctrlp_alldirs) + if len(g:ctrlp_alldirs) <= s:compare_lim + cal sort(g:ctrlp_alldirs, 'ctrlp#complen') + en + cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile) + let g:ctrlp_newdir = 0 + el + if !( exists('s:initcwd') && s:initcwd == s:cwd ) + let s:initcwd = s:cwd + let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile) + en + en + cal extend(s:dircounts, { s:cwd : len(g:ctrlp_alldirs) }) + retu g:ctrlp_alldirs +endf + +fu! ctrlp#dir#accept(mode, str) + let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str + if a:mode =~ 't\|v\|h' + cal ctrlp#exit() + en + cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!') + if a:mode == 'e' + sil! cal ctrlp#statusline() + cal ctrlp#setlines(s:id) + cal ctrlp#recordhist() + cal ctrlp#prtclear() + en +endf + +fu! ctrlp#dir#id() + retu s:id +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/line.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/line.vim new file mode 100644 index 0000000..a2e0dde --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/line.vim @@ -0,0 +1,62 @@ +" ============================================================================= +" File: autoload/ctrlp/line.vim +" Description: Line extension +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line + fini +en +let g:loaded_ctrlp_line = 1 + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#line#init()', + \ 'accept': 'ctrlp#line#accept', + \ 'lname': 'lines', + \ 'sname': 'lns', + \ 'type': 'tabe', + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) +" Utilities {{{1 +fu! s:syntax() + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPBufName', 'Directory') + cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') + sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$' + sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName + en +endf +" Public {{{1 +fu! ctrlp#line#init() + let [bufs, lines] = [ctrlp#buffers('id'), []] + for bufnr in bufs + let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)] + let lfb = lfb == [] ? ctrlp#utils#readfile(fnamemodify(bufn, ':p')) : lfb + cal map(lfb, 'tr(v:val, '' '', '' '')') + let [linenr, len_lfb, buft] = [1, len(lfb), fnamemodify(bufn, ':t')] + wh linenr <= len_lfb + let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|' + let linenr += 1 + endw + cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$''')) + endfo + cal s:syntax() + retu lines +endf + +fu! ctrlp#line#accept(mode, str) + let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$') + let bufnr = str2nr(get(info, 1)) + if bufnr + cal ctrlp#acceptfile(a:mode, bufname(bufnr), get(info, 2)) + en +endf + +fu! ctrlp#line#id() + retu s:id +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/mixed.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/mixed.vim new file mode 100644 index 0000000..cf01d10 --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/mixed.vim @@ -0,0 +1,83 @@ +" ============================================================================= +" File: autoload/ctrlp/mixed.vim +" Description: Mixing Files + MRU + Buffers +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed + fini +en +let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0] + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#mixed#init(s:compare_lim)', + \ 'accept': 'ctrlp#acceptfile', + \ 'lname': 'fil + mru + buf', + \ 'sname': 'mix', + \ 'type': 'path', + \ 'opmul': 1, + \ 'specinput': 1, + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) +" Utilities {{{1 +fu! s:newcache(cwd) + if g:ctrlp_newmix || !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en + retu g:ctrlp_allmixes['cwd'] != a:cwd + \ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile()) + \ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile()) + \ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs()) +endf + +fu! s:getnewmix(cwd, clim) + if g:ctrlp_newmix + cal ctrlp#mrufiles#refresh('raw') + let g:ctrlp_newcache = 1 + en + let g:ctrlp_lines = copy(ctrlp#files()) + cal ctrlp#progress('Mixing...') + let mrufs = copy(ctrlp#mrufiles#list('raw')) + if exists('+ssl') && &ssl + cal map(mrufs, 'tr(v:val, "\\", "/")') + en + let bufs = map(ctrlp#buffers('id'), 'fnamemodify(bufname(v:val), ":p")') + let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0') + if len(mrufs) > len(g:ctrlp_lines) + cal filter(mrufs, 'stridx(v:val, a:cwd)') + el + let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)') + let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs) + for each in cwd_mrufs + let id = index(g:ctrlp_lines, each) + if id >= 0 | cal remove(g:ctrlp_lines, id) | en + endfo + en + cal map(mrufs, 'fnamemodify(v:val, ":.")') + let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines) + \ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines + if len(g:ctrlp_lines) <= a:clim + cal sort(g:ctrlp_lines, 'ctrlp#complen') + en + let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()), + \ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd, + \ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines } +endf +" Public {{{1 +fu! ctrlp#mixed#init(clim) + let cwd = getcwd() + if s:newcache(cwd) + cal s:getnewmix(cwd, a:clim) + el + let g:ctrlp_lines = g:ctrlp_allmixes['data'] + en + let g:ctrlp_newmix = 0 + retu g:ctrlp_lines +endf + +fu! ctrlp#mixed#id() + retu s:id +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/mrufiles.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/mrufiles.vim new file mode 100644 index 0000000..10d7813 --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/mrufiles.vim @@ -0,0 +1,129 @@ +" ============================================================================= +" File: autoload/ctrlp/mrufiles.vim +" Description: Most Recently Used Files extension +" Author: Kien Nguyen +" ============================================================================= + +" Static variables {{{1 +let [s:mrbs, s:mrufs] = [[], []] + +fu! ctrlp#mrufiles#opts() + let [pref, opts] = ['g:ctrlp_mruf_', { + \ 'max': ['s:max', 250], + \ 'include': ['s:in', ''], + \ 'exclude': ['s:ex', ''], + \ 'case_sensitive': ['s:cseno', 1], + \ 'relative': ['s:re', 0], + \ }] + for [ke, va] in items(opts) + let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]] + endfo +endf +cal ctrlp#mrufiles#opts() +" Utilities {{{1 +fu! s:excl(fn) + retu !empty({s:ex}) && a:fn =~# {s:ex} +endf + +fu! s:mergelists() + let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile()) + cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0') + let mrufs = s:mrufs + diskmrufs + retu s:chop(mrufs) +endf + +fu! s:chop(mrufs) + if len(a:mrufs) > {s:max} | cal remove(a:mrufs, {s:max}, -1) | en + retu a:mrufs +endf + +fu! s:reformat(mrufs) + if {s:re} + let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd() + cal filter(a:mrufs, '!stridx(v:val, cwd)') + en + retu map(a:mrufs, 'fnamemodify(v:val, ":.")') +endf + +fu! s:record(bufnr) + if s:locked | retu | en + let bufnr = a:bufnr + 0 + let bufname = bufname(bufnr) + if bufnr > 0 && !empty(bufname) + cal filter(s:mrbs, 'v:val != bufnr') + cal insert(s:mrbs, bufnr) + cal s:addtomrufs(bufname) + en +endf + +fu! s:addtomrufs(fname) + let fn = fnamemodify(a:fname, ':p') + let fn = exists('+ssl') ? tr(fn, '/', '\') : fn + if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} ) + \ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu + en + cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn') + cal insert(s:mrufs, fn) +endf + +fu! s:savetofile(mrufs) + cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile) +endf +" Public {{{1 +fu! ctrlp#mrufiles#refresh(...) + let s:mrufs = s:mergelists() + cal filter(s:mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)') + if exists('+ssl') + cal map(s:mrufs, 'tr(v:val, "/", "\\")') + cal filter(s:mrufs, 'count(s:mrufs, v:val) == 1') + en + cal s:savetofile(s:mrufs) + retu a:0 && a:1 == 'raw' ? [] : s:reformat(copy(s:mrufs)) +endf + +fu! ctrlp#mrufiles#remove(files) + let s:mrufs = [] + if a:files != [] + let s:mrufs = s:mergelists() + cal filter(s:mrufs, 'index(a:files, v:val, 0, '.(!{s:cseno}).') < 0') + en + cal s:savetofile(s:mrufs) + retu s:reformat(copy(s:mrufs)) +endf + +fu! ctrlp#mrufiles#add(fn) + if !empty(a:fn) + cal s:addtomrufs(a:fn) + en +endf + +fu! ctrlp#mrufiles#list(...) + retu a:0 ? a:1 == 'raw' ? s:mergelists() : 0 : s:reformat(s:mergelists()) +endf + +fu! ctrlp#mrufiles#bufs() + retu s:mrbs +endf + +fu! ctrlp#mrufiles#cachefile() + if !exists('s:cadir') || !exists('s:cafile') + let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru' + let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt' + en + retu s:cafile +endf + +fu! ctrlp#mrufiles#init() + if !has('autocmd') | retu | en + let s:locked = 0 + aug CtrlPMRUF + au! + au BufAdd,BufEnter,BufLeave,BufUnload * cal s:record(expand('', 1)) + au QuickFixCmdPre *vimgrep* let s:locked = 1 + au QuickFixCmdPost *vimgrep* let s:locked = 0 + au VimLeavePre * cal s:savetofile(s:mergelists()) + aug END +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/quickfix.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/quickfix.vim new file mode 100644 index 0000000..03ab921 --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/quickfix.vim @@ -0,0 +1,59 @@ +" ============================================================================= +" File: autoload/ctrlp/quickfix.vim +" Description: Quickfix extension +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix + fini +en +let g:loaded_ctrlp_quickfix = 1 + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#quickfix#init()', + \ 'accept': 'ctrlp#quickfix#accept', + \ 'lname': 'quickfix', + \ 'sname': 'qfx', + \ 'type': 'line', + \ 'sort': 0, + \ 'nolim': 1, + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) + +fu! s:lineout(dict) + retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'], + \ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S')) +endf +" Utilities {{{1 +fu! s:syntax() + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPqfLineCol', 'Search') + sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|' + en +endf +" Public {{{1 +fu! ctrlp#quickfix#init() + cal s:syntax() + retu map(getqflist(), 's:lineout(v:val)') +endf + +fu! ctrlp#quickfix#accept(mode, str) + let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|') + if vals == [] || vals[1] == '' | retu | en + cal ctrlp#acceptfile(a:mode, vals[1]) + let cur_pos = getpos('.')[1:2] + if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)') + mark ' + en + cal cursor(vals[2], vals[3]) + sil! norm! zvzz +endf + +fu! ctrlp#quickfix#id() + retu s:id +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/rtscript.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/rtscript.vim new file mode 100644 index 0000000..eed21c6 --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/rtscript.vim @@ -0,0 +1,59 @@ +" ============================================================================= +" File: autoload/ctrlp/rtscript.vim +" Description: Runtime scripts extension +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript + fini +en +let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0] + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#rtscript#init(s:caching)', + \ 'accept': 'ctrlp#acceptfile', + \ 'lname': 'runtime scripts', + \ 'sname': 'rts', + \ 'type': 'path', + \ 'opmul': 1, + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) + +let s:filecounts = {} +" Utilities {{{1 +fu! s:nocache() + retu g:ctrlp_newrts || + \ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching ) +endf +" Public {{{1 +fu! ctrlp#rtscript#init(caching) + let [s:caching, s:cwd] = [a:caching, getcwd()] + if s:nocache() || + \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp ) + sil! cal ctrlp#progress('Indexing...') + let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n") + cal filter(entries, 'count(entries, v:val) == 1') + let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1] + el + let [entries, results] = g:ctrlp_rtscache[2:3] + en + if s:nocache() || + \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] ) + if !exists('echoed') + sil! cal ctrlp#progress('Processing...') + en + let results = map(copy(entries), 'fnamemodify(v:val, '':.'')') + en + let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0] + cal extend(s:filecounts, { s:cwd : len(results) }) + retu results +endf + +fu! ctrlp#rtscript#id() + retu s:id +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/tag.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/tag.vim new file mode 100644 index 0000000..83921a5 --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/tag.vim @@ -0,0 +1,125 @@ +" ============================================================================= +" File: autoload/ctrlp/tag.vim +" Description: Tag file extension +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag + fini +en +let g:loaded_ctrlp_tag = 1 + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#tag#init()', + \ 'accept': 'ctrlp#tag#accept', + \ 'lname': 'tags', + \ 'sname': 'tag', + \ 'enter': 'ctrlp#tag#enter()', + \ 'type': 'tabs', + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) +" Utilities {{{1 +fu! s:findcount(str) + let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$') + let tgs = taglist('^'.tg.'$') + if len(tgs) < 2 + retu [1, 1] + en + let bname = fnamemodify(bufname('%'), ':p') + let fname = expand(fnamemodify(simplify(fname), ':s?^[.\/]\+??:p:.'), 1) + let [fnd, ct, pos, idx] = [0, 0, 0, 0] + wh idx < len(tgs) + if bname == fnamemodify(tgs[idx]["filename"], ':p') + cal insert(tgs, remove(tgs, idx)) + brea + en + let idx += 1 + endw + for each in tgs + let ct += 1 + let fulname = fnamemodify(each["filename"], ':p') + if stridx(fulname, fname) >= 0 + \ && strlen(fname) + stridx(fulname, fname) == strlen(fulname) + let fnd += 1 + let pos = ct + en + if fnd > 1 | brea | en + endfo + retu [fnd, pos] +endf + +fu! s:filter(tags) + let nr = 0 + wh 0 < 1 + if a:tags == [] | brea | en + if a:tags[nr] =~ '^!' && a:tags[nr] !~# '^!_TAG_' + let nr += 1 + con + en + if a:tags[nr] =~# '^!_TAG_' && len(a:tags) > nr + cal remove(a:tags, nr) + el + brea + en + endw + retu a:tags +endf + +fu! s:syntax() + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') + sy match CtrlPTabExtra '\zs\t.*\ze$' + en +endf +" Public {{{1 +fu! ctrlp#tag#init() + if empty(s:tagfiles) | retu [] | en + let g:ctrlp_alltags = [] + let tagfiles = sort(filter(s:tagfiles, 'count(s:tagfiles, v:val) == 1')) + for each in tagfiles + let alltags = s:filter(ctrlp#utils#readfile(each)) + cal extend(g:ctrlp_alltags, alltags) + endfo + cal s:syntax() + retu g:ctrlp_alltags +endf + +fu! ctrlp#tag#accept(mode, str) + cal ctrlp#exit() + let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t') + let [tg, fnd] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)] + let cmds = { + \ 't': ['tab sp', 'tab stj'], + \ 'h': ['sp', 'stj'], + \ 'v': ['vs', 'vert stj'], + \ 'e': ['', 'tj'], + \ } + let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1] + let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw) + \ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd + let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd + if fnd[0] == 1 + if cmd != '' + exe cmd + en + exe fnd[1].'ta' tg + el + exe cmd tg + en + cal ctrlp#setlcdir() +endf + +fu! ctrlp#tag#id() + retu s:id +endf + +fu! ctrlp#tag#enter() + let tfs = tagfiles() + let s:tagfiles = tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'), + \ 'filereadable(v:val)') : [] +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/undo.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/undo.vim new file mode 100644 index 0000000..dee705e --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/undo.vim @@ -0,0 +1,154 @@ +" ============================================================================= +" File: autoload/ctrlp/undo.vim +" Description: Undo extension +" Author: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo ) + fini +en +let g:loaded_ctrlp_undo = 1 + +cal add(g:ctrlp_ext_vars, { + \ 'init': 'ctrlp#undo#init()', + \ 'accept': 'ctrlp#undo#accept', + \ 'lname': 'undo', + \ 'sname': 'udo', + \ 'enter': 'ctrlp#undo#enter()', + \ 'exit': 'ctrlp#undo#exit()', + \ 'type': 'line', + \ 'sort': 0, + \ 'nolim': 1, + \ }) + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) + +let s:text = map(['second', 'seconds', 'minutes', 'hours', 'days', 'weeks', + \ 'months', 'years'], '" ".v:val." ago"') +" Utilities {{{1 +fu! s:getundo() + if exists('*undotree') + \ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) ) + retu [1, undotree()] + el + redi => result + sil! undol + redi END + retu [0, split(result, "\n")[1:]] + en +endf + +fu! s:flatten(tree, cur) + let flatdict = {} + for each in a:tree + let saved = has_key(each, 'save') ? 'saved' : '' + let current = each['seq'] == a:cur ? 'current' : '' + cal extend(flatdict, { each['seq'] : [each['time'], saved, current] }) + if has_key(each, 'alt') + cal extend(flatdict, s:flatten(each['alt'], a:cur)) + en + endfo + retu flatdict +endf + +fu! s:elapsed(nr) + let [text, time] = [s:text, localtime() - a:nr] + let mins = time / 60 + let hrs = time / 3600 + let days = time / 86400 + let wks = time / 604800 + let mons = time / 2592000 + let yrs = time / 31536000 + if yrs > 1 + retu yrs.text[7] + elsei mons > 1 + retu mons.text[6] + elsei wks > 1 + retu wks.text[5] + elsei days > 1 + retu days.text[4] + elsei hrs > 1 + retu hrs.text[3] + elsei mins > 1 + retu mins.text[2] + elsei time == 1 + retu time.text[0] + elsei time < 120 + retu time.text[1] + en +endf + +fu! s:syntax() + if ctrlp#nosy() | retu | en + for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String', + \ 'Sv': 'Comment', 'Po': 'Title'}) + cal ctrlp#hicheck('CtrlPUndo'.ke, va) + endfo + sy match CtrlPUndoT '\v\d+ \zs[^ ]+\ze|\d+:\d+:\d+' + sy match CtrlPUndoBr '\[\|\]' + sy match CtrlPUndoNr '\[\d\+\]' contains=CtrlPUndoBr + sy match CtrlPUndoSv 'saved' + sy match CtrlPUndoPo 'current' +endf + +fu! s:dict2list(dict) + for ke in keys(a:dict) + let a:dict[ke][0] = s:elapsed(a:dict[ke][0]) + endfo + retu map(keys(a:dict), 'eval(''[v:val, a:dict[v:val]]'')') +endf + +fu! s:compval(...) + retu a:2[0] - a:1[0] +endf + +fu! s:format(...) + let saved = !empty(a:1[1][1]) ? ' '.a:1[1][1] : '' + let current = !empty(a:1[1][2]) ? ' '.a:1[1][2] : '' + retu a:1[1][0].' ['.a:1[0].']'.saved.current +endf + +fu! s:formatul(...) + let parts = matchlist(a:1, + \ '\v^\s+(\d+)\s+\d+\s+([^ ]+\s?[^ ]+|\d+\s\w+\s\w+)(\s*\d*)$') + retu parts == [] ? '----' + \ : parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' ) +endf +" Public {{{1 +fu! ctrlp#undo#init() + let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1] + if empty(entries) | retu [] | en + if !exists('s:lines') + if s:undos[0] + let entries = s:dict2list(s:flatten(entries, s:undos[1]['seq_cur'])) + let s:lines = map(sort(entries, 's:compval'), 's:format(v:val)') + el + let s:lines = map(reverse(entries), 's:formatul(v:val)') + en + en + cal s:syntax() + retu s:lines +endf + +fu! ctrlp#undo#accept(mode, str) + let undon = matchstr(a:str, '\[\zs\d\+\ze\]') + if empty(undon) | retu | en + cal ctrlp#exit() + exe 'u' undon +endf + +fu! ctrlp#undo#id() + retu s:id +endf + +fu! ctrlp#undo#enter() + let s:undos = s:getundo() +endf + +fu! ctrlp#undo#exit() + unl! s:lines +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/autoload/ctrlp/utils.vim b/vim/bundle/cctrlp.vim/autoload/ctrlp/utils.vim new file mode 100644 index 0000000..7a74b7f --- /dev/null +++ b/vim/bundle/cctrlp.vim/autoload/ctrlp/utils.vim @@ -0,0 +1,120 @@ +" ============================================================================= +" File: autoload/ctrlp/utils.vim +" Description: Utilities +" Author: Kien Nguyen +" ============================================================================= + +" Static variables {{{1 +fu! ctrlp#utils#lash() + retu &ssl || !exists('+ssl') ? '/' : '\' +endf + +fu! s:lash(...) + retu ( a:0 ? a:1 : getcwd() ) !~ '[\/]$' ? s:lash : '' +endf + +fu! ctrlp#utils#opts() + let s:lash = ctrlp#utils#lash() + let usrhome = $HOME.s:lash($HOME) + let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache' + let cadir = isdirectory(usrhome.'.ctrlp_cache') + \ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp' + if exists('g:ctrlp_cache_dir') + let cadir = expand(g:ctrlp_cache_dir, 1) + if isdirectory(cadir.s:lash(cadir).'.ctrlp_cache') + let cadir = cadir.s:lash(cadir).'.ctrlp_cache' + en + en + let s:cache_dir = cadir +endf +cal ctrlp#utils#opts() + +let s:wig_cond = v:version > 702 || ( v:version == 702 && has('patch051') ) +" Files and Directories {{{1 +fu! ctrlp#utils#cachedir() + retu s:cache_dir +endf + +fu! ctrlp#utils#cachefile(...) + let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()] + let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt' + retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file +endf + +fu! ctrlp#utils#readfile(file) + if filereadable(a:file) + let data = readfile(a:file) + if empty(data) || type(data) != 3 + unl data + let data = [] + en + retu data + en + retu [] +endf + +fu! ctrlp#utils#mkdir(dir) + if exists('*mkdir') && !isdirectory(a:dir) + sil! cal mkdir(a:dir, 'p') + en + retu a:dir +endf + +fu! ctrlp#utils#writecache(lines, ...) + if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir)) + sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile()) + en +endf + +fu! ctrlp#utils#glob(...) + let path = ctrlp#utils#fnesc(a:1, 'g') + retu s:wig_cond ? glob(path, a:2) : glob(path) +endf + +fu! ctrlp#utils#globpath(...) + retu call('globpath', s:wig_cond ? a:000 : a:000[:1]) +endf + +fu! ctrlp#utils#fnesc(path, type, ...) + if exists('*fnameescape') + if exists('+ssl') + if a:type == 'c' + let path = escape(a:path, '%#') + elsei a:type == 'f' + let path = fnameescape(a:path) + elsei a:type == 'g' + let path = escape(a:path, '?*') + en + let path = substitute(path, '[', '[[]', 'g') + el + let path = fnameescape(a:path) + en + el + if exists('+ssl') + if a:type == 'c' + let path = escape(a:path, '%#') + elsei a:type == 'f' + let path = escape(a:path, " \t\n%#*?|<\"") + elsei a:type == 'g' + let path = escape(a:path, '?*') + en + let path = substitute(path, '[', '[[]', 'g') + el + let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<") + en + en + retu a:0 ? escape(path, a:1) : path +endf + +fu! ctrlp#utils#dircompl(...) + let [hsl, str] = [match(a:1, '[\/]'), ''] + let par = substitute(a:1, '[^\/]*$', '', '') + let path = !hsl ? par : hsl > 0 ? getcwd().s:lash().par : getcwd() + for dir in split(globpath(ctrlp#utils#fnesc(path, 'g', ','), '*/'), '\n') + let str .= par.split(dir, '[\/]')[-1]."\n" + endfo + retu str +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/doc/ctrlp.txt b/vim/bundle/cctrlp.vim/doc/ctrlp.txt new file mode 100644 index 0000000..464a6ef --- /dev/null +++ b/vim/bundle/cctrlp.vim/doc/ctrlp.txt @@ -0,0 +1,1395 @@ +*ctrlp.txt* Fuzzy file, buffer, mru, tag, ... finder. v1.78 +*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'* +=============================================================================== +# # +# :::::::: ::::::::::: ::::::::: ::: ::::::::: # +# :+: :+: :+: :+: :+: :+: :+: :+: # +# +:+ +:+ +:+ +:+ +:+ +:+ +:+ # +# +#+ +#+ +#++:++#: +#+ +#++:++#+ # +# +#+ +#+ +#+ +#+ +#+ +#+ # +# #+# #+# #+# #+# #+# #+# #+# # +# ######## ### ### ### ########## ### # +# # +=============================================================================== +CONTENTS *ctrlp-contents* + + 1. Intro........................................|ctrlp-intro| + 2. Options......................................|ctrlp-options| + 3. Commands.....................................|ctrlp-commands| + 4. Mappings.....................................|ctrlp-mappings| + 5. Input Formats................................|ctrlp-input-formats| + 6. Extensions...................................|ctrlp-extensions| + +=============================================================================== +INTRO *ctrlp-intro* + +Full path fuzzy file, buffer, mru, tag, ... finder with an intuitive interface. +Written in pure Vimscript for MacVim, gVim and Vim version 7.0+. Has full +support for Vim's |regexp| as search pattern, built-in MRU files monitoring, +project's root finder, and more. + +To enable optional extensions (tag, dir, rtscript...), see |ctrlp-extensions|. + +=============================================================================== +OPTIONS *ctrlp-options* + +Overview:~ + + |loaded_ctrlp|................Disable the plugin. + |ctrlp_map|...................Default mapping. + |ctrlp_cmd|...................Default command used for the default mapping. + |ctrlp_by_filename|...........Default to filename mode or not. + |ctrlp_regexp|................Default to regexp mode or not. + |ctrlp_match_window_bottom|...Where to show the match window. + |ctrlp_match_window_reversed|.Sort order in the match window. + |ctrlp_max_height|............Max height of the match window. + |ctrlp_switch_buffer|.........Jump to an open buffer if already opened. + |ctrlp_reuse_window|..........Reuse special windows (help, quickfix, etc). + |ctrlp_tabpage_position|......Where to put the new tab page. + |ctrlp_working_path_mode|.....How to set CtrlP's local working directory. + |ctrlp_root_markers|..........Additional, high priority root markers. + |ctrlp_use_caching|...........Use per-session caching or not. + |ctrlp_clear_cache_on_exit|...Keep cache after exiting Vim or not. + |ctrlp_cache_dir|.............Location of the cache directory. + |ctrlp_show_hidden|...........Ignore dotfiles and dotdirs or not. + |ctrlp_custom_ignore|.........Hide stuff when using |globpath()|. + |ctrlp_max_files|.............Number of files to scan initially. + |ctrlp_max_depth|.............Directory depth to recurse into when scanning. + |ctrlp_user_command|..........Use an external scanner. + |ctrlp_max_history|...........Number of entries saved in the prompt history. + |ctrlp_open_new_file|.........How to open a file created by . + |ctrlp_open_multiple_files|...How to open files selected by . + |ctrlp_arg_map|...............Intercept and or not. + |ctrlp_follow_symlinks|.......Follow symbolic links or not. + |ctrlp_lazy_update|...........Only update when typing has stopped. + |ctrlp_default_input|.........Seed the prompt with an initial string. + |ctrlp_abbrev|................Input abbreviations. + |ctrlp_key_loop|..............Use input looping for multi-byte input. + |ctrlp_use_migemo|............Use Migemo patterns for Japanese filenames. + |ctrlp_prompt_mappings|.......Change the mappings inside the prompt. + + MRU mode: + |ctrlp_mruf_max|..............Max MRU entries to remember. + |ctrlp_mruf_exclude|..........Files that shouldn't be remembered. + |ctrlp_mruf_include|..........Files to be remembered. + |ctrlp_mruf_relative|.........Show only MRU files in the working directory. + |ctrlp_mruf_default_order|....Disable sorting. + |ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not. + + Advanced options: + |ctrlp_open_func|.............Use custom file opening functions. + |ctrlp_status_func|...........Change CtrlP's two statuslines. + |ctrlp_buffer_func|...........Call custom functions in the CtrlP buffer. + |ctrlp_match_func|............Replace the built-in matching algorithm. + +------------------------------------------------------------------------------- +Detailed descriptions and default values:~ + + *'g:ctrlp_map'* +Use this option to change the mapping to invoke CtrlP in |Normal| mode: > + let g:ctrlp_map = '' +< + + *'g:ctrlp_cmd'* +Set the default opening command to use when pressing the above mapping: > + let g:ctrlp_cmd = 'CtrlP' +< + + *'g:loaded_ctrlp'* +Use this to disable the plugin completely: > + let g:loaded_ctrlp = 1 +< + + *'g:ctrlp_by_filename'* +Set this to 1 to set searching by filename (as opposed to full path) as the +default: > + let g:ctrlp_by_filename = 0 +< +Can be toggled on/off by pressing inside the prompt. + + *'g:ctrlp_regexp'* +Set this to 1 to set regexp search as the default: > + let g:ctrlp_regexp = 0 +< +Can be toggled on/off by pressing inside the prompt. + + *'g:ctrlp_match_window_bottom'* +Set this to 0 to show the match window at the top of the screen: > + let g:ctrlp_match_window_bottom = 1 +< + + *'g:ctrlp_match_window_reversed'* +Change the listing order of the files in the match window. The default setting +(1) is from bottom to top: > + let g:ctrlp_match_window_reversed = 1 +< + + *'g:ctrlp_max_height'* +Set the maximum height of the match window: > + let g:ctrlp_max_height = 10 +< + + *'g:ctrlp_switch_buffer'* +When opening a file, if it's already open in a window somewhere, CtrlP will try +to jump to it instead of opening a new instance: > + let g:ctrlp_switch_buffer = 'Et' +< + e - jump when is pressed, but only to windows in the current tab. + t - jump when is pressed, but only to windows in another tab. + v - like "e", but jump when is pressed. + h - like "e", but jump when is pressed. + E, T, V, H - like "e", "t", "v", and "h", but jump to windows anywhere. + 0 or - disable this feature. + + *'g:ctrlp_reuse_window'* +When opening a file with , CtrlP avoids opening it in windows created by +plugins, help and quickfix. Use this to setup some exceptions: > + let g:ctrlp_reuse_window = 'netrw' +< +Acceptable values are partial name, filetype or buftype of the special buffers. +Use regexp to specify the pattern. +Example: > + let g:ctrlp_reuse_window = 'netrw\|help\|quickfix' +< + + *'g:ctrlp_tabpage_position'* +Where to put the new tab page when opening one: > + let g:ctrlp_tabpage_position = 'ac' +< + a - after. + b - before. + c - the current tab page. + l - the last tab page. + f - the first tab page. + + *'g:ctrlp_working_path_mode'* +When starting up, CtrlP sets its local working directory according to this +variable: > + let g:ctrlp_working_path_mode = 'ra' +< + c - the directory of the current file. + a - like "c", but only applies when the current working directory outside of + CtrlP isn't a direct ancestor of the directory of the current file. + r - the nearest ancestor that contains one of these directories or files: + .git .hg .svn .bzr _darcs + w - begin finding a root from the current working directory outside of CtrlP + instead of from the directory of the current file (default). Only applies + when "r" is also present. + 0 or - disable this feature. + +Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as +a fallback) when a root can't be found. + +Note #2: you can use a |b:var| to set this option on a per buffer basis. + + *'g:ctrlp_root_markers'* +Use this to set your own root markers in addition to the default ones (.git, +.hg, .svn, .bzr, and _darcs). Your markers will take precedence: > + let g:ctrlp_root_markers = [''] +< +Note: you can use a |b:var| to set this option on a per buffer basis. + + *'g:ctrlp_use_caching'* +Enable/Disable per-session caching: > + let g:ctrlp_use_caching = 1 +< + 0 - Disable caching. + 1 - Enable caching. + n - When bigger than 1, disable caching and use the number as the limit to + enable caching again. + +Note: you can quickly purge the cache by pressing while inside CtrlP. + + *'g:ctrlp_clear_cache_on_exit'* +Set this to 0 to enable cross-session caching by not deleting the cache files +upon exiting Vim: > + let g:ctrlp_clear_cache_on_exit = 1 +< + + *'g:ctrlp_cache_dir'* +Set the directory to store the cache files: > + let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp' +< + + *'g:ctrlp_show_hidden'* +Set this to 1 if you want CtrlP to scan for dotfiles and dotdirs: > + let g:ctrlp_show_hidden = 0 +< +Note: does not apply when a command defined with |g:ctrlp_user_command| is +being used. + + *'ctrlp-wildignore'* +You can use Vim's |'wildignore'| to exclude files and directories from the +results. +Examples: > + " Excluding version control directories + set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX + set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash') +< +Note #1: the `*/` in front of each directory glob is required. + +Note #2: |wildignore| influences the result of |expand()|, |globpath()| and +|glob()| which many plugins use to find stuff on the system (e.g. VCS related +plugins look for .git/, .hg/,... some other plugins look for external *.exe +tools on Windows). So be a little mindful of what you put in your |wildignore|. + + *'g:ctrlp_custom_ignore'* +In addition to |'wildignore'|, use this for files and directories you want only +CtrlP to not show. Use regexp to specify the patterns: > + let g:ctrlp_custom_ignore = '' +< +Examples: > + let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' + let g:ctrlp_custom_ignore = { + \ 'dir': '\v[\/]\.(git|hg|svn)$', + \ 'file': '\v\.(exe|so|dll)$', + \ 'link': 'SOME_BAD_SYMBOLIC_LINKS', + \ } + let g:ctrlp_custom_ignore = { + \ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@ + let g:ctrlp_max_files = 10000 +< +Note: does not apply when a command defined with |g:ctrlp_user_command| is +being used. + + *'g:ctrlp_max_depth'* +The maximum depth of a directory tree to recurse into: > + let g:ctrlp_max_depth = 40 +< +Note: does not apply when a command defined with |g:ctrlp_user_command| is +being used. + + *'g:ctrlp_user_command'* +Specify an external tool to use for listing files instead of using Vim's +|globpath()|. Use %s in place of the target directory: > + let g:ctrlp_user_command = '' +< +Examples: > + let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux + let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows +< +You can also use 'grep', 'findstr' or something else to filter the results. +Examples: > + let g:ctrlp_user_command = + \ 'find %s -type f | grep -v -P "\.jpg$|/tmp/"' " MacOSX/Linux + let g:ctrlp_user_command = + \ 'dir %s /-n /b /s /a-d | findstr /v /l ".jpg \\tmp\\"' " Windows +< +Use a version control listing command when inside a repository, this is faster +when scanning large projects: > + let g:ctrlp_user_command = [root_marker, listing_command, fallback_command] + let g:ctrlp_user_command = { + \ 'types': { + \ 1: [root_marker_1, listing_command_1], + \ n: [root_marker_n, listing_command_n], + \ }, + \ 'fallback': fallback_command, + \ 'ignore': 0 or 1 + \ } +< +Some examples: > + " Single VCS, listing command does not list untracked files: + let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files'] + let g:ctrlp_user_command = ['.hg', 'hg --cwd %s locate -I .'] + + " Multiple VCS's: + let g:ctrlp_user_command = { + \ 'types': { + \ 1: ['.git', 'cd %s && git ls-files'], + \ 2: ['.hg', 'hg --cwd %s locate -I .'], + \ }, + \ 'fallback': 'find %s -type f' + \ } + + " Single VCS, listing command lists untracked files (slower): + let g:ctrlp_user_command = + \ ['.git', 'cd %s && git ls-files . -co --exclude-standard'] + + let g:ctrlp_user_command = + \ ['.hg', 'hg --cwd %s status -numac -I . $(hg root)'] " MacOSX/Linux + + let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') ' + \ . 'do hg --cwd %s status -numac -I . %%a'] " Windows +< +Note #1: if the fallback_command is empty or the 'fallback' key is not defined, +|globpath()| will then be used when scanning outside of a repository. + +Note #2: unless the |Dictionary| format is used and 'ignore' is defined and set +to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when +these custom commands are being used. When not present, 'ignore' is set to 0 by +default to retain the performance advantage of using external commands. + +Note #3: when changing the option's variable type, remember to |:unlet| it +first or restart Vim to avoid the "E706: Variable type mismatch" error. + +Note #4: you can use a |b:var| to set this option on a per buffer basis. + + *'g:ctrlp_max_history'* +The maximum number of input strings you want CtrlP to remember. The default +value mirrors Vim's global |'history'| option: > + let g:ctrlp_max_history = &history +< +Set to 0 to disable prompt's history. Browse the history with and . + + *'g:ctrlp_open_new_file'* +Use this option to specify how the newly created file is to be opened when +pressing : > + let g:ctrlp_open_new_file = 'v' +< + t - in a new tab. + h - in a new horizontal split. + v - in a new vertical split. + r - in the current window. + + *'g:ctrlp_open_multiple_files'* +If non-zero, this will enable opening multiple files with and : > + let g:ctrlp_open_multiple_files = 'v' +< +Example: > + let g:ctrlp_open_multiple_files = '2vjr' +< +For the number: + - If given, it'll be used as the maximum number of windows or tabs to create + when opening the files (the rest will be opened as hidden buffers). + - If not given, will open all files, each in a new window or new tab. + +For the letters: + t - each file in a new tab. + h - each file in a new horizontal split. + v - each file in a new vertical split. + i - all files as hidden buffers. + j - after opening, jump to the first opened tab or window. + r - open the first file in the current window, then the remaining files in + new splits or new tabs depending on which of "h", "v" and "t" is also + present. + + *'g:ctrlp_arg_map'* +When this is set to 1, the and mappings will accept one extra key +as an argument to override their default behavior: > + let g:ctrlp_arg_map = 0 +< +Pressing or will then prompt for a keypress. The key can be: + t - open in tab(s) + h - open in horizontal split(s) + v - open in vertical split(s) + i - open as hidden buffers (for only) + c - clear the marked files (for only) + r - open in the current window (for only) + , , - cancel and go back to the prompt. + - use the default behavior specified with |g:ctrlp_open_new_file| and + |g:ctrlp_open_multiple_files|. + + *'g:ctrlp_follow_symlinks'* +If non-zero, CtrlP will follow symbolic links when listing files: > + let g:ctrlp_follow_symlinks = 0 +< + 0 - don't follow symbolic links. + 1 - follow but ignore looped internal symlinks to avoid duplicates. + 2 - follow all symlinks indiscriminately. + +Note: does not apply when a command defined with |g:ctrlp_user_command| is +being used. + + *'g:ctrlp_lazy_update'* +Set this to 1 to enable the lazy-update feature: only update the match window +after typing's been stopped for a certain amount of time: > + let g:ctrlp_lazy_update = 0 +< +If is 1, update after 250ms. If bigger than 1, the number will be used as the +delay time in milliseconds. + + *'g:ctrlp_default_input'* +Set this to 1 to enable seeding the prompt with the current file's relative +path: > + let g:ctrlp_default_input = 0 +< +Instead of 1 or 0, if the value of the option is a string, it'll be used as-is +as the default input: > + let g:ctrlp_default_input = 'anystring' +< + + *'g:ctrlp_abbrev'* +Define input abbreviations that can be expanded (either internally or visibly) +in the prompt: > + let g:ctrlp_abbrev = {} +< +Examples: > + let g:ctrlp_abbrev = { + \ 'gmode': 'i', + \ 'abbrevs': [ + \ { + \ 'pattern': '^cd b', + \ 'expanded': '@cd ~/.vim/bundle', + \ 'mode': 'pfrz', + \ }, + \ { + \ 'pattern': '\(^@.\+\|\\\@ (use the expanded string in the + new filename). + c - only when auto-completing directory names with (expand the pattern + immediately before doing the auto-completion). + or not defined - always enable. + +Note: the abbrev entries are evaluated in sequence, so a later entry can be +evaluated against the expanded result of a previous entry; this includes itself +when 'gmode' is "t". + + *'g:ctrlp_key_loop'* +An experimental feature. Set this to 1 to enable input looping for the typing +of multi-byte characters: > + let g:ctrlp_key_loop = 0 +< +Note #1: when set, this option resets the |g:ctrlp_lazy_update| option. + +Note #2: you can toggle this feature inside the prompt with a custom mapping: > + let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': [''] } +< + + *'g:ctrlp_use_migemo'* +Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only +works in regexp mode. To split the pattern, separate words with space: > + let g:ctrlp_use_migemo = 0 +< + + *'g:ctrlp_prompt_mappings'* +Use this to customize the mappings inside CtrlP's prompt to your liking. You +only need to keep the lines that you've changed the values (inside []): > + let g:ctrlp_prompt_mappings = { + \ 'PrtBS()': ['', ''], + \ 'PrtDelete()': [''], + \ 'PrtDeleteWord()': [''], + \ 'PrtClear()': [''], + \ 'PrtSelectMove("j")': ['', ''], + \ 'PrtSelectMove("k")': ['', ''], + \ 'PrtSelectMove("t")': ['', ''], + \ 'PrtSelectMove("b")': ['', ''], + \ 'PrtSelectMove("u")': ['', ''], + \ 'PrtSelectMove("d")': ['', ''], + \ 'PrtHistory(-1)': [''], + \ 'PrtHistory(1)': [''], + \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'], + \ 'AcceptSelection("h")': ['', '', ''], + \ 'AcceptSelection("t")': [''], + \ 'AcceptSelection("v")': ['', ''], + \ 'ToggleFocus()': [''], + \ 'ToggleRegex()': [''], + \ 'ToggleByFname()': [''], + \ 'ToggleType(1)': ['', ''], + \ 'ToggleType(-1)': ['', ''], + \ 'PrtExpandDir()': [''], + \ 'PrtInsert("c")': ['', ''], + \ 'PrtInsert()': [''], + \ 'PrtCurStart()': [''], + \ 'PrtCurEnd()': [''], + \ 'PrtCurLeft()': ['', '', ''], + \ 'PrtCurRight()': ['', ''], + \ 'PrtClearCache()': [''], + \ 'PrtDeleteEnt()': [''], + \ 'CreateNewFile()': [''], + \ 'MarkToOpen()': [''], + \ 'OpenMulti()': [''], + \ 'PrtExit()': ['', '', ''], + \ } +< +Note: if pressing moves the cursor one character to the left instead of +deleting a character for you, add this to your |.vimrc| to disable the plugin's +default mapping: > + let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['', ''] } +< + +---------------------------------------- +MRU mode options:~ + + *'g:ctrlp_mruf_max'* +Specify the number of recently opened files you want CtrlP to remember: > + let g:ctrlp_mruf_max = 250 +< + + *'g:ctrlp_mruf_exclude'* +Files you don't want CtrlP to remember. Use regexp to specify the patterns: > + let g:ctrlp_mruf_exclude = '' +< +Examples: > + let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*' " MacOSX/Linux + let g:ctrlp_mruf_exclude = '^C:\\dev\\tmp\\.*' " Windows +< + + *'g:ctrlp_mruf_include'* +And if you want CtrlP to only remember some files, specify them here: > + let g:ctrlp_mruf_include = '' +< +Example: > + let g:ctrlp_mruf_include = '\.py$\|\.rb$' +< + + *'g:ctrlp_mruf_relative'* +Set this to 1 to show only MRU files in the current working directory: > + let g:ctrlp_mruf_relative = 0 +< + + *'g:ctrlp_mruf_default_order'* +Set this to 1 to disable sorting when searching in MRU mode: > + let g:ctrlp_mruf_default_order = 0 +< + + *'g:ctrlp_mruf_case_sensitive'* +Match this with your file system case-sensitivity setting to avoid duplicate +MRU entries: > + let g:ctrlp_mruf_case_sensitive = 1 +< + +---------------------------------------- +Advanced options:~ + + *'g:ctrlp_open_func'* +Define a custom function to open the selected file: > + let g:ctrlp_open_func = {} +< +Example: > + let g:ctrlp_open_func = { + \ 'files' : 'Function_Name_1', + \ 'buffers' : 'Function_Name_2', + \ 'mru files' : 'Function_Name_3', + \ } +< +Structure of the functions: > + function! Function_Name(action, line) + " Arguments: + " | + " +- a:action : The opening action: + " | + 'e' : user pressed (default) + " | + 'h' : user pressed (default) + " | + 'v' : user pressed (default) + " | + 't' : user pressed (default) + " | + 'x' : user used the console dialog (default) and + " | chose "e[x]ternal". + " | + " +- a:line : The selected line. + + endfunction +< +Note: does not apply when opening multiple files with and . + +Example: open HTML files in the default web browser when is pressed and +in Vim otherwise > + function! HTMLOpenFunc(action, line) + if a:action =~ '^[tx]$' && fnamemodify(a:line, ':e') =~? '^html\?$' + + " Get the filename + let filename = fnameescape(fnamemodify(a:line, ':p')) + + " Close CtrlP + call ctrlp#exit() + + " Open the file + silent! execute '!xdg-open' filename + + elseif a:action == 'x' && fnamemodify(a:line, ':e') !~? '^html\?$' + + " Not a HTML file, simulate pressing again and wait for new input + call feedkeys("\") + + else + + " Use CtrlP's default file opening function + call call('ctrlp#acceptfile', [a:action, a:line]) + + endif + endfunction + + let g:ctrlp_open_func = { 'files': 'HTMLOpenFunc' } +< + + *'g:ctrlp_status_func'* +Use this to customize the statuslines for the CtrlP window: > + let g:ctrlp_status_func = {} +< +Example: > + let g:ctrlp_status_func = { + \ 'main': 'Function_Name_1', + \ 'prog': 'Function_Name_2', + \ } +< +Structure of the functions: > + " Main statusline + function! Function_Name_1(focus, byfname, regex, prev, item, next, marked) + " Arguments: + " | + " +- a:focus : The focus of the prompt: "prt" or "win". + " | + " +- a:byfname : In filename mode or in full path mode: "file" or "path". + " | + " +- a:regex : In regex mode: 1 or 0. + " | + " +- a:prev : The previous search mode. + " | + " +- a:item : The current search mode. + " | + " +- a:next : The next search mode. + " | + " +- a:marked : The number of marked files, or a comma separated list of + " the marked filenames. + + return full_statusline + endfunction + + " Progress statusline + function! Function_Name_2(str) + " a:str : Either the number of files scanned so far, or a string indicating + " the current directory is being scanned with a user_command. + + return full_statusline + endfunction +< +See https://gist.github.com/1610859 for a working example. + + *'g:ctrlp_buffer_func'* +Specify the functions that will be called after entering and before exiting the +CtrlP buffer: > + let g:ctrlp_buffer_func = {} +< +Example: > + let g:ctrlp_buffer_func = { + \ 'enter': 'Function_Name_1', + \ 'exit': 'Function_Name_2', + \ } +< + + *'g:ctrlp_match_func'* +Set an external fuzzy matching function for CtrlP to use: > + let g:ctrlp_match_func = {} +< +Example: > + let g:ctrlp_match_func = { 'match': 'Function_Name' } +< +Structure of the function: > + function! Function_Name(items, str, limit, mmode, ispath, crfile, regex) + " Arguments: + " | + " +- a:items : The full list of items to search in. + " | + " +- a:str : The string entered by the user. + " | + " +- a:limit : The max height of the match window. Can be used to limit + " | the number of items to return. + " | + " +- a:mmode : The match mode. Can be one of these strings: + " | + "full-line": match the entire line. + " | + "filename-only": match only the filename. + " | + "first-non-tab": match until the first tab char. + " | + "until-last-tab": match until the last tab char. + " | + " +- a:ispath : Is 1 when searching in file, buffer, mru, mixed, dir, and + " | rtscript modes. Is 0 otherwise. + " | + " +- a:crfile : The file in the current window. Should be excluded from the + " | results when a:ispath == 1. + " | + " +- a:regex : In regex mode: 1 or 0. + + return list_of_matched_items + endfunction +< + +=============================================================================== +COMMANDS *ctrlp-commands* + + *:CtrlP* +:CtrlP [starting-directory] + Open CtrlP in find file mode. + + If no argument is given, the value of |g:ctrlp_working_path_mode| will be + used to determine the starting directory. + + You can use to auto-complete the [starting-directory] when typing it. + + *:CtrlPBuffer* +:CtrlPBuffer + Open CtrlP in find buffer mode. + + *:CtrlPMRU* +:CtrlPMRU + Open CtrlP in find Most-Recently-Used file mode. + + *:CtrlPLastMode* +:CtrlPLastMode [--dir] + Open CtrlP in the last mode used. When having the "--dir" argument, also + reuse the last working directory. + + *:CtrlPRoot* +:CtrlPRoot + This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 'r' and ignores + the variable's current value. + + *:CtrlPClearCache* +:CtrlPClearCache + Flush the cache for the current working directory. The same as pressing + inside CtrlP. + To enable or disable caching, use the |g:ctrlp_use_caching| option. + + *:CtrlPClearAllCaches* +:CtrlPClearAllCaches + Delete all the cache files saved in |g:ctrlp_cache_dir| location. + +------------------------------------------------------------------------------- +For commands provided by bundled extensions, see |ctrlp-extensions|. + +=============================================================================== +MAPPINGS *ctrlp-mappings* + + *'ctrlp-'* + + Default |Normal| mode mapping to open the CtrlP prompt in find file mode. + +---------------------------------------- +Once inside the prompt:~ + + + Toggle between full-path search and filename only search. + Note: in filename mode, the prompt's base is '>d>' instead of '>>>' + + *'ctrlp-fullregexp'* + Toggle between the string mode and full regexp mode. + Note: in full regexp mode, the prompt's base is 'r>>' instead of '>>>' + + See also: |input-formats| (guide) and |g:ctrlp_regexp_search| (option). + + , 'forward' + + Scroll to the 'next' search mode in the sequence. + + , 'backward' + + Scroll to the 'previous' search mode in the sequence. + + *'ctrlp-autocompletion'* + Auto-complete directory names under the current working directory inside + the prompt. + + + Toggle the focus between the match window and the prompt. + + , + + Exit CtrlP. + +Moving:~ + + , + + Move selection down. + + , + + Move selection up. + + + Move the cursor to the 'start' of the prompt. + + + Move the cursor to the 'end' of the prompt. + + , + , + + Move the cursor one character to the 'left'. + + , + + Move the cursor one character to the 'right'. + +Editing:~ + + , + + Delete the preceding character. + + + Delete the current character. + + + Delete a preceding inner word. + + + Clear the input field. + +Browsing input history:~ + + + Next string in the prompt's history. + + + Previous string in the prompt's history. + +Opening/Creating a file:~ + + + Open the selected file in the 'current' window if possible. + + + Open the selected file in a new 'tab'. + + + Open the selected file in a 'vertical' split. + + , + , + + Open the selected file in a 'horizontal' split. + + + Create a new file and its parent directories. + +Opening multiple files:~ + + + - Mark/unmark a file to be opened with . + - Mark/unmark a file to create a new file in its directory using . + + + - Open files marked by . + - When no file has been marked by , open a console dialog with the + following options: + + Open the selected file: + t - in a tab page. + v - in a vertical split. + h - in a horizontal split. + r - in the current window. + i - as a hidden buffer. + x - (optional) with the function defined in |g:ctrlp_open_func|. + + Other options (not shown): + a - mark all files in the match window. + d - change CtrlP's local working directory to the selected file's + directory and switch to find file mode. + +Function keys:~ + + + - Refresh the match window and purge the cache for the current directory. + - Remove deleted files from the MRU list. + + + - Wipe the MRU list. + - Delete MRU entries marked by . + +Pasting:~ + + , *'ctrlp-pasting'* + + Paste the clipboard content into the prompt. + + + Open a console dialog to paste , , the content of the search + register, the last visual selection, the clipboard or any register into the + prompt. + +Choose your own mappings with |g:ctrlp_prompt_mappings|. + +---------------------------------------- +When inside the match window (press to switch):~ + + a-z + 0-9 + ~^-=;`',.+!@#$%&_(){}[] + Cycle through the lines which have the matching first character. + +=============================================================================== +INPUT FORMATS *ctrlp-input-formats* + +Formats for inputting in the prompt:~ + +a) Simple string. + + E.g. 'abc' is understood internally as 'a[^a]\{-}b[^b]\{-}c' + +b) When in regexp mode, the input string's treated as a Vim's regexp |pattern| + without any modification. + + E.g. 'abc\d*efg' will be read as 'abc\d*efg'. + + See |ctrlp-fullregexp| (keymap) and |g:ctrlp_regexp_search| (option) for + how to enable regexp mode. + +c) End the string with a colon ':' followed by a Vim command to execute that + command after opening the file. If you need to use ':' literally, escape it + with a backslash: '\:'. When opening multiple files, the command will be + executed on each opening file. + + E.g. Use ':45' to jump to line 45. + + Use ':/any\:string' to jump to the first instance of 'any:string'. + + Use ':+setf\ myfiletype|50' to set the filetype to 'myfiletype', then + jump to line 50. + + Use ':diffthis' when opening multiple files to run |:diffthis| on the + first 4 files. + + See also: Vim's |++opt| and |+cmd|. + +d) Submit two dots '..' to go upward the directory tree by 1 level. To go up + multiple levels, use one extra dot for each extra level: +> + Raw input Interpreted as + .. ../ + ... ../../ + .... ../../../ +< + Note: if the parent directories are large and uncached, this can be slow. + + You can also use '@cd path/' to change CtrlP's local working directory. + Use '@cd %:h' to change to the directory of the current file. + +e) Similarly, submit '/' or '\' to find and go to the project's root. + + If the project is large, using a VCS listing command to look for files + might help speeding up the intial scan (see |g:ctrlp_user_command| for more + details). + + Note: d) and e) only work in file, directory and mixed modes. + +f) Type the name of a non-existent file and press to create it. Mark a + file with to create the new file in the same directory as the marked + file. + + E.g. Using 'newdir/newfile.txt' will create a directory named 'newdir' as + well as a file named 'newfile.txt'. + + If an entry 'some/old/dirs/oldfile.txt' is marked with , then + 'newdir' and 'newfile.txt' will be created under 'some/old/dirs'. The + final path will then be 'some/old/dirs/newdir/newfile.txt'. + + Note: use '\' in place of '/' on Windows (if |'shellslash'| is not set). + +g) In filename mode (toggle with ), you can use one primary pattern and + one refining pattern separated by a semicolon. Both patterns work like (a), + or (b) when in regexp mode. + +h) Submit ? to open this help file. + +=============================================================================== +EXTENSIONS *ctrlp-extensions* + +Extensions are optional. To enable an extension, add its name to the variable +g:ctrlp_extensions: > + let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript', + \ 'undo', 'line', 'changes', 'mixed', 'bookmarkdir'] +< +The order of the items will be the order they appear on the statusline and when +using , . + +Available extensions:~ + + *:CtrlPTag* + * Tag mode:~ + - Name: 'tag' + - Command: ":CtrlPTag" + - Search for a tag within a generated central tags file, and jump to the + definition. Use the Vim's option |'tags'| to specify the names and the + locations of the tags file(s). + E.g. set tags+=doc/tags + + *:CtrlPBufTag* + *:CtrlPBufTagAll* + * Buffer Tag mode:~ + - Name: 'buffertag' + - Commands: ":CtrlPBufTag [buffer]", + ":CtrlPBufTagAll". + - Search for a tag within the current buffer or all listed buffers and jump + to the definition. Requires |exuberant_ctags| or compatible programs. + + *:CtrlPQuickfix* + * Quickfix mode:~ + - Name: 'quickfix' + - Command: ":CtrlPQuickfix" + - Search for an entry in the current quickfix errors and jump to it. + + *:CtrlPDir* + * Directory mode:~ + - Name: 'dir' + - Command: ":CtrlPDir [starting-directory]" + - Search for a directory and change the working directory to it. + - Mappings: + + change the local working directory for CtrlP and keep it open. + + change the global working directory (exit). + + change the local working directory for the current window (exit). + + change the global working directory to CtrlP's current local + working directory (exit). + + *:CtrlPRTS* + * Runtime script mode:~ + - Name: 'rtscript' + - Command: ":CtrlPRTS" + - Search for files (vimscripts, docs, snippets...) in runtimepath. + + *:CtrlPUndo* + * Undo mode:~ + - Name: 'undo' + - Command: ":CtrlPUndo" + - Browse undo history. + + *:CtrlPLine* + * Line mode:~ + - Name: 'line' + - Command: ":CtrlPLine" + - Search for a line in all listed buffers. + + *:CtrlPChange* + *:CtrlPChangeAll* + * Change list mode:~ + - Name: 'changes' + - Commands: ":CtrlPChange [buffer]", + ":CtrlPChangeAll". + - Search for and jump to a recent change in the current buffer or in all + listed buffers. + + *:CtrlPMixed* + * Mixed mode:~ + - Name: 'mixed' + - Command: ":CtrlPMixed" + - Search in files, buffers and MRU files at the same time. + + *:CtrlPBookmarkDir* + *:CtrlPBookmarkDirAdd* + * BookmarkDir mode:~ + - Name: 'bookmarkdir' + - Commands: ":CtrlPBookmarkDir", + ":CtrlPBookmarkDirAdd [directory]". + - Search for a bookmarked directory and change the working directory to it. + - Mappings: + + change the local working directory for CtrlP, keep it open and + switch to find file mode. + + change the global working directory (exit). + + change the local working directory for the current window (exit). + + + - Wipe bookmark list. + - Delete entries marked by . + +---------------------------------------- +Buffer Tag mode options:~ + + *'g:ctrlp_buftag_ctags_bin'* +If ctags isn't in your $PATH, use this to set its location: > + let g:ctrlp_buftag_ctags_bin = '' +< + + *'g:ctrlp_buftag_systemenc'* +Match this with your OS's encoding (not Vim's). The default value mirrors Vim's +global |'encoding'| option: > + let g:ctrlp_buftag_systemenc = &encoding +< + + *'g:ctrlp_buftag_types'* +Use this to set the arguments for ctags, jsctags... for a given filetype: > + let g:ctrlp_buftag_types = '' +< +Examples: > + let g:ctrlp_buftag_types = { + \ 'erlang' : '--language-force=erlang --erlang-types=drmf', + \ 'javascript' : { + \ 'bin': 'jsctags', + \ 'args': '-f -', + \ }, + \ } +< + +=============================================================================== +CUSTOMIZATION *ctrlp-customization* + +Highlighting:~ + * For the CtrlP buffer: + CtrlPNoEntries : the message when no match is found (Error) + CtrlPMatch : the matched pattern (Identifier) + CtrlPLinePre : the line prefix '>' in the match window + CtrlPPrtBase : the prompt's base (Comment) + CtrlPPrtText : the prompt's text (|hl-Normal|) + CtrlPPrtCursor : the prompt's cursor when moving over the text (Constant) + + * In extensions: + CtrlPTabExtra : the part of each line that's not matched against (Comment) + CtrlPBufName : the buffer name an entry belongs to (|hl-Directory|) + CtrlPTagKind : the kind of the tag in buffer-tag mode (|hl-Title|) + CtrlPqfLineCol : the line and column numbers in quickfix mode (Comment) + CtrlPUndoT : the elapsed time in undo mode (|hl-Directory|) + CtrlPUndoBr : the square brackets [] in undo mode (Comment) + CtrlPUndoNr : the undo number inside [] in undo mode (String) + CtrlPUndoSv : the point where the file was saved (Comment) + CtrlPUndoPo : the current position in the undo tree (|hl-Title|) + CtrlPBookmark : the name of the bookmark (Identifier) + +Statuslines:~ + * Highlight groups: + CtrlPMode1 : 'file' or 'path', and the current mode (Character) + CtrlPMode2 : 'prt' or 'win', 'regex', the working directory (|hl-LineNr|) + CtrlPStats : the scanning status (Function) + + For rebuilding the statuslines, see |g:ctrlp_status_func|. + +=============================================================================== +MISCELLANEOUS CONFIGS *ctrlp-miscellaneous-configs* + +* Using |wildignore| for |g:ctrlp_user_command|: +> + function! s:wig2cmd() + " Change wildignore into space or | separated groups + " e.g. .aux .out .toc .jpg .bmp .gif + " or .aux$\|.out$\|.toc$\|.jpg$\|.bmp$\|.gif$ + let pats = ['[*\/]*\([?_.0-9A-Za-z]\+\)\([*\/]*\)\(\\\@) + +* A standalone function to set the working directory to the project's root, or + to the parent directory of the current file if a root can't be found: +> + function! s:setcwd() + let cph = expand('%:p:h', 1) + if cph =~ '^.\+://' | retu | en + for mkr in ['.git/', '.hg/', '.svn/', '.bzr/', '_darcs/', '.vimprojects'] + let wd = call('find'.(mkr =~ '/$' ? 'dir' : 'file'), [mkr, cph.';']) + if wd != '' | let &acd = 0 | brea | en + endfo + exe 'lc!' fnameescape(wd == '' ? cph : substitute(wd, mkr.'$', '.', '')) + endfunction + + autocmd BufEnter * call s:setcwd() +< +(requires Vim 7.1.299+) + +* Using a |count| to invoke different commands using the same mapping: +> + let g:ctrlp_cmd = 'exe "CtrlP".get(["", "Buffer", "MRU"], v:count)' +< + +=============================================================================== +CREDITS *ctrlp-credits* + +Developed by Kien Nguyen . + +Project's homepage: http://kien.github.com/ctrlp.vim +Git repository: https://github.com/kien/ctrlp.vim +Mercurial repository: https://bitbucket.org/kien/ctrlp.vim + +------------------------------------------------------------------------------- +Thanks to everyone that has submitted ideas, bug reports or helped debugging on +gibhub, bitbucket, and through email. + +Special thanks:~ + + * Woojong Koh + * Simon Ruderich + * Yasuhiro Matsumoto + * Ken Earley + * Kyo Nagashima + * Zak Johnson + * Diego Viola + * Piet Delport + * Thibault Duplessis + * Kent Sibilev + * Tacahiroy + * Luca Pette + * Seth Fowler + * Lowe Thiderman + * Christopher Fredén + * Zahary Karadjov + +=============================================================================== +CHANGELOG *ctrlp-changelog* + + + New options: |g:ctrlp_abbrev|, + |g:ctrlp_key_loop|, + |g:ctrlp_open_func|, + |g:ctrlp_tabpage_position| + + Rename: + *g:ctrlp_dotfiles* -> |g:ctrlp_show_hidden|. + + Change |g:ctrlp_switch_buffer|'s and |g:ctrlp_working_path_mode|'s type + (old values still work). + + New key for |g:ctrlp_user_command| when it's a Dictionary: 'ignore'. + +Before 2012/06/15~ + + + New value for |g:ctrlp_follow_symlinks|: 2. + + New value for |g:ctrlp_open_multiple_files|: 'j'. + + Allow using , , to open files marked by . + + Extend '..' (|ctrlp-input-formats| (d)) + + New input format: '@cd' (|ctrlp-input-formats| (d)) + +Before 2012/04/30~ + + + New option: |g:ctrlp_mruf_default_order| + + New feature: Bookmarked directories extension. + + New commands: |:CtrlPBookmarkDir| + |:CtrlPBookmarkDirAdd| + +Before 2012/04/15~ + + + New option: |g:ctrlp_buffer_func|, callback functions for CtrlP buffer. + + Remove: g:ctrlp_mruf_last_entered, make it a default for MRU mode. + + New commands: |:CtrlPLastMode|, open CtrlP in the last mode used. + |:CtrlPMixed|, search in files, buffers and MRU files. + +Before 2012/03/31~ + + + New options: |g:ctrlp_default_input|, default input when entering CtrlP. + |g:ctrlp_match_func|, allow using a custom fuzzy matcher. + + Rename: + *ClearCtrlPCache* -> |CtrlPClearCache| + *ClearAllCtrlPCaches* -> |CtrlPClearAllCaches| + *ResetCtrlP* -> |CtrlPReload| + +Before 2012/03/02~ + + + Rename: + *g:ctrlp_regexp_search* -> |g:ctrlp_regexp|, + *g:ctrlp_dont_split* -> |g:ctrlp_reuse_window|, + *g:ctrlp_jump_to_buffer* -> |g:ctrlp_switch_buffer|. + + Rename and tweak: + *g:ctrlp_open_multi* -> |g:ctrlp_open_multiple_files|. + + Deprecate *g:ctrlp_highlight_match* + + Extend |g:ctrlp_user_command| to support multiple commands. + + New option: |g:ctrlp_mruf_last_entered| change MRU to Recently-Entered. + +Before 2012/01/15~ + + + New mapping: Switch and . is now used for completion + of directory names under the current working directory. + + New options: |g:ctrlp_arg_map| for , to accept an argument. + |g:ctrlp_status_func| custom statusline. + |g:ctrlp_mruf_relative| show only MRU files inside cwd. + + Extend g:ctrlp_open_multi with new optional values: tr, hr, vr. + + Extend |g:ctrlp_custom_ignore| to specifically filter dir, file and link. + +Before 2012/01/05~ + + + New feature: Buffer Tag extension. + + New commands: |:CtrlPBufTag|, |:CtrlPBufTagAll|. + + New options: |g:ctrlp_cmd|, + |g:ctrlp_custom_ignore| + +Before 2011/11/30~ + + + New features: Tag, Quickfix and Directory extensions. + + New commands: |:CtrlPTag|, |:CtrlPQuickfix|, |:CtrlPDir|. + + New options: |g:ctrlp_use_migemo|, + |g:ctrlp_lazy_update|, + |g:ctrlp_follow_symlinks| + +Before 2011/11/13~ + + + New special input: '/' and '\' find root (|ctrlp-input-formats| (e)) + + Remove ctrlp#SetWorkingPath(). + + Remove *g:ctrlp_mru_files* and make MRU mode permanent. + + Extend g:ctrlp_open_multi, add new ways to open files. + + New option: g:ctrlp_dont_split, + |g:ctrlp_mruf_case_sensitive| + +Before 2011/10/30~ + + + New feature: Support for custom extensions. + also removes non-existent files from MRU list. + + New option: g:ctrlp_jump_to_buffer + +Before 2011/10/12~ + + + New features: Open multiple files. + Pass Vim's |++opt| and |+cmd| to the opening file + (|ctrlp-input-formats| (c)) + Auto-complete each dir for |:CtrlP| [starting-directory] + + New mappings: mark/unmark a file to be opened with . + open all marked files. + + New option: g:ctrlp_open_multi + + Remove *g:ctrlp_persistent_input* *g:ctrlp_live_update* and . + +Before 2011/09/29~ + + + New mappings: , next/prev string in the input history. + create a new file and its parent dirs. + + New options: |g:ctrlp_open_new_file|, + |g:ctrlp_max_history| + + Added a new open-in-horizontal-split mapping: + +Before 2011/09/19~ + + + New command: ResetCtrlP + + New options: |g:ctrlp_max_files|, + |g:ctrlp_max_depth|, + g:ctrlp_live_update + + New mapping: + +Before 2011/09/12~ + + + Ability to cycle through matched lines in the match window. + + Extend the behavior of g:ctrlp_persistent_input + + Extend the behavior of |:CtrlP| + + New options: |g:ctrlp_dotfiles|, + |g:ctrlp_clear_cache_on_exit|, + g:ctrlp_highlight_match, + |g:ctrlp_user_command| + + New special input: '..' (|ctrlp-input-formats| (d)) + + New mapping: . + + New commands: |:CtrlPCurWD|, + |:CtrlPCurFile|, + |:CtrlPRoot| + + + New feature: Search in most recently used (MRU) files + + New mapping: . + + Extended the behavior of . + + New options: g:ctrlp_mru_files, + |g:ctrlp_mruf_max|, + |g:ctrlp_mruf_exclude|, + |g:ctrlp_mruf_include| + + New command: |:CtrlPMRU| + +First public release: 2011/09/06~ + +=============================================================================== +vim:ft=help:et:ts=2:sw=2:sts=2:norl diff --git a/vim/bundle/cctrlp.vim/plugin/ctrlp.vim b/vim/bundle/cctrlp.vim/plugin/ctrlp.vim new file mode 100644 index 0000000..68cae86 --- /dev/null +++ b/vim/bundle/cctrlp.vim/plugin/ctrlp.vim @@ -0,0 +1,69 @@ +" ============================================================================= +" File: plugin/ctrlp.vim +" Description: Fuzzy file, buffer, mru, tag, etc finder. +" Author: Kien Nguyen +" ============================================================================= +" GetLatestVimScripts: 3736 1 :AutoInstall: ctrlp.zip + +if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp + fini +en +let g:loaded_ctrlp = 1 + +let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs, + \ g:ctrlp_allmixes, g:ctrlp_buftags, g:ctrlp_ext_vars, g:ctrlp_builtins] + \ = [[], [], [], [], {}, {}, [], 2] + +if !exists('g:ctrlp_map') | let g:ctrlp_map = '' | en +if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en + +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlP + \ cal ctrlp#init(0, { 'dir': }) + +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPMRUFiles + \ cal ctrlp#init(2, { 'dir': }) + +com! -bar CtrlPBuffer cal ctrlp#init(1) +com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': }) + +com! -bar CtrlPClearCache cal ctrlp#clr() +com! -bar CtrlPClearAllCaches cal ctrlp#clra() + +com! -bar ClearCtrlPCache cal ctrlp#clr() +com! -bar ClearAllCtrlPCaches cal ctrlp#clra() + +com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' }) +com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' }) +com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' }) + +if g:ctrlp_map != '' && !hasmapto(':'.g:ctrlp_cmd.'', 'n') + exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.'' +en + +cal ctrlp#mrufiles#init() + +com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id()) +com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id()) + +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPDir + \ cal ctrlp#init(ctrlp#dir#id(), { 'dir': }) + +com! -n=? -com=buffer CtrlPBufTag + \ cal ctrlp#init(ctrlp#buffertag#cmd(0, )) + +com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1)) +com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id()) +com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id()) +com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id()) + +com! -n=? -com=buffer CtrlPChange + \ cal ctrlp#init(ctrlp#changes#cmd(0, )) + +com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1)) +com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id()) +com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id()) + +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPBookmarkDirAdd + \ cal ctrlp#call('ctrlp#bookmarkdir#add', ) + +" vim:ts=2:sw=2:sts=2 diff --git a/vim/bundle/cctrlp.vim/readme.md b/vim/bundle/cctrlp.vim/readme.md new file mode 100644 index 0000000..2525b83 --- /dev/null +++ b/vim/bundle/cctrlp.vim/readme.md @@ -0,0 +1,86 @@ +# ctrlp.vim +Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim. + +* Written in pure Vimscript for MacVim, gVim and Vim 7.0+. +* Full support for Vim's regexp as search patterns. +* Built-in Most Recently Used (MRU) files monitoring. +* Built-in project's root finder. +* Open multiple files at once. +* Create new files and directories. +* [Extensible][2]. + +![ctrlp][1] + +## Basic Usage +* Run `:CtrlP` or `:CtrlP [starting-directory]` to invoke CtrlP in find file mode. +* Run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in find buffer or find MRU file mode. +* Run `:CtrlPMixed` to search in Files, Buffers and MRU files at the same time. + +Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands. + +##### Once CtrlP is open: +* Press `` to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options. +* Press `` and `` to cycle between modes. +* Press `` to switch to filename only search instead of full path. +* Press `` to switch to regexp mode. +* Use ``, `` to select the next/previous string in the prompt's history. +* Use `` to create a new file and its parent directories. +* Use `` to mark/unmark multiple files and `` to open them. + +Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help. + +* Submit two or more dots `..` to go up the directory tree by one or multiple levels. +* End the input string with a colon `:` followed by a command to execute it on the opening file(s): +Use `:25` to jump to line 25. +Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files. + +## Basic Options +* Change the default mapping and the default command to invoke CtrlP: + + ```vim + let g:ctrlp_map = '' + let g:ctrlp_cmd = 'CtrlP' + ``` + +* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable: + + ```vim + let g:ctrlp_working_path_mode = 'ra' + ``` + + `'c'` - the directory of the current file. + `'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs` + `'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file. + `0` or `''` (empty string) - disable this feature. + + Define additional root markers with the `g:ctrlp_root_markers` option. + +* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`: + + ```vim + set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux + set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows + + let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' + let g:ctrlp_custom_ignore = { + \ 'dir': '\v[\/]\.(git|hg|svn)$', + \ 'file': '\v\.(exe|so|dll)$', + \ 'link': 'some_bad_symbolic_links', + \ } + ``` + +* Use a custom file listing command: + + ```vim + let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux + let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows + ``` + +Check `:help ctrlp-options` for other options. + +## Installation +Use your favorite method or check the homepage for a [quick installation guide][3]. + +[1]: http://i.imgur.com/yIynr.png +[2]: https://github.com/kien/ctrlp.vim/tree/extensions +[3]: http://kien.github.com/ctrlp.vim#installation diff --git a/vim/bundle/gist-vim/Makefile b/vim/bundle/gist-vim/Makefile new file mode 100644 index 0000000..81370a8 --- /dev/null +++ b/vim/bundle/gist-vim/Makefile @@ -0,0 +1,11 @@ +all : gist-vim.zip + +remove-zip: + -rm -f doc/tags + -rm -f gist-vim.zip + +gist-vim.zip: remove-zip + zip -r gist-vim.zip autoload plugin doc README.mkd + +release: gist-vim.zip + vimup update-script gist.vim diff --git a/vim/bundle/gist-vim/README.mkd b/vim/bundle/gist-vim/README.mkd new file mode 100644 index 0000000..d87b02f --- /dev/null +++ b/vim/bundle/gist-vim/README.mkd @@ -0,0 +1,224 @@ +### Gist.vim + +This is a vimscript for creating gists (http://gist.github.com). + +For the latest version please see https://github.com/mattn/gist-vim. + +## Usage: + +- Post current buffer to gist, using default privacy option. + + :Gist + +- Post selected text to gist, using default privacy option. + This applies to all permutations listed below (except multi). + + :'<,'>Gist + +- Create a private gist. + + :Gist -p + +- Create a public gist. + (Only relevant if you've set gists to be private by default.) + + :Gist -P + +> This is only relevant if you've set gists to be private by default; +> if you get an empty gist list, try ":Gist --abandon". + +- Create a gist anonymously. + + :Gist -a + +- Create a gist with all open buffers. + + :Gist -m + +- Edit the gist (you need to have opened the gist buffer first). + You can update the gist with the ":w" command within the gist buffer. + + :Gist -e + +- Edit the gist with name 'foo.js' (you need to have opened the gist buffer + first). + + :Gist -e foo.js + +- Post/Edit with the description " (you need to have opened the gist buffer + first). > + + :Gist -s something + :Gist -e -s something + +- Delete the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -d + +- Fork the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -f + +- Star the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist +1 + +- Unstar the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -1 + +- Get gist XXXXX. + + :Gist XXXXX + +- Get gist XXXXX and add to clipboard. + + :Gist -c XXXXX + +- List your public gists. + + :Gist -l + +- List gists from user "mattn". + + :Gist -l mattn + +- List everyone's gists. + + :Gist -la + +- List gists from your starred gists. + + :Gist -ls + +## Tips: + +If you set g:gist_clip_command, gist.vim will copy the gist code with option +'-c'. + +- Mac: + + let g:gist_clip_command = 'pbcopy' + +- Linux: + + let g:gist_clip_command = 'xclip -selection clipboard' + +- Others (cygwin?): + + let g:gist_clip_command = 'putclip' + +If you want to detect filetype from the filename: + + let g:gist_detect_filetype = 1 + +If you want to open browser after the post: + + let g:gist_open_browser_after_post = 1 + +If you want to change the browser: + + let g:gist_browser_command = 'w3m %URL%' + +or: + + let g:gist_browser_command = 'opera %URL% &' + +On windows, this should work with your user settings. + +If you want to show your private gists with ":Gist -l": + + let g:gist_show_privates = 1 + +If you want your gist to be private by default: + + let g:gist_post_private = 1 + +If you want to manipulate multiple files in a gist: + + let g:gist_get_multiplefile = 1 + +If you want to use on Github Enterprise: + + let g:github_api_url = 'http://your-github-enterprise-domain/api/v3' + +You need to either set global git config: + + $ git config --global github.user Username + +## License: + + Copyright 2010 by Yasuhiro Matsumoto + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``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 + REGENTS OR CONTRIBUTORS 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. + + +## Install: + +Copy it to your plugin directory. +gist.vim will create a curl cookie-jar file in your runtimepath. + +- rtp: + - autoload/gist.vim + - plugin/gist.vim + +If you want to uninstall gist.vim, remember to also remove `~/.gist-vim`. + +You need to install webapi-vim also: + + http://www.vim.org/scripts/script.php?script_id=4019 + +If you want to use latest one: + + https://github.com/mattn/webapi-vim + +### Install with [Vundle](https://github.com/gmarik/vundle) + +Add the following lines to your `.vimrc`. + + Bundle 'mattn/webapi-vim' + Bundle 'mattn/gist-vim' + +Now restart Vim and run `:BundleInstall`. + +## Requirements: + +- curl command (http://curl.haxx.se/) +- webapi-vim (https://github.com/mattn/webapi-vim) +- and if you want to use your git profile, the git command-line client. + +## Setup: + +This plugin uses github API v3. Setting value is stored in `~/.gist-vim`. +gist-vim have two ways to access APIs. + +First, you need to set your Github username in global git config: + + $ git config --global github.user Username + +Then, gist.vim will ask for your password to create an authorization when you +first use it. The password is not stored and only the OAuth access token will +be kept for later use. You can revoke the token at any time from the list of +["Authorized applications" on Github's "Account Settings" page](https://github.com/settings/applications). diff --git a/vim/bundle/gist-vim/autoload/gist.vim b/vim/bundle/gist-vim/autoload/gist.vim new file mode 100644 index 0000000..97ab18a --- /dev/null +++ b/vim/bundle/gist-vim/autoload/gist.vim @@ -0,0 +1,919 @@ +"============================================================================= +" File: gist.vim +" Author: Yasuhiro Matsumoto +" Last Change: 21-Jan-2013. +" Version: 7.1 +" WebPage: http://github.com/mattn/gist-vim +" License: BSD + +let s:save_cpo = &cpo +set cpo&vim + +if !exists('g:github_user') && !executable('git') + echohl ErrorMsg | echomsg "Gist: require 'git' command" | echohl None + finish +endif + +if !executable('curl') + echohl ErrorMsg | echomsg "Gist: require 'curl' command" | echohl None + finish +endif + +let s:configfile = expand('~/.gist-vim') + +if !exists('g:github_user') + let s:system = function(get(g:, 'webapi#system_function', 'system')) + let g:github_user = substitute(s:system('git config --get github.user'), "\n", '', '') + if strlen(g:github_user) == 0 + let g:github_user = $GITHUB_USER + end +endif + +if !exists('g:github_api_url') + let g:github_api_url = 'https://api.github.com' +endif + +if !exists('g:gist_update_on_write') + let g:gist_update_on_write = 1 +endif + +function! s:get_browser_command() + let gist_browser_command = get(g:, 'gist_browser_command', '') + if gist_browser_command == '' + if has('win32') || has('win64') + let gist_browser_command = '!start rundll32 url.dll,FileProtocolHandler %URL%' + elseif has('mac') || has('macunix') || has('gui_macvim') || system('uname') =~? '^darwin' + let gist_browser_command = 'open %URL%' + elseif executable('xdg-open') + let gist_browser_command = 'xdg-open %URL%' + elseif executable('firefox') + let gist_browser_command = 'firefox %URL% &' + else + let gist_browser_command = '' + endif + endif + return gist_browser_command +endfunction + +function! s:open_browser(url) + let cmd = s:get_browser_command() + if len(cmd) == 0 + redraw + echohl WarningMsg + echo "It seems that you don't have general web browser. Open URL below." + echohl None + echo a:url + return + endif + if cmd =~ '^!' + let cmd = substitute(cmd, '%URL%', '\=shellescape(a:url)', 'g') + silent! exec cmd + elseif cmd =~ '^:[A-Z]' + let cmd = substitute(cmd, '%URL%', '\=a:url', 'g') + exec cmd + else + let cmd = substitute(cmd, '%URL%', '\=shellescape(a:url)', 'g') + call system(cmd) + endif +endfunction + +function! s:shellwords(str) + let words = split(a:str, '\%(\([^ \t\''"]\+\)\|''\([^\'']*\)''\|"\(\%([^\"\\]\|\\.\)*\)"\)\zs\s*\ze') + let words = map(words, 'substitute(v:val, ''\\\([\\ ]\)'', ''\1'', "g")') + let words = map(words, 'matchstr(v:val, ''^\%\("\zs\(.*\)\ze"\|''''\zs\(.*\)\ze''''\|.*\)$'')') + return words +endfunction + +function! s:format_gist(gist) + let files = sort(keys(a:gist.files)) + if empty(files) + return "" + endif + let file = a:gist.files[files[0]] + if has_key(file, "content") + let code = file.content + let code = "\n".join(map(split(code, "\n"), '" ".v:val'), "\n") + else + let code = "" + endif + return printf("gist: %s %s%s", a:gist.id, type(a:gist.description)==0?"": a:gist.description, code) +endfunction + +" Note: A colon in the file name has side effects on Windows due to NTFS Alternate Data Streams; avoid it. +let s:bufprefix = 'gist' . (has('unix') ? ':' : '_') +function! s:GistList(gistls, page) + if a:gistls == '-all' + let url = g:github_api_url.'/gists/public' + elseif get(g:, 'gist_show_privates', 0) && a:gistls == 'starred' + let url = g:github_api_url.'/gists/starred' + elseif get(g:, 'gist_show_privates') && a:gistls == 'mine' + let url = g:github_api_url.'/gists' + else + let url = g:github_api_url.'/users/'.a:gistls.'/gists' + endif + let winnum = bufwinnr(bufnr(s:bufprefix.a:gistls)) + if winnum != -1 + if winnum != bufwinnr('%') + exe winnum 'wincmd w' + endif + setlocal modifiable + else + exec 'silent noautocmd split' s:bufprefix.a:gistls + endif + if a:page > 1 + let oldlines = getline(0, line('$')) + let url = url . '?page=' . a:page + endif + + setlocal modifiable + let old_undolevels = &undolevels + let oldlines = [] + silent %d _ + + redraw | echon 'Listing gists... ' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + bw! + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let res = webapi#http#get(url, '', { "Authorization": auth }) + if v:shell_error != 0 + bw! + redraw + echohl ErrorMsg | echomsg 'Gists not found' | echohl None + return + endif + let content = webapi#json#decode(res.content) + if type(content) == 4 && has_key(content, 'message') && len(content.message) + bw! + redraw + echohl ErrorMsg | echomsg content.message | echohl None + if content.message == 'Bad credentials' + call delete(s:configfile) + endif + return + endif + + let lines = map(filter(content, '!empty(v:val.files)'), 's:format_gist(v:val)') + call setline(1, split(join(lines, "\n"), "\n")) + + $put='more...' + + let b:gistls = a:gistls + let b:page = a:page + setlocal buftype=nofile bufhidden=hide noswapfile + setlocal nomodified + setlocal nomodifiable + syntax match SpecialKey /^gist:/he=e-1 + nnoremap :call GistListAction(0) + nnoremap :call GistListAction(1) + + cal cursor(1+len(oldlines),1) + nohlsearch + redraw | echo '' +endfunction + +function! gist#list(user, ...) + let page = get(a:000, 0, 0) + if a:user == '-all' + let url = g:github_api_url.'/gists/public' + elseif get(g:, 'gist_show_privates', 0) && a:user == 'starred' + let url = g:github_api_url.'/gists/starred' + elseif get(g:, 'gist_show_privates') && a:user == 'mine' + let url = g:github_api_url.'/gists' + else + let url = g:github_api_url.'/users/'.a:user.'/gists' + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return [] + endif + let res = webapi#http#get(url, '', { "Authorization": auth }) + return webapi#json#decode(res.content) +endfunction + +function! s:GistGetFileName(gistid) + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return '' + endif + let res = webapi#http#get(g:github_api_url.'/gists/'.a:gistid, '', { "Authorization": auth }) + let gist = webapi#json#decode(res.content) + if has_key(gist, 'files') + return sort(keys(gist.files))[0] + endif + return '' +endfunction + +function! s:GistDetectFiletype(gistid) + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return '' + endif + let res = webapi#http#get(g:github_api_url.'/gists/'.a:gistid, '', { "Authorization": auth }) + let gist = webapi#json#decode(res.content) + let filename = sort(keys(gist.files))[0] + let ext = fnamemodify(filename, ':e') + if has_key(s:extmap, ext) + let type = s:extmap[ext] + else + let type = get(gist.files[filename], "type", "text") + endif + silent! exec "setlocal ft=".tolower(type) +endfunction + +function! s:GistWrite(fname) + if substitute(a:fname, '\\', '/', 'g') == expand("%:p:gs@\\@/@") + if g:gist_update_on_write != 2 || v:cmdbang + Gist -e + else + echohl ErrorMsg | echomsg 'Please type ":w!" to update a gist.' | echohl None + endif + else + exe "w".(v:cmdbang ? "!" : "") fnameescape(v:cmdarg) fnameescape(a:fname) + silent! exe "file" fnameescape(a:fname) + silent! au! BufWriteCmd + endif +endfunction + +function! s:GistGet(gistid, clipboard) + redraw | echon 'Getting gist... ' + let res = webapi#http#get(g:github_api_url.'/gists/'.a:gistid, '', { "Authorization": s:GistGetAuthHeader() }) + let status = matchstr(matchstr(res.header, '^Status:'), '^[^:]\+: \zs.*') + if status =~ '^2' + let gist = webapi#json#decode(res.content) + if get(g:, 'gist_get_multiplefile', 0) != 0 + let num_file = len(keys(gist.files)) + else + let num_file = 1 + endif + redraw + if num_file > len(keys(gist.files)) + echohl ErrorMsg | echomsg 'Gist not found' | echohl None + return + endif + for n in range(num_file) + try + let old_undolevels = &undolevels + let filename = sort(keys(gist.files))[n] + + let winnum = bufwinnr(bufnr(s:bufprefix.a:gistid."/".filename)) + if winnum != -1 + if winnum != bufwinnr('%') + exe winnum 'wincmd w' + endif + setlocal modifiable + else + exec 'silent noautocmd new' + setlocal noswapfile + exec 'noautocmd file' s:bufprefix.a:gistid."/".fnameescape(filename) + endif + set undolevels=-1 + filetype detect + silent %d _ + + let content = gist.files[filename].content + call setline(1, split(content, "\n")) + let b:gist = { + \ "filename": filename, + \ "id": gist.id, + \ "description": gist.description, + \ "private": gist.public =~ 'true', + \} + catch + let &undolevels = old_undolevels + bw! + redraw + echohl ErrorMsg | echomsg 'Gist contains binary' | echohl None + return + endtry + let &undolevels = old_undolevels + setlocal buftype=acwrite bufhidden=delete noswapfile + setlocal nomodified + doau StdinReadPost,BufRead,BufReadPost + let gist_detect_filetype = get(g:, 'gist_detect_filetype', 0) + if (&ft == '' && gist_detect_filetype == 1) || gist_detect_filetype == 2 + call s:GistDetectFiletype(a:gistid) + endif + if a:clipboard + if exists('g:gist_clip_command') + exec 'silent w !'.g:gist_clip_command + elseif has('clipboard') + silent! %yank + + else + %yank + endif + endif + 1 + au! BufWriteCmd call s:GistWrite(expand("")) + endfor + else + bw! + redraw + echohl ErrorMsg | echomsg 'Gist not found' | echohl None + return + endif +endfunction + +function! s:GistListAction(shift) + let line = getline('.') + let mx = '^gist:\s*\zs\(\w\+\)\ze.*' + if line =~# mx + let gistid = matchstr(line, mx) + if a:shift + call s:open_browser("https://gist.github.com/" . gistid) + else + call s:GistGet(gistid, 0) + endif + return + endif + if line =~# '^more\.\.\.$' + call s:GistList(b:gistls, b:page+1) + return + endif +endfunction + +function! s:GistUpdate(content, gistid, gistnm, desc) + let gist = { "id": a:gistid, "files" : {}, "description": "","public": function('webapi#json#true') } + if exists('b:gist') + if has_key(b:gist, 'private') && b:gist.private | let gist["public"] = function('webapi#json#false') | endif + if has_key(b:gist, 'description') | let gist["description"] = b:gist.description | endif + if has_key(b:gist, 'filename') | let filename = b:gist.filename | endif + else + let filename = a:gistnm + if len(filename) == 0 | let filename = s:GistGetFileName(a:gistid) | endif + if len(filename) == 0 | let filename = s:get_current_filename(1) | endif + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + + " Update description + " If no new description specified, keep the old description + if a:desc != ' ' + let gist["description"] = a:desc + else + let res = webapi#http#get(g:github_api_url.'/gists/'.a:gistid, '', { "Authorization": auth }) + let status = matchstr(matchstr(res.header, '^Status:'), '^[^:]\+: \zs.*') + if status =~ '^2' + let old_gist = webapi#json#decode(res.content) + let gist["description"] = old_gist.description + endif + endif + + let gist.files[filename] = { "content": a:content, "filename": filename } + + redraw | echon 'Updating gist... ' + let res = webapi#http#post(g:github_api_url.'/gists/' . a:gistid, + \ webapi#json#encode(gist), { + \ "Authorization": auth, + \ "Content-Type": "application/json", + \}) + let status = matchstr(matchstr(res.header, '^Status:'), '^[^:]\+: \zs.*') + if status =~ '^2' + let obj = webapi#json#decode(res.content) + let loc = obj["html_url"] + redraw | echomsg 'Done: '.loc + let b:gist = {"id": a:gistid, "filename": filename} + setlocal nomodified + else + let loc = '' + let status = matchstr(status, '^\d\+\s*\zs.*') + echohl ErrorMsg | echomsg 'Post failed: '.status | echohl None + endif + return loc +endfunction + +function! s:GistDelete(gistid) + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + + redraw | echon 'Deleting gist... ' + let res = webapi#http#post(g:github_api_url.'/gists/'.a:gistid, '', { + \ "Authorization": auth, + \ "Content-Type": "application/json", + \}, 'DELETE') + let status = matchstr(matchstr(res.header, '^Status:'), '^[^:]\+: \zs.*') + if status =~ '^2' + redraw | echomsg 'Done: ' + if exists('b:gist') + unlet b:gist + endif + else + let status = matchstr(status, '^\d\+\s*\zs.*') + echohl ErrorMsg | echomsg 'Delete failed: '.status | echohl None + endif +endfunction + +function! s:get_current_filename(no) + let filename = expand('%:t') + if len(filename) == 0 && &ft != '' + let pair = filter(items(s:extmap), 'v:val[1] == &ft') + if len(pair) > 0 + let filename = printf('gistfile%d%s', a:no, pair[0][0]) + endif + endif + if filename == '' + let filename = printf('gistfile%d.txt', a:no) + endif + return filename +endfunction + +" GistPost function: +" Post new gist to github +" +" if there is an embedded gist url or gist id in your file, +" it will just update it. +" -- by c9s +" +" embedded gist url format: +" +" Gist: https://gist.github.com/123123 +" +" embedded gist id format: +" +" GistID: 123123 +" +function! s:GistPost(content, private, desc, anonymous) + let gist = { "files" : {}, "description": "","public": function('webapi#json#true') } + if a:desc != ' ' | let gist["description"] = a:desc | endif + if a:private | let gist["public"] = function('webapi#json#false') | endif + let filename = s:get_current_filename(1) + let gist.files[filename] = { "content": a:content, "filename": filename } + + let header = {"Content-Type": "application/json"} + if !a:anonymous + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let header["Authorization"] = auth + endif + + redraw | echon 'Posting it to gist... ' + let res = webapi#http#post(g:github_api_url.'/gists', webapi#json#encode(gist), header) + let status = matchstr(matchstr(res.header, '^Status:'), '^[^:]\+: \zs.*') + if status =~ '^2' + let obj = webapi#json#decode(res.content) + let loc = obj["html_url"] + redraw | echomsg 'Done: '.loc + let b:gist = { + \ "filename": filename, + \ "id": matchstr(loc, '[^/]\+$'), + \ "description": gist['description'], + \ "private": a:private, + \} + else + let loc = '' + let status = matchstr(status, '^\d\+\s*\zs.*') + echohl ErrorMsg | echomsg 'Post failed: '.status | echohl None + endif + return loc +endfunction + +function! s:GistPostBuffers(private, desc, anonymous) + let bufnrs = range(1, bufnr("$")) + let bn = bufnr('%') + let query = [] + + let gist = { "files" : {}, "description": "","public": function('webapi#json#true') } + if a:desc != ' ' | let gist["description"] = a:desc | endif + if a:private | let gist["public"] = function('webapi#json#false') | endif + + let index = 1 + for bufnr in bufnrs + if !bufexists(bufnr) || buflisted(bufnr) == 0 + continue + endif + echo "Creating gist content".index."... " + silent! exec "buffer!" bufnr + let content = join(getline(1, line('$')), "\n") + let filename = s:get_current_filename(index) + let gist.files[filename] = { "content": content, "filename": filename } + let index = index + 1 + endfor + silent! exec "buffer!" bn + + let header = {"Content-Type": "application/json"} + if !a:anonymous + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let header["Authorization"] = auth + endif + + redraw | echon 'Posting it to gist... ' + let res = webapi#http#post(g:github_api_url.'/gists', webapi#json#encode(gist), header) + let status = matchstr(matchstr(res.header, '^Status:'), '^[^:]\+: \zs.*') + if status =~ '^2' + let obj = webapi#json#decode(res.content) + let loc = obj["html_url"] + redraw | echomsg 'Done: '.loc + let b:gist = {"id": matchstr(loc, '[^/]\+$'), "filename": filename, "private": a:private} + else + let loc = '' + let status = matchstr(status, '^\d\+\s*\zs.*') + echohl ErrorMsg | echomsg 'Post failed: '.status | echohl None + endif + return loc +endfunction + +function! gist#Gist(count, line1, line2, ...) + redraw + if strlen(g:github_user) == 0 + echohl ErrorMsg | echomsg "You don't have github account. read ':help gist-vim-setup'." | echohl None + return + endif + let bufname = bufname("%") + " find GistID: in content , then we should just update + let gistid = '' + let gistls = '' + let gistnm = '' + let gistdesc = ' ' + let private = get(g:, 'gist_post_private', 0) + let multibuffer = 0 + let clipboard = 0 + let deletepost = 0 + let editpost = 0 + let anonymous = 0 + let listmx = '^\%(-l\|--list\)\s*\([^\s]\+\)\?$' + let bufnamemx = '^' . s:bufprefix .'\(\zs[0-9a-f]\+\ze\|\zs[0-9a-f]\+\ze[/\\].*\)$' + if bufname =~ bufnamemx + let gistidbuf = matchstr(bufname, bufnamemx) + else + let gistidbuf = matchstr(join(getline(a:line1, a:line2), "\n"), 'GistID:\s*\zs\w\+') + endif + + let args = (a:0 > 0) ? s:shellwords(a:1) : [] + for arg in args + if arg =~ '^\(-h\|--help\)$\C' + help :Gist + return + elseif arg =~ '^\(-la\|--listall\)$\C' + let gistls = '-all' + elseif arg =~ '^\(-ls\|--liststar\)$\C' + let gistls = 'starred' + elseif arg =~ '^\(-l\|--list\)$\C' + if get(g:, 'gist_show_privates') + let gistls = 'mine' + else + let gistls = g:github_user + endif + elseif arg =~ '^\(-m\|--multibuffer\)$\C' + let multibuffer = 1 + elseif arg =~ '^\(-p\|--private\)$\C' + let private = 1 + elseif arg =~ '^\(-P\|--public\)$\C' + let private = 0 + elseif arg =~ '^\(-a\|--anonymous\)$\C' + let anonymous = 1 + elseif arg =~ '^\(-s\|--description\)$\C' + let gistdesc = '' + elseif arg =~ '^\(-c\|--clipboard\)$\C' + let clipboard = 1 + elseif arg =~ '^--rawurl$\C' && gistidbuf != '' && g:github_api_url == 'https://api.github.com' + let gistid = gistidbuf + echo 'https://gist.github.com/raw/'.gistid + return + elseif arg =~ '^\(-d\|--delete\)$\C' && gistidbuf != '' + let gistid = gistidbuf + let deletepost = 1 + elseif arg =~ '^\(-e\|--edit\)$\C' && gistidbuf != '' + let gistid = gistidbuf + let editpost = 1 + elseif arg =~ '^\(+1\|--star\)$\C' && gistidbuf != '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + else + let gistid = gistidbuf + let res = webapi#http#post(g:github_api_url.'/gists/'.gistid.'/star', '', { "Authorization": auth }, 'PUT') + let status = matchstr(matchstr(res.header, '^Status:'), '^[^:]\+: \zs.*') + if status =~ '^2' + echomsg "Stared" gistid + else + echohl ErrorMsg | echomsg 'Star failed' | echohl None + endif + endif + return + elseif arg =~ '^\(-1\|--unstar\)$\C' && gistidbuf != '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + else + let gistid = gistidbuf + let res = webapi#http#post(g:github_api_url.'/gists/'.gistid.'/star', '', { "Authorization": auth }, 'DELETE') + if status =~ '^2' + echomsg "Unstared" gistid + else + echohl ErrorMsg | echomsg 'Unstar failed' | echohl None + endif + endif + return + elseif arg =~ '^\(-f\|--fork\)$\C' && gistidbuf != '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + else + let gistid = gistidbuf + let res = webapi#http#post(g:github_api_url.'/gists/'.gistid.'/fork', '', { "Authorization": auth }) + let status = matchstr(matchstr(res.header, '^Status:'), '^[^:]\+: \zs.*') + if status =~ '^2' + let obj = webapi#json#decode(res.content) + let gistid = obj["id"] + else + echohl ErrorMsg | echomsg 'Fork failed' | echohl None + return + endif + endif + elseif arg !~ '^-' && len(gistnm) == 0 + if gistdesc != ' ' + let gistdesc = matchstr(arg, '^\s*\zs.*\ze\s*$') + elseif editpost == 1 || deletepost == 1 + let gistnm = arg + elseif len(gistls) > 0 && arg != '^\w\+$\C' + let gistls = arg + elseif arg =~ '^[0-9a-z]\+$\C' + let gistid = arg + else + echohl ErrorMsg | echomsg 'Invalid arguments: '.arg | echohl None + unlet args + return 0 + endif + elseif len(arg) > 0 + echohl ErrorMsg | echomsg 'Invalid arguments: '.arg | echohl None + unlet args + return 0 + endif + endfor + unlet args + "echo "gistid=".gistid + "echo "gistls=".gistls + "echo "gistnm=".gistnm + "echo "gistdesc=".gistdesc + "echo "private=".private + "echo "clipboard=".clipboard + "echo "editpost=".editpost + "echo "deletepost=".deletepost + + if gistidbuf != '' && gistid == '' && editpost == 0 && deletepost == 0 + let editpost = 1 + let gistid = gistidbuf + endif + + if len(gistls) > 0 + call s:GistList(gistls, 1) + elseif len(gistid) > 0 && editpost == 0 && deletepost == 0 + call s:GistGet(gistid, clipboard) + else + let url = '' + if multibuffer == 1 + let url = s:GistPostBuffers(private, gistdesc, anonymous) + else + if a:count < 1 + let content = join(getline(a:line1, a:line2), "\n") + else + let save_regcont = @" + let save_regtype = getregtype('"') + silent! normal! gvy + let content = @" + call setreg('"', save_regcont, save_regtype) + endif + if editpost == 1 + let url = s:GistUpdate(content, gistid, gistnm, gistdesc) + elseif deletepost == 1 + call s:GistDelete(gistid) + else + let url = s:GistPost(content, private, gistdesc, anonymous) + endif + if a:count >= 1 && get(g:, 'gist_keep_selection', 0) == 1 + silent! normal! gv + endif + endif + if len(url) > 0 + if get(g:, 'gist_open_browser_after_post', 0) == 1 + call s:open_browser(url) + endif + let gist_put_url_to_clipboard_after_post = get(g:, 'gist_put_url_to_clipboard_after_post', 1) + if gist_put_url_to_clipboard_after_post > 0 + if gist_put_url_to_clipboard_after_post == 2 + let url = url . "\n" + endif + if exists('g:gist_clip_command') + call system(g:gist_clip_command, url) + elseif has('unix') && !has('xterm_clipboard') + let @" = url + else + let @+ = url + endif + endif + endif + endif + return 1 +endfunction + +function! s:GistGetAuthHeader() + if get(g:, 'gist_use_password_in_gitconfig', 0) != 0 + let password = substitute(system('git config --get github.password'), "\n", '', '') + if password =~ '^!' | let password = system(password[1:]) | endif + return printf("basic %s", webapi#base64#b64encode(g:github_user.":".password)) + endif + let auth = "" + if filereadable(s:configfile) + let str = join(readfile(s:configfile), "") + if type(str) == 1 + let auth = str + endif + endif + if len(auth) > 0 + return auth + endif + + redraw + echohl WarningMsg + echo 'Gist.vim requires authorization to use the Github API. These settings are stored in "~/.gist-vim". If you want to revoke, do "rm ~/.gist-vim".' + echohl None + let password = inputsecret("Github Password for ".g:github_user.":") + if len(password) > 0 + let insecureSecret = printf("basic %s", webapi#base64#b64encode(g:github_user.":".password)) + let res = webapi#http#post(g:github_api_url.'/authorizations', webapi#json#encode({ + \ "scopes" : ["gist"], + \ "note" : "Gist.vim on ".hostname(), + \ "note_url" : "http://www.vim.org/scripts/script.php?script_id=2423" + \}), { + \ "Content-Type" : "application/json", + \ "Authorization" : insecureSecret, + \}) + let authorization = webapi#json#decode(res.content) + if has_key(authorization, 'token') + let secret = printf("token %s", authorization.token) + call writefile([secret], s:configfile) + if !(has('win32') || has('win64')) + call system("chmod go= ".s:configfile) + endif + elseif has_key(authorization, 'message') + let secret = '' + let v:errmsg = authorization.message + endif + else + let secret = '' + let v:errmsg = 'Canceled' + endif + return secret +endfunction + +let s:extmap = { +\".adb": "ada", +\".ahk": "ahk", +\".arc": "arc", +\".as": "actionscript", +\".asm": "asm", +\".asp": "asp", +\".aw": "php", +\".b": "b", +\".bat": "bat", +\".befunge": "befunge", +\".bmx": "bmx", +\".boo": "boo", +\".c-objdump": "c-objdump", +\".c": "c", +\".cfg": "cfg", +\".cfm": "cfm", +\".ck": "ck", +\".cl": "cl", +\".clj": "clj", +\".cmake": "cmake", +\".coffee": "coffee", +\".cpp": "cpp", +\".cppobjdump": "cppobjdump", +\".cs": "csharp", +\".css": "css", +\".cw": "cw", +\".d-objdump": "d-objdump", +\".d": "d", +\".darcspatch": "darcspatch", +\".diff": "diff", +\".duby": "duby", +\".dylan": "dylan", +\".e": "e", +\".ebuild": "ebuild", +\".eclass": "eclass", +\".el": "lisp", +\".erb": "erb", +\".erl": "erlang", +\".f90": "f90", +\".factor": "factor", +\".feature": "feature", +\".fs": "fs", +\".fy": "fy", +\".go": "go", +\".groovy": "groovy", +\".gs": "gs", +\".gsp": "gsp", +\".haml": "haml", +\".hs": "haskell", +\".html": "html", +\".hx": "hx", +\".ik": "ik", +\".ino": "ino", +\".io": "io", +\".j": "j", +\".java": "java", +\".js": "javascript", +\".json": "json", +\".jsp": "jsp", +\".kid": "kid", +\".lhs": "lhs", +\".lisp": "lisp", +\".ll": "ll", +\".lua": "lua", +\".ly": "ly", +\".m": "objc", +\".mak": "mak", +\".man": "man", +\".mao": "mao", +\".matlab": "matlab", +\".md": "markdown", +\".minid": "minid", +\".ml": "ml", +\".moo": "moo", +\".mu": "mu", +\".mustache": "mustache", +\".mxt": "mxt", +\".myt": "myt", +\".n": "n", +\".nim": "nim", +\".nu": "nu", +\".numpy": "numpy", +\".objdump": "objdump", +\".ooc": "ooc", +\".parrot": "parrot", +\".pas": "pas", +\".pasm": "pasm", +\".pd": "pd", +\".phtml": "phtml", +\".pir": "pir", +\".pl": "perl", +\".po": "po", +\".py": "python", +\".pytb": "pytb", +\".pyx": "pyx", +\".r": "r", +\".raw": "raw", +\".rb": "ruby", +\".rhtml": "rhtml", +\".rkt": "rkt", +\".rs": "rs", +\".rst": "rst", +\".s": "s", +\".sass": "sass", +\".sc": "sc", +\".scala": "scala", +\".scm": "scheme", +\".scpt": "scpt", +\".scss": "scss", +\".self": "self", +\".sh": "sh", +\".sml": "sml", +\".sql": "sql", +\".st": "smalltalk", +\".tcl": "tcl", +\".tcsh": "tcsh", +\".tex": "tex", +\".textile": "textile", +\".tpl": "smarty", +\".twig": "twig", +\".txt" : "text", +\".v": "verilog", +\".vala": "vala", +\".vb": "vbnet", +\".vhd": "vhdl", +\".vim": "vim", +\".weechatlog": "weechatlog", +\".xml": "xml", +\".xq": "xquery", +\".xs": "xs", +\".yml": "yaml", +\} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et: diff --git a/vim/bundle/gist-vim/doc/gist-vim.txt b/vim/bundle/gist-vim/doc/gist-vim.txt new file mode 100644 index 0000000..aed7220 --- /dev/null +++ b/vim/bundle/gist-vim/doc/gist-vim.txt @@ -0,0 +1,279 @@ +*Gist.vim* Vimscript for creating gists (http://gist.github.com) + +Usage |gist-vim-usage| +Tips |gist-vim-tips| +License |gist-vim-license| +Install |gist-vim-install| +Requirements |gist-vim-requirements| +Setup |gist-vim-setup| + +This is a vimscript for creating gists (http://gist.github.com) + +For the latest version please see https://github.com/mattn/gist-vim. + +============================================================================== +USAGE *:Gist* *gist-vim-usage* + +- Post current buffer to gist, using default privacy option. > + + :Gist +< +- Post selected text to gist, using defualt privacy option. + This applies to all permutations listed below (except multi). > + + :'<,'>Gist +< +- Create a private gist. > + + :Gist -p +< +- Create a public gist. + (Only relevant if you've set gists to be private by default.) > + + :Gist -P +< +- Post whole text to gist as public. + This is only relevant if you've set gists to be private by default. +> + :Gist -P +< +- Create a gist anonymously. > + + :Gist -a +< +- Create a gist with all open buffers. > + + :Gist -m +< +- Edit the gist (you need to have opened the gist buffer first). + You can update the gist with the {:w} command within the gist buffer. > + + :Gist -e +< +- Edit the gist with name "foo.js" (you need to have opened the gist buffer + first). > + + :Gist -e foo.js +< +- Post/Edit with the description " (you need to have opened the gist buffer + first). > + + :Gist -s something + :Gist -e -s something +< +- Delete the gist (you need to have opened the gist buffer first). + Password authentication is needed. > + + :Gist -d +< +- Fork the gist (you need to have opened the gist buffer first). + Password authentication is needed. > + + :Gist -f +< +- Star the gist (you need to have opened the gist buffer first). + Password authentication is needed. +> + :Gist +1 +< +- Unstar the gist (you need to have opened the gist buffer first). + Password authentication is needed. +> + :Gist -1 +< +- Get gist XXXXX. > + + :Gist XXXXX +< +- Get gist XXXXX and add to clipboard. > + + :Gist -c XXXXX +< +- List your public gists. > + + :Gist -l +< +- List gists from user "mattn". > + + :Gist -l mattn +< +- List everyone's gists. > + + :Gist -la +< +- List gists from your starred gists. +> + :Gist -ls +< +============================================================================== +TIPS *gist-vim-tips* + +If you set "g:gist_clip_command", gist.vim will copy the gist code with option +"-c". + + - Mac: > + let g:gist_clip_command = 'pbcopy' +< + - Linux: > + let g:gist_clip_command = 'xclip -selection clipboard' +< + - Others (cygwin?): > + let g:gist_clip_command = 'putclip' +< +If you want to detect filetype from the filename: > + + let g:gist_detect_filetype = 1 +< +If you want to open the browser after the post: > + + let g:gist_open_browser_after_post = 1 +< +If you want to change the browser: > + + let g:gist_browser_command = 'w3m %URL%' +< +or: > + + let g:gist_browser_command = 'opera %URL% &' +< +On windows, this should work with your user settings. + +If you want to show your private gists with ":Gist -l": > + + let g:gist_show_privates = 1 +< +If you want your gist to be private by default: > + + let g:gist_post_private = 1 + +< +If you want to edit all files for gists containing more than one: > + + let g:gist_get_multiplefile = 1 +< + +If you want to use on Github Enterprise: > + + let g:github_api_url = 'http://your-github-enterprise-domain/api/v3' +< + +If you want to update a gist, embed > + + GistID: xxxxx +> +in your local file, then call > + + :Gist +> + +If you want to update a gist when only |:w!|: > + + " :w and :w! update a gist. + let g:gist_update_on_write = 1 + + " Only :w! updates a gist. + let g:gist_update_on_write = 2 +> +All other values are treated as 1. +This variable's value is 1 by default. + +============================================================================== +LICENSE *gist-vim-license* + + + Copyright 2010 by Yasuhiro Matsumoto + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``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 + REGENTS OR CONTRIBUTORS 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. + +============================================================================== +INSTALL *gist-vim-install* + +Copy following files into your plugin directory. + +rtp: + - autoload/gist.vim + - plugin/gist.vim + +If you want to uninstall gist.vim, remember to also remove `~/.gist-vim`. + +You need to install webapi-vim also: + + http://www.vim.org/scripts/script.php?script_id=4019 + +If you want to use latest one: + + https://github.com/mattn/webapi-vim + +============================================================================== +REQUIREMENTS *gist-vim-requirements* + + - curl command (http://curl.haxx.se/) + - webapi-vim (https://github.com/mattn/webapi-vim) + - and, if you want to use your git profile, the git command-line client. + +============================================================================== +SETUP *gist-vim-setup* + +This plugin uses github API v3. Setting value is stored in `~/.gist.vim`. +gist-vim have two ways to access APIs. + +First, you need to set your Github username in global git config: +> + $ git config --global github.user Username +< +Then, gist.vim will ask for your password to create an authorization when you +first use it. The password is not stored and only the OAuth access token will +be kept for later use. You can revoke the token at any time from the list of +"Authorized applications" on Github's "Account Settings" page. +(https://github.com/settings/applications) + +If you happen to have your password already written in ~/.gitconfig like +below: +> + [github] + password = xxxxx +< +Then, add following into your ~/.vimrc +> + let g:gist_use_password_in_gitconfig = 1 +< +This is not secure at all, so strongly discouraged. + +============================================================================== +THANKS *gist-vim-thanks* + + AD7six + Bruno Bigras + c9s + Daniel Bretoi + Jeremy Michael Cantrell + Kien N + kongo2002 + MATSUU Takuto + Matthew Weier O'Phinney + ornicar + Roland Schilter + steve + tyru + Will Gray + netj + + vim:tw=78:ts=8:ft=help:norl: diff --git a/vim/bundle/gist-vim/doc/tags b/vim/bundle/gist-vim/doc/tags new file mode 100644 index 0000000..27d265b --- /dev/null +++ b/vim/bundle/gist-vim/doc/tags @@ -0,0 +1,9 @@ +:Gist gist-vim.txt /*:Gist* +Gist.vim gist-vim.txt /*Gist.vim* +gist-vim-install gist-vim.txt /*gist-vim-install* +gist-vim-license gist-vim.txt /*gist-vim-license* +gist-vim-requirements gist-vim.txt /*gist-vim-requirements* +gist-vim-setup gist-vim.txt /*gist-vim-setup* +gist-vim-thanks gist-vim.txt /*gist-vim-thanks* +gist-vim-tips gist-vim.txt /*gist-vim-tips* +gist-vim-usage gist-vim.txt /*gist-vim-usage* diff --git a/vim/bundle/gist-vim/gist.vim.vimup b/vim/bundle/gist-vim/gist.vim.vimup new file mode 100644 index 0000000..96e6a30 --- /dev/null +++ b/vim/bundle/gist-vim/gist.vim.vimup @@ -0,0 +1,297 @@ +script_name: Gist.vim +script_id: '2423' +script_type: utility +script_package: gist-vim.zip +script_version: '7.1' +required_vim_version: '7.0' +summary: vimscript for gist + +detailed_description: | + This is vimscript for gist (http://gist.github.com) + + Usage: + + :Gist + post whole text to gist. + + :'<,'>Gist + post selected text to gist. + + :Gist -p + post whole text to gist with private. + if you got empty gist list, try :Gist --abandon + + :Gist -a + post whole text to gist with anonymous. + + :Gist -m + post multi buffer to gist. + + :Gist -e + edit the gist. (shoud be work on gist buffer) + you can update the gist with :w command on gist buffer. + + :Gist -e foo.js + edit the gist with name 'foo.js'. (shoud be work on gist buffer) + + :Gist -d + delete the gist. (should be work on gist buffer) + authentication required. + + :Gist -f + fork the gist. (should be work on gist buffer) + authentication required. + + :Gist XXXXX + get gist XXXXX. + + :Gist -c XXXXX. + get gist XXXXX and put to clipboard. + + :Gist -l + list gists from mine. + + :Gist -la + list gists from all. + + Tips: + if set g:gist_clip_command, gist.vim will copy the gist code + with option '-c'. + + # mac + let g:gist_clip_command = 'pbcopy' + + # linux + let g:gist_clip_command = 'xclip -selection clipboard' + + # others(cygwin?) + let g:gist_clip_command = 'putclip' + + if you want to detect filetype from filename... + + let g:gist_detect_filetype = 1 + + if you want to open browser after the post... + + let g:gist_open_browser_after_post = 1 + + if you want to change the browser... + + let g:gist_browser_command = 'w3m %URL%' + + or + + let g:gist_browser_command = 'opera %URL% &' + + on windows, should work with original setting. + + Require: + curl command (http://curl.haxx.se/) + and if you want to use profile of git, it require git command. + +install_details: | + copy it to your plugin directory. + + gist.vim leave cookie-jar file into runtimepath. + + rtp: + plugin/gist.vim + cookies/github + + See also: https://github.com/mattn/gist-vim/blob/master/README.mkd + +versions: +- '7.1': | + This is an upgrade for Gist.vim: updated installation notes. + +- '7.0': | + This is an upgrade for Gist.vim: fixed few bugs. + +- '6.9': | + This is an upgrade for Gist.vim: fixed few bugs. + +- '6.8': | + This is an upgrade for Gist.vim: changed authentication. removed password authentication. if you want to keep using password authentication, let gist_use_password_in_gitconfig to 1. + +- '6.7': | + This is an upgrade for Gist.vim: fix behavior of g:gist_browser_command = ':OpenBrowser %URL%'. + +- '6.6': | + This is an upgrade for Gist.vim: fixed detecting filetype. + +- '6.5': | + This is an upgrade for Gist.vim: use webapi namespace. NOTE: please upgrade webapi-vim also. + +- '6.4': | + This is an upgrade for Gist.vim: fixed updating with description. + +- '6.3': | + This is an upgrade for Gist.vim: fixed typos. + +- '6.2': | + This is an upgrade for Gist.vim: fixed some bugs. + +- '6.1': | + This is an upgrade for Gist.vim: fixed opening browser. + +- '6.0': | + This is an upgrade for Gist.vim: changed to use github APIs. Note to remove cookies directory if you used. + +- '5.9': | + This is an upgrade for Gist.vim: add support anonymous post. fixed many bugs. + +- '5.8': | + This is an upgrade for Gist.vim: add support for description. you can post description using -s option. + +- '5.7': | + This is an upgrade for Gist.vim: post with filetype more cleverly. + +- '5.6': | + This is an upgrade for Gist.vim: fix '--abandon'. + +- '5.5': | + This is an upgrade for Gist.vim: fix: forgot to upload autoload/gist.vim. + +- '5.4': | + This is an upgrade for Gist.vim: fix: does not work correctly with blockwize selection. + +- '5.3': | + This is an upgrade for Gist.vim: upd: support autoload. + +- '5.2': | + This is an upgrade for Gist.vim: add: support block-wise selection. + +- '5.1': | + This is an upgrade for Gist.vim: fix: can't update privates. + +- '5.0': | + This is an upgrade for Gist.vim: follow update of gist.github.com + +- '4.9': | + fix: don't add new line after "Done: xxx". + fix: show WHY FAILED' when failed to post. + add: support for :OpenBrowser. + add: new option 'gist_curl_options'. + +- '4.8': | + This is an upgrade for Gist.vim: fix: can't open private gist with ":Gist XXXXX". + +- '4.7': | + This is an upgrade for Gist.vim: fix: filetype detection. + +- '4.6': | + This is an upgrade for Gist.vim: fix: strange cookies folder. + +- '4.5': | + This is an upgrade for Gist.vim: fix: use gist_clip_command for copying URL to clipboard. this fix strange behavior on Mac OSX. + +- '4.4': | + This is an upgrade for Gist.vim: fix: gist is now only using https. + +- '4.3': | + This is an upgrade for Gist.vim: add new option '-f' for fork. + +- '4.2': | + This is an upgrade for Gist.vim: fixed code for login. + +- '4.1': | + This is an upgrade for Gist.vim: fixed code cleanup. + +- '4.0': | + This is an upgrade for Gist.vim: fixed deleting gist, listing privates. + +- '3.9': | + This is an upgrade for Gist.vim: fixed :w handler in gist buffer. + +- '3.8': | + This is an upgrade for Gist.vim: 'more...' on gist list. + +- '3.7': | + This is an upgrade for Gist.vim: fix problem that break "gist list" window at twice. + +- '3.6': | + This is an upgrade for Gist.vim: fix filetype detection for 'vimscript'. + +- '3.5': | + This is an upgrade for Gist.vim: fix filetype detection. + +- '3.4': | + This is an upgrade for Gist.vim: use '+' register on unix only if built with 'xterm_clipboard'. and some bug fixes. + +- '3.3': | + This is an upgrade for Gist.vim: fix problem that append empty line when getting gist. + +- '3.2': | + This is an upgrade for Gist.vim: added Gist header to recognize the gist. added script type header for Vimana. + +- '3.1': | + This is an upgrade for Gist.vim: fix checking redirect url. + +- '3.0': | + This is an upgrade for Gist.vim: fix for official changes(private button name was changed). + +- '2.9': | + This is an upgrade for Gist.vim: fix for official changes(private button name was changed). + +- '2.8': | + This is an upgrade for Gist.vim: be able to post multi buffer. currently updating or showing not supported. and ':Gist -d' delete the gist. + +- '2.7': | + This is an upgrade for Gist.vim: be able to write the gist to local file with ':w foo.txt'. + +- '2.6': | + This is an upgrade for Gist.vim: fixed problem that does not work 'Gist XXXX'. + +- '2.5': | + This is an upgrade for Gist.vim: use existing buffer when open the list or gist. + +- '2.4': | + This is an upgrade for Gist.vim: show error message when no any github settings. + +- '2.3': | + This is an upgrade for Gist.vim: added :w BufWriteCmd for GistUpdate. + +- '2.2': | + This is an upgrade for Gist.vim: fixed a bug for anonymous post. and new option '-a' for anonymous post. + +- '2.1': | + This is an upgrade for Gist.vim: support changing gist filename. + +- '2.0': | + This is an upgrade for Gist.vim: bugfix for listing gists in specified user. + +- '1.9': | + This is an upgrade for Gist.vim: added support editing the gist. and bits bug fix. + +- '1.8': | + This is an upgrade for Gist.vim: added new option g:gist_open_browser_after_post/g:gist_browser_command to open posted gist. + +- '1.7': | + This is an upgrade for Gist.vim: now changed argument for putting clipboard as ':Gist -c XXXXX'. + +- '1.6': | + This is an upgrade for Gist.vim: add gist's author in gist list. + +- '1.5': | + This is an upgrade for Gist.vim: oops. bugfix for auto-detection. + +- '1.4': | + This is an upgrade for Gist.vim: bugfix for auto-detection. + +- '1.3': | + This is an upgrade for Gist.vim: more auto-detection for filetype. + +- '1.2': | + This is an upgrade for Gist.vim: added new option for detect filetype from filename. + +- '1.1': | + This is an upgrade for Gist.vim: calling StdinReadPost. + +- '1.0': | + This is an upgrade for Gist.vim: treat literal "-" as part of username. + +- '0.9': | + This is an upgrade for Gist.vim: added new option 'g:gist_clip_command' that copy the gist code. + +# __END__ +# vim: filetype=yaml diff --git a/vim/bundle/gist-vim/plugin/gist.vim b/vim/bundle/gist-vim/plugin/gist.vim new file mode 100644 index 0000000..973d300 --- /dev/null +++ b/vim/bundle/gist-vim/plugin/gist.vim @@ -0,0 +1,16 @@ +"============================================================================= +" File: gist.vim +" Author: Yasuhiro Matsumoto +" WebPage: http://github.com/mattn/gist-vim +" License: BSD +" GetLatestVimScripts: 2423 1 :AutoInstall: gist.vim +" script type: plugin + +if &cp || (exists('g:loaded_gist_vim') && g:loaded_gist_vim) + finish +endif +let g:loaded_gist_vim = 1 + +command! -nargs=? -range=% Gist :call gist#Gist(, , , ) + +" vim:set et: diff --git a/vim/bundle/vim-bundler/.gitignore b/vim/bundle/vim-bundler/.gitignore new file mode 100644 index 0000000..0a56e3f --- /dev/null +++ b/vim/bundle/vim-bundler/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/vim/bundle/vim-bundler/CONTRIBUTING.markdown b/vim/bundle/vim-bundler/CONTRIBUTING.markdown new file mode 100644 index 0000000..77b6cfa --- /dev/null +++ b/vim/bundle/vim-bundler/CONTRIBUTING.markdown @@ -0,0 +1,2 @@ +See the contribution guidelines for +[rails.vim](https://github.com/tpope/vim-rails/blob/HEAD/CONTRIBUTING.markdown). diff --git a/vim/bundle/vim-bundler/README.markdown b/vim/bundle/vim-bundler/README.markdown new file mode 100644 index 0000000..546931e --- /dev/null +++ b/vim/bundle/vim-bundler/README.markdown @@ -0,0 +1,55 @@ +# bundler.vim + +This is a lightweight bag of Vim goodies for +[Bundler](http://gembundler.com), best accompanied by +[rake.vim](https://github.com/tpope/vim-rake) and/or +[rails.vim](https://github.com/tpope/vim-rails). Features: + +* `:Bundle`, which wraps `bundle`. +* An internalized version of `bundle open`: `:Bopen` (and `:Bsplit`, + `:Btabedit`, etc.). +* `'path'` and `'tags'` are automatically altered to include all gems + from your bundle. (Generate those tags with + [gem-ctags](https://github.com/tpope/gem-ctags)!) +* Highlight Bundler keywords in `Gemfile`. +* Support for `gf` in `Gemfile.lock`, plus syntax highlighting that + distinguishes between installed and missing gems. + +## 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-bundler.git + +Once help tags have been generated, you can view the manual with +`:help bundler`. + +## FAQ + +> I installed the plugin and started Vim. Why don't any of the commands +> exist? + +This plugin cares about the current file, not the current working +directory. Edit a file that's covered by a `Gemfile`. + +> I opened a new tab. Why don't any of the commands exist? + +This plugin cares about the current file, not the current working +directory. Edit a file that's covered by a `Gemfile`. + +## Self-Promotion + +Like bundler.vim? Follow the repository on +[GitHub](https://github.com/tpope/vim-bundler) and vote for it on +[vim.org](http://www.vim.org/scripts/script.php?script_id=4280). 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/vim/bundle/vim-bundler/compiler/bundler.vim b/vim/bundle/vim-bundler/compiler/bundler.vim new file mode 100644 index 0000000..b129793 --- /dev/null +++ b/vim/bundle/vim-bundler/compiler/bundler.vim @@ -0,0 +1,26 @@ +" Vim compiler file + +if exists("current_compiler") + finish +endif +let current_compiler = "bundler" + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=bundle + +CompilerSet errorformat= + \%+E%f:%l:\ parse\ error, + \%W%f:%l:\ warning:\ %m, + \%E%f:%l:in\ %*[^:]:\ %m, + \%E%f:%l:\ %m, + \%-C%\tfrom\ %f:%l:in\ %.%#, + \%-Z%\tfrom\ %f:%l, + \%-Z%p^, + \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: sw=2: diff --git a/vim/bundle/vim-bundler/doc/bundler.txt b/vim/bundle/vim-bundler/doc/bundler.txt new file mode 100644 index 0000000..cc57e6f --- /dev/null +++ b/vim/bundle/vim-bundler/doc/bundler.txt @@ -0,0 +1,68 @@ +*bundler.txt* Support for Ruby's Bundler + +Author: Tim Pope +License: Same terms as Vim itself (see |license|) + +This plugin is only available if 'compatible' is not set. + +INTRODUCTION *bundler* + +This lightweight companion to rails.vim and rake.vim provides support for +Bundler. In addition to the below commands, it also syntax highlights +Gemfile and Gemfile.lock, and alters 'path' and 'tags' to include bundled +gems. I recommend gem-ctags for generating tags for your gems. + +COMMANDS *bundler-commands* + + *bundler-:Bundle* +:Bundle[!] [args] Invoke `bundle` via |:make|. + + + *bundler-:Bopen* +:Bopen[!] [gem] With no argument, edits the Gemfile. Otherwise, + effectively does a `bundle open` of a gem inside of + Vim, including an |:lcd| to the gem's root directory. + Add ! to discard the current buffer's changes. + + *bundler-:Bedit* +:Bedit[!] [gem] Like |:Bopen|, but don't |:lcd| afterwards. + + *bundler-:Bsplit* +:Bsplit[!] [gem] Like |:Bopen|, but horizontally split. Add ! to + suppress the |:lcd|. + + *bundler-:Bvsplit* +:Bvsplit[!] [gem] Like |:Bopen|, but vertically split. Add ! to + suppress the |:lcd|. + + *bundler-:Btabedit* +:Btabedit[!] [gem] Like |:Bopen|, but use a new tab. Add ! to + suppress the |:lcd|. + + *bundler-:Bpedit* +:Bpedit[!] [gem] Like |:Bopen|, but use a preview window. Add ! to + suppress the |:lcd|. + +API *bundler-api* + +Use bundler#project(root) to retrieve an object for the project at the given +root path. If no path is given, the current buffer's project root is used. +An empty object is returned if no project is found. Use |empty()| to check +for that. + +On the bundler#project() object, versions() returns a dictionary mapping +between gem names and their locked versions, paths() returns a dictionary +mapping between gem names and their installation path (omitting gems which +aren't installed), and has(gem) returns true if the given gem name is in the +bundle (regardless of whether or not it is installed). + +The original data structures are returned for performance reasons. Do not +mutate. + +ABOUT *bundler-about* + +Grab the latest version or report a bug on GitHub: + +http://github.com/tpope/vim-bundler + + vim:tw=78:et:ft=help:norl: diff --git a/vim/bundle/vim-bundler/plugin/bundler.vim b/vim/bundle/vim-bundler/plugin/bundler.vim new file mode 100644 index 0000000..6d8d703 --- /dev/null +++ b/vim/bundle/vim-bundler/plugin/bundler.vim @@ -0,0 +1,581 @@ +" bundler.vim - Support for Ruby's Bundler +" Maintainer: Tim Pope +" Version: 2.0 + +if exists('g:loaded_bundler') || &cp || v:version < 700 + finish +endif +let g:loaded_bundler = 1 + +" Utility {{{1 + +function! s:function(name) abort + return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) +endfunction + +function! s:sub(str,pat,rep) abort + return substitute(a:str,'\v\C'.a:pat,a:rep,'') +endfunction + +function! s:gsub(str,pat,rep) abort + return substitute(a:str,'\v\C'.a:pat,a:rep,'g') +endfunction + +function! s:shellesc(arg) abort + if a:arg =~ '^[A-Za-z0-9_/.-]\+$' + return a:arg + else + return shellescape(a:arg) + endif +endfunction + +function! s:fnameescape(file) abort + if exists('*fnameescape') + return fnameescape(a:file) + else + return escape(a:file," \t\n*?[{`$\\%#'\"|!<") + endif +endfunction + +function! s:shellslash(path) + if exists('+shellslash') && !&shellslash + return s:gsub(a:path,'\\','/') + else + return a:path + endif +endfunction + +function! s:completion_filter(results,A) + let results = sort(copy(a:results)) + call filter(results,'v:val !~# "\\~$"') + let filtered = filter(copy(results),'v:val[0:strlen(a:A)-1] ==# a:A') + if !empty(filtered) | return filtered | endif + let regex = s:gsub(a:A,'[^/:]','[&].*') + let filtered = filter(copy(results),'v:val =~# "^".regex') + if !empty(filtered) | return filtered | endif + let filtered = filter(copy(results),'"/".v:val =~# "[/:]".regex') + if !empty(filtered) | return filtered | endif + let regex = s:gsub(a:A,'.','[&].*') + let filtered = filter(copy(results),'"/".v:val =~# regex') + return filtered +endfunction + +function! s:throw(string) abort + let v:errmsg = 'bundler: '.a:string + throw v:errmsg +endfunction + +function! s:warn(str) + echohl WarningMsg + echomsg a:str + echohl None + let v:warningmsg = a:str +endfunction + +function! s:add_methods(namespace, method_names) abort + for name in a:method_names + let s:{a:namespace}_prototype[name] = s:function('s:'.a:namespace.'_'.name) + endfor +endfunction + +let s:commands = [] +function! s:command(definition) abort + let s:commands += [a:definition] +endfunction + +function! s:define_commands() + for command in s:commands + exe 'command! -buffer '.command + endfor +endfunction + +augroup bundler_utility + autocmd! + autocmd User Bundler call s:define_commands() +augroup END + +let s:abstract_prototype = {} + +" }}}1 +" Syntax highlighting {{{1 + +function! s:syntaxfile() + syntax keyword rubyGemfileMethod gemspec gem source path git group platforms env ruby + hi def link rubyGemfileMethod Function +endfunction + +function! s:syntaxlock() + setlocal iskeyword+=-,. + syn match gemfilelockHeading '^[[:upper:]]\+$' + syn match gemfilelockKey '^\s\+\zs\S\+:'he=e-1 skipwhite nextgroup=gemfilelockRevision + syn match gemfilelockKey 'remote:'he=e-1 skipwhite nextgroup=gemfilelockRemote + syn match gemfilelockRemote '\S\+' contained + syn match gemfilelockRevision '[[:alnum:]._-]\+$' contained + syn match gemfilelockGem '^\s\+\zs[[:alnum:]._-]\+\%([ !]\|$\)\@=' contains=gemfilelockFound,gemfilelockMissing skipwhite nextgroup=gemfilelockVersions,gemfilelockBang + syn match gemfilelockVersions '([^()]*)' contained contains=gemfilelockVersion + syn match gemfilelockVersion '[^,()]*' contained + syn match gemfilelockBang '!' contained + if !empty(bundler#project()) + exe 'syn match gemfilelockFound "\<\%(bundler\|' . join(keys(s:project().paths()), '\|') . '\)\>" contained' + exe 'syn match gemfilelockMissing "\<\%(' . join(keys(filter(s:project().versions(), '!has_key(s:project().paths(), v:key)')), '\|') . '\)\>" contained' + else + exe 'syn match gemfilelockFound "\<\%(\S*\)\>" contained' + endif + syn match gemfilelockHeading '^PLATFORMS$' nextgroup=gemfilelockPlatform skipnl skipwhite + syn match gemfilelockPlatform '^ \zs[[:alnum:]._-]\+$' contained nextgroup=gemfilelockPlatform skipnl skipwhite + + hi def link gemfilelockHeading PreProc + hi def link gemfilelockPlatform Typedef + hi def link gemfilelockKey Identifier + hi def link gemfilelockRemote String + hi def link gemfilelockRevision Number + hi def link gemfilelockFound Statement + hi def link gemfilelockMissing Error + hi def link gemfilelockVersion Type + hi def link gemfilelockBang Special +endfunction + +function! s:setuplock() + nnoremap gf :Bopen + nnoremap f :Bsplit + nnoremap :Bsplit + nnoremap gf :Btabedit +endfunction + +augroup bundler_syntax + autocmd! + autocmd BufNewFile,BufRead */.bundle/config set filetype=yaml + autocmd BufNewFile,BufRead Gemfile set filetype=ruby + autocmd Syntax ruby if expand(':t') ==? 'gemfile' | call s:syntaxfile() | endif + autocmd BufNewFile,BufRead [Gg]emfile.lock setf gemfilelock + autocmd FileType gemfilelock set suffixesadd=.rb + autocmd Syntax gemfilelock call s:syntaxlock() + autocmd FileType gemfilelock call s:setuplock() + autocmd User Rails/Gemfile.lock call s:setuplock() +augroup END + +" }}}1 +" Initialization {{{1 + +function! s:FindBundlerRoot(path) abort + let path = s:shellslash(a:path) + let fn = fnamemodify(path,':s?[\/]$??') + let ofn = "" + let nfn = fn + while fn != ofn + if filereadable(fn.'/Gemfile') + return s:sub(simplify(fnamemodify(fn,':p')),'[\\/]$','') + endif + let ofn = fn + let fn = fnamemodify(ofn,':h') + endwhile + return '' +endfunction + +function! s:Detect(path) + if !exists('b:bundler_root') + let dir = s:FindBundlerRoot(a:path) + if dir != '' + let b:bundler_root = dir + endif + endif + if exists('b:bundler_root') + silent doautocmd User Bundler + endif +endfunction + +augroup bundler + autocmd! + autocmd FileType * call s:Detect(expand(':p')) + autocmd BufNewFile,BufReadPost * + \ if empty(&filetype) | + \ call s:Detect(expand(':p')) | + \ endif + autocmd VimEnter * if expand('')==''|call s:Detect(getcwd())|endif +augroup END + +" }}}1 +" Project {{{1 + +let s:project_prototype = {} +let s:projects = {} + +function! bundler#project(...) abort + let dir = a:0 ? a:1 : (exists('b:bundler_root') && b:bundler_root !=# '' ? b:bundler_root : s:FindBundlerRoot(expand('%:p'))) + if dir !=# '' + if has_key(s:projects,dir) + let project = get(s:projects,dir) + else + let project = {'root': dir} + let s:projects[dir] = project + endif + return extend(extend(project,s:project_prototype,'keep'),s:abstract_prototype,'keep') + endif + return {} +endfunction + +function! s:project(...) abort + let project = a:0 ? bundler#project(a:1) : bundler#project() + if empty(project) + call s:throw('not a Bundler project: '.(a:0 ? a:1 : expand('%'))) + else + return project + endif +endfunction + +function! s:project_path(...) dict abort + return join([self.root]+a:000,'/') +endfunction + +call s:add_methods('project',['path']) + +function! s:project_locked() dict abort + let lock_file = self.path('Gemfile.lock') + let time = getftime(lock_file) + if time != -1 && time != get(self,'_lock_time',-1) + let self._locked = {'git': [], 'gem': [], 'path': []} + let self._versions = {} + + for line in readfile(lock_file) + if line =~# '^\S' + let properties = {'versions': {}} + if has_key(self._locked, tolower(line)) + call extend(self._locked[tolower(line)], [properties]) + endif + elseif line =~# '^ \w\+: ' + let properties[matchstr(line, '\w\+')] = matchstr(line, ': \zs.*') + elseif line =~# '^ [a-zA-Z0-9._-]\+\s\+(\d\+' + let name = split(line, ' ')[0] + let ver = substitute(line, '.*(\|).*', '', 'g') + let properties.versions[name] = ver + let self._versions[name] = ver + endif + endfor + let self._lock_time = time + endif + return get(self, '_locked', {}) +endfunction + +function! s:project_paths(...) dict abort + call self.locked() + let time = get(self, '_lock_time', -1) + if a:0 && a:1 ==# 'refresh' || time != -1 && time != get(self, '_path_time', -1) + let paths = {} + + let chdir = exists("*haslocaldir") && haslocaldir() ? "lchdir" : "chdir" + let cwd = getcwd() + + " Explicitly setting $PATH means /etc/zshenv on OS X can't touch it. + if executable('env') + let prefix = 'env PATH='.s:shellesc($PATH).' ' + else + let prefix = '' + endif + + let gem_paths = [] + if exists('$GEM_PATH') + let gem_paths = split($GEM_PATH, has('win32') ? ';' : ':') + else + try + exe chdir s:fnameescape(self.path()) + let gem_paths = split(system(prefix.'ruby -rubygems -e "print Gem.path.join(%(;))"'), ';') + finally + exe chdir s:fnameescape(cwd) + endtry + endif + + let abi_version = matchstr(get(gem_paths, 0, '1.9.1'), '[0-9.]\+$') + for config in [expand('~/.bundle/config'), self.path('.bundle/config')] + if filereadable(config) + let body = join(readfile(config), "\n") + let bundle_path = matchstr(body, "\\C\\ 0 + call insert(self._sorted, remove(self._sorted,index)) + endif + call self.alter_buffer_paths() + return paths + endif + return get(self,'_paths',{}) +endfunction + +function! s:project_sorted() dict abort + call self.paths() + return get(self, '_sorted', []) +endfunction + +function! s:project_gems() dict abort + return self.paths() +endfunction + +function! s:project_versions() dict abort + call self.locked() + return get(self, '_versions', {}) +endfunction + +function! s:project_has(gem) dict abort + call self.locked() + return has_key(self.versions(), a:gem) +endfunction + +call s:add_methods('project', ['locked', 'gems', 'paths', 'sorted', 'versions', 'has']) + +" }}}1 +" Buffer {{{1 + +let s:buffer_prototype = {} + +function! s:buffer(...) abort + let buffer = {'#': bufnr(a:0 ? a:1 : '%')} + let g:buffer = buffer + call extend(extend(buffer,s:buffer_prototype,'keep'),s:abstract_prototype,'keep') + if buffer.getvar('bundler_root') !=# '' + return buffer + endif + call s:throw('not a Bundler project: '.(a:0 ? a:1 : expand('%'))) +endfunction + +function! bundler#buffer(...) abort + return s:buffer(a:0 ? a:1 : '%') +endfunction + +function! s:buffer_getvar(var) dict abort + return getbufvar(self['#'],a:var) +endfunction + +function! s:buffer_setvar(var,value) dict abort + return setbufvar(self['#'],a:var,a:value) +endfunction + +function! s:buffer_project() dict abort + return s:project(self.getvar('bundler_root')) +endfunction + +call s:add_methods('buffer',['getvar','setvar','project']) + +" }}}1 +" Bundle {{{1 + +function! s:push_chdir() + if !exists("s:command_stack") | let s:command_stack = [] | endif + let chdir = exists("*haslocaldir") && haslocaldir() ? "lchdir " : "chdir " + call add(s:command_stack,chdir.s:fnameescape(getcwd())) + exe chdir.'`=s:project().path()`' +endfunction + +function! s:pop_command() + if exists("s:command_stack") && len(s:command_stack) > 0 + exe remove(s:command_stack,-1) + endif +endfunction + +function! s:Bundle(bang,arg) + let old_makeprg = &l:makeprg + let old_errorformat = &l:errorformat + let old_compiler = get(b:, 'current_compiler', '') + try + compiler bundler + execute 'make! '.a:arg + if a:bang ==# '' + return 'if !empty(getqflist()) | cfirst | endif' + else + return '' + endif + finally + let &l:errorformat = old_errorformat + let &l:makeprg = old_makeprg + let b:current_compiler = old_compiler + if empty(b:current_compiler) + unlet b:current_compiler + endif + endtry +endfunction + +function! s:BundleComplete(A,L,P) + if a:L =~# '^\S\+\s\+\%(show\|update\) ' + return s:completion_filter(keys(s:project().paths()),a:A) + endif + return s:completion_filter(['install','update','exec','package','config','check','list','show','outdated','console','viz','benchmark'],a:A) +endfunction + +function! s:SetupMake() abort + compiler bundler +endfunction + +call s:command("-bar -bang -nargs=? -complete=customlist,s:BundleComplete Bundle :execute s:Bundle('',)") + +augroup bundler_make + autocmd FileType gemfilelock call s:SetupMake() + autocmd FileType ruby + \ if expand(':t') ==? 'gemfile' | + \ call s:SetupMake() | + \ endif + autocmd QuickFixCmdPre make,lmake + \ if &makeprg =~# '^bundle' && exists('b:bundler_root') | + \ call s:push_chdir() | + \ endif + autocmd QuickFixCmdPost make,lmake + \ if &makeprg =~# '^bundle' && exists('b:bundler_root') | + \ call s:pop_command() | + \ call s:project().paths("refresh") | + \ endif +augroup END + +" }}}1 +" Bopen {{{1 + +function! s:Open(cmd,gem,lcd) + if a:gem ==# '' && a:lcd + return a:cmd.' `=bundler#buffer().project().path("Gemfile")`' + elseif a:gem ==# '' + return a:cmd.' `=bundler#buffer().project().path("Gemfile.lock")`' + else + if !has_key(s:project().paths(), a:gem) + call s:project().paths('refresh') + endif + if !has_key(s:project().paths(), a:gem) + if has_key(s:project().versions(), a:gem) + let v:errmsg = "Gem \"".a:gem."\" is in bundle but not installed" + else + let v:errmsg = "Gem \"".a:gem."\" is not in bundle" + endif + return 'echoerr v:errmsg' + endif + let path = fnameescape(bundler#buffer().project().paths()[a:gem]) + let exec = a:cmd.' '.path + if a:cmd =~# '^pedit' && a:lcd + let exec .= '|wincmd P|lcd '.path.'|wincmd p' + elseif a:lcd + let exec .= '|lcd '.path + endif + return exec + endif +endfunction + +function! s:OpenComplete(A,L,P) + return s:completion_filter(keys(s:project().paths()),a:A) +endfunction + +call s:command("-bar -bang -nargs=? -complete=customlist,s:OpenComplete Bopen :execute s:Open('edit',,1)") +call s:command("-bar -bang -nargs=? -complete=customlist,s:OpenComplete Bedit :execute s:Open('edit',,0)") +call s:command("-bar -bang -nargs=? -complete=customlist,s:OpenComplete Bsplit :execute s:Open('split',,1)") +call s:command("-bar -bang -nargs=? -complete=customlist,s:OpenComplete Bvsplit :execute s:Open('vsplit',,1)") +call s:command("-bar -bang -nargs=? -complete=customlist,s:OpenComplete Btabedit :execute s:Open('tabedit',,1)") +call s:command("-bar -bang -nargs=? -complete=customlist,s:OpenComplete Bpedit :execute s:Open('pedit',,1)") + +" }}}1 +" Paths {{{1 + +function! s:build_path_option(paths,suffix) abort + return join(map(copy(a:paths),'",".escape(s:shellslash(v:val."/".a:suffix),", ")'),'') +endfunction + +function! s:buffer_alter_paths() dict abort + if self.getvar('&suffixesadd') =~# '\.rb\>' + let new = self.project().sorted() + let old = type(self.getvar('bundler_paths')) == type([]) ? self.getvar('bundler_paths') : [] + for [option, suffix] in [['path', 'lib'], ['tags', 'tags']] + let value = self.getvar('&'.option) + if !empty(old) + let drop = s:build_path_option(old,suffix) + let index = stridx(value,drop) + if index > 0 + let value = value[0:index-1] . value[index+strlen(drop):-1] + endif + endif + call self.setvar('&'.option,value.s:build_path_option(new,suffix)) + endfor + call self.setvar('bundler_paths',new) + endif +endfunction + +call s:add_methods('buffer',['alter_paths']) + +function! s:project_alter_buffer_paths() dict abort + for bufnr in range(1,bufnr('$')) + if getbufvar(bufnr,'bundler_root') ==# self.path() + let vim_parsing_quirk = s:buffer(bufnr).alter_paths() + endif + if getbufvar(bufnr, '&syntax') ==# 'gemfilelock' + call setbufvar(bufnr, '&syntax', 'gemfilelock') + endif + endfor +endfunction + +call s:add_methods('project',['alter_buffer_paths']) + +augroup bundler_path + autocmd! + autocmd User Bundler call s:buffer().alter_paths() +augroup END + +" }}}1 + +" vim:set sw=2 sts=2: diff --git a/vim/bundle/vim-colors-solarized/README.mkd b/vim/bundle/vim-colors-solarized/README.mkd new file mode 100644 index 0000000..a163b02 --- /dev/null +++ b/vim/bundle/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/vim/bundle/vim-colors-solarized/autoload/togglebg.vim b/vim/bundle/vim-colors-solarized/autoload/togglebg.vim new file mode 100644 index 0000000..108511f --- /dev/null +++ b/vim/bundle/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 ") + +" post draft +let id = atom#createEntry("http://d.hatena.ne.jp/".hatena_id."/atom/draft", hatena_id, password, entry) + +" modify it. publish it. +call entry.setContent("") +let id = atom#updateEntry(id, hatena_id, password, entry, {"X-HATENA-PUBLISH": 1}) + +" get the entry. +let entry = atom#getEntry(id, hatena_id, password) +echo entry.getTitle() +echo entry.getContent() + +" delete the entry. +call atom#deleteEntry(id, hatena_id, password) + +" vim:set ft=vim: diff --git a/vim/bundle/webapi-vim/example/jugem.vim b/vim/bundle/webapi-vim/example/jugem.vim new file mode 100644 index 0000000..0fb7b63 --- /dev/null +++ b/vim/bundle/webapi-vim/example/jugem.vim @@ -0,0 +1,24 @@ +scriptencoding utf-8 + +let jugem_id = 'your-jugem-id' +let password = 'your-jugem-password' +let imageName = "my-image.gif" +let imagePath = "/path/to/images/my-image.gif" + +let api = metaWeblog#proxy("http://".jugem_id.".jugem.jp/admin/xmlrpc.php") + +let imgurl = api.newMediaObject(jugem_id, jugem_id, password, { +\ "name": imageName, +\ "path": imagePath, +\}) + +let text = "How about this?
" + +echo api.newPost(jugem_id, jugem_id, password, { +\ "title": "post from webpi-vim", +\ "description": text, +\ "dateCreated": "", +\ "categories": ["test"], +\}, 1) + +" vim:set ft=vim: diff --git a/vim/bundle/webapi-vim/example/livedoor.vim b/vim/bundle/webapi-vim/example/livedoor.vim new file mode 100644 index 0000000..ff99eef --- /dev/null +++ b/vim/bundle/webapi-vim/example/livedoor.vim @@ -0,0 +1,15 @@ +scriptencoding utf-8 + +let livedoor_id = 'your-livedoor-id' +let password = 'your-livedoor-password' + +" write entry +let entry = atom#newEntry() +call entry.setTitle("title of entry") +call entry.setContentType("text/html") +call entry.setContent("") + +let postUrl = "http://cms.blog.livedoor.com/atom" +echo atom#createEntry(postUrl, livedoor_id, password, entry) + +" vim:set ft=vim: diff --git a/vim/bundle/webapi-vim/example/rss.vim b/vim/bundle/webapi-vim/example/rss.vim new file mode 100644 index 0000000..ae042d9 --- /dev/null +++ b/vim/bundle/webapi-vim/example/rss.vim @@ -0,0 +1,4 @@ +for item in webapi#feed#parseURL('http://rss.slashdot.org/Slashdot/slashdot') + echo item.link + echo " " item.title +endfor diff --git a/vim/bundle/webapi-vim/example/twitter.vim b/vim/bundle/webapi-vim/example/twitter.vim new file mode 100644 index 0000000..dfb174a --- /dev/null +++ b/vim/bundle/webapi-vim/example/twitter.vim @@ -0,0 +1,29 @@ +set rtp+=webapi-vim + +let ctx = {} +let configfile = expand('~/.twitter-vim') +if filereadable(configfile) + let ctx = eval(join(readfile(configfile), "")) +else + let ctx.consumer_key = input("consumer_key:") + let ctx.consumer_secret = input("consumer_secret:") + + let request_token_url = "https://twitter.com/oauth/request_token" + let auth_url = "https://twitter.com/oauth/authorize" + let access_token_url = "https://api.twitter.com/oauth/access_token" + + let ctx = webapi#oauth#request_token(request_token_url, ctx) + if has("win32") || has("win64") + exe "!start rundll32 url.dll,FileProtocolHandler ".auth_url."?oauth_token=".ctx.request_token + else + call system("xdg-open '".auth_url."?oauth_token=".ctx.request_token."'") + endif + let pin = input("PIN:") + let ctx = webapi#oauth#access_token(access_token_url, ctx, {"oauth_verifier": pin}) + call writefile([string(ctx)], configfile) +endif + +let post_url = "https://api.twitter.com/1/statuses/update.xml" +let status = "tweeeeeeeeeeeeeet" +let ret = webapi#oauth#post(post_url, ctx, {}, {"status": status}) +echo ret diff --git a/vim/bundle/webapi-vim/example/weather.vim b/vim/bundle/webapi-vim/example/weather.vim new file mode 100644 index 0000000..7b9d3ff --- /dev/null +++ b/vim/bundle/webapi-vim/example/weather.vim @@ -0,0 +1,3 @@ +let loc = 'Osaka' +let dom = webapi#xml#parseURL(printf('http://www.google.com/ig/api?weather=%s', webapi#http#encodeURIComponent(loc))) +echo loc.'''s current weather is '.dom.find('current_conditions').childNode('condition').attr['data'] diff --git a/vim/bundle/webapi-vim/webapi.vim.vimup b/vim/bundle/webapi-vim/webapi.vim.vimup new file mode 100644 index 0000000..917d595 --- /dev/null +++ b/vim/bundle/webapi-vim/webapi.vim.vimup @@ -0,0 +1,31 @@ +script_name: WebAPI.vim +script_id: '4019' +script_type: utility +script_package: webapi-vim.zip +script_version: '0.2' +required_vim_version: '7.0' +summary: vimscript for gist + +detailed_description: | + Interface to Web APIs + + webapi-vim include: + + * XML parser Library. + * HTML parser Library. + * JSON parser Library. + * HTTP client. + + and some utility functions. + +install_details: | + copy it to your plugin directory. + +versions: +- '0.2': | + Bug fixes. +- '0.1': | + First post. + +# __END__ +# vim: filetype=yaml diff --git a/vim/ftdetect/markdown.vim b/vim/ftdetect/markdown.vim new file mode 100644 index 0000000..8e10a06 --- /dev/null +++ b/vim/ftdetect/markdown.vim @@ -0,0 +1,2 @@ +" Markdown +autocmd BufNewFile,BufRead *.{md,mkd,mkdn,mark*} set filetype=markdown diff --git a/vim/snippets/markdown.snippets b/vim/snippets/markdown.snippets new file mode 100644 index 0000000..7388bf1 --- /dev/null +++ b/vim/snippets/markdown.snippets @@ -0,0 +1,43 @@ +# [link][] +snippet [] + [${1:link_id}][]${2} +# [link][id] +snippet [[ + [${1:link}][${2:id}]${3} +# [link](url) +snippet [( + [${1:link}](http://${2:url})${3} +# [link](email) +snippet [@ + [${1:link}(mailto:${2:email})${3} +# [link](url "title") +snippet [(" + [${1:link}](${2:url} "${3:title}")${4} +# [id]: url "title" +snippet [: + [${1:id}]: http://${2:url} "${3:title}" +# [id]: email "title" +snippet [:@ + [${1:id}]: mailto:${2:url} "${3:title}" +# ![alt][id] +snippet ![ + ![${1:alt}][${2:id}]${3} +# ![alt](url) +snippet !( + ![${1:alt}](${2:url})${3} +# ![alt](url "title") +snippet !(" + ![${1:alt}](${2:url} "${3:title}")${4} +# *emphasis* or _emphasis_ +snippet * + *${1}*${2} +snippet _ + _${1}_${2} +# **strong** or __strong__ +snippet ** + **${1}**${2} +snippet __ + __${1}__${2} +# `code` +snippet ` + \`${1}\`${2} diff --git a/vim/syntax/markdown.vim b/vim/syntax/markdown.vim new file mode 100644 index 0000000..b79de52 --- /dev/null +++ b/vim/syntax/markdown.vim @@ -0,0 +1,110 @@ +" Vim syntax file +" Language: Markdown +" Author: Ben Williams +" Maintainer: Hallison Batista +" URL: http://plasticboy.com/markdown-vim-mode/ +" Version: 1.0.1 +" Last Change: Fri Dec 4 08:36:48 AMT 2009 +" Remark: Uses HTML syntax file +" Remark: I don't do anything with angle brackets (<>) because that would too easily +" easily conflict with HTML syntax +" TODO: Handle stuff contained within stuff (e.g. headings within blockquotes) + +" Read the HTML syntax to start with +if version < 600 + so :p:h/html.vim +else + runtime! syntax/html.vim + unlet b:current_syntax +endif + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Don't use standard HiLink, it will not work with included syntax files +if version < 508 + command! -nargs=+ HtmlHiLink hi link +else + command! -nargs=+ HtmlHiLink hi def link +endif + +syntax spell toplevel +syntax case ignore +syntax sync linebreaks=1 + +" Additions to HTML groups +syntax region htmlBold start=/\\\@) +syntax region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite +syntax region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline +syntax region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained +syntax region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained +syntax region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained + +" Define Markdown groups +syntax match mkdLineContinue ".$" contained +syntax match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/ +syntax match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/ +syntax match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/ +syntax match mkdRule /^\s*-\{3,}$/ +syntax match mkdRule /^\s*\*\{3,5}$/ +syntax match mkdListItem /^\s*[-*+]\s\+.*\n\(\(^.\+\n\)*\n\?\)\(\(^\(\s\{4}\|\t\)\+.*\n\)\(^.\+\n\)*\n\?\)*/ contains=mkdListCode,mkdCode,htmlBold,htmlItalic,htmlSpecialChar +syntax match mkdListItem /^\s*\d\+\.\s\+.*\n\(\(^.\+\n\)*\n\?\)\(\(^\(\s\{4}\|\t\)\+.*\n\)\(^.\+\n\)*\n\?\)*/ contains=mkdListCode,mkdCode,htmlBold,htmlItalic,htmlSpecialChar +" +syntax match mkdBlockCode /^\s*\n\(^\(\s\{4}\|\t\).*\n\)\+/ +syntax match mkdListCode /^\s*\n\(^\(\s\{8}\|\t{2}\).*\n\)\+/ +syntax match mkdLineBreak / \+$/ +syntax region mkdCode start=/\\\@/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell +syntax region mkdCode start="]*>" end="" +syntax region mkdCode start="]*>" end="" + +" HTML headings +syntax region htmlH1 start="^\s*#" end="\($\|#\+\)" contains=@Spell +syntax region htmlH2 start="^\s*##" end="\($\|#\+\)" contains=@Spell +syntax region htmlH3 start="^\s*###" end="\($\|#\+\)" contains=@Spell +syntax region htmlH4 start="^\s*####" end="\($\|#\+\)" contains=@Spell +syntax region htmlH5 start="^\s*#####" end="\($\|#\+\)" contains=@Spell +syntax region htmlH6 start="^\s*######" end="\($\|#\+\)" contains=@Spell +syntax match htmlH1 /^.\+\n=\+$/ contains=@Spell +syntax match htmlH2 /^.\+\n-\+$/ contains=@Spell + +"highlighting for Markdown groups +HtmlHiLink mkdString String +HtmlHiLink mkdCode String +HtmlHiLink mkdListCode String +HtmlHiLink mkdBlockCode String +HtmlHiLink mkdBlockquote Comment +HtmlHiLink mkdLineContinue Comment +HtmlHiLink mkdListItem Identifier +HtmlHiLink mkdRule Identifier +HtmlHiLink mkdLineBreak Todo +HtmlHiLink mkdLink htmlLink +HtmlHiLink mkdURL htmlString +HtmlHiLink mkdID Identifier +HtmlHiLink mkdLinkDef mkdID +HtmlHiLink mkdLinkDefTarget mkdURL +HtmlHiLink mkdLinkTitle htmlString + +HtmlHiLink mkdDelimiter Delimiter + +let b:current_syntax = "markdown" + +delcommand HtmlHiLink +" vim: tabstop=2 diff --git a/.vimrc b/vimrc similarity index 100% rename from .vimrc rename to vimrc diff --git a/zlogin b/zlogin new file mode 100644 index 0000000..dee8256 --- /dev/null +++ b/zlogin @@ -0,0 +1,5 @@ +# go to saved path if there is one +if [[ -f ~/.current_path~ ]]; then + cd `cat ~/.current_path~` + rm ~/.current_path~ +fi diff --git a/zprofile b/zprofile new file mode 100644 index 0000000..fed5738 --- /dev/null +++ b/zprofile @@ -0,0 +1 @@ +source ~/.zshrc diff --git a/zsh/aliases b/zsh/aliases new file mode 100644 index 0000000..2213661 --- /dev/null +++ b/zsh/aliases @@ -0,0 +1,125 @@ +# Handle the fact that this file will be used with multiple OSs +platform=`uname` +if [[ $platform == 'Linux' ]]; then + alias a='ls -lrth --color' +elif [[ $platform == 'Darwin' ]]; then + alias a='ls -lrthG' +fi + +alias amend="git commit --amend" +alias asu="cd ~/code/rails/activesupport" +alias aliases='vim ~/.dotfiles/zsh/aliases' +alias b='ssh -t ben@benorenstein.com screen -rd irc' +alias bake='bundle exec rake' +alias be='bundle exec' +alias ben='ssh ben@benorenstein.com' +alias bi='bundle install' +alias be='bundle exec' +alias bo='cd ~/code/boardwalk' +alias bu='bundle update' +alias bunbang='bundle install && !!' +alias c='cd' +alias code='cd ~/code' +alias codereview='vim ~/Dropbox/notes/code-review-checklist.txt' +alias d='cd ~/.dotfiles' +alias dbprep='rdm && rdtp' +alias di='cd ~/code/discourse' +alias dr='cd ~/Dropbox' +alias drop='cd ~/Dropbox' +alias fs='foreman start' +alias -g G='| grep' +alias gad='git add .' +alias gadu='git add -u .' +alias gbc='gdc' +alias gca='git commit -a' +alias gcaa='git commit -a --amend -C HEAD' +alias gcl='git clone' +alias gcm="git commit -m" +alias gco='git checkout' +alias gd='git diff' +alias gdc='git diff --cached' +alias gdm='git diff master' +alias get='sudo apt-get install' +alias gg='git lg' +alias gpush='echo "Use gp!" && git push' +alias gp='git push' +alias gpf='git push -f' +alias gpr='git pull --rebase' +alias grc='git rebase --continue' +alias grake='rspec --drb spec/ && cucumber --drb features/' +alias gurad='guard' +alias h='sync' +alias he='cd ~/code/hacker-engine' +alias herkou='heroku' +alias hpush='git push heroku' +alias irb='irb --readline -r irb/completion' +alias journal='vim ~/Dropbox/docs/journal/2011.txt' +alias killruby='killall -9 ruby' +alias killrudy='killall -9 ruby' +alias -g M='| more' +alias mastre='master' +alias newscreen="screen -S foo" +#alias l='cd ~/code/learn' +alias -g L='| less' +alias pc='production-console' +alias parallel='rdtp && rake parallel:prepare test:parallel_with_specs' +alias patch='git format-patch HEAD^ --stdout > patch.diff' +alias podcast='vim ~/Dropbox/work/thoughtbot/notes/podcast.txt' +alias prepdb='dbprep' +alias r='cd ~/code/refactoring-good-to-great' +alias remore='!! | more' +alias reguard='killall -9 ruby ; guard' +alias rerake='!! && rake' +alias restart_apache="sudo /etc/init.d/apache2 restart" +alias restart_postgres="stoppostgres && startpostgres" +alias retag='ctags -R --exclude=.svn --exclude=.git --exclude=log --exclude=tmp *' +alias retagwithcoffee='ctags -R --exclude=.svn --exclude=.git --exclude=log --exclude=tmp * && coffeetags -R -f >> tags' +alias repush="gpr && git push" +alias review="git diff master" +alias rc='rails console' +alias remigrate='rake db:migrate && rake db:migrate:redo && rake db:schema:dump && rake db:test:prepare' +alias rdm="be rake db:migrate" +alias rdtp="be rake db:test:prepare" +alias rs='bundle install && rails server -p 3000' +alias safepush='git pull --rebase && bundle install && rdm && rake && git push' +alias sfh='cd ~/code/speaking-for-hackers-book' +alias shpush='rake && hpush' +alias sc='staging-console' +alias so='source ~/.dotfiles/zsh/aliases' +alias sp='safepush' +alias speaking='cd ~/Dropbox/speaking' +alias ss='ruby app.rb' +alias startpostgres='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start' +alias startredis='redis-server /usr/local/etc/redis.conf &' +alias stoppostgres='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop' +alias staging='git push heroku-staging master' +alias sync='git add -u . && git commit -m "Minor changes. Commit message skipped." && repush' +alias tail-logs='heroku logs -t' +alias track='git checkout -t' +alias warmup='vim ~/Dropbox/barbershop/warmups/ideas.txt' +alias worknotes='vim ~/Dropbox/work/thoughtbot/notes' +alias u='cd ..' +alias v='vim' +alias vi='vim' +alias vu='cd ~/code/vim-university' +alias y='cd ~/code/ybuy' +alias z='zeus' +alias zs='zeus start' + +# Heroku staging +alias staging-console='heroku run console --remote staging' +alias staging-tail='heroku logs --tail --remote staging' + +# Heroku production +alias production-console='heroku run console --remote production' +alias production-tail='heroku logs --tail --remote production' + +# # Heroku databases +alias db-pull-staging='heroku db:pull --remote staging --confirm `basename $PWD`-staging' +alias db-pull-production='heroku db:pull --remote production --confirm `basename $PWD`-production' +alias db-copy-production-to-staging='heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging --confirm `basename $PWD`-staging' +alias db-backup-production='heroku pgbackups:capture --remote production' +alias db-backups='heroku pgbackups --remote production' + +alias levelup-get-production='curl -o ~/Downloads/latest.dump `heroku pgbackups:url --app levelup-production`' +alias levelup-db-fix='killruby ; rake db:drop:all db:create:all ; pg_restore --verbose --clean --no-acl --no-owner -d levelup_development ~/Downloads/latest.dump -j 8 ; prepdb && rake levelup:dev:create_admin && rails runner CreditCard.delete_all' diff --git a/.zsh/func/prompt_grb_setup b/zsh/func/prompt_grb_setup similarity index 98% rename from .zsh/func/prompt_grb_setup rename to zsh/func/prompt_grb_setup index 2c0894d..88b4d87 100644 --- a/.zsh/func/prompt_grb_setup +++ b/zsh/func/prompt_grb_setup @@ -127,6 +127,7 @@ prompt_grb_setup() { attcode[no-conceal]=28 local -A pc + pc[divider]='black' pc[default]='default' pc[date]='cyan' pc[time]='Blue' @@ -161,7 +162,8 @@ prompt_grb_setup() { p_line="$pc[line]%y$pc[reset]" - PROMPT= + PROMPT="$pc[divider]\$(repeat \$COLUMNS printf '-')$pc[reset]" + PROMPT+= if [ $verbose ]; then PROMPT+="$pc[host]%m$pc[reset]" fi diff --git a/.zsh/func/prompt_wunjo_setup b/zsh/func/prompt_wunjo_setup similarity index 100% rename from .zsh/func/prompt_wunjo_setup rename to zsh/func/prompt_wunjo_setup diff --git a/.zsh/func/zgitinit b/zsh/func/zgitinit similarity index 100% rename from .zsh/func/zgitinit rename to zsh/func/zgitinit diff --git a/zsh/functions b/zsh/functions new file mode 100644 index 0000000..2e38f07 --- /dev/null +++ b/zsh/functions @@ -0,0 +1,47 @@ +function git-new-remote-tracking { + git checkout -b $1 && git push -u origin $1 +} + +function git_branch_name { + val=`git branch 2>/dev/null | grep '^*' | colrm 1 2` + echo "$val" +} + +function git-done { + branch=`git_branch_name` + git checkout master && git merge $branch --ff-only && bundle install && rake db:migrate db:test:prepare && rake && git push && git branch -D $branch && git push origin :$branch +} + +function git-nuke { + git branch -D $1 && git push origin :$1 +} + +function git-on-master { + branch=`git_branch_name` + git checkout master && git pull --rebase + git checkout $branch + git rebase master + } + +function g { + if [[ $# > 0 ]]; then + git $@ + else + git status + fi +} +compdef g=git + +function rrg { + rake routes | grep $1 +} + +function take { + mkdir $1 + cd $1 +} + +# Allows commit message without typing quotes (can't have quotes in the commit msg though). +function gc { + git commit -m "$*" +} diff --git a/zshenv b/zshenv new file mode 100644 index 0000000..76e4b02 --- /dev/null +++ b/zshenv @@ -0,0 +1,2 @@ +fpath=($fpath $HOME/.zsh/func) +typeset -U fpath diff --git a/.zshrc b/zshrc similarity index 51% rename from .zshrc rename to zshrc index 8cc0543..5265657 100644 --- a/.zshrc +++ b/zshrc @@ -1,9 +1,6 @@ # Path to your oh-my-zsh configuration. ZSH=$HOME/.zsh -fpath=($fpath $HOME/.zsh/func) -typeset -U fpath - setopt promptsubst autoload -U promptinit promptinit @@ -12,30 +9,52 @@ prompt grb autoload -U compinit compinit -# Check for updates on initial load... -if [ "$DISABLE_AUTO_UPDATE" != "true" ] -then - /usr/bin/env ZSH=$ZSH zsh $ZSH/tools/check_for_upgrade.sh -fi +# Never know when you're gonna need to popd! +setopt AUTO_PUSHD -# Load all of the config files that end in .zsh -for config_file ($ZSH/lib/*.zsh) source $config_file +# Allow completing of the remainder of a command +bindkey "^N" insert-last-word -# Customize to your needs... -export PATH=/usr/local/sbin:/usr/local/bin:${PATH} -#/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin -export PATH="$HOME/bin:$PATH" +# Show contents of directory after cd-ing into it +chpwd() { + ls -lrthG +} # Unbreak broken, non-colored terminal export TERM=xterm-256color -# Unbreak history -export HISTSIZE=10000 +# Grep tweaks +export GREP_OPTIONS="-nRi --color --exclude-dir=tmp" # --exclude-dir=public --exclude-dir=log --exclude-dir=vendor/assets --exclude-dir=fonts --exclude-dir=images --exclude-dir=coverage --exclude-dir=rdoc" + +# Save a ton of history +export HISTSIZE=20000 export HISTFILE="$HOME/.history" export SAVEHIST=$HISTSIZE -# Grep tweaks -export GREP_OPTIONS="-nRi --color --exclude-dir=tmp --exclude-dir=public --exclude-dir=log --exclude-dir=vendor/assets --exclude-dir=fonts --exclude-dir=images --exclude-dir=coverage --exclude-dir=rdoc" +# Set to this to use case-sensitive completion +# CASE_SENSITIVE="true" + +# Comment this out to disable weekly auto-update checks +# DISABLE_AUTO_UPDATE="true" + +# Uncomment following line if you want to disable colors in ls +# DISABLE_LS_COLORS="true" + +# Uncomment following line if you want to disable autosetting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment following line if you want red dots to be displayed while waiting for completion +# COMPLETION_WAITING_DOTS="true" + +# Source my custom files after oh-my-zsh so I can override things. +source $HOME/.dotfiles/zsh/aliases +source $HOME/.dotfiles/zsh/functions + +# Customize to your needs... +export PATH=/usr/local/sbin:/usr/local/bin:${PATH} +PATH=$PATH:$HOME/bin +PATH="/usr/local/heroku/bin:$PATH" +PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting # Alias alias ls='ls -G' @@ -71,6 +90,7 @@ alias cd.....='cd ../../../..' alias cd/='cd /' # easier reload alias reload='source ~/.zshrc' +alias beg='bundle exec guard' # Misc activate_virtualenv() { @@ -82,6 +102,10 @@ activate_virtualenv() { } ### Added by the Heroku Toolbelt -export PATH="/usr/local/heroku/bin:$PATH" -PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting +# Shaves about 0.5s off Rails boot time (when using perf patch). Taken from https://gist.github.com/1688857 +export RUBY_HEAP_MIN_SLOTS=1000000 +export RUBY_HEAP_SLOTS_INCREMENT=1000000 +export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 +export RUBY_GC_MALLOC_LIMIT=1000000000 +export RUBY_HEAP_FREE_MIN=500000