Updated vimrc

pull/133/head
amix 8 years ago
parent 9a2843c2a5
commit d7752b59ae
  1. 6
      .gitmodules
  2. 1
      README.md
  3. 15
      sources_non_forked/ack.vim/README.md
  4. 22
      sources_non_forked/ack.vim/autoload/ack.vim
  5. 11
      sources_non_forked/ack.vim/doc/ack.txt
  6. 4
      sources_non_forked/ack.vim/plugin/ack.vim
  7. 2
      sources_non_forked/ag.vim/.gitignore
  8. 76
      sources_non_forked/ag.vim/README.md
  9. 3
      sources_non_forked/ag.vim/Rakefile
  10. 216
      sources_non_forked/ag.vim/autoload/ag.vim
  11. 174
      sources_non_forked/ag.vim/doc/ag.txt
  12. 11
      sources_non_forked/ag.vim/plugin/ag.vim
  13. 113
      sources_non_forked/goyo.vim/autoload/goyo.vim
  14. 2
      sources_non_forked/goyo.vim/plugin/goyo.vim
  15. 48
      sources_non_forked/nerdtree/README.markdown
  16. 282
      sources_non_forked/nerdtree/autoload/nerdtree.vim
  17. 24
      sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim
  18. 44
      sources_non_forked/nerdtree/doc/NERD_tree.txt
  19. 2
      sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim
  20. 17
      sources_non_forked/nerdtree/lib/nerdtree/creator.vim
  21. 100
      sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim
  22. 50
      sources_non_forked/nerdtree/lib/nerdtree/opener.vim
  23. 36
      sources_non_forked/nerdtree/lib/nerdtree/path.vim
  24. 16
      sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim
  25. 232
      sources_non_forked/nerdtree/lib/nerdtree/ui.vim
  26. 11
      sources_non_forked/nerdtree/plugin/NERD_tree.vim
  27. 27
      sources_non_forked/syntastic/README.markdown
  28. 42
      sources_non_forked/syntastic/autoload/syntastic/c.vim
  29. 47
      sources_non_forked/syntastic/autoload/syntastic/log.vim
  30. 2
      sources_non_forked/syntastic/autoload/syntastic/postprocess.vim
  31. 28
      sources_non_forked/syntastic/autoload/syntastic/preprocess.vim
  32. 59
      sources_non_forked/syntastic/autoload/syntastic/util.vim
  33. 89
      sources_non_forked/syntastic/doc/syntastic.txt
  34. 32
      sources_non_forked/syntastic/plugin/syntastic.vim
  35. 2
      sources_non_forked/syntastic/plugin/syntastic/autoloclist.vim
  36. 2
      sources_non_forked/syntastic/plugin/syntastic/balloons.vim
  37. 45
      sources_non_forked/syntastic/plugin/syntastic/checker.vim
  38. 2
      sources_non_forked/syntastic/plugin/syntastic/cursor.vim
  39. 4
      sources_non_forked/syntastic/plugin/syntastic/highlighting.vim
  40. 32
      sources_non_forked/syntastic/plugin/syntastic/loclist.vim
  41. 4
      sources_non_forked/syntastic/plugin/syntastic/modemap.vim
  42. 2
      sources_non_forked/syntastic/plugin/syntastic/notifiers.vim
  43. 27
      sources_non_forked/syntastic/plugin/syntastic/registry.vim
  44. 8
      sources_non_forked/syntastic/plugin/syntastic/signs.vim
  45. 2
      sources_non_forked/syntastic/syntax_checkers/actionscript/mxmlc.vim
  46. 4
      sources_non_forked/syntastic/syntax_checkers/ada/gcc.vim
  47. 2
      sources_non_forked/syntastic/syntax_checkers/apiblueprint/snowcrash.vim
  48. 2
      sources_non_forked/syntastic/syntax_checkers/applescript/osacompile.vim
  49. 2
      sources_non_forked/syntastic/syntax_checkers/asciidoc/asciidoc.vim
  50. 2
      sources_non_forked/syntastic/syntax_checkers/bemhtml/bemhtmllint.vim
  51. 4
      sources_non_forked/syntastic/syntax_checkers/bro/bro.vim
  52. 2
      sources_non_forked/syntastic/syntax_checkers/c/checkpatch.vim
  53. 2
      sources_non_forked/syntastic/syntax_checkers/c/clang_check.vim
  54. 2
      sources_non_forked/syntastic/syntax_checkers/c/clang_tidy.vim
  55. 2
      sources_non_forked/syntastic/syntax_checkers/c/cppcheck.vim
  56. 2
      sources_non_forked/syntastic/syntax_checkers/c/oclint.vim
  57. 4
      sources_non_forked/syntastic/syntax_checkers/c/pc_lint.vim
  58. 4
      sources_non_forked/syntastic/syntax_checkers/c/sparse.vim
  59. 2
      sources_non_forked/syntastic/syntax_checkers/c/splint.vim
  60. 4
      sources_non_forked/syntastic/syntax_checkers/cabal/cabal.vim
  61. 2
      sources_non_forked/syntastic/syntax_checkers/chef/foodcritic.vim
  62. 2
      sources_non_forked/syntastic/syntax_checkers/co/coco.vim
  63. 2
      sources_non_forked/syntastic/syntax_checkers/coffee/coffee.vim
  64. 2
      sources_non_forked/syntastic/syntax_checkers/coffee/coffeelint.vim
  65. 2
      sources_non_forked/syntastic/syntax_checkers/coq/coqtop.vim
  66. 2
      sources_non_forked/syntastic/syntax_checkers/cpp/clang_check.vim
  67. 2
      sources_non_forked/syntastic/syntax_checkers/cpp/clang_tidy.vim
  68. 2
      sources_non_forked/syntastic/syntax_checkers/cpp/cppcheck.vim
  69. 2
      sources_non_forked/syntastic/syntax_checkers/cpp/cpplint.vim
  70. 2
      sources_non_forked/syntastic/syntax_checkers/cpp/oclint.vim
  71. 2
      sources_non_forked/syntastic/syntax_checkers/cpp/pc_lint.vim
  72. 48
      sources_non_forked/syntastic/syntax_checkers/cpp/verapp.vim
  73. 4
      sources_non_forked/syntastic/syntax_checkers/cs/mcs.vim
  74. 2
      sources_non_forked/syntastic/syntax_checkers/css/csslint.vim
  75. 2
      sources_non_forked/syntastic/syntax_checkers/css/phpcs.vim
  76. 10
      sources_non_forked/syntastic/syntax_checkers/css/prettycss.vim
  77. 2
      sources_non_forked/syntastic/syntax_checkers/css/recess.vim
  78. 2
      sources_non_forked/syntastic/syntax_checkers/cucumber/cucumber.vim
  79. 2
      sources_non_forked/syntastic/syntax_checkers/cuda/nvcc.vim
  80. 2
      sources_non_forked/syntastic/syntax_checkers/dart/dartanalyzer.vim
  81. 2
      sources_non_forked/syntastic/syntax_checkers/docbk/xmllint.vim
  82. 2
      sources_non_forked/syntastic/syntax_checkers/dustjs/swiffer.vim
  83. 13
      sources_non_forked/syntastic/syntax_checkers/elixir/elixir.vim
  84. 119
      sources_non_forked/syntastic/syntax_checkers/erlang/erlang_check_file.erl
  85. 2
      sources_non_forked/syntastic/syntax_checkers/erlang/syntaxerl.vim
  86. 6
      sources_non_forked/syntastic/syntax_checkers/eruby/ruby.vim
  87. 73
      sources_non_forked/syntastic/syntax_checkers/fortran/gfortran.vim
  88. 6
      sources_non_forked/syntastic/syntax_checkers/glsl/cgc.vim
  89. 6
      sources_non_forked/syntastic/syntax_checkers/go/go.vim
  90. 2
      sources_non_forked/syntastic/syntax_checkers/go/gofmt.vim
  91. 2
      sources_non_forked/syntastic/syntax_checkers/go/golint.vim
  92. 2
      sources_non_forked/syntastic/syntax_checkers/go/gotype.vim
  93. 2
      sources_non_forked/syntastic/syntax_checkers/go/govet.vim
  94. 2
      sources_non_forked/syntastic/syntax_checkers/haml/haml_lint.vim
  95. 8
      sources_non_forked/syntastic/syntax_checkers/handlebars/handlebars.vim
  96. 12
      sources_non_forked/syntastic/syntax_checkers/haskell/ghc-mod.vim
  97. 2
      sources_non_forked/syntastic/syntax_checkers/haskell/hdevtools.vim
  98. 6
      sources_non_forked/syntastic/syntax_checkers/haxe/haxe.vim
  99. 2
      sources_non_forked/syntastic/syntax_checkers/hss/hss.vim
  100. 64
      sources_non_forked/syntastic/syntax_checkers/html/tidy.vim
  101. Some files were not shown because too many files have changed in this diff Show More

