diff --git a/README.markdown b/README.markdown new file mode 100644 index 00000000..8f3ea0fd --- /dev/null +++ b/README.markdown @@ -0,0 +1,248 @@ +# Janus: Carlhuda's vim Distribution + +This is a basic distribution of vim plugins and tools intended to be run +on top of the latest MacVIM snapshot. + +We (Carl and Yehuda) both use this distribution for our own use, and +welcome patches and contributions to help make it an effective way to +get started with vim and then use it productively for years to come. + +At present, we are still learning to use vim ourselves, so you should +anticipate a period of rapid development while we get a handle on the +best tools for the job. So far, we have mostly integrated existing +plugins and tools, and we anticipate to continue doing so while also +writing our own plugins as appropriate. + +In general, you can expect that the tools we use work well together and +that we have given careful thought to the experience of using MacVIM +with the tools in question. If you run into an issue using it, please +report an issue to the issue tracker. + +## Installation + +0. `for i in ~/.vim ~/.vimrc ~/.gvimrc; do [ -e $i ] && mv $i $i.old; + done` +1. `git clone git://github.com/carlhuda/janus.git ~/.vim` +2. `cd ~/.vim` +3. `rake` + +or + + `curl http://github.com/carlhuda/janus/raw/master/bootstrap.sh \ + -o - | sh` + +## Updating to the latest version + +To update to the latest version of the distribution, just run `rake` +again inside your `~/.vim` directory. + +# Intro to VIM + +Here's some tips if you've never used VIM before: + +## Tutorial + +* Type `vimtutor` into a shell to go through a brief interactive + tutorial inside VIM. + +## Modes + +* VIM has two modes: + * insert mode- stuff you type is added to the buffer + * normal mode- keys you hit are interpretted as commands +* To enter insert mode, hit `i` +* To exit insert mode, hit `` + +## Useful commands + +* Use `:q` to exit vim +* Certain commands are prefixed with a `` key, which maps to `\` + by default. Use `let mapleader = ","` to change this. + +# Features + +This vim distribution includes a number of packages built by others. + +## Base Customizations + +Janus ships with a number of basic customizations for vim: + +* Line numbers +* Ruler (line and column numbers) +* No wrap (turn off per-buffer via set :wrap) +* Soft 2-space tabs, and default hard tabs to 2 spaces +* Show tailing whitespace as `.` +* Make searching highlighted, incremental, and case insensitive unless a + capital letter is used +* Always show a status line +* Allow backspacing over everything (identations, eol, and start + characters) in insert mode +* `e` expands to `:e {directory of current file}/` (open in the + current buffer) +* `tr` expands to `:te {directory of current file}/` (open in a + new MacVIM tab) +* `` inserts the directory of the current file into a command +* Automatic insertion of closing quotes, parenthesis, and braces + +## "Project Drawer" aka NERDTree + +NERDTree is a file explorer plugin that provides "project drawer" +functionality to your vim projects. You can learn more about it with +:help NERDTree. + +**Customizations**: Janus adds a number of customizations to the core +NERDTree: + +* Use `n` to toggle NERDTree +* Ignore `*.rbc` and `*~` files +* Automatically activate NERDTree when MacVIM opens and make the + original buffer the active one +* Provide alternative :e, :cd, :rm and :touch abbreviations which also + refresh NERDTree when done (when NERDTree is open) +* When opening vim with vim /path, open the left NERDTree to that + directory, set the vim pwd, and clear the right buffer +* Disallow `:e`ing files into the NERDTree buffer +* In general, assume that there is a single NERDTree buffer on the left + and one or more editing buffers on the right + +## Ack.vim + +Ack.vim uses ack to search inside the current directory for a pattern. +You can learn more about it with :help Ack + +**Customizations**: Janus rebinds command-shift-f (``) to bring up +`:Ack `. + +## Command-T + +Command-T provides a mechanism for searching for a file inside the +current working directory. It behaves similarly to command-t in +Textmate. + +**Customizations**: Janus rebinds command-t (``) to bring up this +plugin. It defaults to `t`. + +## ConqueTerm + +ConqueTerm embeds a basic terminal inside a vim buffer. The terminal has +an insert mode in which you can type commands, tab complete and use the +terminal like normal. You can also escape out of insert mode to use +other vim commands on the buffer, like yank and paste. + +**Customizations**: Janus binds command-e (``) to bring up +`:ConqueTerm bash --login` in the current buffer. + +**Note**: To get colors working, you might have to `export TERM=xterm` +and use `ls -G` or `gls --color` + +## indent\_object + +Indent object creates a "text object" that is relative to the current +ident. Text objects work inside of visual mode, and with `c` (change), +`d` (delete) and `y` (yank). For instance, try going into a method in +normal mode, and type `v ii`. Then repeat `ii`. + +**Note**: indent\_object seems a bit busted. It would also be nice if +there was a text object for Ruby `class` and `def` blocks. + +## surround + +Surround allows you to modify "surroundings" around the current text. +For instance, if the cursor was inside `"foo bar"`, you could type +`cs"'` to convert the text to `'foo bar'`. + +There's a lot more; check it out at `:help surround` + +## NERDCommenter + +NERDCommenter allows you to wrangle your code comments, regardless of +filetype. View `help :NERDCommenter` for all the details. + +**Customizations**: Janus binds command-/ (``) to toggle comments. + +## SuperTab + +In insert mode, start typing something and hit `` to tab-complete +based on the current context. + +## ctags + +Janus includes the TagList plugin, which binds `:Tlist` to an overview +panel that lists all ctags for easy navigation. + +**Customizations**: Janus binds `rt` to the ctags command to +update tags. + +**Note**: For full language support, run `brew install ctags` to install +exuberant-ctags. + +**Tip**: Check out `:help ctags` for information about VIM's built-in +ctag support. Tag navigation creates a stack which can traversed via +`Ctrl-]` (to find the source of a token) and `Ctrl-T` (to jump back up +one level). + +## Git Support (Fugitive) + +Fugitive adds pervasive git support to git directories in vim. For more +information, use `:help fugitive` + +Use `:Gstatus` to view `git status` and type `-` on any file to stage or +unstage it. Type `p` on a file to enter `git add -p` and stage specific +hunks in the file. + +Use `:Gdiff` on an open file to see what changes have been made to that +file + +## ZoomWin + +When working with split windows, ZoomWin lets you zoom into a window and +out again using `Ctrl-W o` + +**Customizations**: Janus binds `z` to `:ZoomWin` + +## Markdown Preview + +Markdown preview takes the current buffer, converts the Markdown to +HTML, and opens it in your default browser. + +**Customizations**: Janus binds `p` to this plugin. + +## Additional Syntaxes + +Janus ships with a few additional syntaxes: + +* Markdown (bound to \*.markdown, \*.md, and \*.mk) +* Mustache (bound to \*.mustache) +* Haml (bound to \*.haml) +* Sass (bound to \*.sass) +* SCSS (bound to \*.scss) +* An improved JavaScript syntax (bound to \*.js) +* Map Gemfile, Rakefile and Thorfile to Ruby +* Git commits (set your `EDITOR` to `mvim -f`) + +## Color schemes + +Janus includes the vim color sampler pack, which includes [over 100 +popular color themes](http://www.vi-improved.org/color_sampler_pack/): + +* jellybeans +* matrix +* railscasts2 +* tango +* vibrantink +* vividchalk +* wombat +* xoria256 + +Use `:color vibrantink` to switch to a color scheme. + +Janus also has a few customized versions of popular themes: + +* jellybeans+ +* molokai +* railscasts+ + +To permanently set a color scheme, update your local vimrc files: + + echo color desert > ~/.vimrc.local + echo color jellybeans+ > ~/.gvimrc.local diff --git a/bootstrap.sh b/bootstrap.sh index c99d77ee..649f59c7 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,44 +1,4 @@ -#!/bin/bash - -function die() -{ - echo "${@}" - exit 1 -} - -function backup_previous_install() -{ - # Add .old to any existing Vim file in the home directory - for filepath in "${HOME}/.vim" "${HOME}/.vimrc" "${HOME}/.gvimrc"; do - if [ -e $filepath ]; then - mv "${filepath}" "${filepath}.old" || die "Could not move ${filepath} to ${filepath}.old" - echo "${filepath} has been renamed to ${filepath}.old" - fi - done -} - -function clone_janus() -{ - # Clone Janus into .vim - git clone --recursive https://github.com/carlhuda/janus.git "${HOME}/.vim" \ - || die "Could not clone the repository to ${HOME}/.vim" -} - -function run_rake() -{ - # Run rake inside .vim - pushd "${HOME}/.vim" || die "Could not go into the ${HOME}/.vim" - rake || die "Rake failed." - popd -} - -function main() -{ - if [ ! -e "${HOME}/.vim/janus" -o "$1" == "--force" ]; then - backup_previous_install - clone_janus - fi - run_rake -} - -main $1 +for i in ~/.vim ~/.vimrc ~/.gvimrc; do [ -e $i ] && mv $i $i.old; done +git clone git://github.com/carlhuda/janus.git ~/.vim +cd ~/.vim +rake \ No newline at end of file diff --git a/doc/ack.txt b/doc/ack.txt new file mode 100644 index 00000000..683ef8d0 --- /dev/null +++ b/doc/ack.txt @@ -0,0 +1,70 @@ +*ack.txt* Plugin that integrates ack with Vim + +============================================================================== +Author: Antoine Imbert *ack-author* +License: Same terms as Vim itself (see |license|) + +============================================================================== +INTRODUCTION *ack* + +This plugin is a front for the Perl module App::Ack. Ack can be used as a +replacement for grep. This plugin will allow you to run ack from vim, and +shows the results in a split window. + +:Ack[!] [options] {pattern} [{directory}] *:Ack* + + 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. + +:AckAdd [options] {pattern} [{directory}] *:AckAdd* + + Just like |:Ack|, but instead of making a new list, the matches are + appended to the current |quickfix| list. + +:AckFromSearch [{directory}] *:AckFromSearch* + + Just like |:Ack| but the pattern is from previous search. + +:LAck [options] {pattern} [{directory}] *:LAck* + + Just like |:Ack| but instead of the |quickfix| list, matches are placed in + the current |location-list|. + +:LAckAdd [options] {pattern} [{directory}] *:LAckAdd* + + Just like |:AckAdd| but instead of the |quickfix| list, matches are added + to the current |location-list| + +:AckFile [options] {pattern} [{directory}] *:AckFile* + + 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. + +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 *ack-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 ack.vim results). + +t open in a new tab. + +T open in new tab silently. + +v open in vertical split. + +gv open in vertical split silently. + +q close the quickfix window. diff --git a/plugin/ack.vim b/plugin/ack.vim new file mode 100644 index 00000000..30f28043 --- /dev/null +++ b/plugin/ack.vim @@ -0,0 +1,78 @@ +" NOTE: You must, of course, install the ack script +" in your path. +" On Debian / Ubuntu: +" sudo apt-get install ack-grep +" With MacPorts: +" sudo port install p5-app-ack + +" Location of the ack utility +if !exists("g:ackprg") + let s:ackcommand = executable('ack-grep') ? 'ack-grep' : 'ack' + let g:ackprg=s:ackcommand." -H --nocolor --nogroup --column" +endif + +function! s:Ack(cmd, args, ...) + redraw + echo "Searching ..." + + " 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:ackformat="%f" + else + let g:ackformat="%f:%l:%c:%m" + end + + let grepprg_bak=&grepprg + let grepformat_bak=&grepformat + try + let &grepprg=g:ackprg + let &grepformat=g:ackformat + silent execute a:cmd . " " . escape(l:grepargs, '|') + finally + let &grepprg=grepprg_bak + let &grepformat=grepformat_bak + endtry + + if a:cmd =~# '^l' + botright lopen + else + botright copen + endif + + exec "nnoremap q :ccl" + exec "nnoremap t T" + exec "nnoremap T TgT" + exec "nnoremap o " + exec "nnoremap go " + exec "nnoremap v v" + exec "nnoremap gv v" + + " If highlighting is on, highlight the search keyword. + if exists("g:ackhighlight") + let @/=a:args + set hlsearch + end + + redraw! +endfunction + +function! s:AckFromSearch(cmd, args) + let search = getreg('/') + " translate vim regular expression to perl regular expression. + let search = substitute(search,'\(\\<\|\\>\)','\\b','g') + call s:Ack(a:cmd, '"' . search .'" '. a:args) +endfunction + +command! -bang -nargs=* -complete=file Ack call s:Ack('grep',) +command! -bang -nargs=* -complete=file AckAdd call s:Ack('grepadd', ) +command! -bang -nargs=* -complete=file AckFromSearch call s:AckFromSearch('grep', ) +command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep', ) +command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd', ) +command! -bang -nargs=* -complete=file AckFile call s:Ack('grep -g', ) diff --git a/tmp/ack.vim b/tmp/ack.vim new file mode 160000 index 00000000..fd9632b4 --- /dev/null +++ b/tmp/ack.vim @@ -0,0 +1 @@ +Subproject commit fd9632b40ac07b39adb270311cde2c460c9ba6da