6
.gitmodules vendored

@ -1,6 +0,0 @@
[submodule "sources_non_forked/vim-gitgutter"]
path = sources_non_forked/vim-gitgutter
url = git://github.com/airblade/vim-gitgutter.git
[submodule "sources_non_forked/gruvbox"]
path = sources_non_forked/gruvbox
url = git@github.com:morhetz/gruvbox.git

@ -69,6 +69,7 @@ I recommend reading the docs of these plugins to understand them better. Each of
* [bufexplorer.zip](https://github.com/vim-scripts/bufexplorer.zip): Buffer Explorer / Browser. This plugin can be opened with `<leader+o>`
* [NERD Tree](https://github.com/scrooloose/nerdtree): A tree explorer plugin for vim
* [ack.vim](https://github.com/mileszs/ack.vim): Vim plugin for the Perl module / CLI script 'ack'
* [ag.vim](https://github.com/rking/ag.vim): A much faster Ack
* [ctrlp.vim](https://github.com/kien/ctrlp.vim): Fuzzy file, buffer, mru and tag finder. In my config it's mapped to `<Ctrl+F>`, because `<Ctrl+P>` is used by YankRing
* [mru.vim](https://github.com/vim-scripts/mru.vim): Plugin to manage Most Recently Used (MRU) files. Includes my own fork which adds syntax highlighting to MRU. This plugin can be opened with `<leader+f>`
* [open_file_under_cursor.vim](https://github.com/amix/open_file_under_cursor.vim): Open file under cursor when pressing `gf`

@ -4,7 +4,7 @@ Run your favorite search tool from Vim, with an enhanced results list.
This plugin was designed as a Vim frontend for the Perl module [App::Ack]. Ack
can be used as a replacement for 99% of the uses of _grep_. The plugin allows
you to run ack from vim, and shows the results in a split window.
you to run ack from Vim, and shows the results in a split window.
But here's a little secret for the Vim-seasoned: it's just a light wrapper for
Vim's [grepprg] and the [quickfix] window for match results. This makes it easy
@ -28,13 +28,21 @@ It is recommended to use one of the popular plugin managers for Vim. There are
many and you probably already have a preferred one, but a few examples for your
copy-and-paste convenience:
#### Pathogen
$ git clone https://github.com/mileszs/ack.vim.git ~/.vim/bundle/ack.vim
#### Vundle
Plugin 'mileszs/ack.vim'
```vim
Plugin 'mileszs/ack.vim'
```
#### NeoBundle
NeoBundle 'mileszs/ack.vim'
```vim
NeoBundle 'mileszs/ack.vim'
```
#### Manual (not recommended)
@ -127,6 +135,7 @@ Please see [the Github releases page][releases].
* Fix the quick help overlay clobbering the list mappings
* Fix `:AckFile` when using Dispatch
* Restore original `'makeprg'` and `'errorformat'` when using Dispatch
* Arrow keys also work for auto-preview (#158)
* Internal refactoring and clean-up
## Credits

@ -27,11 +27,7 @@ function! ack#Ack(cmd, args) "{{{
endif
" If no pattern is provided, search for the word under the cursor
if empty(a:args)
let l:grepargs = expand("<cword>")
else
let l:grepargs = a:args . join(a:000, ' ')
end
let l:grepargs = empty(a:args) ? expand("<cword>") : a:args . join(a:000, ' ')
" NOTE: we escape special chars, but not everything using shellescape to
" allow for passing arguments etc
@ -118,6 +114,8 @@ function! s:ApplyMappings() "{{{
if exists("g:ackpreview") " if auto preview in on, remap j and k keys
nnoremap <buffer> <silent> j j<CR><C-W><C-W>
nnoremap <buffer> <silent> k k<CR><C-W><C-W>
nmap <buffer> <silent> <Down> j
nmap <buffer> <silent> <Up> k
endif
endfunction "}}}
@ -157,17 +155,11 @@ function! s:QuickHelp() "{{{
execute 'edit' globpath(&rtp, 'doc/ack_quick_help.txt')
silent normal gg
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal noswapfile
setlocal nobuflisted
setlocal nomodifiable
setlocal buftype=nofile bufhidden=hide nobuflisted
setlocal nomodifiable noswapfile
setlocal filetype=help
setlocal nonumber
setlocal norelativenumber
setlocal nowrap
setlocal foldlevel=20
setlocal foldmethod=diff
setlocal nonumber norelativenumber nowrap
setlocal foldmethod=diff foldlevel=20
nnoremap <buffer> <silent> ? :q!<CR>:call ack#ShowResults()<CR>
endfunction "}}}

@ -84,18 +84,23 @@ g:ackprg
Default for ubuntu: "ack-grep"
Default for other systems: "ack"
Use this option to specify the ack command and its options
Use this option to specify the search command and its default arguments.
Example:
>
let g:ackprg = "other-bin-ack"
let g:ackprg = "ag --vimgrep"
<
*g:ack_default_options*
g:ack_default_options
Default: " -s -H --nocolor --nogroup --column"
Use this option to specify the options used by ack
Use this option to specify the default arguments given to `ack`. This is only
used if |g:ackprg| has not been customized from the default--if you are using
a custom search program instead of Ack, set your preferred options in
|g:ackprg|.
NOTE: This option may be deprecated in the future. ~
Example:
>

@ -71,8 +71,8 @@ command! -bang -nargs=* -complete=file LAckAdd call ack#Ack('lgrepadd<bang
command! -bang -nargs=* -complete=file AckFile call ack#Ack('grep<bang> -g', <q-args>)
command! -bang -nargs=* -complete=help AckHelp call ack#AckHelp('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=help LAckHelp call ack#AckHelp('lgrep<bang>', <q-args>)
command! -bang -nargs=* -complete=help AckWindow call ack#AckWindow('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=help LAckWindow call ack#AckWindow('lgrep<bang>', <q-args>)
command! -bang -nargs=* AckWindow call ack#AckWindow('grep<bang>', <q-args>)
command! -bang -nargs=* LAckWindow call ack#AckWindow('lgrep<bang>', <q-args>)
let g:loaded_ack = 1

@ -0,0 +1,2 @@
tags
ag-vim.tgz

@ -0,0 +1,76 @@
# 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 ##
See [the_silver_searcher's README](https://github.com/ggreer/the_silver_searcher#installing) for its installation instructions (if you haven't installed it already).
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:
Vim has various ways of installing plugins, the standard way is in [the documentation](http://vimdoc.sourceforge.net/htmldoc/usr_05.html#plugin), but most people use a plugin to manage their plugins. If you don't already have a preferred plugin manager plugin, why not try one of the following?
- [vim-plug](https://github.com/junegunn/vim-plug#readme)
- [vim-pathogen](https://github.com/tpope/vim-pathogen#readme)
- [Vundle.vim](https://github.com/gmarik/Vundle.vim#readme)
- Or, if you don't use any sort of Vim plugin management:
```sh
cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && echo "set runtimepath^=~/.vim/bundle/ag" >> ~/.vimrc
```
Then open vim and rum `:helptags ~/.vim/bundle/ag/doc`.
### Configuration ###
You can specify a custom ag name and path in your .vimrc like so:
let g:agprg="<custom-ag-path-goes-here> --vimgrep"
You can configure ag.vim to always start searching from your project root
instead of the cwd
let g:ag_working_path_mode="r"
## 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 noticeably so.
### Keyboard Shortcuts ###
In the quickfix window, you can use:
e to open file and close the quickfix window
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.

@ -0,0 +1,3 @@
task :tgz do
sh 'cd ..; tar czvf ag/ag-vim.tgz ag/{plugin,autoload,doc}'
end

@ -0,0 +1,216 @@
" NOTE: You must, of course, install ag / the_silver_searcher
" FIXME: Delete deprecated options below on or after 15-7 (6 months from when they were changed) {{{
if exists("g:agprg")
let g:ag_prg = g:agprg
endif
if exists("g:aghighlight")
let g:ag_highlight = g:aghighlight
endif
if exists("g:agformat")
let g:ag_format = g:agformat
endif
" }}} FIXME: Delete the deprecated options above on or after 15-7 (6 months from when they were changed)
" Location of the ag utility
if !exists("g:ag_prg")
" --vimgrep (consistent output we can parse) is available from version 0.25.0+
if split(system("ag --version"), "[ \n\r\t]")[2] =~ '\d\+.\(\(2[5-9]\)\|\([3-9][0-9]\)\)\(.\d\+\)\?'
let g:ag_prg="ag --vimgrep"
else
" --noheading seems odd here, but see https://github.com/ggreer/the_silver_searcher/issues/361
let g:ag_prg="ag --column --nogroup --noheading"
endif
endif
if !exists("g:ag_apply_qmappings")
let g:ag_apply_qmappings=1
endif
if !exists("g:ag_apply_lmappings")
let g:ag_apply_lmappings=1
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
if !exists("g:ag_mapping_message")
let g:ag_mapping_message=1
endif
if !exists("g:ag_working_path_mode")
let g:ag_working_path_mode = 'c'
endif
function! ag#AgBuffer(cmd, args)
let l:bufs = filter(range(1, bufnr('$')), 'buflisted(v:val)')
let l:files = []
for buf in l:bufs
let l:file = fnamemodify(bufname(buf), ':p')
if !isdirectory(l:file)
call add(l:files, l:file)
endif
endfor
call ag#Ag(a:cmd, a:args . ' ' . join(l:files, ' '))
endfunction
function! ag#Ag(cmd, args)
let l:ag_executable = get(split(g:ag_prg, " "), 0)
" Ensure that `ag` is installed
if !executable(l:ag_executable)
echoe "Ag command '" . l:ag_executable . "' was not found. Is the silver searcher installed and on your $PATH?"
return
endif
" If no pattern is provided, search for the word under the cursor
if empty(a:args)
let l:grepargs = expand("<cword>")
else
let l:grepargs = a:args . join(a:000, ' ')
end
" Format, used to manage column jump
if a:cmd =~# '-g$'
let s:ag_format_backup=g:ag_format
let g:ag_format="%f"
elseif exists("s:ag_format_backup")
let g:ag_format=s:ag_format_backup
elseif !exists("g:ag_format")
let g:ag_format="%f:%l:%c:%m"
endif
let l:grepprg_bak=&grepprg
let l:grepformat_bak=&grepformat
let l:t_ti_bak=&t_ti
let l:t_te_bak=&t_te
try
let &grepprg=g:ag_prg
let &grepformat=g:ag_format
set t_ti=
set t_te=
if g:ag_working_path_mode ==? 'r' " Try to find the projectroot for current buffer
let l:cwd_back = getcwd()
let l:cwd = s:guessProjectRoot()
try
exe "lcd ".l:cwd
catch
echom 'Failed to change directory to:'.l:cwd
finally
silent! execute a:cmd . " " . escape(l:grepargs, '|')
exe "lcd ".l:cwd_back
endtry
else " Someone chose an undefined value or 'c' so we revert to the default
silent! execute a:cmd . " " . escape(l:grepargs, '|')
endif
finally
let &grepprg=l:grepprg_bak
let &grepformat=l:grepformat_bak
let &t_ti=l:t_ti_bak
let &t_te=l:t_te_bak
endtry
if a:cmd =~# '^l'
let l:match_count = len(getloclist(winnr()))
else
let l:match_count = len(getqflist())
endif
if a:cmd =~# '^l' && l:match_count
exe g:ag_lhandler
let l:apply_mappings = g:ag_apply_lmappings
let l:matches_window_prefix = 'l' " we're using the location list
elseif l:match_count
exe g:ag_qhandler
let l:apply_mappings = g:ag_apply_qmappings
let l:matches_window_prefix = 'c' " we're using the quickfix window
endif
" If highlighting is on, highlight the search keyword.
if exists('g:ag_highlight')
let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]")
call feedkeys(":let &hlsearch=1 \| echo \<CR>", 'n')
end
redraw!
if l:match_count
if l:apply_mappings
nnoremap <silent> <buffer> h <C-W><CR><C-w>K
nnoremap <silent> <buffer> H <C-W><CR><C-w>K<C-w>b
nnoremap <silent> <buffer> o <CR>
nnoremap <silent> <buffer> t <C-w><CR><C-w>T
nnoremap <silent> <buffer> T <C-w><CR><C-w>TgT<C-W><C-W>
nnoremap <silent> <buffer> v <C-w><CR><C-w>H<C-W>b<C-W>J<C-W>t
exe 'nnoremap <silent> <buffer> e <CR><C-w><C-w>:' . l:matches_window_prefix .'close<CR>'
exe 'nnoremap <silent> <buffer> go <CR>:' . l:matches_window_prefix . 'open<CR>'
exe 'nnoremap <silent> <buffer> q :' . l:matches_window_prefix . 'close<CR>'
exe 'nnoremap <silent> <buffer> gv :let b:height=winheight(0)<CR><C-w><CR><C-w>H:' . l:matches_window_prefix . 'open<CR><C-w>J:exe printf(":normal %d\<lt>c-w>_", b:height)<CR>'
" Interpretation:
" :let b:height=winheight(0)<CR> Get the height of the quickfix/location list window
" <CR><C-w> Open the current item in a new split
" <C-w>H Slam the newly opened window against the left edge
" :copen<CR> -or- :lopen<CR> Open either the quickfix window or the location list (whichever we were using)
" <C-w>J Slam the quickfix/location list window against the bottom edge
" :exe printf(":normal %d\<lt>c-w>_", b:height)<CR> Restore the quickfix/location list window's height from before we opened the match
if g:ag_mapping_message && l:apply_mappings
echom "ag.vim keys: q=quit <cr>/e/t/h/v=enter/edit/tab/split/vsplit go/T/H/gv=preview versions of same"
endif
endif
else
echom 'No matches for "'.a:args.'"'
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(&runtimepath,',')
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
function! s:guessProjectRoot()
let l:splitsearchdir = split(getcwd(), "/")
while len(l:splitsearchdir) > 2
let l:searchdir = '/'.join(l:splitsearchdir, '/').'/'
for l:marker in ['.rootdir', '.git', '.hg', '.svn', 'bzr', '_darcs', 'build.xml']
" found it! Return the dir
if filereadable(l:searchdir.l:marker) || isdirectory(l:searchdir.l:marker)
return l:searchdir
endif
endfor
let l:splitsearchdir = l:splitsearchdir[0:-2] " Splice the list to get rid of the tail directory
endwhile
" Nothing found, fallback to current working dir
return getcwd()
endfunction

@ -0,0 +1,174 @@
*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.
:AgBuffer[!] [options] {pattern} *:AgBuffer*
Search for {pattern} in all open buffers. Behaves just like the |:grep|
command, but will open the |Quickfix| window for you. If [!] is not given
the first error is jumped to.
Note: this will not find changes in modified buffers, since ag can only
find what is on disk! You can save buffers automatically when searching
with the 'autowrite' option. A buffer will be ignored if it is a directory
(an explorer, like netrw).
: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|.
:LAgBuffer [options] {pattern} *:LAgBuffer*
Just like |:AgBuffer| 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. <Enter> on a
line in this window will open the file, and place the cursor on the matching
line.
See http://geoff.greer.fm/2011/12/27/the-silver-searcher-better-than-ack/ for
more information.
==============================================================================
OPTIONS *ag-options*
*g:ag_prg*
The location of the Ag program, and any options you want passed to it before
searching. Default: "ag --vimgrep" (for parsable output). Example: >
let g:ag_prg="ag --vimgrep --smart-case"
<
Note: the `--vimgrep` option was added in Ag 0.25.0. If ag.vim detects that
you're using a lower version, the following default will be used instead: >
let g:ag_prg="ag --column --nogroup --noheading"
<
This works around inconsistent behaviors in earlier Ag versions, but it is
recommended that you upgrade if possible for a better experience. `--vimgrep`
supports multiple matches on the same line of text, for example.
For background, see: https://github.com/rking/ag.vim/pull/88
*g:ag_working_path_mode*
A mapping that describes where ag will be run. Default is the current working
directory. Specifying 'r' as the argument will tell it to run from the project
rootdirectory. For now any other mapping will result to the default.
Example:
let g:ag_working_path_mode='r'
*g:ag_highlight*
If 1, highlight the search terms after searching. Default: 0. Example: >
let g:ag_highlight=1
<
*g:ag_format*
Format to recognize the matches. See 'errorformat' for more info. Default:
"%f" when searching for files, "%f:%l:%c:%m" if not otherwise set. For
example, if your `g:ag_prg` is set to just "ag" (no column numbers in the
output, so when you jump to a match your cursor will be on the start of the
line): >
let g:ag_format="%f:%l:%m"
<
*g:ag_apply_lmappings*
Whether or not to add custom mappings to location list windows opened by this
plugin. Only applies if you're using the location list. Default 1. Example: >
let g:ag_apply_lmappings=0
<
*g:ag_apply_qmappings*
Whether or not to add custom mappings to quickfix windows opened by this
plugin. Only applies if you're using the error list. Default 1. Example: >
let g:ag_apply_qmappings=0
<
*g:ag_lhandler*
A custom command used to open the location list after it's populated.
Default: "botright lopen". You might want to set this to change where the
location list is opened, or what size it is. Example: >
let g:ag_lhandler="topleft lopen"
<
*g:ag_qhandler*
A custom command used to open the error list after it's populated. Default:
"botright copen". You might want to set this to change where the quickfix
window is opened, or what size it is. Example: >
let g:ag_qhandler="copen 20"
<
*g:ag_mapping_message*
Whether or not to show the message explaining the extra mappings that are
added to the results list this plugin populates. This message is not shown if
the mappings are not applied (see |g:ag_apply_qmappings| and
|g:ag_apply_lmappings| for more info. Default 1. Example: >
let g:ag_mapping_message=0
<
==============================================================================
MAPPINGS *ag-mappings*
The following keyboard shortcuts are available in the quickfix window:
e open file and close 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.
vim:tw=78:fo=tcq2:ft=help:norl:

@ -0,0 +1,11 @@
" NOTE: You must, of course, install ag / the_silver_searcher
command! -bang -nargs=* -complete=file Ag call ag#Ag('grep<bang>',<q-args>)
command! -bang -nargs=* -complete=file AgBuffer call ag#AgBuffer('grep<bang>',<q-args>)
command! -bang -nargs=* -complete=file AgAdd call ag#Ag('grepadd<bang>', <q-args>)
command! -bang -nargs=* -complete=file AgFromSearch call ag#AgFromSearch('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAg call ag#Ag('lgrep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAgBuffer call ag#AgBuffer('lgrep<bang>',<q-args>)
command! -bang -nargs=* -complete=file LAgAdd call ag#Ag('lgrepadd<bang>', <q-args>)
command! -bang -nargs=* -complete=file AgFile call ag#Ag('grep<bang> -g', <q-args>)
command! -bang -nargs=* -complete=help AgHelp call ag#AgHelp('grep<bang>',<q-args>)
command! -bang -nargs=* -complete=help LAgHelp call ag#AgHelp('lgrep<bang>',<q-args>)

@ -24,6 +24,10 @@
let s:cpo_save = &cpo
set cpo&vim
function! s:const(val, min, max)
return min([max([a:val, a:min]), a:max])
endfunction
function! s:get_color(group, attr)
return synIDattr(synIDtrans(hlID(a:group)), a:attr)
endfunction
@ -78,28 +82,27 @@ function! s:setup_pad(bufnr, vert, size, repel)
execute winnr('#') . 'wincmd w'
endfunction
function! s:hmargin()
let nwidth = max([len(string(line('$'))) + 1, &numberwidth])
let width = t:goyo_width + (&number ? nwidth : 0)
return (&columns - width)
endfunction
function! s:resize_pads()
let t:goyo_width = max([2, t:goyo_width])
let t:goyo_margin_top = min([max([2, t:goyo_margin_top]), &lines / 2 - 1])
let t:goyo_margin_bottom = min([max([2, t:goyo_margin_bottom]), &lines / 2 - 1])
let hmargin = s:hmargin()
augroup goyop
autocmd!
augroup END
call s:setup_pad(t:goyo_pads.t, 0, t:goyo_margin_top - 1, 'j')
call s:setup_pad(t:goyo_pads.b, 0, t:goyo_margin_bottom - 2, 'k')
call s:setup_pad(t:goyo_pads.l, 1, hmargin / 2 - 1, 'l')
call s:setup_pad(t:goyo_pads.r, 1, hmargin / 2 - 1, 'h')
let t:goyo_width = winwidth(0)
let t:goyo_dim.width = s:const(t:goyo_dim.width, 2, &columns)
let t:goyo_dim.height = s:const(t:goyo_dim.height, 2, &lines)
let vmargin = max([0, (&lines - t:goyo_dim.height) / 2 - 1])
let yoff = s:const(t:goyo_dim.yoff, - vmargin, vmargin)
let top = vmargin + yoff
let bot = vmargin - yoff - 1
call s:setup_pad(t:goyo_pads.t, 0, top, 'j')
call s:setup_pad(t:goyo_pads.b, 0, bot, 'k')
let nwidth = max([len(string(line('$'))) + 1, &numberwidth])
let width = t:goyo_dim.width + (&number ? nwidth : 0)
let hmargin = max([0, (&columns - width) / 2 - 1])
let xoff = s:const(t:goyo_dim.xoff, - hmargin, hmargin)
call s:setup_pad(t:goyo_pads.l, 1, hmargin + xoff, 'l')
call s:setup_pad(t:goyo_pads.r, 1, hmargin - xoff, 'h')
endfunction
function! s:tranquilize()
@ -145,11 +148,11 @@ endfunction
function! s:maps_resize()
let commands = {
\ '=': ':<c-u>let [t:goyo_width, t:goyo_margin_top, t:goyo_margin_bottom] = t:goyo_initial_dim <bar> call <sid>resize_pads()<cr>',
\ '>': ':<c-u>let t:goyo_width = winwidth(0) + 2 * v:count1 <bar> call <sid>resize_pads()<cr>',
\ '<': ':<c-u>let t:goyo_width = winwidth(0) - 2 * v:count1 <bar> call <sid>resize_pads()<cr>',
\ '+': ':<c-u>let t:goyo_margin_top -= v:count1 <bar> let t:goyo_margin_bottom -= v:count1 <bar> call <sid>resize_pads()<cr>',
\ '-': ':<c-u>let t:goyo_margin_top += v:count1 <bar> let t:goyo_margin_bottom += v:count1 <bar> call <sid>resize_pads()<cr>'
\ '=': ':<c-u>let t:goyo_dim = <sid>parse_arg(t:goyo_dim_expr) <bar> call <sid>resize_pads()<cr>',
\ '>': ':<c-u>let t:goyo_dim.width = winwidth(0) + 2 * v:count1 <bar> call <sid>resize_pads()<cr>',
\ '<': ':<c-u>let t:goyo_dim.width = winwidth(0) - 2 * v:count1 <bar> call <sid>resize_pads()<cr>',
\ '+': ':<c-u>let t:goyo_dim.height += 2 * v:count1 <bar> call <sid>resize_pads()<cr>',
\ '-': ':<c-u>let t:goyo_dim.height -= 2 * v:count1 <bar> call <sid>resize_pads()<cr>'
\ }
let mapped = filter(keys(commands), "empty(maparg(\"\<c-w>\".v:val, 'n'))")
for c in mapped
@ -158,7 +161,12 @@ function! s:maps_resize()
return mapped
endfunction
function! s:goyo_on(width)
function! s:goyo_on(dim)
let dim = s:parse_arg(a:dim)
if empty(dim)
return
endif
let s:orig_tab = tabpagenr()
let settings =
\ { 'laststatus': &laststatus,
@ -177,10 +185,8 @@ function! s:goyo_on(width)
tab split
let t:goyo_master = winbufnr(0)
let t:goyo_width = a:width
let t:goyo_margin_top = get(g:, 'goyo_margin_top', 4)
let t:goyo_margin_bottom = get(g:, 'goyo_margin_bottom', 4)
let t:goyo_initial_dim = [t:goyo_width, t:goyo_margin_top, t:goyo_margin_bottom]
let t:goyo_dim = dim
let t:goyo_dim_expr = a:dim
let t:goyo_pads = {}
let t:goyo_revert = settings
let t:goyo_maps = extend(s:maps_nop(), s:maps_resize())
@ -360,19 +366,60 @@ function! s:goyo_off()
silent! doautocmd User GoyoLeave
endfunction
function! goyo#execute(bang, ...)
let width = a:0 > 0 ? a:1 : get(g:, 'goyo_width', 80)
function! s:relsz(expr, limit)
if a:expr !~ '%$'
return str2nr(a:expr)
endif
return a:limit * str2nr(a:expr[:-2]) / 100
endfunction
function! s:parse_arg(arg)
if exists('g:goyo_height') || !exists('g:goyo_margin_top') && !exists('g:goyo_margin_bottom')
let height = s:relsz(get(g:, 'goyo_height', '85%'), &lines)
let yoff = 0
else
let top = max([0, s:relsz(get(g:, 'goyo_margin_top', 4), &lines)])
let bot = max([0, s:relsz(get(g:, 'goyo_margin_bottom', 4), &lines)])
let height = &lines - top - bot
let yoff = top - bot
endif
let dim = { 'width': s:relsz(get(g:, 'goyo_width', 80), &columns),
\ 'height': height,
\ 'xoff': 0,
\ 'yoff': yoff }
if empty(a:arg)
return dim
endif
let parts = matchlist(a:arg, '^\s*\([0-9]\+%\?\)\?\([+-][0-9]\+%\?\)\?\%(x\([0-9]\+%\?\)\?\([+-][0-9]\+%\?\)\?\)\?\s*$')
if empty(parts)
echohl WarningMsg
echo 'Invalid dimension expression: '.a:arg
echohl None
return {}
endif
if !empty(parts[1]) | let dim.width = s:relsz(parts[1], &columns) | endif
if !empty(parts[2]) | let dim.xoff = s:relsz(parts[2], &columns) | endif
if !empty(parts[3]) | let dim.height = s:relsz(parts[3], &lines) | endif
if !empty(parts[4]) | let dim.yoff = s:relsz(parts[4], &lines) | endif
return dim
endfunction
function! goyo#execute(bang, dim)
if a:bang
if exists('#goyo')
call s:goyo_off()
endif
else
if exists('#goyo') == 0
call s:goyo_on(width)
elseif a:0 > 0
let t:goyo_width = width
call s:resize_pads()
call s:goyo_on(a:dim)
elseif !empty(a:dim)
let dim = s:parse_arg(a:dim)
if !empty(dim)
let t:goyo_dim = dim
let t:goyo_dim_expr = a:dim
call s:resize_pads()
endif
else
call s:goyo_off()
end

@ -21,4 +21,4 @@
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
command! -nargs=? -bar -bang Goyo call goyo#execute(<bang>0, <args>)
command! -nargs=? -bar -bang Goyo call goyo#execute(<bang>0, <q-args>)

@ -66,48 +66,42 @@ Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`.
Faq
---
__Q. Can I have the nerdtree on every tab automatically?__
> Is there any support for `git` flags?
A. Nope. If this is something you want then chances are you aren't using tabs
and buffers as they were intended to be used. Read this
http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers
Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin).
If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs)
__Q. How can I open a NERDTree automatically when vim starts up?__
> Can I have the nerdtree on every tab automatically?
A. Stick this in your vimrc: `autocmd vimenter * NERDTree`
Nope. If this is something you want then chances are you aren't using tabs and
buffers as they were intended to be used. Read this
http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers
__Q. How can I open a NERDTree automatically when vim starts up if no files were specified?__
If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs)
A. Stick this in your vimrc
> How can I open a NERDTree automatically when vim starts up?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
Stick this in your vimrc: `autocmd vimenter * NERDTree`
__Q. How can I map a specific key or shortcut to open NERDTree?__
> How can I open a NERDTree automatically when vim starts up if no files were specified?
A. Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
Stick this in your vimrc
`map <C-n> :NERDTreeToggle<CR>`
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
__Q. How can I close vim if the only window left open is a NERDTree?__
> How can I map a specific key or shortcut to open NERDTree?
A. Stick this in your vimrc:
Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
`autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif`
map <C-n> :NERDTreeToggle<CR>
> How can I close vim if the only window left open is a NERDTree?
Changelog
---------
Stick this in your vimrc:
4.2.0 (2011-12-28)
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
* Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill)
* shift the syntax highlighting out into its own syntax file (gnap) * add some mac specific options to the filesystem menu - for macvim only (andersonfreitas)
* Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson)
* tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger)
* if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung)
* use 'file' completion when doing copying, create, and move operations (EvanDotPro)
* lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
> Can I have different highlighting for different file extensions?
See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696

@ -34,6 +34,17 @@ function! nerdtree#compareNodes(n1, n2)
return a:n1.path.compareTo(a:n2.path)
endfunction
"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2
function! nerdtree#compareNodesBySortKey(n1, n2)
if a:n1.path.getSortKey() <# a:n2.path.getSortKey()
return -1
elseif a:n1.path.getSortKey() ># a:n2.path.getSortKey()
return 1
else
return 0
endif
endfunction
" FUNCTION: nerdtree#deprecated(func, [msg]) {{{2
" Issue a deprecation warning for a:func. If a second arg is given, use this
" as the deprecation message
@ -95,175 +106,9 @@ function! nerdtree#runningWindows()
return has("win16") || has("win32") || has("win64")
endfunction
"FUNCTION: nerdtree#treeMarkupReg(dir) {{{2
function! nerdtree#treeMarkupReg()
if g:NERDTreeDirArrows
return '^\([▾▸] \| \+[▾▸] \| \+\)'
endif
return '^[ `|]*[\-+~]'
endfunction
"FUNCTION: nerdtree#treeUpDirLine(dir) {{{2
function! nerdtree#treeUpDirLine()
return '.. (up a dir)'
endfunction
"FUNCTION: nerdtree#treeWid(dir) {{{2
function! nerdtree#treeWid()
return 2
endfunction
" SECTION: View Functions {{{1
"============================================================
"FUNCTION: nerdtree#closeTree() {{{2
"Closes the primary NERD tree window for this tab
function! nerdtree#closeTree()
if !nerdtree#isTreeOpen()
throw "NERDTree.NoTreeFoundError: no NERDTree is open"
endif
if winnr("$") != 1
if winnr() == nerdtree#getTreeWinNum()
call nerdtree#exec("wincmd p")
let bufnr = bufnr("")
call nerdtree#exec("wincmd p")
else
let bufnr = bufnr("")
endif
call nerdtree#exec(nerdtree#getTreeWinNum() . " wincmd w")
close
call nerdtree#exec(bufwinnr(bufnr) . " wincmd w")
else
close
endif
endfunction
"FUNCTION: nerdtree#closeTreeIfOpen() {{{2
"Closes the NERD tree window if it is open
function! nerdtree#closeTreeIfOpen()
if nerdtree#isTreeOpen()
call nerdtree#closeTree()
endif
endfunction
"FUNCTION: nerdtree#closeTreeIfQuitOnOpen() {{{2
"Closes the NERD tree window if the close on open option is set
function! nerdtree#closeTreeIfQuitOnOpen()
if g:NERDTreeQuitOnOpen && nerdtree#isTreeOpen()
call nerdtree#closeTree()
endif
endfunction
"FUNCTION: nerdtree#dumpHelp {{{2
"prints out the quick help
function! nerdtree#dumpHelp()
let old_h = @h
if b:treeShowHelp ==# 1
let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n"
let @h=@h."\" ============================\n"
let @h=@h."\" File node mappings~\n"
let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
let @h=@h."\" <CR>,\n"
if b:NERDTreeType ==# "primary"
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
else
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n"
endif
if b:NERDTreeType ==# "primary"
let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n"
endif
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
let @h=@h."\" middle-click,\n"
let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n"
let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n"
let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n"
let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n"
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Directory node mappings~\n"
let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n"
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n"
let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n"
let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n"
let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n"
let @h=@h."\" current node recursively\n"
let @h=@h."\" middle-click,\n"
let @h=@h."\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n"
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Bookmark table mappings~\n"
let @h=@h."\" double-click,\n"
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n"
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n"
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Tree navigation mappings~\n"
let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n"
let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n"
let @h=@h."\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n"
let @h=@h."\" ". g:NERDTreeMapJumpLastChild .": go to last child\n"
let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n"
let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n"
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Filesystem mappings~\n"
let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n"
let @h=@h."\" selected dir\n"
let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n"
let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n"
let @h=@h."\" but leave old root open\n"
let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n"
let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n"
let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n"
let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n"
let @h=@h."\" selected dir\n"
let @h=@h."\" ". g:NERDTreeMapCWD .":change tree root to CWD\n"
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Tree filtering mappings~\n"
let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n"
"add quickhelp entries for each custom key map
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Custom mappings~\n"
for i in g:NERDTreeKeyMap.All()
if !empty(i.quickhelpText)
let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n"
endif
endfor
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Other mappings~\n"
let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n"
let @h=@h."\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n"
let @h=@h."\" the NERDTree window\n"
let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n"
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Bookmark commands~\n"
let @h=@h."\" :Bookmark [<name>]\n"
let @h=@h."\" :BookmarkToRoot <name>\n"
let @h=@h."\" :RevealBookmark <name>\n"
let @h=@h."\" :OpenBookmark <name>\n"
let @h=@h."\" :ClearBookmarks [<names>]\n"
let @h=@h."\" :ClearAllBookmarks\n"
silent! put h
elseif g:NERDTreeMinimalUI == 0
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
silent! put h
endif
let @h = old_h
endfunction
"FUNCTION: nerdtree#echo {{{2
"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages
"
@ -294,114 +139,9 @@ function! nerdtree#echoWarning(msg)
echohl normal
endfunction
"FUNCTION: nerdtree#getTreeWinNum() {{{2
"gets the nerd tree window number for this tab
function! nerdtree#getTreeWinNum()
if exists("t:NERDTreeBufName")
return bufwinnr(t:NERDTreeBufName)
else
return -1
endif
endfunction
"FUNCTION: nerdtree#isTreeOpen() {{{2
function! nerdtree#isTreeOpen()
return nerdtree#getTreeWinNum() != -1
endfunction
"FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2
"Places the cursor at the top of the bookmarks table
function! nerdtree#putCursorOnBookmarkTable()
if !b:NERDTreeShowBookmarks
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
endif
if g:NERDTreeMinimalUI
return cursor(1, 2)
endif
let rootNodeLine = b:NERDTree.ui.getRootLineNum()
let line = 1
while getline(line) !~# '^>-\+Bookmarks-\+$'
let line = line + 1
if line >= rootNodeLine
throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
endif
endwhile
call cursor(line, 2)
endfunction
"FUNCTION: nerdtree#putCursorInTreeWin(){{{2
"Places the cursor in the nerd tree window
function! nerdtree#putCursorInTreeWin()
if !nerdtree#isTreeOpen()
throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists"
endif
call nerdtree#exec(nerdtree#getTreeWinNum() . "wincmd w")
endfunction
"FUNCTION: nerdtree#renderBookmarks {{{2
function! nerdtree#renderBookmarks()
if g:NERDTreeMinimalUI == 0
call setline(line(".")+1, ">----------Bookmarks----------")
call cursor(line(".")+1, col("."))
endif
for i in g:NERDTreeBookmark.Bookmarks()
call setline(line(".")+1, i.str())
call cursor(line(".")+1, col("."))
endfor
call setline(line(".")+1, '')
call cursor(line(".")+1, col("."))
endfunction
"FUNCTION: nerdtree#renderView {{{2
function! nerdtree#renderView()
call b:NERDTree.render()
endfunction
"
"FUNCTION: nerdtree#stripMarkupFromLine(line, removeLeadingSpaces){{{2
"returns the given line with all the tree parts stripped off
"
"Args:
"line: the subject line
"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces =
"any spaces before the actual text of the node)
function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces)
let line = a:line
"remove the tree parts and the leading space
let line = substitute (line, nerdtree#treeMarkupReg(),"","")
"strip off any read only flag
let line = substitute (line, ' \[RO\]', "","")
"strip off any bookmark flags
let line = substitute (line, ' {[^}]*}', "","")
"strip off any executable flags
let line = substitute (line, '*\ze\($\| \)', "","")
"strip off any generic flags
let line = substitute (line, '\[[^]]*\]', "","")
let wasdir = 0
if line =~# '/$'
let wasdir = 1
endif
let line = substitute (line,' -> .*',"","") " remove link to
if wasdir ==# 1
let line = substitute (line, '/\?$', '/', "")
endif
if a:removeLeadingSpaces
let line = substitute (line, '^ *', '', '')
endif
return line
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

@ -85,7 +85,7 @@ endfunction
"FUNCTION: s:activateAll() {{{1
"handle the user activating the updir line
function! s:activateAll()
if getline(".") ==# nerdtree#treeUpDirLine()
if getline(".") ==# g:NERDTreeUI.UpDirLine()
return nerdtree#ui_glue#upDir(0)
endif
endfunction
@ -93,13 +93,13 @@ endfunction
"FUNCTION: s:activateDirNode() {{{1
"handle the user activating a tree node
function! s:activateDirNode(node)
call a:node.activate({'reuse': 1})
call a:node.activate()
endfunction
"FUNCTION: s:activateFileNode() {{{1
"handle the user activating a tree node
function! s:activateFileNode(node)
call a:node.activate({'reuse': 1, 'where': 'p'})
call a:node.activate({'reuse': 'all', 'where': 'p'})
endfunction
"FUNCTION: s:activateBookmark() {{{1
@ -212,7 +212,7 @@ function! s:closeTreeWindow()
exec "buffer " . b:NERDTreePreviousBuf
else
if winnr("$") > 1
call nerdtree#closeTree()
call g:NERDTree.Close()
else
call nerdtree#echo("Cannot close last window")
endif
@ -275,20 +275,20 @@ function! s:findAndRevealPath()
endif
else
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
if !nerdtree#isTreeOpen()
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.TogglePrimary('')
else
call nerdtree#putCursorInTreeWin()
call g:NERDTree.CursorToTreeWin()
endif
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
else
if !nerdtree#isTreeOpen()
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.TogglePrimary("")
endif
endif
endif
call nerdtree#putCursorInTreeWin()
call g:NERDTree.CursorToTreeWin()
call b:NERDTreeRoot.reveal(p)
if p.isUnixHiddenFile()
@ -312,7 +312,7 @@ function! s:handleLeftClick()
endfor
if currentNode.path.isDirectory
if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$'
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~▾▸] \?$'
call currentNode.activate()
return
endif
@ -320,11 +320,11 @@ function! s:handleLeftClick()
if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
let char = strpart(startToCur, strlen(startToCur)-1, 1)
if char !~# nerdtree#treeMarkupReg()
if char !~# g:NERDTreeUI.MarkupReg()
if currentNode.path.isDirectory
call currentNode.activate()
else
call currentNode.activate({'reuse': 1, 'where': 'p'})
call currentNode.activate({'reuse': 'all', 'where': 'p'})
endif
return
endif
@ -547,7 +547,7 @@ endfunction
function! nerdtree#ui_glue#setupCommands()
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen()
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()

@ -34,6 +34,8 @@ CONTENTS *NERDTree-contents*
4.The NERD tree API.......................|NERDTreeAPI|
4.1.Key map API.......................|NERDTreeKeymapAPI|
4.2.Menu API..........................|NERDTreeMenuAPI|