1
0
Fork 0
mirror of synced 2024-11-22 16:55:34 -05:00

Change plugin manager to Vundle

This commit is contained in:
陳泓宇 2018-01-25 15:47:03 +08:00
parent fd40d449ec
commit eeb78f5204
1455 changed files with 83 additions and 112349 deletions

4
.gitignore vendored
View file

@ -1,9 +1,5 @@
temp_dirs/undodir/* temp_dirs/undodir/*
sources_non_forked/ack.vim/.netrwhist
temp_dirs/yankring_history_v2.txt temp_dirs/yankring_history_v2.txt
sources_forked/yankring/doc/tags sources_forked/yankring/doc/tags
sources_non_forked/tlib/doc/tags
sources_non_forked/ctrlp.vim/doc/tags*
tags tags
my_plugins/**/*
.DS_Store .DS_Store

View file

@ -14,4 +14,20 @@ This is the vim configurations based on [amix/vimrc](https://github.com/amix/vim
* Change [lightline](https://github.com/itchyny/lightline.vim) to [vim-airline](https://github.com/vim-airline/vim-airline). * Change [lightline](https://github.com/itchyny/lightline.vim) to [vim-airline](https://github.com/vim-airline/vim-airline).
Detail changes can be found in [./my_configs.vim](./my_configs.vim) and [./my_plugins](./my_plugins). * Change default plugin manager (or 'runtimepath manager') from [pathogen](https://github.com/tpope/vim-pathogen) to [Vundle](https://github.com/VundleVim/Vundle.vim).
# Something to know about the change of plugin manager
Since I can't figure out how to use local plugin with Vundle properly, I didn't include some plugins used by the original version in the `/sources_forked` directory.
If you come out with how to do this, please let me know and I would be appreciate it.
If you want to use Vundle as your plugin manager with the original configuration, you can check the following 2 files:
1. [./vimrcs/vundle_config.vim](./vimrcs/vundle_config.vim), this file has all the vundle-related setups.
2. [./install_awesome_vimrc.sh](./install_awesome_vimrc.sh), this file add one line to source the `vundle_config.vim` at top of the sources.
# Also
Some personal preferences can be found in [./my_configs.vim](./my_configs.vim).

1
bundle/Vundle.vim Submodule

@ -0,0 +1 @@
Subproject commit fcc204205e3305c4f86f07e09cd756c7d06f0f00

View file

@ -5,6 +5,7 @@ cd ~/.vim_runtime
echo 'set runtimepath+=~/.vim_runtime echo 'set runtimepath+=~/.vim_runtime
source ~/.vim_runtime/vimrcs/vundle_config.vim
source ~/.vim_runtime/vimrcs/basic.vim source ~/.vim_runtime/vimrcs/basic.vim
source ~/.vim_runtime/vimrcs/filetypes.vim source ~/.vim_runtime/vimrcs/filetypes.vim
source ~/.vim_runtime/vimrcs/plugins_config.vim source ~/.vim_runtime/vimrcs/plugins_config.vim

View file

@ -1 +0,0 @@
Subproject commit 038789f0ed42cfffbd442a6a399cb2395591821d

@ -1 +0,0 @@
Subproject commit ae5315396cd0f3958750f10a5f3ad9d34d33f40d

@ -1 +0,0 @@
Subproject commit 439348543c9ffe2c5c4469a6e8f005f67bf73cc1

@ -1 +0,0 @@
Subproject commit c2ffb8b3ec114301795036f7bf22995746d2acaf

@ -1 +0,0 @@
Subproject commit 4b7f77e770a2165726072a2b6f109f2457783080

@ -1 +0,0 @@
Subproject commit 528a59f26d12278698bb946f8fb82a63711eec21

@ -1 +0,0 @@
Subproject commit 342549e7a1e5b07a030803e0e4b6f0415aa51275

@ -1 +0,0 @@
Subproject commit b40687195c01caf40f62d20093296590b48e3a75

@ -1 +0,0 @@
Subproject commit a0e1442d86a070331c800107fbee6394ee6d3d08

@ -1 +0,0 @@
Subproject commit 5b968dfa512c57c38ad7fe420f3e8ab75a73949a

@ -1 +0,0 @@
Subproject commit 6518e738863f0acd190c7564a109be021cae1b56

View file

@ -1 +0,0 @@
tags

View file

@ -1,89 +0,0 @@
ack.vim is distributed under the same license terms as Vim itself, which you
can find in full with `:help license` within Vim, or copied in full herein.
Copyright (c) 2007-2015 Antoine Imbert <antoine.imbert+ackvim@gmail.com>
and contributors.
Maintainers may be contacted via GitHub Issues at:
https://github.com/mileszs/ack.vim/issues
VIM LICENSE
I) There are no restrictions on distributing unmodified copies of Vim except
that they must include this license text. You can also distribute
unmodified parts of Vim, likewise unrestricted except that they must
include this license text. You are also allowed to include executables
that you made from the unmodified Vim sources, plus your own usage
examples and Vim scripts.
II) It is allowed to distribute a modified (or extended) version of Vim,
including executables and/or source code, when the following four
conditions are met:
1) This license text must be included unmodified.
2) The modified Vim must be distributed in one of the following five ways:
a) If you make changes to Vim yourself, you must clearly describe in
the distribution how to contact you. When the maintainer asks you
(in any way) for a copy of the modified Vim you distributed, you
must make your changes, including source code, available to the
maintainer without fee. The maintainer reserves the right to
include your changes in the official version of Vim. What the
maintainer will do with your changes and under what license they
will be distributed is negotiable. If there has been no negotiation
then this license, or a later version, also applies to your changes.
The current maintainer is Bram Moolenaar <Bram@vim.org>. If this
changes it will be announced in appropriate places (most likely
vim.sf.net, www.vim.org and/or comp.editors). When it is completely
impossible to contact the maintainer, the obligation to send him
your changes ceases. Once the maintainer has confirmed that he has
received your changes they will not have to be sent again.
b) If you have received a modified Vim that was distributed as
mentioned under a) you are allowed to further distribute it
unmodified, as mentioned at I). If you make additional changes the
text under a) applies to those changes.
c) Provide all the changes, including source code, with every copy of
the modified Vim you distribute. This may be done in the form of a
context diff. You can choose what license to use for new code you
add. The changes and their license must not restrict others from
making their own changes to the official version of Vim.
d) When you have a modified Vim which includes changes as mentioned
under c), you can distribute it without the source code for the
changes if the following three conditions are met:
- The license that applies to the changes permits you to distribute
the changes to the Vim maintainer without fee or restriction, and
permits the Vim maintainer to include the changes in the official
version of Vim without fee or restriction.
- You keep the changes for at least three years after last
distributing the corresponding modified Vim. When the maintainer
or someone who you distributed the modified Vim to asks you (in
any way) for the changes within this period, you must make them
available to him.
- You clearly describe in the distribution how to contact you. This
contact information must remain valid for at least three years
after last distributing the corresponding modified Vim, or as long
as possible.
e) When the GNU General Public License (GPL) applies to the changes,
you can distribute the modified Vim under the GNU GPL version 2 or
any later version.
3) A message must be added, at least in the output of the ":version"
command and in the intro screen, such that the user of the modified Vim
is able to see that it was modified. When distributing as mentioned
under 2)e) adding the message is only required for as far as this does
not conflict with the license used for the changes.
4) The contact information as required under 2)a) and 2)d) must not be
removed or changed, except that the person himself can make
corrections.
III) If you distribute a modified version of Vim, you are encouraged to use
the Vim license for your changes and make them available to the
maintainer, including the source code. The preferred way to do this is
by e-mail or by uploading the files to a server and e-mailing the URL.
If the number of changes is small (e.g., a modified Makefile) e-mailing a
context diff will do. The e-mail address to be used is
<maintainer@vim.org>
IV) It is not allowed to remove this license from the distribution of the Vim
sources, parts of it or from a modified version. You may use this
license for previous Vim releases instead of the license that they came
with, at your option.

View file

@ -1,163 +0,0 @@
# ack.vim
Run your favorite search tool from Vim, with an enhanced results list.
This plugin was designed as a Vim frontend for the programmer's search tool
[ack]. ack can be used as a replacement for 99% of the uses of `grep`. The
plugin allows you to search with ack from within 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
to integrate with your own Vim configuration and use existing knowledge of core
features. It also means the plugin is flexible to use with other search tools.
[grepprg]: http://vimdoc.sourceforge.net/htmldoc/options.html#'grepprg'
[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
## Installation
### ack
You will need ack (>= 2.0), of course. To install it follow the
[manual](http://beyondgrep.com/install/).
### The Plugin
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
```vim
Plugin 'mileszs/ack.vim'
```
#### NeoBundle
```vim
NeoBundle 'mileszs/ack.vim'
```
#### Manual (not recommended)
[Download][releases] the plugin and extract it in `~/.vim/` (or
`%PROGRAMFILES%/Vim/vimfiles` on Windows).
## Usage
:Ack [options] {pattern} [{directories}]
Search recursively in `{directories}` (which defaults to the current directory)
for the `{pattern}`.
Files containing the search term will be listed in the quickfix 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 `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `:help Ack`
after installing, or [`doc/ack.txt`][doc] in the repo, for more information.)
For more ack help see [ack documentation](http://beyondgrep.com/documentation/).
[doc]: https://github.com/mileszs/ack.vim/blob/master/doc/ack.txt
### Keyboard Shortcuts
The quickfix results window is augmented with these convenience mappings:
? a quick summary of these keys, repeat to close
o to open (same as Enter)
O to open and close the quickfix window
go to preview file, open but maintain focus on ack.vim results
t to open in new tab
T to open in new tab without moving to it
h to open in horizontal split
H to open in horizontal split, keeping focus on the results
v to open in vertical split
gv to open in vertical split, keeping focus on the results
q to close the quickfix window
### Gotchas
To search for a pattern that contains whitespace, you need to enclose the
pattern in single quotes. For example: `:Ack 'foo bar'` to search for
'foo bar'.
Some characters have special meaning, and need to be escaped in your search
pattern. For instance, `#`. You need to escape it with `:Ack '\\\#define
foo'` to search for '#define foo'. See [issue #5].
[issue #5]: https://github.com/mileszs/ack.vim/issues/5
## Possibly FAQ
#### Can I use `ag` ([The Silver Searcher]) with this?
Absolutely, and probably other tools if their output is similar or you can
write a pattern match for it--just set `g:ackprg`. If you like, you can fall
back to Ack in case you use your vimrc on a system without Ag available:
```vim
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
```
Since Ack is quite portable you might check a copy of it into your dotfiles
repository in `~/bin` so you'll nearly always have it available.
#### What's the difference from ag.vim?
Well... not a lot really.
Present maintainer, yours truly, [kind of wishes they never forked][sadface],
contributes to both, and wouldn't mind seeing them merged again. ag.vim got a
nice code clean-up (which ack.vim is now hopefully getting), and ack.vim picked
up a few features that haven't made their way to ag.vim, like `:AckWindow`,
optional background search execution with [vim-dispatch], and auto-previewing.
#### I don't want to jump to the first result automatically. ####
Use `:Ack!`, with bang. If you want this behavior most of the time, you might
like an abbreviation or mapping in your personal config, something like these:
```vim
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
```
Most of the `:[L]Ack*` commands support this. Note that this behavior follows
the convention of Vim's built-in `:grep` and `:make` commands.
[The Silver Searcher]: https://github.com/ggreer/the_silver_searcher
[sadface]: https://github.com/mileszs/ack.vim/commit/d97090fb502d40229e6976dfec0e06636ba227d5#commitcomment-5771145
## Changelog
Please see [the GitHub releases page][releases].
## Credits
This plugin is derived from Antoine Imbert's blog post [ack and Vim
Integration][] (in particular, the function in the update to the post). [Miles
Sterrett][mileszs] packaged it up as a plugin and documented it in Vim's help
format, and since then [many contributors][contributors] have submitted
enhancements and fixes.
And of course, where would we be without [ack]. And, you know, Vim.
[ack and Vim Integration]: http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html
[mileszs]: https://github.com/mileszs
[contributors]: https://github.com/mileszs/ack.vim/graphs/contributors
[ack]: http://beyondgrep.com/
[vim-dispatch]: https://github.com/tpope/vim-dispatch
[releases]: https://github.com/mileszs/ack.vim/releases

View file

@ -1,246 +0,0 @@
if exists('g:autoloaded_ack') || &cp
finish
endif
if exists('g:ack_use_dispatch')
if g:ack_use_dispatch && !exists(':Dispatch')
call s:Warn('Dispatch not loaded! Falling back to g:ack_use_dispatch = 0.')
let g:ack_use_dispatch = 0
endif
else
let g:ack_use_dispatch = 0
endif
"-----------------------------------------------------------------------------
" Public API
"-----------------------------------------------------------------------------
function! ack#Ack(cmd, args) "{{{
call s:Init(a:cmd)
redraw
" Local values that we'll temporarily set as options when searching
let l:grepprg = g:ackprg
let l:grepformat = '%f:%l:%c:%m,%f:%l:%m' " Include column number
" Strip some options that are meaningless for path search and set match
" format accordingly.
if s:SearchingFilepaths()
let l:grepprg = substitute(l:grepprg, '-H\|--column', '', 'g')
let l:grepformat = '%f'
endif
" Check user policy for blank searches
if empty(a:args)
if !g:ack_use_cword_for_empty_search
echo "No regular expression found."
return
endif
endif
" If no pattern is provided, search for the word under the cursor
let l:grepargs = empty(a:args) ? expand("<cword>") : a:args . join(a:000, ' ')
"Bypass search if cursor is on blank string
if l:grepargs == ""
echo "No regular expression found."
return
endif
" NOTE: we escape special chars, but not everything using shellescape to
" allow for passing arguments etc
let l:escaped_args = escape(l:grepargs, '|#%')
echo "Searching ..."
if g:ack_use_dispatch
call s:SearchWithDispatch(l:grepprg, l:escaped_args, l:grepformat)
else
call s:SearchWithGrep(a:cmd, l:grepprg, l:escaped_args, l:grepformat)
endif
" Dispatch has no callback mechanism currently, we just have to display the
" list window early and wait for it to populate :-/
call ack#ShowResults()
call s:Highlight(l:grepargs)
endfunction "}}}
function! ack#AckFromSearch(cmd, args) "{{{
let search = getreg('/')
" translate vim regular expression to perl regular expression.
let search = substitute(search, '\(\\<\|\\>\)', '\\b', 'g')
call ack#Ack(a:cmd, '"' . search . '" ' . a:args)
endfunction "}}}
function! ack#AckHelp(cmd, args) "{{{
let args = a:args . ' ' . s:GetDocLocations()
call ack#Ack(a:cmd, args)
endfunction "}}}
function! ack#AckWindow(cmd, args) "{{{
let files = tabpagebuflist()
" remove duplicated filenames (files appearing in more than one window)
let files = filter(copy(sort(files)), 'index(files,v:val,v:key+1)==-1')
call map(files, "bufname(v:val)")
" remove unnamed buffers as quickfix (empty strings before shellescape)
call filter(files, 'v:val != ""')
" expand to full path (avoid problems with cd/lcd in au QuickFixCmdPre)
let files = map(files, "shellescape(fnamemodify(v:val, ':p'))")
let args = a:args . ' ' . join(files)
call ack#Ack(a:cmd, args)
endfunction "}}}
function! ack#ShowResults() "{{{
let l:handler = s:UsingLocList() ? g:ack_lhandler : g:ack_qhandler
execute l:handler
call s:ApplyMappings()
redraw!
endfunction "}}}
"-----------------------------------------------------------------------------
" Private API
"-----------------------------------------------------------------------------
function! s:ApplyMappings() "{{{
if !s:UsingListMappings() || &filetype != 'qf'
return
endif
let l:wintype = s:UsingLocList() ? 'l' : 'c'
let l:closemap = ':' . l:wintype . 'close<CR>'
let g:ack_mappings.q = l:closemap
nnoremap <buffer> <silent> ? :call <SID>QuickHelp()<CR>
if g:ack_autoclose
" We just map the 'go' and 'gv' mappings to close on autoclose, wtf?
for key_map in items(g:ack_mappings)
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1) . l:closemap)
endfor
execute "nnoremap <buffer> <silent> <CR> <CR>" . l:closemap
else
for key_map in items(g:ack_mappings)
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1))
endfor
endif
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 "}}}
function! s: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! s:Highlight(args) "{{{
if !g:ackhighlight
return
endif
let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]")
call feedkeys(":let &hlsearch=1 \| echo \<CR>", "n")
endfunction "}}}
" Initialize state for an :Ack* or :LAck* search
function! s:Init(cmd) "{{{
let s:searching_filepaths = (a:cmd =~# '-g$') ? 1 : 0
let s:using_loclist = (a:cmd =~# '^l') ? 1 : 0
if g:ack_use_dispatch && s:using_loclist
call s:Warn('Dispatch does not support location lists! Proceeding with quickfix...')
let s:using_loclist = 0
endif
endfunction "}}}
function! s:QuickHelp() "{{{
execute 'edit' globpath(&rtp, 'doc/ack_quick_help.txt')
silent normal gg
setlocal buftype=nofile bufhidden=hide nobuflisted
setlocal nomodifiable noswapfile
setlocal filetype=help
setlocal nonumber norelativenumber nowrap
setlocal foldmethod=diff foldlevel=20
nnoremap <buffer> <silent> ? :q!<CR>:call ack#ShowResults()<CR>
endfunction "}}}
function! s:SearchWithDispatch(grepprg, grepargs, grepformat) "{{{
let l:makeprg_bak = &l:makeprg
let l:errorformat_bak = &l:errorformat
" We don't execute a :grep command for Dispatch, so add -g here instead
if s:SearchingFilepaths()
let l:grepprg = a:grepprg . ' -g'
else
let l:grepprg = a:grepprg
endif
try
let &l:makeprg = l:grepprg . ' ' . a:grepargs
let &l:errorformat = a:grepformat
Make
finally
let &l:makeprg = l:makeprg_bak
let &l:errorformat = l:errorformat_bak
endtry
endfunction "}}}
function! s:SearchWithGrep(grepcmd, grepprg, grepargs, grepformat) "{{{
let l:grepprg_bak = &l:grepprg
let l:grepformat_bak = &grepformat
try
let &l:grepprg = a:grepprg
let &grepformat = a:grepformat
silent execute a:grepcmd a:grepargs
finally
let &l:grepprg = l:grepprg_bak
let &grepformat = l:grepformat_bak
endtry
endfunction "}}}
" Are we finding matching files, not lines? (the -g option -- :AckFile)
function! s:SearchingFilepaths() "{{{
return get(s:, 'searching_filepaths', 0)
endfunction "}}}
" Predicate for whether mappings are enabled for list type of current search.
function! s:UsingListMappings() "{{{
if s:UsingLocList()
return g:ack_apply_lmappings
else
return g:ack_apply_qmappings
endif
endfunction "}}}
" Were we invoked with a :LAck command?
function! s:UsingLocList() "{{{
return get(s:, 'using_loclist', 0)
endfunction "}}}
function! s:Warn(msg) "{{{
echohl WarningMsg | echomsg 'Ack: ' . a:msg | echohl None
endf "}}}
let g:autoloaded_ack = 1
" vim:set et sw=2 ts=2 tw=78 fdm=marker

View file

@ -1,315 +0,0 @@
*ack.txt* Plugin that integrates ack with Vim
==============================================================================
Author: Antoine Imbert <antoine.imbert+ackvim@gmail.com> *ack-author*
License: Same terms as Vim itself (see |license|)
This plugin is only available if 'compatible' is not set.
{Vi does not have any of this}
==============================================================================
INTRODUCTION *ack*
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
occurrence 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.
:AckHelp[!] [options] {pattern} *:AckHelp*
Search vim documentation files for the {pattern}. Behaves just like the
|:Ack| command, but searches only vim documentation .txt files
:LAckHelp [options] {pattern} *:LAckHelp*
Just like |:AckHelp| but instead of the |quickfix| list, matches are placed
in the current |location-list|.
:AckWindow[!] [options] {pattern} *:AckWindow*
Search all buffers visible in the screen (current tab page only) files for
the {pattern}.
:LAckWindow [options] {pattern} *:LAckWindow*
Just like |:AckWindow| 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.
Note that if you are using Dispatch.vim with |g:ack_use_dispatch|, location
lists are not supported, because Dispatch does not support them at this time.
`:LAck` versions of commands above will give a warning and proceed to use the
quickfix list instead.
See http://beyondgrep.com/ for more information on searching with ack.
==============================================================================
CONFIGURATION *ack-configuration*
*g:ackprg*
g:ackprg
Default for ubuntu: "ack-grep"
Default for other systems: "ack"
Use this option to specify the search command and its default arguments.
Example:
>
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 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:
>
let g:ack_default_options =
\ " -s -H --nocolor --nogroup --column --smart-case --follow"
<
*g:ack_apply_qmappings*
g:ack_apply_qmappings
Default: 1
This option enables mappings on the |quickfix| window.
*g:ack_apply_lmappings*
g:ack_apply_lmappings
Default: 1
This option enables mappings on |location-list| windows.
*g:ack_mappings*
g:ack_mappings
Default: {
\ "t": "<C-W><CR><C-W>T",
\ "T": "<C-W><CR><C-W>TgT<C-W>j",
\ "o": "<CR>",
\ "O": "<CR><C-W><C-W>:ccl<CR>",
\ "go": "<CR><C-W>j",
\ "h": "<C-W><CR><C-W>K",
\ "H": "<C-W><CR><C-W>K<C-W>b",
\ "v": "<C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t",
\ "gv": "<C-W><CR><C-W>H<C-W>b<C-W>J" }
This option list all maps create on quickfix/Location list window.
Example, if you want to open the result in the middle of the screen:
>
let g:ack_mappings = { "o": "<CR>zz" }
<
*g:ack_qhandler*
g:ack_qhandler
Default: "botright copen"
Command to open the quickview window.
If you want to open a quickview window with 30 lines you can do:
>
let g:ack_qhandler = "botright copen 30"
<
*g:ack_lhandler*
g:ack_lhandler
Default: "botright lopen"
Command to open the Location list window.
If you want to open a Location list window with 30 lines you can do:
>
let g:ack_lhandler = "botright lopen 30"
<
*g:ackhighlight*
g:ackhighlight
Default: 0
Use this option to highlight the searched term.
Example:
>
let g:ackhighlight = 1
<
*g:ack_autoclose*
g:ack_autoclose
Default: 0
Use this option to specify whether to close the quickfix window after
using any of the shortcuts.
Example:
>
let g:ack_autoclose = 1
<
*g:ack_autofold_results*
g:ack_autofold_results
Default: 0
Use this option to fold the results in quickfix by file name. Only the current
fold will be open by default and while you press 'j' and 'k' to move between the
results if you hit other fold the last one will be closed and the current will
be open.
Example:
>
let g:ack_autofold_results = 1
<
*g:ackpreview*
g:ackpreview
Default: 0
Use this option to automagically open the file with 'j' or 'k'.
Example:
>
let g:ackpreview = 1
<
*g:ack_use_dispatch*
g:ack_use_dispatch
Default: 0
Use this option to use vim-dispatch to run searches in the background, with a
variety of execution backends for different systems.
Due to limitations in Dispatch at this time, location lists are unsupported
and result windows will appear before results are ready. Still, these may be
acceptable tradeoffs for very large projects where searches are slow.
Example:
>
let g:ack_use_dispatch = 1
<
*g:ack_use_cword_for_empty_search*
g:ack_use_cword_for_empty_search
Default: 1
Use this option to enable blank searches to run against the word under the
cursor. When this option is not set, blank searches will only output an error
message.
Example:
>
let g:ack_use_cword_for_empty_search = 0
<
==============================================================================
MAPPINGS *ack-mappings*
The following keyboard shortcuts are available in the |quickfix| and
|location-list| windows:
? display a quick summary of these mappings.
o open file (same as Enter).
O open file and close the quickfix window.
go preview file (open but maintain focus on ack.vim results).
t open in a new tab.
T open in new tab without moving to it.
h open in horizontal split.
H open in horizontal split, keeping focus on the results.
v open in vertical split.
gv open in vertical split, keeping focus on the results.
q close the quickfix window.
To adjust these, see |g:ack_mappings|.
==============================================================================
Ignoring files *ack-ignore*
If you're using this plugin with ag, The Silver Searcher, bear in mind that:
- It ignores file patterns from your .gitignore and .hgignore.
- If there are other files in your source repository you don't wish to
search, you can add their patterns to an .agignore file.
==============================================================================
ISSUES AND FAQ *ack-issues-and-faq*
I don't want to jump to the first result automatically.~
Use `:Ack!`, with bang. If you want this behavior most of the time, you
might like an abbreviation or mapping in your personal config, something
like these:
>
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
<
Most of the `:[L]Ack*` commands support this. Note that this behavior
follows the convention of Vim's built-in |:grep| and |:make| commands.
I use NERDTree and opening ack.vim results in a vertical split displacing it.~
You are probably using NERDTree with its default alignment at the left
side of the window. Set these custom mappings in your vimrc to work around
this:
>
let g:ack_mappings = {
\ 'v': '<C-W><CR><C-W>L<C-W>p<C-W>J<C-W>p',
\ 'gv': '<C-W><CR><C-W>L<C-W>p<C-W>J' }
<
This solution will be improved in the future.
Results show a mix of relative and absolute paths, making them hard to read.~
This is a quirk of Vim that can happen with plain |:vimgrep| too. You can
try this in your vimrc to work around it:
>
autocmd BufAdd * exe "cd" fnameescape(getcwd())
<
but for some users this may be disruptive to their Vim workflow. For more
details, see:
http://vi.stackexchange.com/a/4816/7174
https://github.com/mileszs/ack.vim/issues/143
vim:set et sw=4 ts=4 tw=78:

View file

@ -1,15 +0,0 @@
==== ack.vim quick help ===============
*?:* a quick summary of these keys, repeat to close
*o:* to open (same as Enter)
*O:* to open and close the quickfix window
*go:* to preview file, open but maintain focus on ack.vim results
*t:* to open in new tab
*T:* to open in new tab without moving to it
*h:* to open in horizontal split
*H:* to open in horizontal split, keeping focus on the results
*v:* to open in vertical split
*gv:* to open in vertical split, keeping focus on the results
*q:* to close the quickfix window
========================================

View file

@ -1,9 +0,0 @@
if exists("g:ack_autofold_results") && g:ack_autofold_results
setlocal foldlevel=0
setlocal foldmethod=expr
setlocal foldexpr=matchstr(getline(v:lnum),'^[^\|]\\+')==#matchstr(getline(v:lnum+1),'^[^\|]\\+')?1:'<1'
setlocal foldenable
setlocal foldclose=all
setlocal foldopen=all
nnoremap <buffer> j jzz
endif

View file

@ -1,83 +0,0 @@
if exists('g:loaded_ack') || &cp
finish
endif
if !exists("g:ack_default_options")
let g:ack_default_options = " -s -H --nopager --nocolor --nogroup --column"
endif
" Location of the ack utility
if !exists("g:ackprg")
if executable('ack-grep')
let g:ackprg = "ack-grep"
elseif executable('ack')
let g:ackprg = "ack"
else
finish
endif
let g:ackprg .= g:ack_default_options
endif
if !exists("g:ack_apply_qmappings")
let g:ack_apply_qmappings = !exists("g:ack_qhandler")
endif
if !exists("g:ack_apply_lmappings")
let g:ack_apply_lmappings = !exists("g:ack_lhandler")
endif
let s:ack_mappings = {
\ "t": "<C-W><CR><C-W>T",
\ "T": "<C-W><CR><C-W>TgT<C-W>j",
\ "o": "<CR>",
\ "O": "<CR><C-W>p<C-W>c",
\ "go": "<CR><C-W>p",
\ "h": "<C-W><CR><C-W>K",
\ "H": "<C-W><CR><C-W>K<C-W>b",
\ "v": "<C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t",
\ "gv": "<C-W><CR><C-W>H<C-W>b<C-W>J" }
if exists("g:ack_mappings")
let g:ack_mappings = extend(s:ack_mappings, g:ack_mappings)
else
let g:ack_mappings = s:ack_mappings
endif
if !exists("g:ack_qhandler")
let g:ack_qhandler = "botright copen"
endif
if !exists("g:ack_lhandler")
let g:ack_lhandler = "botright lopen"
endif
if !exists("g:ackhighlight")
let g:ackhighlight = 0
endif
if !exists("g:ack_autoclose")
let g:ack_autoclose = 0
endif
if !exists("g:ack_autofold_results")
let g:ack_autofold_results = 0
endif
if !exists("g:ack_use_cword_for_empty_search")
let g:ack_use_cword_for_empty_search = 1
endif
command! -bang -nargs=* -complete=file Ack call ack#Ack('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAck call ack#Ack('lgrep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAckAdd call ack#Ack('lgrepadd<bang>', <q-args>)
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=* AckWindow call ack#AckWindow('grep<bang>', <q-args>)
command! -bang -nargs=* LAckWindow call ack#AckWindow('lgrep<bang>', <q-args>)
let g:loaded_ack = 1
" vim:set et sw=2 ts=2 tw=78 fdm=marker

View file

@ -1,39 +0,0 @@
created by
---------
[jeff lanzarotta](http://www.vim.org/account/profile.php?user_id=97)
script type
----------
utility
description
-----------
With bufexplorer, you can quickly and easily switch between buffers by using the one of the default public interfaces:
'\be' (normal open) or
'\bs' (force horizontal split open) or
'\bv' (force vertical split open)
Once the bufexplorer window is open you can use the normal movement keys (hjkl) to move around and then use <Enter> or <Left-Mouse-Click> to select the buffer you would like to open. If you would like to have the selected buffer opened in a new tab, simply press either <Shift-Enter> or 't'. Please note that when opening a buffer in a tab, that if the buffer is already in another tab, bufexplorer can switch to that tab automatically for you if you would like. More about that in the supplied VIM help.
Bufexplorer also offers various options including:
* Display the list of buffers in various sort orders including:
* Most Recently Used (MRU) which is the default
* Buffer number
* File name
* File extension
* Full file path name
* Delete buffer from list
For more about options, sort orders, configuration options, etc. please see the supplied VIM help.
install details
---------------
Simply unzip bufexplorer.zip into a directory in your 'runtimepath', usually ~/.vim or c:\vimfiles, and restart Vim. This zip file contains plugin\bufexplorer.vim, and doc\bufexplorer.txt. See ':help add-local-help' on how to add bufexplorer.txt to vim's help system.
NOTE
----
Version 7.0.12 and above will ONLY work with 7.0 and above of Vim.
**IMPORTANT**: If you have a version prior to 7.1.2 that contains an autoload\bufexplorer.vim file, please REMOVE the autoload\bufexlorer.vim AND the plugin\bufexplorer.vim files before installing a new version.

View file

@ -1,513 +0,0 @@
*bufexplorer.txt* Buffer Explorer Last Change: 22 Oct 2010
Buffer Explorer *buffer-explorer* *bufexplorer*
Version 7.2.8
Plugin for easily exploring (or browsing) Vim |:buffers|.
|bufexplorer-installation| Installation
|bufexplorer-usage| Usage
|bufexplorer-windowlayout| Window Layout
|bufexplorer-customization| Customization
|bufexplorer-changelog| Change Log
|bufexplorer-todo| Todo
|bufexplorer-credits| Credits
For Vim version 7.0 and above.
This plugin is only available if 'compatible' is not set.
{Vi does not have any of this}
==============================================================================
INSTALLATION *bufexplorer-installation*
To install:
- Download the bufexplorer.zip.
- Extract the zip archive into your runtime directory.
The archive contains plugin/bufexplorer.vim, and doc/bufexplorer.txt.
- Start Vim or goto an existing instance of Vim.
- Execute the following command:
>
:helptag <your runtime directory>/doc
<
This will generate all the help tags for any file located in the doc
directory.
==============================================================================
USAGE *bufexplorer-usage*
To start exploring in the current window, use: >
\be or :BufExplorer
To start exploring in a newly split horizontal window, use: >
\bs or :BufExplorerHorizontalSplit
To start exploring in a newly split vertical window, use: >
\bv or :BufExplorerVerticalSplit
If you would like to use something other than '\', you may simply change the
leader (see |mapleader|).
Note: If the current buffer is modified when bufexplorer started, the current
window is always split and the new bufexplorer is displayed in that new
window.
Commands to use once exploring:
<F1> Toggle help information.
<enter> Opens the buffer that is under the cursor into the current
window.
<leftmouse> Opens the buffer that is under the cursor into the current
window.
<shift-enter> Opens the buffer that is under the cursor in another tab.
d |:delete|the buffer under the cursor from the list. The
buffer's 'buflisted' is cleared. This allows for the buffer to
be displayed again using the 'show unlisted' command.
R Toggles relative path/absolute path.
T Toggles to show only buffers for this tab or not.
D |:wipeout|the buffer under the cursor from the list. When a
buffers is wiped, it will not be shown when unlisted buffer are
displayed.
f Toggles whether you are taken to the active window when
selecting a buffer or not.
o Opens the buffer that is under the cursor into the current
window.
p Toggles the showing of a split filename/pathname.
q Quit exploring.
r Reverses the order the buffers are listed in.
s Selects the order the buffers are listed in. Either by buffer
number, file name, file extension, most recently used (MRU), or
full path.
t Opens the buffer that is under the cursor in another tab.
u Toggles the showing of "unlisted" buffers.
Once invoked, Buffer Explorer displays a sorted list (MRU is the default
sort method) of all the buffers that are currently opened. You are then
able to move the cursor to the line containing the buffer's name you are
wanting to act upon. Once you have selected the buffer you would like,
you can then either open it, close it(delete), resort the list, reverse
the sort, quit exploring and so on...
===============================================================================
WINDOW LAYOUT *bufexplorer-windowlayout*
-------------------------------------------------------------------------------
" Press <F1> for Help
" Sorted by mru | Locate buffer | Absolute Split path
"=
01 %a bufexplorer.txt C:\Vim\vimfiles\doc line 87
02 # bufexplorer.vim c:\Vim\vimfiles\plugin line 1
-------------------------------------------------------------------------------
| | | | |
| | | | +-- Current Line #.
| | | +-- Relative/Full Path
| | +-- Buffer Name.
| +-- Buffer Attributes. See|:buffers|for more information.
+-- Buffer Number. See|:buffers|for more information.
===============================================================================
CUSTOMIZATION *bufexplorer-customization*
*g:bufExplorerChgWin*
If set, bufexplorer will bring up the selected buffer in the window specified
by g:bufExplorerChgWin.
*g:bufExplorerDefaultHelp*
To control whether the default help is displayed or not, use: >
let g:bufExplorerDefaultHelp=0 " Do not show default help.
let g:bufExplorerDefaultHelp=1 " Show default help.
The default is to show the default help.
*g:bufExplorerDetailedHelp*
To control whether detailed help is display by, use: >
let g:bufExplorerDetailedHelp=0 " Do not show detailed help.
let g:bufExplorerDetailedHelp=1 " Show detailed help.
The default is NOT to show detailed help.
*g:bufExplorerFindActive*
To control whether you are taken to the active window when selecting a buffer,
use: >
let g:bufExplorerFindActive=0 " Do not go to active window.
let g:bufExplorerFindActive=1 " Go to active window.
The default is to be taken to the active window.
*g:bufExplorerFuncRef*
When a buffer is selected, the functions specified either singly or as a list
will be called.
*g:bufExplorerReverseSort*
To control whether to sort the buffer in reverse order or not, use: >
let g:bufExplorerReverseSort=0 " Do not sort in reverse order.
let g:bufExplorerReverseSort=1 " Sort in reverse order.
The default is NOT to sort in reverse order.
*g:bufExplorerShowDirectories*
Directories usually show up in the list from using a command like ":e .".
To control whether to show directories in the buffer list or not, use: >
let g:bufExplorerShowDirectories=1 " Show directories.
let g:bufExplorerShowDirectories=0 " Don't show directories.
The default is to show directories.
*g:bufExplorerShowRelativePath*
To control whether to show absolute paths or relative to the current
directory, use: >
let g:bufExplorerShowRelativePath=0 " Show absolute paths.
let g:bufExplorerShowRelativePath=1 " Show relative paths.
The default is to show absolute paths.
*g:bufExplorerShowTabBuffer*
To control weither or not to show buffers on for the specific tab or not, use: >
let g:bufExplorerShowTabBuffer=0 " No.
let g:bufExplorerShowTabBuffer=1 " Yes.
The default is not to show.
*g:bufExplorerShowUnlisted*
To control whether to show unlisted buffer or not, use: >
let g:bufExplorerShowUnlisted=0 " Do not show unlisted buffers.
let g:bufExplorerShowUnlisted=1 " Show unlisted buffers.
The default is to NOT show unlisted buffers.
*g:bufExplorerSortBy*
To control what field the buffers are sorted by, use: >
let g:bufExplorerSortBy='extension' " Sort by file extension.
let g:bufExplorerSortBy='fullpath' " Sort by full file path name.
let g:bufExplorerSortBy='mru' " Sort by most recently used.
let g:bufExplorerSortBy='name' " Sort by the buffer's name.
let g:bufExplorerSortBy='number' " Sort by the buffer's number.
The default is to sort by mru.
*g:bufExplorerSplitBelow*
To control where the new split window will be placed above or below the
current window, use: >
let g:bufExplorerSplitBelow=1 " Split new window below current.
let g:bufExplorerSplitBelow=0 " Split new window above current.
The default is to use what ever is set by the global &splitbelow
variable.
*g:bufExplorerSplitOutPathName*
To control whether to split out the path and file name or not, use: >
let g:bufExplorerSplitOutPathName=1 " Split the path and file name.
let g:bufExplorerSplitOutPathName=0 " Don't split the path and file
" name.
The default is to split the path and file name.
*g:bufExplorerSplitRight*
To control where the new vsplit window will be placed to the left or right of
current window, use: >
let g:bufExplorerSplitRight=0 " Split left.
let g:bufExplorerSplitRight=1 " Split right.
The default is to use the global &splitright.
===============================================================================
CHANGE LOG *bufexplorer-changelog*
7.2.8 - Enhancements:
* Thanks to Charles Campbell for integrating bufexplorer with GDBMGR.
http://mysite.verizon.net/astronaut/vim/index.html#GDBMGR
7.2.7 - Fix:
* My 1st attempt to fix the "cache" issue where buffers information
has changed but the cache/display does not reflect those changes.
More work still needs to be done.
7.2.6 - Fix:
* Thanks to Michael Henry for pointing out that I totally forgot to
update the inline help to reflect the previous change to the 'd'
and 'D' keys. Opps!
7.2.5 - Fix:
* Philip Morant suggested switching the command (bwipe) associated
with the 'd' key with the command (bdelete) associated with the 'D'
key. This made sense since the 'd' key is more likely to be used
compared to the 'D' key.
7.2.4 - Fix:
* I did not implement the patch provided by Godefroid Chapelle
correctly. I missed one line which happened to be the most
important one :)
7.2.3 - Enhancements:
* Thanks to David Fishburn for helping me out with a much needed
code overhaul as well as some awesome performance enhancements.
He also reworked the handling of tabs.
* Thanks to Vladimir Dobriakov for making the suggestions on
enhancing the documentation to include a better explaination of
what is contained in the main bufexplorer window.
* Thanks to Yuriy Ershov for added code that when the bufexplorer
window is opened, the cursor is now positioned at the line with the
active buffer (useful in non-MRU sort modes).
* Yuriy also added the abiltiy to cycle through the sort fields in
reverse order.
Fixes:
* Thanks to Michael Henry for supplying a patch that allows
bufexplorer to be opened even when there is one buffer or less.
* Thanks to Godefroid Chapelle for supplying a patch that fixed
MRU sort order after loading a session.
7.2.2 - Fixes:
* Thanks to David L. Dight for spotting and fixing an issue when
using ctrl^. bufexplorer would incorrectly handle the previous
buffer so that when ctrl^ was pressed the incorrect file was opened.
7.2.1 - Fixes:
* Thanks to Dimitar for spotting and fixing a feature that was
inadvertently left out of the previous version. The feature was
when bufexplorer was used together with WinManager, you could use
the tab key to open a buffer in a split window.
7.2.0 - Enhancements:
* For all those missing the \bs and \bv commands, these have now
returned. Thanks to Phil O'Connell for asking for the return of
these missing features and helping test out this version.
Fixes:
* Fixed problem with the bufExplorerFindActive code not working
correctly.
* Fixed an incompatibility between bufexplorer and netrw that caused
buffers to be incorrectly removed from the MRU list.
7.1.7 - Fixes:
* TaCahiroy fixed several issues related to opening a buffer in a
tab.
7.1.6 - Fixes:
* Removed ff=unix from modeline in bufexplorer.txt. Found by Bill
McCarthy.
7.1.5 - Fixes:
* Could not open unnamed buffers. Fixed by TaCahiroy.
7.1.4 - Fixes:
* Sometimes when a file's path has 'white space' in it, extra buffers
would be created containing each piece of the path. i.e:
opening c:\document and settings\test.txt would create a buffer
named "and" and a buffer named "Documents". This was reported and
fixed by TaCa Yoss.
7.1.3 - Fixes:
* Added code to allow only one instance of the plugin to run at a
time. Thanks Dennis Hostetler.
7.1.2 - Fixes:
* Fixed a jumplist issue spotted by JiangJun. I overlooked the
'jumplist' and with a couple calls to 'keepjumps', everything is
fine again.
* Went back to just having a plugin file, no autoload file. By having
the autoload, WinManager was no longer working and without really
digging into the cause, it was easier to go back to using just a
plugin file.
7.1.1 - Fixes:
* A problem spotted by Thomas Arendsen Hein.
When running Vim (7.1.94), error E493 was being thrown.
Enhancements:
* Added 'D' for 'delete' buffer as the 'd' command was a 'wipe'
buffer.
7.1.0 - Another 'major' update, some by Dave Larson, some by me.
* Making use of 'autoload' now to make the plugin load quicker.
* Removed '\bs' and '\bv'. These are now controlled by the user. The
user can issue a ':sp' or ':vs' to create a horizontal or vertical
split window and then issue a '\be'
* Added handling of tabs.
7.0.17 - Fixed issue with 'drop' command.
Various enhancements and improvements.
7.0.16 - Fixed issue reported by Liu Jiaping on non Windows systems, which was
...
Open file1, open file2, modify file1, open bufexplorer, you get the
following error:
--------8<--------
Error detected while processing function
<SNR>14_StartBufExplorer..<SNR>14_SplitOpen:
line 4:
E37: No write since last change (add ! to override)
But the worse thing is, when I want to save the current buffer and
type ':w', I get another error message:
E382: Cannot write, 'buftype' option is set
--------8<--------
7.0.15 - Thanks to Mark Smithfield for suggesting bufexplorer needed to handle
the ':args' command.
7.0.14 - Thanks to Randall Hansen for removing the requirement of terminal
versions to be recompiled with 'gui' support so the 'drop' command
would work. The 'drop' command is really not needed in terminal
versions.
7.0.13 - Fixed integration with WinManager.
Thanks to Dave Eggum for another update.
- Fix: The detailed help didn't display the mapping for toggling
the split type, even though the split type is displayed.
- Fixed incorrect description in the detailed help for toggling
relative or full paths.
- Deprecated s:ExtractBufferNbr(). Vim's str2nr() does the same
thing.
- Created a s:Set() function that sets a variable only if it hasn't
already been defined. It's useful for initializing all those
default settings.
- Removed checks for repetitive command definitions. They were
unnecessary.
- Made the help highlighting a little more fancy.
- Minor reverse compatibility issue: Changed ambiguous setting
names to be more descriptive of what they do (also makes the code
easier to follow):
Changed bufExplorerSortDirection to bufExplorerReverseSort
Changed bufExplorerSplitType to bufExplorerSplitVertical
Changed bufExplorerOpenMode to bufExplorerUseCurrentWindow
- When the BufExplorer window closes, all the file-local marks are
now deleted. This may have the benefit of cleaning up some of the
jumplist.
- Changed the name of the parameter for StartBufExplorer from
"split" to "open". The parameter is a string which specifies how
the buffer will be open, not if it is split or not.
- Deprecated DoAnyMoreBuffersExist() - it is a one line function
only used in one spot.
- Created four functions (SplitOpen(), RebuildBufferList(),
UpdateHelpStatus() and ReSortListing()) all with one purpose - to
reduce repeated code.
- Changed the name of AddHeader() to CreateHelp() to be more
descriptive of what it does. It now returns an array instead of
updating the window directly. This has the benefit of making the
code more efficient since the text the function returns is used a
little differently in the two places the function is called.
- Other minor simplifications.
7.0.12 - MAJOR Update.
This version will ONLY run with Vim version 7.0 or greater.
Dave Eggum has made some 'significant' updates to this latest
version:
- Added BufExplorerGetAltBuf() global function to be used in the
users rulerformat.
- Added g:bufExplorerSplitRight option.
- Added g:bufExplorerShowRelativePath option with mapping.
- Added current line highlighting.
- The split type can now be changed whether bufexplorer is opened
in split mode or not.
- Various major and minor bug fixes and speed improvements.
- Sort by extension.
Other improvements/changes:
- Changed the help key from '?' to <F1> to be more 'standard'.
- Fixed splitting of vertical bufexplorer window.
Hopefully I have not forgot something :)
7.0.11 - Fixed a couple of highlighting bugs, reported by David Eggum. He also
changed passive voice to active on a couple of warning messages.
7.0.10 - Fixed bug report by Xiangjiang Ma. If the 'ssl' option is set,
the slash character used when displaying the path was incorrect.
7.0.9 - Martin Grenfell found and eliminated an annoying bug in the
bufexplorer/winmanager integration. The bug was were an
annoying message would be displayed when a window was split or
a new file was opened in a new window. Thanks Martin!
7.0.8 - Thanks to Mike Li for catching a bug in the WinManager integration.
The bug was related to the incorrect displaying of the buffer
explorer's window title.
7.0.7 - Thanks to Jeremy Cowgar for adding a new enhancement. This
enhancement allows the user to press 'S', that is capital S, which
will open the buffer under the cursor in a newly created split
window.
7.0.6 - Thanks to Larry Zhang for finding a bug in the "split" buffer code.
If you force set g:bufExplorerSplitType='v' in your vimrc, and if you
tried to do a \bs to split the bufexplorer window, it would always
split horizontal, not vertical. He also found that I had a typeo in
that the variable g:bufExplorerSplitVertSize was all lower case in
the documentation which was incorrect.
7.0.5 - Thanks to Mun Johl for pointing out a bug that if a buffer was
modified, the '+' was not showing up correctly.
7.0.4 - Fixed a problem discovered first by Xiangjiang Ma. Well since I've
been using vim 7.0 and not 6.3, I started using a function (getftype)
that is not in 6.3. So for backward compatibility, I conditionaly use
this function now. Thus, the g:bufExplorerShowDirectories feature is
only available when using vim 7.0 and above.
7.0.3 - Thanks to Erwin Waterlander for finding a problem when the last
buffer was deleted. This issue got me to rewrite the buffer display
logic (which I've wanted to do for sometime now).
Also great thanks to Dave Eggum for coming up with idea for
g:bufExplorerShowDirectories. Read the above information about this
feature.
7.0.2 - Thanks to Thomas Arendsen Hein for finding a problem when a user
has the default help turned off and then brought up the explorer. An
E493 would be displayed.
7.0.1 - Thanks to Erwin Waterlander for finding a couple problems.
The first problem allowed a modified buffer to be deleted. Opps! The
second problem occurred when several files were opened, BufExplorer
was started, the current buffer was deleted using the 'd' option, and
then BufExplorer was exited. The deleted buffer was still visible
while it is not in the buffers list. Opps again!
7.0.0 - Thanks to Shankar R. for suggesting to add the ability to set
the fixed width (g:bufExplorerSplitVertSize) of a new window
when opening bufexplorer vertically and fixed height
(g:bufExplorerSplitHorzSize) of a new window when opening
bufexplorer horizontally. By default, the windows are normally
split to use half the existing width or height.
6.3.0 - Added keepjumps so that the jumps list would not get cluttered with
bufexplorer related stuff.
6.2.3 - Thanks to Jay Logan for finding a bug in the vertical split position
of the code. When selecting that the window was to be split
vertically by doing a '\bv', from then on, all splits, i.e. '\bs',
were split vertically, even though g:bufExplorerSplitType was not set
to 'v'.
6.2.2 - Thanks to Patrik Modesto for adding a small improvement. For some
reason his bufexplorer window was always showing up folded. He added
'setlocal nofoldenable' and it was fixed.
6.2.1 - Thanks goes out to Takashi Matsuo for added the 'fullPath' sorting
logic and option.
6.2.0 - Thanks goes out to Simon Johann-Ganter for spotting and fixing a
problem in that the last search pattern is overridden by the search
pattern for blank lines.
6.1.6 - Thanks to Artem Chuprina for finding a pesky bug that has been around
for sometime now. The <esc> key mapping was causing the buffer
explored to close prematurely when vim was run in an xterm. The <esc>
key mapping is now removed.
6.1.5 - Thanks to Khorev Sergey. Added option to show default help or not.
6.1.4 - Thanks goes out to Valery Kondakoff for suggesting the addition of
setlocal nonumber and foldcolumn=0. This allows for line numbering
and folding to be turned off temporarily while in the explorer.
6.1.3 - Added folding. Did some code cleanup. Added the ability to force the
newly split window to be temporarily vertical, which was suggested by
Thomas Glanzmann.
6.1.2 - Now pressing the <esc> key will quit, just like 'q'.
Added folds to hide winmanager configuration.
If anyone had the 'C' option in their cpoptions they would receive
a E10 error on startup of BufExplorer. cpo is now saved, updated and
restored. Thanks to Charles E Campbell, Jr.
Attempted to make sure there can only be one BufExplorer window open
at a time.
6.1.1 - Thanks to Brian D. Goodwin for adding toupper to FileNameCmp. This
way buffers sorted by name will be in the correct order regardless of
case.
6.0.16 - Thanks to Andre Pang for the original patch/idea to get bufexplorer
to work in insertmode/modeless mode (evim). Added Initialize
and Cleanup autocommands to handle commands that need to be
performed when starting or leaving bufexplorer.
6.0.15 - Srinath Avadhanulax added a patch for winmanager.vim.
6.0.14 - Fix a few more bug that I thought I already had fixed. Thanks
to Eric Bloodworth for adding 'Open Mode/Edit in Place'. Added
vertical splitting.
6.0.13 - Thanks to Charles E Campbell, Jr. for pointing out some embarrassing
typos that I had in the documentation. I guess I need to run
the spell checker more :o)
6.0.12 - Thanks to Madoka Machitani, for the tip on adding the augroup command
around the MRUList autocommands.
6.0.11 - Fixed bug report by Xiangjiang Ma. '"=' was being added to the
search history which messed up hlsearch.
6.0.10 - Added the necessary hooks so that the Srinath Avadhanula's
winmanager.vim script could more easily integrate with this script.
Tried to improve performance.
6.0.9 - Added MRU (Most Recently Used) sort ordering.
6.0.8 - Was not resetting the showcmd command correctly.
Added nifty help file.
6.0.7 - Thanks to Brett Carlane for some great enhancements. Some are added,
some are not, yet. Added highlighting of current and alternate
filenames. Added splitting of path/filename toggle. Reworked
ShowBuffers().
Changed my email address.
6.0.6 - Copyright notice added. Needed this so that it could be distributed
with Debian Linux. Fixed problem with the SortListing() function
failing when there was only one buffer to display.
6.0.5 - Fixed problems reported by David Pascoe, in that you where unable to
hit 'd' on a buffer that belonged to a files that no longer existed
and that the 'yank' buffer was being overridden by the help text when
the bufexplorer was opened.
6.0.4 - Thanks to Charles Campbell, Jr. for making this plugin more plugin
*compliant*, adding default keymappings of <Leader>be and <Leader>bs
as well as fixing the 'w:sortDirLabel not being defined' bug.
6.0.3 - Added sorting capabilities. Sort taken from explorer.vim.
6.0.2 - Can't remember. (2001-07-25)
6.0.1 - Initial release.
===============================================================================
TODO *bufexplorer-todo*
- Nothing as of now, buf if you have any suggestions, drop me an email.
===============================================================================
CREDITS *bufexplorer-credits*
Author: Jeff Lanzarotta <delux256-vim at yahoo dot com>
Credit must go out to Bram Moolenaar and all the Vim developers for
making the world's best editor (IMHO). I also want to thank everyone who
helped and gave me suggestions. I wouldn't want to leave anyone out so I
won't list names.
===============================================================================
vim:tw=78:noet:wrap:ts=8:ft=help:norl:

File diff suppressed because it is too large Load diff

View file

@ -1,7 +0,0 @@
*.markdown
*.zip
note.txt
tags
tags-cn
.hg*
tmp/*

File diff suppressed because it is too large Load diff

View file

@ -1,173 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/autoignore.vim
" Description: Auto-ignore Extension
" Author: Ludovic Chabant <github.com/ludovicchabant>
" =============================================================================
" Global Settings {{{
if exists('g:ctrlp_autoignore_loaded') && g:ctrlp_autoignore_loaded
\ && !g:ctrlp_autoignore_debug
finish
endif
let g:ctrlp_autoignore_loaded = 1
if !exists('g:ctrlp_autoignore_debug')
let g:ctrlp_autoignore_debug = 0
endif
if !exists('g:ctrlp_autoignore_trace')
let g:ctrlp_autoignore_trace = 0
endif
" }}}
" Initialization {{{
if !exists('g:ctrlp_custom_ignore')
let g:ctrlp_custom_ignore = {}
endif
let g:ctrlp_custom_ignore['func'] = 'ctrlp#autoignore#ignore'
let g:ctrlp_custom_ignore['func-init'] = 'ctrlp#autoignore#ignore_init'
let g:ctrlp_custom_ignore['func-close'] = 'ctrlp#autoignore#ignore_close'
if !exists('g:ctrlp_root_markers')
let g:ctrlp_root_markers = []
endif
call add(g:ctrlp_root_markers, '.ctrlpignore')
" }}}
" Internals {{{
function! s:trace(message) abort
if g:ctrlp_autoignore_trace
echom "ctrlp_autoignore: " . a:message
endif
endfunction
let s:proj_cache = {}
let s:active_cwd = ''
let s:active_cwd_len = 0
let s:active_patterns = []
let s:changed_wildignore = 0
let s:prev_wildignore = ''
function! s:load_project_patterns(root_dir) abort
let l:ign_path = a:root_dir . '/.ctrlpignore'
if !filereadable(l:ign_path)
call s:trace("No pattern file at: " . l:ign_path)
return []
endif
let l:cursyntax = 'regexp'
let l:knownsyntaxes = ['regexp', 'wildignore']
let l:patterns = []
let l:lines = readfile(l:ign_path)
for line in l:lines
" Comment line?
if match(line, '\v^\s*$') >= 0 || match(line, '\v^\s*#') >= 0
continue
endif
" Syntax change?
let l:matches = matchlist(line, '\v^syntax:\s?(\w+)\s*$')
if len(l:matches) > 0
let l:cursyntax = l:matches[1]
if index(l:knownsyntaxes, l:cursyntax) < 0
echoerr "ctrlp_autoignore: Unknown syntax '".l:cursyntax."' in: ".l:ign_path
endif
continue
endif
" Patterns!
let l:matches = matchlist(line, '\v^((dir|file|link)\:)?(.*)')
let l:mtype = l:matches[2]
let l:mpat = l:matches[3]
call add(l:patterns, {'syn': l:cursyntax, 'type': l:mtype, 'pat': l:mpat})
endfor
call s:trace("Loaded " . len(l:patterns) . " patterns from: " . l:ign_path)
return l:patterns
endfunction
function! s:get_project_patterns(root_dir) abort
let l:ign_path = a:root_dir . '/.ctrlpignore'
let l:ign_mtime = getftime(l:ign_path)
let l:patterns = get(s:proj_cache, a:root_dir)
if type(l:patterns) == type({})
" Check that these patterns are still valid.
if l:ign_mtime < 0
" File got deleted! :(
let l:patterns['pats'] = []
return l:patterns['pats']
elseif l:ign_mtime <= l:patterns['mtime']
" File hasn't changed! :)
return l:patterns['pats']
endif
endif
call s:trace("Loading patterns for project: " . a:root_dir)
let l:loaded = s:load_project_patterns(a:root_dir)
let s:proj_cache[a:root_dir] = {
\'mtime': localtime(),
\'pats': l:loaded}
return l:loaded
endfunction
" The custom ignore function that CtrlP will be using in addition to
" normal pattern-based matching.
function! ctrlp#autoignore#ignore(item, type) abort
let l:cnv_item = tr(strpart(a:item, s:active_cwd_len), "\\", "/")
for pat in s:active_patterns
if pat['syn'] != 'regexp'
continue
endif
if pat['type'] == '' || pat['type'] == a:type
if match(l:cnv_item, pat['pat']) >= 0
call s:trace("Ignoring ".l:cnv_item." because of ".pat['pat'])
return 1
endif
endif
endfor
return 0
endfunction
function! ctrlp#autoignore#ignore_init() abort
let l:root = getcwd()
let s:active_cwd = l:root
" len+1 is for including the next separator after the root.
let s:active_cwd_len = len(l:root) + 1
let s:active_patterns = s:get_project_patterns(l:root)
call s:trace("Got ".len(s:active_patterns)." patterns for ".l:root)
let s:changed_wildignore = 0
let s:prev_wildignore = &wildignore
for pat in s:active_patterns
if pat['syn'] == 'wildignore'
execute 'set wildignore+='.pat['pat']
let s:changed_wildignore = 1
endif
endfor
if s:changed_wildignore
call s:trace("Set wildignore to ".&wildignore)
endif
endfunction
function! ctrlp#autoignore#ignore_close() abort
if s:changed_wildignore
execute 'set wildignore='.s:prev_wildignore
let s:prev_wildignore = ''
call s:trace("Set wildignore back to ".&wildignore)
endif
endfunction
" List patterns for a given project's root.
function! ctrlp#autoignore#get_patterns(root_dir) abort
let l:patterns = s:get_project_patterns(a:root_dir)
for pat in l:patterns
let l:prefix = pat['type'] == '' ? '(all)' : pat['type']
echom l:prefix . ':' . pat['pat']
endfor
endfunction
" }}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View file

@ -1,147 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/bookmarkdir.vim
" Description: Bookmarked directories extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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(bang, dir, ...)
let ctrlp_tilde_homedir = get(g:, 'ctrlp_tilde_homedir', 0)
let cwd = fnamemodify(getcwd(), ctrlp_tilde_homedir ? ':p:~' : ':p')
let dir = fnamemodify(a:dir, ctrlp_tilde_homedir ? ':p:~' : ':p')
if a:bang == '!'
let cwd = dir != '' ? dir : cwd
let name = a:0 && a:1 != '' ? a:1 : cwd
el
let str = 'Directory to bookmark: '
let cwd = dir != '' ? dir : s:getinput(str, cwd, 'dir')
if cwd == '' | retu | en
let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
if name == '' | retu | en
en
let name = tr(name, ' ', ' ')
cal s:savebookmark(name, cwd)
cal s:msg(name, cwd)
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

View file

@ -1,277 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/buffertag.vim
" Description: Buffer Tag extension
" Maintainer: Kien Nguyen <github.com/kien>
" 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 = {
\ 'ant' : '%sant%sant%spt',
\ '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',
\ 'delphi' : '%spascal%spascal%sfp',
\ 'dosbatch': '%sdosbatch%sdosbatch%slv',
\ 'eiffel' : '%seiffel%seiffel%scf',
\ 'erlang' : '%serlang%serlang%sdrmf',
\ 'expect' : '%stcl%stcl%scfp',
\ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
\ 'go' : '%sgo%sgo%sfctv',
\ 'html' : '%shtml%shtml%saf',
\ 'java' : '%sjava%sjava%spcifm',
\ 'javascript': '%sjavascript%sjavascript%sf',
\ 'lisp' : '%slisp%slisp%sf',
\ 'lua' : '%slua%slua%sf',
\ 'make' : '%smake%smake%sm',
\ 'matlab' : '%smatlab%smatlab%sf',
\ 'ocaml' : '%socaml%socaml%scmMvtfCre',
\ 'pascal' : '%spascal%spascal%sfp',
\ 'perl' : '%sperl%sperl%sclps',
\ 'php' : '%sphp%sphp%scdvf',
\ 'python' : '%spython%spython%scmf',
\ 'rexx' : '%srexx%srexx%ss',
\ 'ruby' : '%sruby%sruby%scfFm',
\ 'rust' : '%srust%srust%sfTgsmctid',
\ 'scheme' : '%sscheme%sscheme%ssf',
\ 'sh' : '%ssh%ssh%sf',
\ 'csh' : '%ssh%ssh%sf',
\ 'zsh' : '%ssh%ssh%sf',
\ 'scala' : '%sscala%sscala%sctTmlp',
\ 'slang' : '%sslang%sslang%snf',
\ 'sml' : '%ssml%ssml%secsrtvf',
\ 'sql' : '%ssql%ssql%scFPrstTvfp',
\ 'tex' : '%stex%stex%sipcsubPGl',
\ 'tcl' : '%stcl%stcl%scfmp',
\ 'vera' : '%svera%svera%scdefgmpPtTvx',
\ 'verilog': '%sverilog%sverilog%smcPertwpvf',
\ 'vhdl' : '%svhdl%svhdl%sPctTrefp',
\ 'vim' : '%svim%svim%savf',
\ 'yacc' : '%syacc%syacc%sl',
\ }
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 --extra= --file-scope=yes ', 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) : ''
if (has('win32') || has('win64'))
let cmd = a:bin.' '.a:args.' '.fname
else
let cmd = shellescape(a:bin).' '.a:args.' '.fname
endif
if &sh =~ 'cmd\.exe'
let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
en
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, 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:btmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufname = fnamemodify(bname, ':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

View file

@ -1,98 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/changes.vim
" Description: Change list extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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 bname = bufname(each)
let fnamet = fnamemodify(bname == '' ? '[No Name]' : bname, ':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, 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:clmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufnr = bufnr('^'.fnamemodify(bname, ':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

View file

@ -1,95 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/dir.vim
" Description: Directory extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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, []]
if !ctrlp#igncwd(s:cwd)
cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0)
en
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#call('s:lash', s:cwd).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

View file

@ -1,79 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/line.vim
" Description: Line extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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(s:crbufnr)',
\ 'accept': 'ctrlp#line#accept',
\ 'act_farg' : 'dict',
\ '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(bufnr)
let [lines, bufnr] = [[], exists('s:bufnr') ? s:bufnr : a:bufnr]
let bufs = exists('s:lnmode') && !empty(s:lnmode) ? ctrlp#buffers('id') : [bufnr]
for bufnr in bufs
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
if lfb == [] && bufn != ''
let lfb = ctrlp#utils#readfile(fnamemodify(bufn, ':p'))
en
cal map(lfb, 'tr(v:val, '' '', '' '')')
let [linenr, len_lfb] = [1, len(lfb)]
let buft = bufn == '' ? '[No Name]' : 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(dict)
let mode = a:dict['action']
let str = a:dict['line']
let input = a:dict['input']
let info = matchlist(str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
let bufnr = str2nr(get(info, 1))
if bufnr
cal ctrlp#acceptfile(mode, bufnr, get(info, 2))
let @/ = input
call search(input, 'c')
call histadd("search", input)
en
endf
fu! ctrlp#line#cmd(mode, ...)
let s:lnmode = a:mode
if a:0 && !empty(a:1)
let s:lnmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
en
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View file

@ -1,88 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/mixed.vim
" Description: Mixing Files + MRU + Buffers
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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 allbufs = map(ctrlp#buffers(), 'fnamemodify(v:val, ":p")')
let [bufs, ubufs] = [[], []]
for each in allbufs
cal add(filereadable(each) ? bufs : ubufs, each)
endfo
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
let mrufs += ubufs
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

View file

@ -1,158 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/mrufiles.vim
" Description: Most Recently Used Files extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Static variables {{{1
let [s:mrbs, s:mrufs] = [[], []]
let s:mruf_map_string = '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val'
fu! ctrlp#mrufiles#opts()
let [pref, opts] = ['g:ctrlp_mruf_', {
\ 'max': ['s:max', 250],
\ 'include': ['s:in', ''],
\ 'exclude': ['s:ex', ''],
\ 'case_sensitive': ['s:cseno', 1],
\ 'relative': ['s:re', 0],
\ 'save_on_update': ['s:soup', 1],
\ 'map_string': ['g:ctrlp_mruf_map_string', s:mruf_map_string],
\ }]
for [ke, va] in items(opts)
let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
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, ...)
let cwd = getcwd()
let cwd .= cwd !~ '[\/]$' ? ctrlp#utils#lash() : ''
if {s:re}
let cwd = exists('+ssl') ? tr(cwd, '/', '\') : cwd
cal filter(a:mrufs, '!stridx(v:val, cwd)')
en
if a:0 && a:1 == 'raw' | retu a:mrufs | en
let idx = strlen(cwd)
if exists('+ssl') && &ssl
let cwd = tr(cwd, '\', '/')
cal map(a:mrufs, 'tr(v:val, "\\", "/")')
en
retu map(a:mrufs, g:ctrlp_mruf_map_string)
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, get(g:, 'ctrlp_tilde_homedir', 0) ? ':p:~' : ':p')
let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
let abs_fn = fnamemodify(fn,':p')
if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
\ || !empty(getbufvar('^' . abs_fn . '$', '&bt')) || !filereadable(abs_fn)
retu
en
let idx = index(s:mrufs, fn, 0, !{s:cseno})
if idx
cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
cal insert(s:mrufs, fn)
if {s:soup} && idx < 0
cal s:savetofile(s:mergelists())
en
en
endf
fu! s:savetofile(mrufs)
cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile)
endf
" Public {{{1
fu! ctrlp#mrufiles#refresh(...)
let mrufs = s:mergelists()
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
if exists('+ssl')
cal map(mrufs, 'tr(v:val, "/", "\\")')
cal map(s:mrufs, 'tr(v:val, "/", "\\")')
let cond = 'count(mrufs, v:val, !{s:cseno}) == 1'
cal filter(mrufs, cond)
cal filter(s:mrufs, cond)
en
cal s:savetofile(mrufs)
retu a:0 && a:1 == 'raw' ? [] : s:reformat(mrufs)
endf
fu! ctrlp#mrufiles#remove(files)
let mrufs = []
if a:files != []
let mrufs = s:mergelists()
let cond = 'index(a:files, v:val, 0, !{s:cseno}) < 0'
cal filter(mrufs, cond)
cal filter(s:mrufs, cond)
en
cal s:savetofile(mrufs)
retu s:reformat(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:reformat(s:mergelists(), a:1) : 0
\ : s:reformat(s:mergelists())
endf
fu! ctrlp#mrufiles#bufs()
retu s:mrbs
endf
fu! ctrlp#mrufiles#tgrel()
let {s:re} = !{s:re}
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 BufWinEnter,BufWinLeave,BufWritePost * cal s:record(expand('<abuf>', 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

View file

@ -1,59 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/quickfix.vim
" Description: Quickfix extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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

View file

@ -1,59 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/rtscript.vim
" Description: Runtime scripts extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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

View file

@ -1,146 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/tag.vim
" Description: Tag file extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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, tgaddr)
let [tg, ofname] = split(a:str, '\t\+\ze[^\t]\+$')
let tgs = taglist('^'.tg.'$')
if len(tgs) < 2
retu [0, 0, 0, 0]
en
let bname = fnamemodify(bufname('%'), ':p')
let fname = expand(fnamemodify(simplify(ofname), ':s?^[.\/]\+??:p:.'), 1)
let [fnd, cnt, pos, ctgs, otgs] = [0, 0, 0, [], []]
for tgi in tgs
let lst = bname == fnamemodify(tgi["filename"], ':p') ? 'ctgs' : 'otgs'
cal call('add', [{lst}, tgi])
endfo
let ntgs = ctgs + otgs
for tgi in ntgs
let cnt += 1
let fulname = fnamemodify(tgi["filename"], ':p')
if stridx(fulname, fname) >= 0
\ && strlen(fname) + stridx(fulname, fname) == strlen(fulname)
let fnd += 1
let pos = cnt
en
endfo
let cnt = 0
for tgi in ntgs
let cnt += 1
if tgi["filename"] == ofname
if a:tgaddr != ""
if a:tgaddr == tgi["cmd"]
let [fnd, pos] = [0, cnt]
en
else
let [fnd, pos] = [0, cnt]
en
en
endfo
retu [1, fnd, pos, len(ctgs)]
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 tgaddr = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\t\zs[^\t]\{-1,}\ze\%(;"\)\?\t')
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str, tgaddr)]
let cmds = {
\ 't': ['tab sp', 'tab stj'],
\ 'h': ['sp', 'stj'],
\ 'v': ['vs', 'vert stj'],
\ 'e': ['', 'tj'],
\ }
let utg = fdcnt[3] < 2 && fdcnt[0] == 1 && fdcnt[1] == 1
let cmd = !fdcnt[0] || utg ? 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 !fdcnt[0] || utg
if cmd != ''
exe cmd
en
let save_cst = &cst
set cst&
cal feedkeys(":".( utg ? fdcnt[2] : "" )."ta ".tg."\r", 'nt')
let &cst = save_cst
el
let ext = ""
if fdcnt[1] < 2 && fdcnt[2]
let [sav_more, &more] = [&more, 0]
let ext = fdcnt[2]."\r".":let &more = ".sav_more."\r"
en
cal feedkeys(":".cmd." ".tg."\r".ext, 'nt')
en
cal feedkeys('zvzz', 'nt')
cal ctrlp#setlcdir()
endf
fu! ctrlp#tag#id()
retu s:id
endf
fu! ctrlp#tag#enter()
let tfs = get(g:, 'ctrlp_custom_tag_files', tagfiles())
let s:tagfiles = type(tfs) == 3 && 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

View file

@ -1,154 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/undo.vim
" Description: Undo extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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

View file

@ -1,110 +0,0 @@
" =============================================================================
" File: autoload/ctrlp/utils.vim
" Description: Utilities
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,72 +0,0 @@
" =============================================================================
" File: plugin/ctrlp.vim
" Description: Fuzzy file, buffer, mru, tag, etc finder.
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" 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 = '<c-p>' | en
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': <q-args> })
com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init('mru', { 'dir': <q-args> })
com! -bar CtrlPBuffer cal ctrlp#init('buf')
com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': <q-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('fil', { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init('fil', { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init('fil', { 'mode': 'r' })
exe 'nn <silent> <plug>(ctrlp) :<c-u>'.g:ctrlp_cmd.'<cr>'
if g:ctrlp_map != '' && !hasmapto('<plug>(ctrlp)')
exe 'map' g:ctrlp_map '<plug>(ctrlp)'
en
if !exists('g:ctrlp_types') || index(g:ctrlp_types, 'mru') >= 0
cal ctrlp#mrufiles#init()
en
com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id())
com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
com! -n=? -com=dir CtrlPDir
\ cal ctrlp#init(ctrlp#dir#id(), { 'dir': <q-args> })
com! -n=? -com=buffer CtrlPBufTag
\ cal ctrlp#init(ctrlp#buffertag#cmd(0, <q-args>))
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! -n=? -com=buffer CtrlPLine
\ cal ctrlp#init(ctrlp#line#cmd('buf', <q-args>))
com! -n=? -com=buffer CtrlPChange
\ cal ctrlp#init(ctrlp#changes#cmd('fil', <q-args>))
com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id())
com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id())
com! -n=? -com=dir -bang CtrlPBookmarkDirAdd
\ cal ctrlp#call('ctrlp#bookmarkdir#add', '<bang>', <q-args>)
" vim:ts=2:sw=2:sts=2

View file

@ -1,105 +0,0 @@
# 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 `<F5>` to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options.
* Press `<c-f>` and `<c-b>` to cycle between modes.
* Press `<c-d>` to switch to filename only search instead of full path.
* Press `<c-r>` to switch to regexp mode.
* Use `<c-j>`, `<c-k>` or the arrow keys to navigate the result list.
* Use `<c-t>` or `<c-v>`, `<c-x>` to open the selected entry in a new tab or in a new split.
* Use `<c-n>`, `<c-p>` to select the next/previous string in the prompt's history.
* Use `<c-y>` to create a new file and its parent directories.
* Use `<c-z>` to mark/unmark multiple files and `<c-o>` 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 = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
```
* When invoked without an explicit starting directory, CtrlP will set its local working directory according to this variable:
```vim
let g:ctrlp_working_path_mode = 'ra'
```
`'c'` - the directory of the current file.
`'a'` - the directory of the current file, unless it is a subdirectory of the cwd
`'r'` - the nearest ancestor of the current file that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
`'w'` - modifier to "r": start search from the cwd instead of the current file's directory
`0` or `''` (empty string) - disable this feature.
If none of the default markers (`.git` `.hg` `.svn` `.bzr` `_darcs`) are present in a project, you can define additional ones with `g:ctrlp_root_markers`:
```vim
let g:ctrlp_root_markers = ['pom.xml', '.p4ignore']
```
If more than one mode is specified, they will be tried in order until a directory is located.
* If a file is already open, open it again in a new pane instead of switching to the existing pane
`let g:ctrlp_switch_buffer = 'et'`
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`. If a custom listing command is being used, exclusions are ignored:
```vim
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
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
```
* Ignore files in `.gitignore`
```vim
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
```
Check `:help ctrlp-options` for other options.
## Installation
Use your favorite method or check the homepage for a [quick installation guide][3].
[1]: http://i.imgur.com/aOcwHwt.png
[2]: https://github.com/ctrlpvim/ctrlp.vim/tree/extensions
[3]: http://ctrlpvim.github.com/ctrlp.vim#installation

View file

@ -1,447 +0,0 @@
" Copyright (c) 2015 Junegunn Choi
"
" MIT License
"
" 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.
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
function! s:set_color(group, attr, color)
let gui = has('gui_running') || has('termguicolors') && &termguicolors
execute printf('hi %s %s%s=%s', a:group, gui ? 'gui' : 'cterm', a:attr, a:color)
endfunction
function! s:blank(repel)
if bufwinnr(t:goyo_pads.r) <= bufwinnr(t:goyo_pads.l) + 1
\ || bufwinnr(t:goyo_pads.b) <= bufwinnr(t:goyo_pads.t) + 3
call s:goyo_off()
endif
execute 'wincmd' a:repel
endfunction
function! s:init_pad(command)
execute a:command
setlocal buftype=nofile bufhidden=wipe nomodifiable nobuflisted noswapfile
\ nonu nocursorline nocursorcolumn winfixwidth winfixheight statusline=\
if exists('&rnu')
setlocal nornu
endif
if exists('&colorcolumn')
setlocal colorcolumn=
endif
let bufnr = winbufnr(0)
execute winnr('#') . 'wincmd w'
return bufnr
endfunction
function! s:setup_pad(bufnr, vert, size, repel)
let win = bufwinnr(a:bufnr)
execute win . 'wincmd w'
execute (a:vert ? 'vertical ' : '') . 'resize ' . max([0, a:size])
augroup goyop
execute 'autocmd WinEnter,CursorMoved <buffer> nested call s:blank("'.a:repel.'")'
autocmd WinLeave <buffer> call s:hide_statusline()
augroup END
" To hide scrollbars of pad windows in GVim
let diff = winheight(0) - line('$') - (has('gui_running') ? 2 : 0)
if diff > 0
setlocal modifiable
call append(0, map(range(1, diff), '""'))
normal! gg
setlocal nomodifiable
endif
execute winnr('#') . 'wincmd w'
endfunction
function! s:resize_pads()
augroup goyop
autocmd!
augroup END
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()
let bg = s:get_color('Normal', 'bg#')
for grp in ['NonText', 'FoldColumn', 'ColorColumn', 'VertSplit',
\ 'StatusLine', 'StatusLineNC', 'SignColumn']
" -1 on Vim / '' on GVim
if bg == -1 || empty(bg)
call s:set_color(grp, 'fg', get(g:, 'goyo_bg', 'black'))
call s:set_color(grp, 'bg', 'NONE')
else
call s:set_color(grp, 'fg', bg)
call s:set_color(grp, 'bg', bg)
endif
call s:set_color(grp, '', 'NONE')
endfor
endfunction
function! s:hide_statusline()
setlocal statusline=\
endfunction
function! s:hide_linenr()
if !get(g:, 'goyo_linenr', 0)
setlocal nonu
if exists('&rnu')
setlocal nornu
endif
endif
if exists('&colorcolumn')
setlocal colorcolumn=
endif
endfunction
function! s:maps_nop()
let mapped = filter(['R', 'H', 'J', 'K', 'L', '|', '_'],
\ "empty(maparg(\"\<c-w>\".v:val, 'n'))")
for c in mapped
execute 'nnoremap <c-w>'.escape(c, '|').' <nop>'
endfor
return mapped
endfunction
function! s:maps_resize()
let commands = {
\ '=': ':<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
execute 'nnoremap <silent> <c-w>'.c.' '.commands[c]
endfor
return mapped
endfunction
nnoremap <silent> <plug>(goyo-resize) :<c-u>call <sid>resize_pads()<cr>
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,
\ 'showtabline': &showtabline,
\ 'fillchars': &fillchars,
\ 'winminwidth': &winminwidth,
\ 'winwidth': &winwidth,
\ 'winminheight': &winminheight,
\ 'winheight': &winheight,
\ 'ruler': &ruler,
\ 'sidescroll': &sidescroll,
\ 'sidescrolloff': &sidescrolloff
\ }
" New tab
tab split
let t:goyo_master = winbufnr(0)
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())
if has('gui_running')
let t:goyo_revert.guioptions = &guioptions
endif
" vim-gitgutter
let t:goyo_disabled_gitgutter = get(g:, 'gitgutter_enabled', 0)
if t:goyo_disabled_gitgutter
silent! GitGutterDisable
endif
" vim-signify
let t:goyo_disabled_signify = exists('b:sy') && b:sy.active
if t:goyo_disabled_signify
SignifyToggle
endif
" vim-airline
let t:goyo_disabled_airline = exists('#airline')
if t:goyo_disabled_airline
AirlineToggle
endif
" vim-powerline
let t:goyo_disabled_powerline = exists('#PowerlineMain')
if t:goyo_disabled_powerline
augroup PowerlineMain
autocmd!
augroup END
augroup! PowerlineMain
endif
" lightline.vim
let t:goyo_disabled_lightline = exists('#lightline')
if t:goyo_disabled_lightline
silent! call lightline#disable()
endif
call s:hide_linenr()
" Global options
let &winheight = max([&winminheight, 1])
set winminheight=1
set winheight=1
set winminwidth=1 winwidth=1
set laststatus=0
set showtabline=0
set noruler
set fillchars+=vert:\
set fillchars+=stl:\
set fillchars+=stlnc:\
set sidescroll=1
set sidescrolloff=0
" Hide left-hand scrollbars
if has('gui_running')
set guioptions-=l
set guioptions-=L
endif
let t:goyo_pads.l = s:init_pad('vertical topleft new')
let t:goyo_pads.r = s:init_pad('vertical botright new')
let t:goyo_pads.t = s:init_pad('topleft new')
let t:goyo_pads.b = s:init_pad('botright new')
call s:resize_pads()
call s:tranquilize()
augroup goyo
autocmd!
autocmd TabLeave * call s:goyo_off()
autocmd VimResized * call s:resize_pads()
autocmd ColorScheme * call s:tranquilize()
autocmd BufWinEnter * call s:hide_linenr() | call s:hide_statusline()
autocmd WinEnter,WinLeave * call s:hide_statusline()
if has('nvim')
autocmd TermClose * call feedkeys("\<plug>(goyo-resize)")
endif
augroup END
call s:hide_statusline()
if exists('g:goyo_callbacks[0]')
call g:goyo_callbacks[0]()
endif
if exists('#User#GoyoEnter')
doautocmd User GoyoEnter
endif
endfunction
function! s:goyo_off()
if !exists('#goyo')
return
endif
" Oops, not this tab
if !exists('t:goyo_revert')
return
endif
" Clear auto commands
augroup goyo
autocmd!
augroup END
augroup! goyo
augroup goyop
autocmd!
augroup END
augroup! goyop
for c in t:goyo_maps
execute 'nunmap <c-w>'.escape(c, '|')
endfor
let goyo_revert = t:goyo_revert
let goyo_disabled_gitgutter = t:goyo_disabled_gitgutter
let goyo_disabled_signify = t:goyo_disabled_signify
let goyo_disabled_airline = t:goyo_disabled_airline
let goyo_disabled_powerline = t:goyo_disabled_powerline
let goyo_disabled_lightline = t:goyo_disabled_lightline
let goyo_orig_buffer = t:goyo_master
let [line, col] = [line('.'), col('.')]
if tabpagenr() == 1
tabnew
normal! gt
bd
endif
tabclose
execute 'normal! '.s:orig_tab.'gt'
if winbufnr(0) == goyo_orig_buffer
" Doesn't work if window closed with `q`
execute printf('normal! %dG%d|', line, col)
endif
let wmw = remove(goyo_revert, 'winminwidth')
let ww = remove(goyo_revert, 'winwidth')
let &winwidth = ww
let &winminwidth = wmw
let wmh = remove(goyo_revert, 'winminheight')
let wh = remove(goyo_revert, 'winheight')
let &winheight = max([wmh, 1])
let &winminheight = wmh
let &winheight = wh
for [k, v] in items(goyo_revert)
execute printf('let &%s = %s', k, string(v))
endfor
execute 'colo '. get(g:, 'colors_name', 'default')
if goyo_disabled_gitgutter
silent! GitGutterEnable
endif
if goyo_disabled_signify
silent! if !b:sy.active
SignifyToggle
endif
endif
if goyo_disabled_airline && !exists('#airline')
AirlineToggle
" For some reason, Airline requires two refreshes to avoid display
" artifacts
silent! AirlineRefresh
silent! AirlineRefresh
endif
if goyo_disabled_powerline && !exists('#PowerlineMain')
doautocmd PowerlineStartup VimEnter
silent! PowerlineReloadColorscheme
endif
if goyo_disabled_lightline
silent! call lightline#enable()
endif
if exists('#Powerline')
doautocmd Powerline ColorScheme
endif
if exists('g:goyo_callbacks[1]')
call g:goyo_callbacks[1]()
endif
if exists('#User#GoyoLeave')
doautocmd User GoyoLeave
endif
endfunction
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(a:dim)
elseif !empty(a:dim)
if winnr('$') < 5
call s:goyo_off()
return goyo#execute(a:bang, a:dim)
endif
let dim = s:parse_arg(a:dim)
if !empty(dim)
let t:goyo_dim = dim
let t:goyo_dim_expr = a:dim
call s:resize_pads()
endif
else
call s:goyo_off()
end
end
endfunction
let &cpo = s:cpo_save
unlet s:cpo_save

View file

@ -1,170 +0,0 @@
goyo.txt goyo Last change: April 2 2017
GOYO - TABLE OF CONTENTS *goyo* *goyo-toc*
==============================================================================
goyo.vim (고요)
Installation
Usage
Dimension expression
Configuration
Callbacks
Inspiration
Pros.
License
GOYO.VIM (고요) *goyo-vim*
==============================================================================
Distraction-free writing in Vim.
https://raw.github.com/junegunn/i/master/goyo.png
(Color scheme: {seoul256}{1})
Best served with {limelight.vim}{2}.
{1} https://github.com/junegunn/seoul256.vim
{2} https://github.com/junegunn/limelight.vim
INSTALLATION *goyo-installation*
==============================================================================
Use your favorite plugin manager.
*:PlugInstall*
- {vim-plug}{3}
1. Add `Plug'junegunn/goyo.vim'` to .vimrc
2. Run `:PlugInstall`
{3} https://github.com/junegunn/vim-plug
USAGE *goyo-usage*
==============================================================================
*:Goyo*
- `:Goyo`
- Toggle Goyo
- `:Goyo[dimension]`
- Turn on or resize Goyo
- `:Goyo!`
- Turn Goyo off
The window can be resized with the usual count]<CTRL-W + `>`, `<`, `+`, `-`
keys.
< Dimension expression >______________________________________________________~
*goyo-dimension-expression*
The expected format of a dimension expression is
`[WIDTH][XOFFSET][x[HEIGHT][YOFFSET]]`. `XOFFSET` and `YOFFSET` should be
prefixed by `+` or `-`. Each component can be given in percentage.
>
" Width
Goyo 120
" Height
Goyo x30
" Both
Goyo 120x30
" In percentage
Goyo 120x50%
" With offsets
Goyo 50%+25%x50%-25%
<
CONFIGURATION *goyo-configuration*
==============================================================================
*g:goyo_width* *g:goyo_height* *g:goyo_linenr*
- `g:goyo_width` (default: 80)
- `g:goyo_height` (default: 85%)
- `g:goyo_linenr` (default: 0)
< Callbacks >_________________________________________________________________~
*goyo-callbacks*
By default, {vim-airline}{4}, {vim-powerline}{5}, {powerline}{6},
{lightline.vim}{7}, {vim-signify}{8}, and {vim-gitgutter}{9} are temporarily
disabled while in Goyo mode.
If you have other plugins that you want to disable/enable, or if you want to
change the default settings of Goyo window, you can set up custom routines to
be triggered on `GoyoEnter` and `GoyoLeave` events.
>
function! s:goyo_enter()
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
set noshowmode
set noshowcmd
set scrolloff=999
Limelight
" ...
endfunction
function! s:goyo_leave()
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
set showmode
set showcmd
set scrolloff=5
Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
<
More examples can be found here: {Customization}{10}
{4} https://github.com/bling/vim-airline
{5} https://github.com/Lokaltog/vim-powerline
{6} https://github.com/Lokaltog/powerline
{7} https://github.com/itchyny/lightline.vim
{8} https://github.com/mhinz/vim-signify
{9} https://github.com/airblade/vim-gitgutter
{10} https://github.com/junegunn/goyo.vim/wiki/Customization
INSPIRATION *goyo-inspiration*
==============================================================================
- {LiteDFM}{11}
- {VimRoom}{12}
{11} https://github.com/bilalq/lite-dfm
{12} http://projects.mikewest.org/vimroom/
PROS. *goyo-pros*
==============================================================================
1. Works well with splits. Doesn't mess up with the current window arrangement
2. Works well with popular statusline plugins
3. Prevents accessing the empty windows around the central buffer
4. Can be closed with any of `:q[uit]`, `:clo[se]`, `:tabc[lose]`, or `:Goyo`
5. Can dynamically change the width of the window
6. Adjusts its colors when color scheme is changed
7. Realigns the window when the terminal (or window) is resized or when the size
of the font is changed
8. Correctly hides colorcolumns and Emojis in statusline
9. Highly customizable with callbacks
LICENSE *goyo-license*
==============================================================================
MIT
==============================================================================
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:

View file

@ -1,24 +0,0 @@
" Copyright (c) 2015 Junegunn Choi
"
" MIT License
"
" 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.
command! -nargs=? -bar -bang Goyo call goyo#execute(<bang>0, <q-args>)

View file

@ -1,117 +0,0 @@
# Change Log
## [Unreleased](https://github.com/morhetz/gruvbox/tree/HEAD)
[Full Changelog](https://github.com/morhetz/gruvbox/compare/v1.3.5...HEAD)
**Fixed bugs:**
- Lighter background on terminal [\#8](https://github.com/morhetz/gruvbox/issues/8)
**Closed issues:**
- Installation issue. [\#54](https://github.com/morhetz/gruvbox/issues/54)
- Italic font in terminal\(urxvt\) [\#49](https://github.com/morhetz/gruvbox/issues/49)
- Unable to log in when sourcing the palette shellscript [\#48](https://github.com/morhetz/gruvbox/issues/48)
- How can i modify multiple comment scheme [\#46](https://github.com/morhetz/gruvbox/issues/46)
- Remove comment highlight in iterm [\#44](https://github.com/morhetz/gruvbox/issues/44)
- Comments looking strange withing tmux [\#43](https://github.com/morhetz/gruvbox/issues/43)
- comments are reverse-video in xterm [\#41](https://github.com/morhetz/gruvbox/issues/41)
- What font are you using in the screenshots? [\#39](https://github.com/morhetz/gruvbox/issues/39)
- vim-signature crashes when I use gruvbox [\#38](https://github.com/morhetz/gruvbox/issues/38)
- Color of statusbar in inactive windows [\#37](https://github.com/morhetz/gruvbox/issues/37)
- Go method and struct highlighting missing [\#36](https://github.com/morhetz/gruvbox/issues/36)
- gruvbox\_256palette.sh doesn't work for Konsole [\#35](https://github.com/morhetz/gruvbox/issues/35)
- Contrast in jekyll markdown files [\#33](https://github.com/morhetz/gruvbox/issues/33)
- Pentadactyl Gruvbox Theme [\#32](https://github.com/morhetz/gruvbox/issues/32)
- make vertsplit better [\#31](https://github.com/morhetz/gruvbox/issues/31)
- Console support. [\#30](https://github.com/morhetz/gruvbox/issues/30)
- How can I change the background color? [\#29](https://github.com/morhetz/gruvbox/issues/29)
- Some words are not bold [\#28](https://github.com/morhetz/gruvbox/issues/28)
- Terminal theme on base gruvbox [\#25](https://github.com/morhetz/gruvbox/issues/25)
- Markdown has inverted colors when using \* [\#24](https://github.com/morhetz/gruvbox/issues/24)
- how install it on mac osx [\#23](https://github.com/morhetz/gruvbox/issues/23)
- Comments color for Terminal Vim [\#22](https://github.com/morhetz/gruvbox/issues/22)
- Move palette files to gruvbox-generalized [\#20](https://github.com/morhetz/gruvbox/issues/20)
- Maybe add Gruvbox Airline theme? [\#19](https://github.com/morhetz/gruvbox/issues/19)
- For Sublime text [\#18](https://github.com/morhetz/gruvbox/issues/18)
**Merged pull requests:**
- Fix the 256 palette script failed login issue [\#53](https://github.com/morhetz/gruvbox/pull/53) ([jonasmalacofilho](https://github.com/jonasmalacofilho))
- add minimal coloring for gitcommit highlighting [\#52](https://github.com/morhetz/gruvbox/pull/52) ([daniely](https://github.com/daniely))
- For terminals, turn off italics by default. [\#47](https://github.com/morhetz/gruvbox/pull/47) ([ryanmjacobs](https://github.com/ryanmjacobs))
- Change color of vertical/horizontal seperators between split windows [\#45](https://github.com/morhetz/gruvbox/pull/45) ([deshtop](https://github.com/deshtop))
- Improve gruvbox with C code [\#34](https://github.com/morhetz/gruvbox/pull/34) ([gladiac](https://github.com/gladiac))
- Fix for linux console [\#27](https://github.com/morhetz/gruvbox/pull/27) ([vyp](https://github.com/vyp))
- Colors for plugin vimshell.vim [\#21](https://github.com/morhetz/gruvbox/pull/21) ([joelmo](https://github.com/joelmo))
## [v1.3.5](https://github.com/morhetz/gruvbox/tree/v1.3.5) (2014-03-19)
[Full Changelog](https://github.com/morhetz/gruvbox/compare/v0.0.8...v1.3.5)
**Implemented enhancements:**
- Better selection colors [\#15](https://github.com/morhetz/gruvbox/issues/15)
- When hlsearch is on, the cursor inverts the search color and not visible [\#2](https://github.com/morhetz/gruvbox/issues/2)
**Fixed bugs:**
- Problem with changing between dark and light on 256 color terminal [\#7](https://github.com/morhetz/gruvbox/issues/7)
- IndentGuides coloring doesn't show up [\#1](https://github.com/morhetz/gruvbox/issues/1)
**Closed issues:**
- Requesting rxvt-unicode theme [\#17](https://github.com/morhetz/gruvbox/issues/17)
- gruvbox\_256palette.sh gets reset \(gnome-terminal on Ubuntu\) [\#13](https://github.com/morhetz/gruvbox/issues/13)
- Powerline colors [\#12](https://github.com/morhetz/gruvbox/issues/12)
- Info necessary for making a port of this colorscheme [\#10](https://github.com/morhetz/gruvbox/issues/10)
**Merged pull requests:**
- Fix GNU screen detection for \*-bce [\#16](https://github.com/morhetz/gruvbox/pull/16) ([blueyed](https://github.com/blueyed))
- Added iTerm2 dark theme [\#11](https://github.com/morhetz/gruvbox/pull/11) ([Greduan](https://github.com/Greduan))
- Fix typo in Readme [\#5](https://github.com/morhetz/gruvbox/pull/5) ([ViViDboarder](https://github.com/ViViDboarder))
## [v0.0.8](https://github.com/morhetz/gruvbox/tree/v0.0.8) (2012-12-08)
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

View file

@ -1,113 +0,0 @@
<p align="center"><img src="http://svgur.com/i/3Dp.svg"></p>
gruvbox is heavily inspired by [badwolf][], [jellybeans][] and [solarized][].
Designed as a bright theme with pastel 'retro groove' colors and light/dark mode switching in the way of [solarized][]. The main focus when developing gruvbox is to keep colors easily distinguishable, contrast enough and still pleasant for the eyes.
[badwolf]: https://github.com/sjl/badwolf
[jellybeans]: https://github.com/nanotech/jellybeans.vim
[solarized]: http://ethanschoonover.com/solarized
Attention
---------
1. [Read this first](https://github.com/morhetz/gruvbox/wiki/Terminal-specific)
2. Typeface from gallery is [Fantasque Sans Mono](https://github.com/belluzj/fantasque-sans)
3. Typeface from screenshots below is [Fira Mono](http://www.carrois.com/fira-4-1/)
Screenshots
-----------
Refer [Gallery][] for more syntax-specific screenshots.
[Gallery]: https://github.com/morhetz/gruvbox/wiki/Gallery
### Dark mode
![Screenshot Dark](http://i.imgur.com/GkIl8Fn.png)
### Light mode
![Screenshot Light](http://i.imgur.com/X75niEa.png)
### Airline theme
![Screenshot Airline](http://i.imgur.com/wRQceUR.png)
Palette
-------
### Dark mode
![Palette Dark](http://i.imgur.com/wa666xg.png)
### Light mode
![Palette Light](http://i.imgur.com/49qKyYW.png)
Contrast options
----------------
Refer [wiki section][] for contrast configuration and other options.
[wiki section]: https://github.com/morhetz/gruvbox/wiki/Configuration#ggruvbox_contrast_dark
![Contrast Options](http://i.imgur.com/5MSbe6T.png)
Documentation
-------------
Please check [wiki][] for installation details, terminal-specific setup, troubleshooting, configuration options and others.
[wiki]: https://github.com/morhetz/gruvbox/wiki
Features
--------
* Lots of style-customization options (contrast, color invertion, italics usage etc.)
* Extended filetype highlighting: Html, Xml, Vim, Clojure, C, Python, JavaScript, TypeScript, PureScript, CoffeeScript, Ruby, Objective-C, Go, Lua, MoonScript, Java, Markdown, Haskell, Elixir
* Supported plugins: [EasyMotion][], [vim-sneak][], [Indent Guides][], [indentLine][], [Rainbow Parentheses][], [Airline][], [Lightline][], [GitGutter][], [Signify][], [ShowMarks][], [Signature][], [Syntastic][], [Ale][], [CtrlP][], [Startify][], [NERDTree][], [Dirvish][]
[EasyMotion]: https://github.com/Lokaltog/vim-easymotion
[vim-sneak]: https://github.com/justinmk/vim-sneak
[Indent Guides]: https://github.com/nathanaelkane/vim-indent-guides
[indentLine]: https://github.com/Yggdroot/indentLine
[Rainbow Parentheses]: https://github.com/kien/rainbow_parentheses.vim
[Airline]: https://github.com/bling/vim-airline
[Lightline]: https://github.com/itchyny/lightline.vim
[GitGutter]: https://github.com/airblade/vim-gitgutter
[Signify]: https://github.com/mhinz/vim-signify
[ShowMarks]: http://www.vim.org/scripts/script.php?script_id=152
[Signature]: https://github.com/kshenoy/vim-signature
[Syntastic]: https://github.com/scrooloose/syntastic
[Ale]: https://github.com/w0rp/ale
[CtrlP]: https://github.com/kien/ctrlp.vim
[Startify]: https://github.com/mhinz/vim-startify
[NERDTree]: https://github.com/scrooloose/nerdtree
[Dirvish]: https://github.com/justinmk/vim-dirvish
Contributions
-------------
See [gruvbox-contrib][] repo for contributions, ports and extras.
[gruvbox-contrib]: https://github.com/morhetz/gruvbox-contrib
ToDo
----
* Filetype syntax highlighting (R, TeX, Swift, Erlang)
* Plugin support (Tagbar, VimPlug)
Self-Promotion
--------------
If you like gruvbox follow the repository on
[GitHub](https://github.com/morhetz/gruvbox) and vote for it on
[vim.org](http://www.vim.org/scripts/script.php?script_id=4349).
License
-------
[MIT/X11][]
[MIT/X11]: https://en.wikipedia.org/wiki/MIT_License

View file

@ -1,79 +0,0 @@
" -----------------------------------------------------------------------------
" File: gruvbox.vim
" Description: Retro groove color scheme for Airline
" Author: morhetz <morhetz@gmail.com>
" Source: https://github.com/morhetz/gruvbox
" Last Modified: 12 Aug 2017
" -----------------------------------------------------------------------------
let g:airline#themes#gruvbox#palette = {}
function! airline#themes#gruvbox#refresh()
let M0 = airline#themes#get_highlight('Identifier')
let accents_group = airline#themes#get_highlight('Special')
let modified_group = [M0[0], '', M0[2], '', '']
let warning_group = airline#themes#get_highlight2(['Normal', 'bg'], ['Question', 'fg'])
let error_group = airline#themes#get_highlight2(['Normal', 'bg'], ['WarningMsg', 'fg'])
let s:N1 = airline#themes#get_highlight2(['Normal', 'bg'], ['StatusLineNC', 'bg'])
let s:N2 = airline#themes#get_highlight2(['StatusLineNC', 'bg'], ['Pmenu', 'bg'])
let s:N3 = airline#themes#get_highlight2(['StatusLineNC', 'bg'], ['CursorLine', 'bg'])
let g:airline#themes#gruvbox#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
let g:airline#themes#gruvbox#palette.normal_modified = { 'airline_c': modified_group }
let g:airline#themes#gruvbox#palette.normal.airline_warning = warning_group
let g:airline#themes#gruvbox#palette.normal_modified.airline_warning = warning_group
let g:airline#themes#gruvbox#palette.normal.airline_error = error_group
let g:airline#themes#gruvbox#palette.normal_modified.airline_error = error_group
let s:I1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Identifier', 'fg'])
let s:I2 = s:N2
let s:I3 = airline#themes#get_highlight2(['Normal', 'fg'], ['Pmenu', 'bg'])
let g:airline#themes#gruvbox#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3)
let g:airline#themes#gruvbox#palette.insert_modified = g:airline#themes#gruvbox#palette.normal_modified
let g:airline#themes#gruvbox#palette.insert.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning
let g:airline#themes#gruvbox#palette.insert_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning
let g:airline#themes#gruvbox#palette.insert.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error
let g:airline#themes#gruvbox#palette.insert_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error
let s:R1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Structure', 'fg'])
let s:R2 = s:I2
let s:R3 = s:I3
let g:airline#themes#gruvbox#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3)
let g:airline#themes#gruvbox#palette.replace_modified = g:airline#themes#gruvbox#palette.normal_modified
let g:airline#themes#gruvbox#palette.replace.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning
let g:airline#themes#gruvbox#palette.replace_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning
let g:airline#themes#gruvbox#palette.replace.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error
let g:airline#themes#gruvbox#palette.replace_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error
let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Question', 'fg'])
let s:V2 = s:N2
let s:V3 = airline#themes#get_highlight2(['Normal', 'bg'], ['TabLine', 'fg'])
let g:airline#themes#gruvbox#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3)
let g:airline#themes#gruvbox#palette.visual_modified = { 'airline_c': [ s:V3[0], '', s:V3[2], '', '' ] }
let g:airline#themes#gruvbox#palette.visual.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning
let g:airline#themes#gruvbox#palette.visual_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning
let g:airline#themes#gruvbox#palette.visual.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error
let g:airline#themes#gruvbox#palette.visual_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error
let s:IA = airline#themes#get_highlight2(['TabLine', 'fg'], ['CursorLine', 'bg'])
let g:airline#themes#gruvbox#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA)
let g:airline#themes#gruvbox#palette.inactive_modified = { 'airline_c': modified_group }
let g:airline#themes#gruvbox#palette.accents = { 'red': accents_group }
let s:TF = airline#themes#get_highlight2(['Normal', 'bg'], ['Normal', 'bg'])
let g:airline#themes#gruvbox#palette.tabline = {
\ 'airline_tab': s:N2,
\ 'airline_tabsel': s:N1,
\ 'airline_tabtype': s:V1,
\ 'airline_tabfill': s:TF,
\ 'airline_tabhid': s:IA,
\ 'airline_tabmod': s:I1
\ }
endfunction
call airline#themes#gruvbox#refresh()
" vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker:

View file

@ -1,41 +0,0 @@
" -----------------------------------------------------------------------------
" File: gruvbox.vim
" Description: Retro groove color scheme for Vim
" Author: morhetz <morhetz@gmail.com>
" Source: https://github.com/morhetz/gruvbox
" Last Modified: 09 Apr 2014
" -----------------------------------------------------------------------------
function! gruvbox#invert_signs_toggle()
if g:gruvbox_invert_signs == 0
let g:gruvbox_invert_signs=1
else
let g:gruvbox_invert_signs=0
endif
colorscheme gruvbox
endfunction
" Search Highlighting {{{
function! gruvbox#hls_show()
set hlsearch
call GruvboxHlsShowCursor()
endfunction
function! gruvbox#hls_hide()
set nohlsearch
call GruvboxHlsHideCursor()
endfunction
function! gruvbox#hls_toggle()
if &hlsearch
call gruvbox#hls_hide()
else
call gruvbox#hls_show()
endif
endfunction
" }}}
" vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker:

View file

@ -1,57 +0,0 @@
" -----------------------------------------------------------------------------
" File: gruvbox.vim
" Description: Gruvbox colorscheme for Lightline (itchyny/lightline.vim)
" Author: gmoe <me@griffinmoe.com>
" Source: https://github.com/morhetz/gruvbox
" Last Modified: 20 Sep 2017
" -----------------------------------------------------------------------------
function! s:getGruvColor(group)
let guiColor = synIDattr(hlID(a:group), "fg", "gui")
let termColor = synIDattr(hlID(a:group), "fg", "cterm")
return [ guiColor, termColor ]
endfunction
if exists('g:lightline')
let s:bg0 = s:getGruvColor('GruvboxBg0')
let s:bg1 = s:getGruvColor('GruvboxBg1')
let s:bg2 = s:getGruvColor('GruvboxBg2')
let s:bg4 = s:getGruvColor('GruvboxBg4')
let s:fg1 = s:getGruvColor('GruvboxFg1')
let s:fg4 = s:getGruvColor('GruvboxFg4')
let s:yellow = s:getGruvColor('GruvboxYellow')
let s:blue = s:getGruvColor('GruvboxBlue')
let s:aqua = s:getGruvColor('GruvboxAqua')
let s:orange = s:getGruvColor('GruvboxOrange')
let s:green = s:getGruvColor('GruvboxGreen')
let s:p = {'normal':{}, 'inactive':{}, 'insert':{}, 'replace':{}, 'visual':{}, 'tabline':{}, 'terminal':{}}
let s:p.normal.left = [ [ s:bg0, s:fg4, 'bold' ], [ s:fg4, s:bg2 ] ]
let s:p.normal.right = [ [ s:bg0, s:fg4 ], [ s:fg4, s:bg2 ] ]
let s:p.normal.middle = [ [ s:fg4, s:bg1 ] ]
let s:p.inactive.right = [ [ s:bg4, s:bg1 ], [ s:bg4, s:bg1 ] ]
let s:p.inactive.left = [ [ s:bg4, s:bg1 ], [ s:bg4, s:bg1 ] ]
let s:p.inactive.middle = [ [ s:bg4, s:bg1 ] ]
let s:p.insert.left = [ [ s:bg0, s:blue, 'bold' ], [ s:fg1, s:bg2 ] ]
let s:p.insert.right = [ [ s:bg0, s:blue ], [ s:fg1, s:bg2 ] ]
let s:p.insert.middle = [ [ s:fg4, s:bg2 ] ]
let s:p.terminal.left = [ [ s:bg0, s:green, 'bold' ], [ s:fg1, s:bg2 ] ]
let s:p.terminal.right = [ [ s:bg0, s:green ], [ s:fg1, s:bg2 ] ]
let s:p.terminal.middle = [ [ s:fg4, s:bg2 ] ]
let s:p.replace.left = [ [ s:bg0, s:aqua, 'bold' ], [ s:fg1, s:bg2 ] ]
let s:p.replace.right = [ [ s:bg0, s:aqua ], [ s:fg1, s:bg2 ] ]
let s:p.replace.middle = [ [ s:fg4, s:bg2 ] ]
let s:p.visual.left = [ [ s:bg0, s:orange, 'bold' ], [ s:bg0, s:bg4 ] ]
let s:p.visual.right = [ [ s:bg0, s:orange ], [ s:bg0, s:bg4 ] ]
let s:p.visual.middle = [ [ s:fg4, s:bg1 ] ]
let s:p.tabline.left = [ [ s:fg4, s:bg2 ] ]
let s:p.tabline.tabsel = [ [ s:bg0, s:fg4 ] ]
let s:p.tabline.middle = [ [ s:bg0, s:bg0 ] ]
let s:p.tabline.right = [ [ s:bg0, s:orange ] ]
let s:p.normal.error = [ [ s:bg0, s:orange ] ]
let s:p.normal.warning = [ [ s:bg2, s:yellow ] ]
let g:lightline#colorscheme#gruvbox#palette = lightline#colorscheme#flatten(s:p)
endif

File diff suppressed because it is too large Load diff

View file

@ -1,118 +0,0 @@
#!/bin/sh
if [ "${TERM%%-*}" = "screen" ]; then
if [ -n "$TMUX" ]; then
printf "\033Ptmux;\033\033]4;236;rgb:32/30/2f\007\033\\"
printf "\033Ptmux;\033\033]4;234;rgb:1d/20/21\007\033\\"
printf "\033Ptmux;\033\033]4;235;rgb:28/28/28\007\033\\"
printf "\033Ptmux;\033\033]4;237;rgb:3c/38/36\007\033\\"
printf "\033Ptmux;\033\033]4;239;rgb:50/49/45\007\033\\"
printf "\033Ptmux;\033\033]4;241;rgb:66/5c/54\007\033\\"
printf "\033Ptmux;\033\033]4;243;rgb:7c/6f/64\007\033\\"
printf "\033Ptmux;\033\033]4;244;rgb:92/83/74\007\033\\"
printf "\033Ptmux;\033\033]4;245;rgb:92/83/74\007\033\\"
printf "\033Ptmux;\033\033]4;228;rgb:f2/e5/bc\007\033\\"
printf "\033Ptmux;\033\033]4;230;rgb:f9/f5/d7\007\033\\"
printf "\033Ptmux;\033\033]4;229;rgb:fb/f1/c7\007\033\\"
printf "\033Ptmux;\033\033]4;223;rgb:eb/db/b2\007\033\\"
printf "\033Ptmux;\033\033]4;250;rgb:d5/c4/a1\007\033\\"
printf "\033Ptmux;\033\033]4;248;rgb:bd/ae/93\007\033\\"
printf "\033Ptmux;\033\033]4;246;rgb:a8/99/84\007\033\\"
printf "\033Ptmux;\033\033]4;167;rgb:fb/49/34\007\033\\"
printf "\033Ptmux;\033\033]4;142;rgb:b8/bb/26\007\033\\"
printf "\033Ptmux;\033\033]4;214;rgb:fa/bd/2f\007\033\\"
printf "\033Ptmux;\033\033]4;109;rgb:83/a5/98\007\033\\"
printf "\033Ptmux;\033\033]4;175;rgb:d3/86/9b\007\033\\"
printf "\033Ptmux;\033\033]4;108;rgb:8e/c0/7c\007\033\\"
printf "\033Ptmux;\033\033]4;208;rgb:fe/80/19\007\033\\"
printf "\033Ptmux;\033\033]4;88;rgb:9d/00/06\007\033\\"
printf "\033Ptmux;\033\033]4;100;rgb:79/74/0e\007\033\\"
printf "\033Ptmux;\033\033]4;136;rgb:b5/76/14\007\033\\"
printf "\033Ptmux;\033\033]4;24;rgb:07/66/78\007\033\\"
printf "\033Ptmux;\033\033]4;96;rgb:8f/3f/71\007\033\\"
printf "\033Ptmux;\033\033]4;66;rgb:42/7b/58\007\033\\"
printf "\033Ptmux;\033\033]4;130;rgb:af/3a/03\007\033\\"
else
printf "\033P\033]4;236;rgb:32/30/2f\007\033\\"
printf "\033P\033]4;234;rgb:1d/20/21\007\033\\"
printf "\033P\033]4;235;rgb:28/28/28\007\033\\"
printf "\033P\033]4;237;rgb:3c/38/36\007\033\\"
printf "\033P\033]4;239;rgb:50/49/45\007\033\\"
printf "\033P\033]4;241;rgb:66/5c/54\007\033\\"
printf "\033P\033]4;243;rgb:7c/6f/64\007\033\\"
printf "\033P\033]4;244;rgb:92/83/74\007\033\\"
printf "\033P\033]4;245;rgb:92/83/74\007\033\\"
printf "\033P\033]4;228;rgb:f2/e5/bc\007\033\\"
printf "\033P\033]4;230;rgb:f9/f5/d7\007\033\\"
printf "\033P\033]4;229;rgb:fb/f1/c7\007\033\\"
printf "\033P\033]4;223;rgb:eb/db/b2\007\033\\"
printf "\033P\033]4;250;rgb:d5/c4/a1\007\033\\"
printf "\033P\033]4;248;rgb:bd/ae/93\007\033\\"
printf "\033P\033]4;246;rgb:a8/99/84\007\033\\"
printf "\033P\033]4;167;rgb:fb/49/34\007\033\\"
printf "\033P\033]4;142;rgb:b8/bb/26\007\033\\"
printf "\033P\033]4;214;rgb:fa/bd/2f\007\033\\"
printf "\033P\033]4;109;rgb:83/a5/98\007\033\\"
printf "\033P\033]4;175;rgb:d3/86/9b\007\033\\"
printf "\033P\033]4;108;rgb:8e/c0/7c\007\033\\"
printf "\033P\033]4;208;rgb:fe/80/19\007\033\\"
printf "\033P\033]4;88;rgb:9d/00/06\007\033\\"
printf "\033P\033]4;100;rgb:79/74/0e\007\033\\"
printf "\033P\033]4;136;rgb:b5/76/14\007\033\\"
printf "\033P\033]4;24;rgb:07/66/78\007\033\\"
printf "\033P\033]4;96;rgb:8f/3f/71\007\033\\"
printf "\033P\033]4;66;rgb:42/7b/58\007\033\\"
printf "\033P\033]4;130;rgb:af/3a/03\007\033\\"
fi
elif [ "$TERM" != "linux" ] && [ "$TERM" != "vt100" ] && [ "$TERM" != "vt220" ]; then
printf "\033]4;236;rgb:32/30/2f\033\\"
printf "\033]4;234;rgb:1d/20/21\033\\"
printf "\033]4;235;rgb:28/28/28\033\\"
printf "\033]4;237;rgb:3c/38/36\033\\"
printf "\033]4;239;rgb:50/49/45\033\\"
printf "\033]4;241;rgb:66/5c/54\033\\"
printf "\033]4;243;rgb:7c/6f/64\033\\"
printf "\033]4;244;rgb:92/83/74\033\\"
printf "\033]4;245;rgb:92/83/74\033\\"
printf "\033]4;228;rgb:f2/e5/bc\033\\"
printf "\033]4;230;rgb:f9/f5/d7\033\\"
printf "\033]4;229;rgb:fb/f1/c7\033\\"
printf "\033]4;223;rgb:eb/db/b2\033\\"
printf "\033]4;250;rgb:d5/c4/a1\033\\"
printf "\033]4;248;rgb:bd/ae/93\033\\"
printf "\033]4;246;rgb:a8/99/84\033\\"
printf "\033]4;167;rgb:fb/49/34\033\\"
printf "\033]4;142;rgb:b8/bb/26\033\\"
printf "\033]4;214;rgb:fa/bd/2f\033\\"
printf "\033]4;109;rgb:83/a5/98\033\\"
printf "\033]4;175;rgb:d3/86/9b\033\\"
printf "\033]4;108;rgb:8e/c0/7c\033\\"
printf "\033]4;208;rgb:fe/80/19\033\\"
printf "\033]4;88;rgb:9d/00/06\033\\"
printf "\033]4;100;rgb:79/74/0e\033\\"
printf "\033]4;136;rgb:b5/76/14\033\\"
printf "\033]4;24;rgb:07/66/78\033\\"
printf "\033]4;96;rgb:8f/3f/71\033\\"
printf "\033]4;66;rgb:42/7b/58\033\\"
printf "\033]4;130;rgb:af/3a/03\033\\"
fi

View file

@ -1,116 +0,0 @@
#!/bin/sh
if [ "${TERM%%-*}" = "screen" ]; then
if [ -n "$TMUX" ]; then
printf "\033Ptmux;\033\033]4;236;rgb:26/24/23\007\033\\"
printf "\033Ptmux;\033\033]4;234;rgb:16/18/19\007\033\\"
printf "\033Ptmux;\033\033]4;235;rgb:1e/1e/1e\007\033\\"
printf "\033Ptmux;\033\033]4;237;rgb:2e/2a/29\007\033\\"
printf "\033Ptmux;\033\033]4;239;rgb:3f/39/35\007\033\\"
printf "\033Ptmux;\033\033]4;241;rgb:53/4a/42\007\033\\"
printf "\033Ptmux;\033\033]4;243;rgb:68/5c/51\007\033\\"
printf "\033Ptmux;\033\033]4;244;rgb:7f/70/61\007\033\\"
printf "\033Ptmux;\033\033]4;245;rgb:7f/70/61\007\033\\"
printf "\033Ptmux;\033\033]4;228;rgb:ef/df/ae\007\033\\"
printf "\033Ptmux;\033\033]4;230;rgb:f8/f4/cd\007\033\\"
printf "\033Ptmux;\033\033]4;229;rgb:fa/ee/bb\007\033\\"
printf "\033Ptmux;\033\033]4;223;rgb:e6/d4/a3\007\033\\"
printf "\033Ptmux;\033\033]4;250;rgb:cb/b8/90\007\033\\"
printf "\033Ptmux;\033\033]4;248;rgb:af/9f/81\007\033\\"
printf "\033Ptmux;\033\033]4;246;rgb:97/87/71\007\033\\"
printf "\033Ptmux;\033\033]4;167;rgb:f7/30/28\007\033\\"
printf "\033Ptmux;\033\033]4;142;rgb:aa/b0/1e\007\033\\"
printf "\033Ptmux;\033\033]4;214;rgb:f7/b1/25\007\033\\"
printf "\033Ptmux;\033\033]4;109;rgb:71/95/86\007\033\\"
printf "\033Ptmux;\033\033]4;175;rgb:c7/70/89\007\033\\"
printf "\033Ptmux;\033\033]4;108;rgb:7d/b6/69\007\033\\"
printf "\033Ptmux;\033\033]4;208;rgb:fb/6a/16\007\033\\"
printf "\033Ptmux;\033\033]4;88;rgb:89/00/09\007\033\\"
printf "\033Ptmux;\033\033]4;100;rgb:66/62/0d\007\033\\"
printf "\033Ptmux;\033\033]4;136;rgb:a5/63/11\007\033\\"
printf "\033Ptmux;\033\033]4;24;rgb:0e/53/65\007\033\\"
printf "\033Ptmux;\033\033]4;96;rgb:7b/2b/5e\007\033\\"
printf "\033Ptmux;\033\033]4;66;rgb:35/6a/46\007\033\\"
printf "\033Ptmux;\033\033]4;130;rgb:9d/28/07\007\033\\"
else
printf "\033P\033]4;236;rgb:26/24/23\007\033\\"
printf "\033P\033]4;234;rgb:16/18/19\007\033\\"
printf "\033P\033]4;235;rgb:1e/1e/1e\007\033\\"
printf "\033P\033]4;237;rgb:2e/2a/29\007\033\\"
printf "\033P\033]4;239;rgb:3f/39/35\007\033\\"
printf "\033P\033]4;241;rgb:53/4a/42\007\033\\"
printf "\033P\033]4;243;rgb:68/5c/51\007\033\\"
printf "\033P\033]4;244;rgb:7f/70/61\007\033\\"
printf "\033P\033]4;245;rgb:7f/70/61\007\033\\"
printf "\033P\033]4;228;rgb:ef/df/ae\007\033\\"
printf "\033P\033]4;230;rgb:f8/f4/cd\007\033\\"
printf "\033P\033]4;229;rgb:fa/ee/bb\007\033\\"
printf "\033P\033]4;223;rgb:e6/d4/a3\007\033\\"
printf "\033P\033]4;250;rgb:cb/b8/90\007\033\\"
printf "\033P\033]4;248;rgb:af/9f/81\007\033\\"
printf "\033P\033]4;246;rgb:97/87/71\007\033\\"
printf "\033P\033]4;167;rgb:f7/30/28\007\033\\"
printf "\033P\033]4;142;rgb:aa/b0/1e\007\033\\"
printf "\033P\033]4;214;rgb:f7/b1/25\007\033\\"
printf "\033P\033]4;109;rgb:71/95/86\007\033\\"
printf "\033P\033]4;175;rgb:c7/70/89\007\033\\"
printf "\033P\033]4;108;rgb:7d/b6/69\007\033\\"
printf "\033P\033]4;208;rgb:fb/6a/16\007\033\\"
printf "\033P\033]4;88;rgb:89/00/09\007\033\\"
printf "\033P\033]4;100;rgb:66/62/0d\007\033\\"
printf "\033P\033]4;136;rgb:a5/63/11\007\033\\"
printf "\033P\033]4;24;rgb:0e/53/65\007\033\\"
printf "\033P\033]4;96;rgb:7b/2b/5e\007\033\\"
printf "\033P\033]4;66;rgb:35/6a/46\007\033\\"
printf "\033P\033]4;130;rgb:9d/28/07\007\033\\"
fi
else
printf "\033]4;236;rgb:26/24/23\033\\"
printf "\033]4;234;rgb:16/18/19\033\\"
printf "\033]4;235;rgb:1e/1e/1e\033\\"
printf "\033]4;237;rgb:2e/2a/29\033\\"
printf "\033]4;239;rgb:3f/39/35\033\\"
printf "\033]4;241;rgb:53/4a/42\033\\"
printf "\033]4;243;rgb:68/5c/51\033\\"
printf "\033]4;244;rgb:7f/70/61\033\\"
printf "\033]4;245;rgb:7f/70/61\033\\"
printf "\033]4;228;rgb:ef/df/ae\033\\"
printf "\033]4;230;rgb:f8/f4/cd\033\\"
printf "\033]4;229;rgb:fa/ee/bb\033\\"
printf "\033]4;223;rgb:e6/d4/a3\033\\"
printf "\033]4;250;rgb:cb/b8/90\033\\"
printf "\033]4;248;rgb:af/9f/81\033\\"
printf "\033]4;246;rgb:97/87/71\033\\"
printf "\033]4;167;rgb:f7/30/28\033\\"
printf "\033]4;142;rgb:aa/b0/1e\033\\"
printf "\033]4;214;rgb:f7/b1/25\033\\"
printf "\033]4;109;rgb:71/95/86\033\\"
printf "\033]4;175;rgb:c7/70/89\033\\"
printf "\033]4;108;rgb:7d/b6/69\033\\"
printf "\033]4;208;rgb:fb/6a/16\033\\"
printf "\033]4;88;rgb:89/00/09\033\\"
printf "\033]4;100;rgb:66/62/0d\033\\"
printf "\033]4;136;rgb:a5/63/11\033\\"
printf "\033]4;24;rgb:0e/53/65\033\\"
printf "\033]4;96;rgb:7b/2b/5e\033\\"
printf "\033]4;66;rgb:35/6a/46\033\\"
printf "\033]4;130;rgb:9d/28/07\033\\"
fi

View file

@ -1,10 +0,0 @@
{
"name": "gruvbox",
"version": "2.0.0",
"repository": "git@github.com:morhetz/gruvbox.git",
"author": "Pavel Pertsev <morhetz@gmail.com>",
"license": "MIT",
"vim": {
"opt": true
}
}

View file

@ -1,43 +0,0 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3065
This is a pleasant and ergonomic light-background color scheme, designed for long hours of coding and working. The UI elements are muted without being drab, the syntax elements are colorful without being garish, and the background is relaxing without being soporific. It is of a low-enough contrast so as not to cause eye-burn, but high-enough contrast so as not to cause eye-strain. The syntax coloration offers just a little higher resolution than most, distinguishing between class names vs. functions, strings and numbers vs. other constants, etc. Many of the colors in this color scheme are drawn from Mayan murals, paintings and codices, and thus the name.
Screenshots:
==========
- Python: http://jeetworks.org/files/images/mayansmoke-python1.png
- C++: http://jeetworks.org/files/images/mayansmoke-cpp1.png
Customization:
==============
If any of the following highlights are defined (e.g., in your "~/.vimrc"), these will override the default highlight definitions:
MayanSmokeCursorLine (will be applied to: CursorColumn and CursorLine)
MayanSmokeSearch (will be applied to: Search and IncSearch)
MayanSmokeSpecialKey (will be applied to: SpecialKey)
For example, you can set the following in your "~/.vimrc" to select your own colors for these items:
hi MayanSmokeCursorLine guifg=NONE guibg=yellow gui=NONE
hi MayanSmokeSearch guifg=white guibg=blue gui=NONE
hi MayanSmokeSpecialKey guifg=NONE guibg=green gui=NONE
Alternatively, you can define one or more of the following values in your "~/.vimrc" to select different pre-defined levels of visibility for the above highlights:
let g:mayansmoke_cursor_line_visibility = 0 " lower visibility
let g:mayansmoke_cursor_line_visibility = 1 " medium visibility
let g:mayansmoke_cursor_line_visibility = 2 " higher visibility
let g:mayansmoke_search_visibility = 0 " low visibility
let g:mayansmoke_search_visibility = 1 " medium visibility (default)
let g:mayansmoke_search_visibility = 2 " high visibility
let g:mayansmoke_search_visibility = 3 " very high visibility
let g:mayansmoke_search_visibility = 4 " highest visibility
let g:mayansmoke_special_key_visibility = 0 " lower visibility
let g:mayansmoke_special_key_visibility = 1 " medium visibility
let g:mayansmoke_special_key_visibility = 2 " higher visibility

View file

@ -1,343 +0,0 @@
" =============================================================================
"
" File: mayansmoke.vim
" Description: Vim color scheme file
" Maintainer: Jeet Sukumaran (GUI colors); Clayton Parker (cterm colors)
"
" =============================================================================
" Initialization and Setup {{{1
" =============================================================================
set background=light
highlight clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "mayansmoke"
" }}}
" Normal Color {{{1
" =============================================================================
hi Normal gui=NONE guifg=Black guibg=#F4F4E8
" }}}
" Highlight Groups {{{1
" =============================================================================
" Groups (see ':help highlight-groups'):
" ColorColumn highlight to use with ':set colorcolumn'
" Cursor the character under the cursor
" CursorIM like Cursor, but used when in IME mode |CursorIM|
" CursorColumn the screen column that the cursor is in when 'cursorcolumn' is set
" CursorLine the screen line that the cursor is in when 'cursorline' is set
" Directory directory names (and other special names in listings)
" DiffAdd diff mode: Added line |diff.txt|
" DiffChange diff mode: Changed line |diff.txt|
" DiffDelete diff mode: Deleted line |diff.txt|
" DiffText diff mode: Changed text within a changed line |diff.txt|
" ErrorMsg error messages on the command line
" VertSplit the column separating vertically split windows
" Folded line used for closed folds
" FoldColumn 'foldcolumn'
" SignColumn column where |signs| are displayed
" IncSearch 'incsearch' highlighting; also used for the text replaced with ":s///c"
" LineNr Line number for ":number" and ":#" commands, and when 'number' option is set.
" MatchParen The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt|
" ModeMsg 'showmode' message (e.g., "-- INSERT --")
" MoreMsg |more-prompt|
" NonText '~' and '@' at the end of the window, etc.
" Normal normal text
" Pmenu Popup menu: normal item.
" PmenuSel Popup menu: selected item.
" PmenuSbar Popup menu: scrollbar.
" PmenuThumb Popup menu: Thumb of the scrollbar.
" Question |hit-enter| prompt and yes/no questions
" Search Last search pattern highlighting (see 'hlsearch').
" SpecialKey Meta and special keys listed with ":map", text that is displayed differently from what it really is (such as tabs, spaces in listchars etc.).
" SpellBad Word that is not recognized by the spellchecker. |spell|
" SpellCap Word that should start with a capital. |spell|
" SpellLocal Word that is recognized by the spellchecker as one that is
" SpellRare Word that is recognized by the spellchecker as one that is hardly ever used. |spell|
" StatusLine status line of current window
" StatusLineNC status lines of not-current windows
" TabLine tab pages line, not active tab page label
" TabLineFill tab pages line, where there are no labels
" TabLineSel tab pages line, active tab page label
" Title titles for output from ":set all", ":autocmd" etc.
" Visual Visual mode selection
" VisualNOS Visual mode selection when vim is "Not Owning the Selection".
" WarningMsg warning messages
" WildMenu current match in 'wildmenu' completion
hi ColorColumn guifg=NONE guibg=#EEEEDD
hi Cursor guifg=bg guibg=fg gui=NONE
if hlexists('MayanSmokeCursorLine')
hi link CursorColumn MayanSmokeCursorLine
hi link CursorLine MayanSmokeCursorLine
elseif exists('g:mayansmoke_cursor_line_visibility') && g:mayansmoke_cursor_line_visibility >= 2
hi CursorColumn guifg=NONE guibg=NavajoWhite gui=NONE
hi CursorLine guifg=NONE guibg=NavajoWhite gui=NONE
elseif exists('g:mayansmoke_cursor_line_visibility') && g:mayansmoke_cursor_line_visibility >= 1
hi CursorColumn guifg=NONE guibg=white gui=NONE
hi CursorLine guifg=NONE guibg=white gui=NONE
else
hi CursorColumn guifg=NONE guibg=#FFFDD0 gui=NONE
hi CursorLine guifg=NONE guibg=#FFFDD0 gui=NONE
endif
hi CursorIM guifg=bg guibg=fg gui=NONE
hi lCursor guifg=bg guibg=fg gui=NONE
hi DiffAdd guifg=NONE guibg=SeaGreen1 gui=NONE
hi DiffChange guifg=NONE guibg=LightSkyBlue1 gui=NONE
hi DiffDelete guifg=NONE guibg=LightCoral gui=NONE
hi DiffText guifg=black guibg=LightCyan1 gui=NONE
hi Directory guifg=#1600FF guibg=bg gui=NONE
hi ErrorMsg guifg=Red2 guibg=NONE gui=NONE
hi FoldColumn guifg=SteelBlue4 guibg=LightYellow2 gui=bold
hi Folded guifg=SteelBlue4 guibg=Gainsboro gui=italic
if hlexists('MayanSmokeSearch')
hi link IncSearch MayanSmokeSearch
hi link Search MayanSmokeSearch
elseif exists('g:mayansmoke_search_visibility') && g:mayansmoke_search_visibility >= 4
hi IncSearch guifg=white guibg=red gui=NONE
hi Search guifg=white guibg=red gui=NONE
elseif exists('g:mayansmoke_search_visibility') && g:mayansmoke_search_visibility == 3
hi IncSearch guifg=black guibg=gold gui=NONE
hi Search guifg=black guibg=gold gui=NONE
elseif exists('g:mayansmoke_search_visibility') && g:mayansmoke_search_visibility == 2
hi IncSearch guifg=white guibg=darkorange gui=NONE
hi Search guifg=white guibg=darkorange gui=NONE
elseif exists('g:mayansmoke_search_visibility') && g:mayansmoke_search_visibility == 0
hi IncSearch guifg=black guibg=tan gui=NONE
hi Search guifg=black guibg=tan gui=NONE
else
hi IncSearch guifg=black guibg=khaki gui=NONE
hi Search guifg=black guibg=khaki gui=NONE
endif
hi LineNr guifg=#666677 guibg=#cccfbf gui=NONE
hi MatchParen guifg=black guibg=LemonChiffon3 gui=bold
hi ModeMsg guifg=White guibg=tomato1 gui=bold
hi MoreMsg guifg=SeaGreen4 guibg=bg gui=bold
hi NonText guifg=LightCyan3 guibg=bg gui=bold
hi Pmenu guifg=Orange4 guibg=LightYellow3 gui=NONE
hi PmenuSel guifg=ivory2 guibg=NavajoWhite4 gui=bold
hi PmenuSbar guifg=White guibg=#999666 gui=NONE
hi PmenuThumb guifg=White guibg=#7B7939 gui=NONE
hi Question guifg=Chartreuse4 guibg=bg gui=bold
hi SignColumn guifg=white guibg=LightYellow3 gui=NONE
if hlexists('MayanSmokeSpecialKey')
hi link SpecialKey MayanSmokeSpecialKey
elseif exists('g:mayansmoke_special_key_visibility') && g:mayansmoke_special_key_visibility >= 2
hi SpecialKey guifg=black guibg=NavajoWhite gui=NONE
elseif exists('g:mayansmoke_special_key_visibility') && g:mayansmoke_special_key_visibility == 0
hi SpecialKey guifg=bisque3 guibg=NONE gui=NONE
else
hi SpecialKey guifg=white guibg=ivory3 gui=NONE
endif
hi SpellBad guisp=Firebrick2 gui=undercurl
hi SpellCap guisp=Blue gui=undercurl
hi SpellLocal guisp=DarkCyan gui=undercurl
hi SpellRare guisp=Magenta gui=undercurl
hi StatusLine guifg=#FFFEEE guibg=#557788 gui=NONE
" hi StatusLineNC guifg=#EAE6E2 guibg=LightSteelBlue3 gui=italic
hi StatusLineNC guifg=#F4F4EE guibg=#99aabb gui=italic
hi TabLine guifg=fg guibg=LightGrey gui=underline
hi TabLineFill guifg=fg guibg=bg gui=reverse
hi TabLineSel guifg=fg guibg=bg gui=bold
hi Title guifg=DeepSkyBlue3 guibg=bg gui=bold
hi VertSplit guifg=#99aabb guibg=#99aabb
hi Visual guifg=white guibg=DeepSkyBlue1 gui=NONE
hi WarningMsg guifg=Firebrick2 guibg=bg gui=NONE
hi WildMenu guifg=Black guibg=SkyBlue gui=NONE
" }}}
" 256-Color Terminal Colors, by Clayton Parker {{{1
" =============================================================================
hi Normal cterm=NONE ctermfg=16 ctermbg=255
hi Comment ctermfg=110
hi Constant ctermfg=214
hi String ctermfg=30
hi Boolean ctermfg=88
hi Identifier ctermfg=160
hi Function ctermfg=132
hi Statement ctermfg=21
hi Keyword ctermfg=45
hi PreProc ctermfg=27
hi Type ctermfg=147
hi Special ctermfg=64
hi Ignore ctermfg=255
hi Error ctermfg=196 ctermbg=255 term=none
hi Todo ctermfg=136 ctermbg=255 cterm=NONE
hi VimError ctermfg=160 ctermbg=16
hi VimCommentTitle ctermfg=110
hi qfLineNr ctermfg=16 ctermbg=46 cterm=NONE
hi pythonDecorator ctermfg=208 ctermbg=255 cterm=NONE
hi Cursor ctermfg=255 ctermbg=16 cterm=NONE
hi CursorColumn ctermfg=NONE ctermbg=255 cterm=NONE
hi CursorIM ctermfg=255 ctermbg=16 cterm=NONE
hi CursorLine ctermfg=NONE ctermbg=254 cterm=NONE
hi lCursor ctermfg=255 ctermbg=16 cterm=NONE
hi DiffAdd ctermfg=16 ctermbg=48 cterm=NONE
hi DiffChange ctermfg=16 ctermbg=153 cterm=NONE
hi DiffDelete ctermfg=16 ctermbg=203 cterm=NONE
hi DiffText ctermfg=16 ctermbg=226 cterm=NONE
hi Directory ctermfg=21 ctermbg=255 cterm=NONE
hi ErrorMsg ctermfg=160 ctermbg=NONE cterm=NONE
hi FoldColumn ctermfg=24 ctermbg=252 cterm=NONE
hi Folded ctermfg=24 ctermbg=252 cterm=NONE
hi IncSearch ctermfg=255 ctermbg=160 cterm=NONE
hi LineNr ctermfg=253 ctermbg=110 cterm=NONE
hi NonText ctermfg=110 ctermbg=255 cterm=NONE
hi Pmenu ctermfg=fg ctermbg=195 cterm=NONE
hi PmenuSbar ctermfg=255 ctermbg=153 cterm=NONE
hi PmenuSel ctermfg=255 ctermbg=21 cterm=NONE
hi PmenuThumb ctermfg=111 ctermbg=255 cterm=NONE
hi SignColumn ctermfg=110 ctermbg=254 cterm=NONE
hi Search ctermfg=255 ctermbg=160 cterm=NONE
hi SpecialKey ctermfg=255 ctermbg=144 cterm=NONE
hi SpellBad ctermfg=16 ctermbg=229 cterm=NONE
hi SpellCap ctermfg=16 ctermbg=231 cterm=NONE
hi SpellLocal ctermfg=16 ctermbg=231 cterm=NONE
hi SpellRare ctermfg=16 ctermbg=226 cterm=NONE
hi StatusLine ctermfg=255 ctermbg=24 cterm=NONE
hi StatusLineNC ctermfg=253 ctermbg=110 cterm=NONE
hi Title ctermfg=75 ctermbg=255 cterm=NONE
hi VertSplit ctermfg=255 ctermbg=24 cterm=NONE
hi Visual ctermfg=255 ctermbg=153 cterm=NONE
hi WildMenu ctermfg=16 ctermbg=117 cterm=NONE
" 1}}}
" Syntax {{{1
" =============================================================================
" General {{{2
" -----------------------------------------------------------------------------
" Groups ('*' = major; see 'help group-name'):
" *Comment any comment
" *Constant any constant
" String a string constant: "this is a string"
" Character a character constant: 'c', '\n'
" Number a number constant: 234, 0xff
" Boolean a boolean constant: TRUE, false
" Float a floating point constant: 2.3e10
" *Identifier any variable name
" Function function name (also: methods for classes)
" *Statement any statement
" Conditional if, then, else, endif, switch, etc.
" Repeat for, do, while, etc.
" Label case, default, etc.
" Operator "sizeof", "+", "*", etc.
" Keyword any other keyword
" Exception try, catch, throw
" *PreProc generic Preprocessor
" Include preprocessor #include
" Define preprocessor #define
" Macro same as Define
" PreCondit preprocessor #if, #else, #endif, etc.
" *Type int, long, char, etc.
" StorageClass static, register, volatile, etc.
" Structure struct, union, enum, etc.
" Typedef A typedef
" *Special any special symbol
" SpecialChar special character in a constant
" Tag you can use CTRL-] on this
" Delimiter character that needs attention
" SpecialComment special things inside a comment
" Debug debugging statements
" *Error any erroneous construct
" *Todo anything that needs extra attention
" hi Comment guifg=#A2B5CD guibg=NONE gui=italic
hi Comment guifg=#96AAC2 guibg=NONE gui=italic
hi Constant guifg=DarkOrange guibg=NONE gui=NONE
hi String guifg=Aquamarine4 guibg=NONE gui=NONE
hi Boolean guifg=IndianRed4 guibg=NONE gui=NONE
hi Identifier guifg=brown3 guibg=NONE gui=NONE
hi Function guifg=VioletRed4 guibg=NONE gui=NONE
hi Statement guifg=blue1 guibg=NONE gui=NONE
hi Keyword guifg=DodgerBlue guibg=NONE gui=NONE
hi PreProc guifg=blue1 guibg=NONE gui=NONE
hi Type guifg=LightSlateBlue guibg=NONE gui=NONE
hi Special guifg=DarkOliveGreen4 guibg=NONE gui=NONE
hi Ignore guifg=bg guibg=NONE gui=NONE
hi Error guifg=Red guibg=NONE gui=underline
hi Todo guifg=tan4 guibg=NONE gui=underline
" 2}}}
" Vim {{{2
" -----------------------------------------------------------------------------
hi VimError guifg=red guibg=Black gui=bold
hi VimCommentTitle guifg=DarkSlateGray4 guibg=bg gui=bold,italic
" 2}}}
" QuickFix {{{2
" -----------------------------------------------------------------------------
" syn match qfFileName "^[^|]*" nextgroup=qfSeparator
" syn match qfSeparator "|" nextgroup=qfLineNr contained
" syn match qfLineNr "[^|]*" contained contains=qfError
" syn match qfError "error" contained
hi qfFileName guifg=LightSkyBlue4 guibg=NONE gui=italic
hi qfLineNr guifg=coral guibg=NONE gui=bold
hi qfError guifg=red guibg=NONE gui=bold
" 2}}}
" Python {{{2
" -----------------------------------------------------------------------------
hi pythonDecorator guifg=orange3 guibg=NONE gui=bold
hi link pythonDecoratorFunction pythonDecorator
" 2}}}
" Diff {{{2
" -----------------------------------------------------------------------------
hi diffOldFile guifg=#006666 guibg=NONE gui=NONE
hi diffNewFile guifg=#0088FF guibg=NONE gui=bold
hi diffFile guifg=#0000FF guibg=NONE gui=NONE
hi link diffOnly Constant
hi link diffIdentical Constant
hi link diffDiffer Constant
hi link diffBDiffer Constant
hi link diffIsA Constant
hi link diffNoEOL Constant
hi link diffCommon Constant
hi diffRemoved guifg=#BB0000 guibg=NONE gui=NONE
hi diffChanged guifg=DarkSeaGreen guibg=NONE gui=NONE
hi diffAdded guifg=#00AA00 guibg=NONE gui=NONE
hi diffLine guifg=thistle4 guibg=NONE gui=italic
hi link diffSubname diffLine
hi link diffComment Comment
" 2}}}
" PHP (contributed by Ryan Kulla) {{{2
" -----------------------------------------------------------------------------
" Ryan Kulla's addition for PHP syntax highlighting (for regular/terminal vim)
hi phpConditional ctermfg=21 cterm=NONE guifg=black
hi phpIdentifier ctermfg=0 cterm=NONE guifg=black
hi phpOperator ctermfg=black cterm=NONE guifg=black
hi phpRegion ctermfg=132 cterm=NONE guifg=VioletRed4
hi phpComparison ctermfg=black cterm=NONE guifg=black
hi phpType ctermfg=darkgreen cterm=NONE guifg=darkgreen
hi phpParent ctermfg=black cterm=NONE guifg=black
hi phpMethodsVar ctermfg=132 cterm=NONE guifg=VioletRed4
hi phpStatement ctermfg=21 cterm=NONE guifg=blue
hi phpStorageClass ctermfg=21 cterm=NONE guifg=blue
hi phpStringSingle ctermfg=30 cterm=NONE guifg=Aquamarine4
hi phpStringDouble ctermfg=30 cterm=NONE guifg=Aquamarine4
hi phpFunctions ctermfg=21 cterm=NONE guifg=blue
hi phpSpecialFunction ctermfg=21 cterm=NONE guifg=blue
hi phpRepeat ctermfg=21 cterm=NONE guifg=blue
hi phpNumber ctermfg=214 cterm=bold guifg=brown
hi phpTodo ctermfg=red cterm=bold guifg=red gui=bold
hi phpDefine ctermfg=21 cterm=NONE guifg=blue
hi phpConstant ctermfg=21 cterm=NONE guifg=black
hi phpCoreConstant ctermfg=21 cterm=NONE guifg=black
hi phpMemberSelector ctermfg=black cterm=NONE guifg=black
hi phpLabel ctermfg=21 cterm=NONE guifg=blue
hi phpStructure ctermfg=black cterm=NONE guifg=black
hi phpRelation ctermfg=black cterm=NONE guifg=black
hi phpEnvVar ctermfg=black cterm=NONE guifg=black
hi phpIntVar ctermfg=0 cterm=bold guifg=black gui=bold
hi phpBoolean ctermfg=58 cterm=NONE guifg=brown
" 2}}}
" 1}}}

View file

@ -1,192 +0,0 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=521
Overview
The Most Recently Used (MRU) plugin provides an easy access to a list of
recently opened/edited files in Vim. This plugin automatically stores the
file names as you open/edit them in Vim.
This plugin will work on all the platforms where Vim is supported. This
plugin will work in both console and GUI Vim. This version of the MRU
plugin needs Vim 7.0 and above. If you are using an earlier version of
Vim, then you should use an older version of the MRU plugin.
The recently used filenames are stored in a file specified by the Vim
MRU_File variable.
The Github repository for the MRU plugin is available at:
http://github.com/yegappan/mru
Usage
To list and edit files from the MRU list, you can use the ":MRU" command.
The ":MRU" command displays the MRU file list in a temporary Vim window. If
the MRU window is already opened, then the MRU list displayed in the window
is refreshed.
If you are using GUI Vim, then the names of the recently edited files are
added to the "File->Recent Files" menu. You can select the name of a file
from this sub-menu to edit the file.
You can use the normal Vim commands to move around in the MRU window. You
cannot make changes in the MRU window.
You can select a file name to edit by pressing the <Enter> key or by double
clicking the left mouse button on a file name. The selected file will be
opened. If the file is already opened in a window, the cursor will be moved
to that window. Otherwise, the file is opened in the previous window. If the
previous window has a modified buffer or is the preview window or is used by
some other plugin, then the file is opened in a new window.
You can press the 'o' key to open the file name under the cursor in the
MRU window in a new window. You can also press <Shift-Enter> instead of 'o'
to open the file in a new window.
To open a file from the MRU window in read-only mode (view), press the 'v'
key.
To open a file from the MRU window in a new tab, press the 't' key. If the
file is already opened in a window in the current or in another tab, then
the cursor is moved to that tab. Otherwise, a new tab is opened.
You can open multiple files from the MRU window by specifying a count before
pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually (using
linewise visual mode) select multiple filenames and invoke the commands to
open the files. Each selected file will be opened in a separate window or
tab.
You can press the 'u' key in the MRU window to update the file list. This is
useful if you keep the MRU window open always.
You can close the MRU window by pressing the 'q' key or the <Esc> key or
using one of the Vim window commands.
To display only files matching a pattern from the MRU list in the MRU
window, you can specify a pattern to the ":MRU" command. For example, to
display only file names matching "vim" in them, you can use the following
command ":MRU vim". When you specify a partial file name and only one
matching filename is found, then the ":MRU" command will edit that file.
The ":MRU" command supports command-line completion of file names from
the MRU list. You can enter a partial file name and then press <Tab>
or <Ctrl-D> to complete or list all the matching file names. Note that
after typing the ":MRU" command, you have to enter a space before completing
the file names with <Tab>.
When a file supplied to the ":MRU" command is not present in the MRU list,
but it is a readable file, then the file will be opened (even though it is
not present in the MRU list). This is useful if you want to open a file
present in the same directory as a file in the MRU list. You can use the
command-line completion of the ":MRU" command to complete the full path of a
file and then modify the path to open another file present in the same path.
Whenever the MRU list changes, the MRU file is updated with the latest MRU
list. When you have multiple instances of Vim running at the same time, the
latest MRU list will show up in all the instances of Vim.
The MRUFilename syntax group is used to highlight the file names in the MRU
window. By default, this syntax group is linked to the Identifier highlight
group. You can change the highlight group by adding the following line in
your .vimrc:
highlight link MRUFileName LineNr
The MRU buffer uses the 'mru file type. You can use this file type to add
custom auto commands, syntax highlighting, etc.
Configuration
By changing the following variables you can configure the behavior of this
plugin. Set the following variables in your .vimrc file using the 'let'
command.
The list of recently edited file names is stored in the file specified by the
MRU_File variable. The default setting for this variable is
$HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files
for MS-Windows systems. You can change this variable to point to a file by
adding the following line to the .vimrc file:
let MRU_File = 'd:\myhome\_vim_mru_files'
By default, the plugin will remember the names of the last 100 used files.
As you edit more files, old file names will be removed from the MRU list.
You can set the 'MRU_Max_Entries' variable to remember more file names. For
example, to remember 1000 most recently used file names, you can use
let MRU_Max_Entries = 1000
By default, all the edited file names will be added to the MRU list. If you
want to exclude file names matching a list of patterns, you can set the
MRU_Exclude_Files variable to a list of Vim regular expressions. By default,
this variable is set to an empty string. For example, to not include files
in the temporary (/tmp, /var/tmp and d:\temp) directories, you can set the
MRU_Exclude_Files variable to
let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix
let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows
The specified pattern should be a Vim regular expression pattern.
If you want to add only file names matching a set of patterns to the MRU
list, then you can set the MRU_Include_Files variable. This variable should
be set to a Vim regular expression pattern. For example, to add only .c and
.h files to the MRU list, you can set this variable as below:
let MRU_Include_Files = '\.c$\|\.h$'
By default, MRU_Include_Files is set to an empty string and all the edited
filenames are added to the MRU list.
The default height of the MRU window is 8. You can set the MRU_Window_Height
variable to change the window height.
let MRU_Window_Height = 15
By default, when the :MRU command is invoked, the MRU list will be displayed
in a new window. Instead, if you want the MRU plugin to reuse the current
window, then you can set the 'MRU_Use_Current_Window' variable to one.
let MRU_Use_Current_Window = 1
The MRU plugin will reuse the current window. When a file name is selected,
the file is also opened in the current window.
When you select a file from the MRU window, the MRU window will be
automatically closed and the selected file will be opened in the previous
window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU
window open.
let MRU_Auto_Close = 0
If you don't use the "File->Recent Files" menu and want to disable it,
then you can set the 'MRU_Add_Menu' variable to zero. By default, the
menu is enabled.
let MRU_Add_Menu = 0
If too many file names are present in the MRU list, then updating the MRU
menu to list all the file names makes Vim slow. To avoid this, the
MRU_Max_Menu_Entries variable controls the number of file names to show in
the MRU menu. By default, this is set to 10. You can change this to show
more entries in the menu.
let MRU_Max_Menu_Entries = 20
If many file names are present in the MRU list, then the MRU menu is split
into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names.
The default setting for this is 10. You can change this to increase the
number of file names displayed in a single sub-menu:
let MRU_Max_Submenu_Entries = 15
In the MRU window, the filenames are displayed in two parts. The first part
contains the file name without the path and the second part contains the
full path to the file in parenthesis. This format is controlled by the
MRU_Filename_Format variable. If you prefer to change this to some other
format, then you can modify the MRU_Filename_Format variable. For example,
to display the full path without splitting it, you can set this variable
as shown below:
let MRU_Filename_Format={'formatter':'v:val', 'parser':'.*'}

File diff suppressed because it is too large Load diff

View file

@ -1,37 +0,0 @@
_To assist in resolving your issue, provide as much information as possible, in place of the ellipses (`…`) below._
---
**Environment:** _Describe your Vim/NERDTree setup._
>* Operating System: …
>* Vim version `:version`: …
>* NERDTree version `git rev-parse --short HEAD`: …
>* NERDTree settings applied in your vimrc, if any:
>
> ```
> …
> ```
**Process:** _List the steps that will recreate the issue._
>1. …
**Current Result:** _Describe what you you currently experience from this process._
>…
**Expected Result:** _Describe what you would expect to have resulted from this process._
>…
---
**Optional**
**Screenshot(s):**
>…
**Possible Fix:** _(Have you poked around in the code?)_
>…

View file

@ -1,3 +0,0 @@
*~
*.swp
tags

View file

@ -1,179 +0,0 @@
Next
- Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) #759
- Update doc with already existing mapping variables (asnr) #699
- Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) #696
- Correct NERDTreeIgnore pattern in doc (cntoplolicon) #648
- Remove empty segments when splitting path (sooth-sayer) #574
- Suppress autocmds less agressively (wincent) #578 #691
- Add an Issues template to ask for more info initially.
- Fix markdown headers in readme (josephfrazier) #676
- Don't touch @o and @h registers when rendering
- Fix bug with files and directories with dollar signs (alegen) #649
- Reuse/reopen existing window trees where possible #244
- Remove NERDTree.previousBuf()
- Change color of arrow (Leeiio) #630
- Improved a tip in README.markdown (ggicci) #628
- Shorten delete confimration of empty directory to 'y' (mikeperri) #530
- Fix API call to open directory tree in window (devm33) #533
- Change default arrows on non-Windows platforms (gwilk) #546
- Update to README - combine cd and git clone (zwhitchcox) #584
- Update to README - Tip: start NERDTree when vim starts (therealplato) #593
- Escape filename when moving an open buffer (zacharyvoase) #595
- Fixed incorrect :helptags command in README (curran) #619
- Fixed incomplete escaping of folder arrows (adityanatraj) #548
- Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558
- Replace strchars() with backward compatible workaround.
- Add support for copy command in Windows (SkylerLipthay) #231
- Fixed typo in README.markdown - :Helptags -> :helptags
- Rename "primary" and "secondary" trees to "tab" and "window" trees.
- Move a bunch of buffer level variables into the NERDTree and UI classes.
- Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing)
- Remove the old style UI - Remove 'NERDTreeDirArrows' option.
- On windows default to + and ~ for expand/collapse directory symbols.
- Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends.
5.0.0
- Refactor the code significantly:
* Break the classes out into their own files.
* Make the majority of the code OO - previously large parts were
effectively a tangle of "global" methods.
- Add an API to assign flags to nodes. This allows VCS plugins like
https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to
Xuyuanp for helping design/test/build said API.
- add 'scope' argument to the key map API see :help NERDTreeAddKeyMap()
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
- add support for custom path filters. See :help NERDTreeAddPathFilter()
- add path listener API. See :help NERDTreePathListenerAPI.
- expand the fs menu functionality to list file properties (PhilRunninger,
apbarrero, JESii)
- make bookmarks work with `~` home shortcuts (hiberabyss)
- show OSX specific fsmenu options in regular vim on mac (evindor)
- make dir arrow icons configurable (PickRelated)
- optimise node sorting performance when opening large dirs (vtsang)
- make the root note render prettier by truncating it at a path slash (gcmt)
- remove NERDChristmasTree option - its always christmas now
- add "cascade" open and closing for dirs containing only another single
dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm)
Many other fixes, doc updates and contributions from:
actionshrimp
SchDen
egalpin
cperl82 - many small fixes
toiffel
WoLpH
handcraftedbits
devmanhinton
xiaodili
zhangoose
gastropoda
mixvin
alvan
lucascaton
kelaban
shanesmith
staeff
pendulm
stephenprater
franksort
agrussellknives
AndrewRadev
Twinside
4.2.0
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars
instead of the old +~| chars to define the tree structure (sickill)
- shift the syntax highlighting out into its own syntax file (gnap)
- add some mac specific options to the filesystem menu - for macvim
only (andersonfreitas)
- Add NERDTreeMinimalUI option to remove some non functional parts of the
nerdtree ui (camthompson)
- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the
new behaviour (benjamingeiger)
- if no name is given to :Bookmark, make it default to the name of the
target file/dir (minyoung)
- use 'file' completion when doing copying, create, and move
operations (EvanDotPro)
- lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly
Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
4.1.0
features:
- NERDTreeFind to reveal the node for the current buffer in the tree,
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
Doug McInnes) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
Ritter and Rémi Prévost.
- truncate the root node if wider than the tree window. Thanks to Victor
Gonzalez.
bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
jfilip1024, and Chris Chambers
4.0.0
- add a new programmable menu system (see :help NERDTreeMenu).
- add new APIs to add menus/menu-items to the menu system as well as
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
- fix a bug where the script ignored directories whose name ended in a dot,
thanks to Aggelos Orfanakos for the patch.
- fix a bug when using the x mapping on the tree root, thanks to Bryan
Venteicher for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer
wasnt being stored on closing the window, thanks to Richard Hart.
- fix a bug where NERDTreeMirror would mirror the wrong tree
3.1.1
- fix a bug where a non-listed no-name buffer was getting created every
time the tree windows was created, thanks to Derek Wyatt and owen1
- make <CR> behave the same as the 'o' mapping
- some helptag fixes in the doc, thanks strull
- fix a bug when using :set nohidden and opening a file where the previous
buf was modified. Thanks iElectric
- other minor fixes
3.1.0
New features:
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
NERDTree-gs
- make the statusline for the nerd tree window default to something
hopefully more useful. See :help 'NERDTreeStatusline'
Bugfixes:
- make the hijack netrw functionality work when vim is started with "vim
<some dir>" (thanks to Alf Mikula for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
- add -bar to all the nerd tree :commands so they can chain with other
:commands (thanks to tpope)
- fix bugs when ignorecase was set (thanks to nach)
- fix a bug with the relative path code (thanks to nach)
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
3.0.1
Bugfixes:
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
was not set
- fix a bug where :NERDTree <path> would fail if <path> was relative and
didnt start with a ./ or ../ Thanks to James Kanze.
- make the q mapping work with secondary (:e <dir> style) trees,
thanks to jamessan
- fix a bunch of small bugs with secondary trees
More insane refactoring.
3.0.0
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
- allow sharing of trees across tabs, see :help :NERDTreeMirror
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
- change the '<tab>' mapping to 'i'
- change the 'H' mapping to 'I'
- lots of refactoring

View file

@ -1,13 +0,0 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View file

@ -1,96 +0,0 @@
The NERDTree
=============
Introduction
------------
The NERDTree is a file system explorer for the Vim editor. Using this plugin,
users can visually browse complex directory hierarchies, quickly open files for
reading or editing, and perform basic file system operations.
This plugin can also be extended with custom mappings using a special API. The
details of this API and of other NERDTree features are described in the
included documentation.
![NERDTree Screenshot](https://github.com/scrooloose/nerdtree/raw/master/screenshot.png)
Installation
------------
#### [pathogen.vim](https://github.com/tpope/vim-pathogen)
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERDTree.txt`.
#### [apt-vim](https://github.com/egalpin/apt-vim)
apt-vim install -y https://github.com/scrooloose/nerdtree.git
F.A.Q.
------
> Is there any support for `git` flags?
Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin).
---
> Can I have the nerdtree on every tab automatically?
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
If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs)
---
> How can I open a NERDTree automatically when vim starts up?
Stick this in your vimrc: `autocmd vimenter * NERDTree`
---
> How can I open a NERDTree automatically when vim starts up if no files were specified?
Stick this in your vimrc:
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
Note: Now start vim with plain `vim`, not `vim .`
---
> How can I open NERDTree automatically when vim starts up on opening a directory?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.
---
> How can I map a specific key or shortcut to open NERDTree?
Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
map <C-n> :NERDTreeToggle<CR>
---
> How can I close vim if the only window left open is a NERDTree?
Stick this in your vimrc:
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
---
> Can I have different highlighting for different file extensions?
See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696
---
> How can I change default arrows?
Use these variables in your vimrc. Note that below are default arrow symbols
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'

View file

@ -1,201 +0,0 @@
if exists("g:loaded_nerdtree_autoload")
finish
endif
let g:loaded_nerdtree_autoload = 1
function! nerdtree#version()
return '5.0.0'
endfunction
" SECTION: General Functions {{{1
"============================================================
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
"inits a window tree in the current buffer if appropriate
function! nerdtree#checkForBrowse(dir)
if !isdirectory(a:dir)
return
endif
if s:reuseWin(a:dir)
return
endif
call g:NERDTreeCreator.CreateWindowTree(a:dir)
endfunction
"FUNCTION: s:reuseWin(dir) {{{2
"finds a NERDTree buffer with root of dir, and opens it.
function! s:reuseWin(dir) abort
let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p"))
for i in range(1, bufnr("$"))
unlet! nt
let nt = getbufvar(i, "NERDTree")
if empty(nt)
continue
endif
if nt.isWinTree() && nt.root.path.equals(path)
call nt.setPreviousBuf(bufnr("#"))
exec "buffer " . i
return 1
endif
endfor
return 0
endfunction
" FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2
" completion function for the bookmark commands
function! nerdtree#completeBookmarks(A,L,P)
return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
endfunction
"FUNCTION: nerdtree#compareNodes(dir) {{{2
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)
let sortKey1 = a:n1.path.getSortKey()
let sortKey2 = a:n2.path.getSortKey()
let i = 0
while i < min([len(sortKey1), len(sortKey2)])
" Compare chunks upto common length.
" If chunks have different type, the one which has
" integer type is the lesser.
if type(sortKey1[i]) == type(sortKey2[i])
if sortKey1[i] <# sortKey2[i]
return - 1
elseif sortKey1[i] ># sortKey2[i]
return 1
endif
elseif sortKey1[i] == type(0)
return -1
elseif sortKey2[i] == type(0)
return 1
endif
let i = i + 1
endwhile
" Keys are identical upto common length.
" The key which has smaller chunks is the lesser one.
if len(sortKey1) < len(sortKey2)
return -1
elseif len(sortKey1) > len(sortKey2)
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
function! nerdtree#deprecated(func, ...)
let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated'
if !exists('s:deprecationWarnings')
let s:deprecationWarnings = {}
endif
if !has_key(s:deprecationWarnings, a:func)
let s:deprecationWarnings[a:func] = 1
echomsg msg
endif
endfunction
" FUNCTION: nerdtree#exec(cmd) {{{2
" Same as :exec cmd but with eventignore set for the duration
" to disable the autocommands used by NERDTree (BufEnter,
" BufLeave and VimEnter)
function! nerdtree#exec(cmd)
let old_ei = &ei
set ei=BufEnter,BufLeave,VimEnter
exec a:cmd
let &ei = old_ei
endfunction
" FUNCTION: nerdtree#has_opt(options, name) {{{2
function! nerdtree#has_opt(options, name)
return has_key(a:options, a:name) && a:options[a:name] == 1
endfunction
" FUNCTION: nerdtree#loadClassFiles() {{{2
function! nerdtree#loadClassFiles()
runtime lib/nerdtree/path.vim
runtime lib/nerdtree/menu_controller.vim
runtime lib/nerdtree/menu_item.vim
runtime lib/nerdtree/key_map.vim
runtime lib/nerdtree/bookmark.vim
runtime lib/nerdtree/tree_file_node.vim
runtime lib/nerdtree/tree_dir_node.vim
runtime lib/nerdtree/opener.vim
runtime lib/nerdtree/creator.vim
runtime lib/nerdtree/flag_set.vim
runtime lib/nerdtree/nerdtree.vim
runtime lib/nerdtree/ui.vim
runtime lib/nerdtree/event.vim
runtime lib/nerdtree/notifier.vim
endfunction
" FUNCTION: nerdtree#postSourceActions() {{{2
function! nerdtree#postSourceActions()
call g:NERDTreeBookmark.CacheBookmarks(1)
call nerdtree#ui_glue#createDefaultBindings()
"load all nerdtree plugins
runtime! nerdtree_plugin/**/*.vim
endfunction
"FUNCTION: nerdtree#runningWindows(dir) {{{2
function! nerdtree#runningWindows()
return has("win16") || has("win32") || has("win64")
endfunction
"FUNCTION: nerdtree#runningCygwin(dir) {{{2
function! nerdtree#runningCygwin()
return has("win32unix")
endfunction
" SECTION: View Functions {{{1
"============================================================
"FUNCTION: nerdtree#echo {{{2
"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages
"
"Args:
"msg: the message to echo
function! nerdtree#echo(msg)
redraw
echomsg "NERDTree: " . a:msg
endfunction
"FUNCTION: nerdtree#echoError {{{2
"Wrapper for nerdtree#echo, sets the message type to errormsg for this message
"Args:
"msg: the message to echo
function! nerdtree#echoError(msg)
echohl errormsg
call nerdtree#echo(a:msg)
echohl normal
endfunction
"FUNCTION: nerdtree#echoWarning {{{2
"Wrapper for nerdtree#echo, sets the message type to warningmsg for this message
"Args:
"msg: the message to echo
function! nerdtree#echoWarning(msg)
echohl warningmsg
call nerdtree#echo(a:msg)
echohl normal
endfunction
"FUNCTION: nerdtree#renderView {{{2
function! nerdtree#renderView()
call b:NERDTree.render()
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,687 +0,0 @@
if exists("g:loaded_nerdtree_ui_glue_autoload")
finish
endif
let g:loaded_nerdtree_ui_glue_autoload = 1
" FUNCTION: nerdtree#ui_glue#createDefaultBindings() {{{1
function! nerdtree#ui_glue#createDefaultBindings()
let s = '<SNR>' . s:SID() . '_'
call NERDTreeAddKeyMap({ 'key': '<MiddleMouse>', 'scope': 'all', 'callback': s . 'handleMiddleMouse' })
call NERDTreeAddKeyMap({ 'key': '<LeftRelease>', 'scope': "all", 'callback': s."handleLeftClick" })
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" })
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" })
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" })
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': "nerdtree#ui_glue#chRootCwd" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Bookmark', 'callback': s . 'openInNewTab' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" })
endfunction
"SECTION: Interface bindings {{{1
"============================================================
"FUNCTION: s:activateAll() {{{1
"handle the user activating the updir line
function! s:activateAll()
if getline(".") ==# g:NERDTreeUI.UpDirLine()
return nerdtree#ui_glue#upDir(0)
endif
endfunction
" FUNCTION: s:activateDirNode(directoryNode) {{{1
function! s:activateDirNode(directoryNode)
if a:directoryNode.isRoot() && a:directoryNode.isOpen
call nerdtree#echo('cannot close tree root')
return
endif
call a:directoryNode.activate()
endfunction
"FUNCTION: s:activateFileNode() {{{1
"handle the user activating a tree node
function! s:activateFileNode(node)
call a:node.activate({'reuse': 'all', 'where': 'p'})
endfunction
"FUNCTION: s:activateBookmark() {{{1
"handle the user activating a bookmark
function! s:activateBookmark(bm)
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {})
endfunction
" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1
" Associate the current node with the given name
function! nerdtree#ui_glue#bookmarkNode(...)
let currentNode = g:NERDTreeFileNode.GetSelected()
if currentNode != {}
let name = a:1
if empty(name)
let name = currentNode.path.getLastPathComponent(0)
endif
try
call currentNode.bookmark(name)
call b:NERDTree.render()
catch /^NERDTree.IllegalBookmarkNameError/
call nerdtree#echo("bookmark names must not contain spaces")
endtry
else
call nerdtree#echo("select a node first")
endif
endfunction
" FUNCTION: s:chCwd(node) {{{1
function! s:chCwd(node)
try
call a:node.path.changeToDir()
catch /^NERDTree.PathChangeError/
call nerdtree#echoWarning("could not change cwd")
endtry
endfunction
" FUNCTION: s:chRoot(node) {{{1
" changes the current root to the selected one
function! s:chRoot(node)
call b:NERDTree.changeRoot(a:node)
endfunction
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
" changes the current root to CWD
function! nerdtree#ui_glue#chRootCwd()
try
let cwd = g:NERDTreePath.New(getcwd())
catch /^NERDTree.InvalidArgumentsError/
call nerdtree#echo("current directory does not exist.")
return
endtry
if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str()
return
endif
call s:chRoot(g:NERDTreeDirNode.New(cwd, b:NERDTree))
endfunction
" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1
function! nerdtree#ui_glue#clearBookmarks(bookmarks)
if a:bookmarks ==# ''
let currentNode = g:NERDTreeFileNode.GetSelected()
if currentNode != {}
call currentNode.clearBookmarks()
endif
else
for name in split(a:bookmarks, ' ')
let bookmark = g:NERDTreeBookmark.BookmarkFor(name)
call bookmark.delete()
endfor
endif
call b:NERDTree.root.refresh()
call b:NERDTree.render()
endfunction
" FUNCTION: s:closeChildren(node) {{{1
" closes all childnodes of the current node
function! s:closeChildren(node)
call a:node.closeChildren()
call b:NERDTree.render()
call a:node.putCursorHere(0, 0)
endfunction
" FUNCTION: s:closeCurrentDir(node) {{{1
" Close the parent directory of the current node.
function! s:closeCurrentDir(node)
if a:node.isRoot()
call nerdtree#echo('cannot close parent of tree root')
return
endif
let l:parent = a:node.parent
while l:parent.isCascadable()
let l:parent = l:parent.parent
endwhile
if l:parent.isRoot()
call nerdtree#echo('cannot close tree root')
return
endif
call l:parent.close()
call b:NERDTree.render()
call l:parent.putCursorHere(0, 0)
endfunction
" FUNCTION: s:closeTreeWindow() {{{1
" close the tree window
function! s:closeTreeWindow()
if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1
exec "buffer " . b:NERDTree.previousBuf()
else
if winnr("$") > 1
call g:NERDTree.Close()
else
call nerdtree#echo("Cannot close last window")
endif
endif
endfunction
" FUNCTION: s:deleteBookmark(bookmark) {{{1
" Prompt the user to confirm the deletion of the selected bookmark.
function! s:deleteBookmark(bookmark)
let l:message = "Delete the bookmark \"" . a:bookmark.name
\ . "\" from the bookmark list?"
let l:choices = "&Yes\n&No"
echo | redraw
let l:selection = confirm(l:message, l:choices, 1, 'Warning')
if l:selection != 1
call nerdtree#echo('bookmark not deleted')
return
endif
try
call a:bookmark.delete()
silent call b:NERDTree.root.refresh()
call b:NERDTree.render()
echo | redraw
catch /^NERDTree/
call nerdtree#echoWarning('could not remove bookmark')
endtry
endfunction
" FUNCTION: s:displayHelp() {{{1
" toggles the help display
function! s:displayHelp()
call b:NERDTree.ui.toggleHelp()
call b:NERDTree.render()
call b:NERDTree.ui.centerView()
endfunction
" FUNCTION: s:findAndRevealPath(path) {{{1
function! s:findAndRevealPath(path)
let l:path = a:path
if empty(l:path)
let l:path = expand('%:p')
endif
try
let p = g:NERDTreePath.New(l:path)
catch /^NERDTree.InvalidArgumentsError/
call nerdtree#echo("no file for the current buffer")
return
endtry
if p.isUnixHiddenPath()
let showhidden=g:NERDTreeShowHidden
let g:NERDTreeShowHidden = 1
endif
if !g:NERDTree.ExistsForTab()
try
let cwd = g:NERDTreePath.New(getcwd())
catch /^NERDTree.InvalidArgumentsError/
call nerdtree#echo("current directory does not exist.")
let cwd = p.getParent()
endtry
if p.isUnder(cwd)
call g:NERDTreeCreator.CreateTabTree(cwd.str())
else
call g:NERDTreeCreator.CreateTabTree(p.getParent().str())
endif
else
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.ToggleTabTree('')
else
call g:NERDTree.CursorToTreeWin()
endif
call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden)
call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree))
else
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.ToggleTabTree("")
endif
endif
endif
call g:NERDTree.CursorToTreeWin()
let node = b:NERDTree.root.reveal(p)
call b:NERDTree.render()
call node.putCursorHere(1,0)
if p.isUnixHiddenFile()
let g:NERDTreeShowHidden = showhidden
endif
endfunction
"FUNCTION: s:handleLeftClick() {{{1
"Checks if the click should open the current node
function! s:handleLeftClick()
let currentNode = g:NERDTreeFileNode.GetSelected()
if currentNode != {}
"the dir arrows are multibyte chars, and vim's string functions only
"deal with single bytes - so split the line up with the hack below and
"take the line substring manually
let line = split(getline(line(".")), '\zs')
let startToCur = ""
for i in range(0,len(line)-1)
let startToCur .= line[i]
endfor
if currentNode.path.isDirectory
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \?$'
call currentNode.activate()
return
endif
endif
if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
let char = strpart(startToCur, strlen(startToCur)-1, 1)
if char !~# g:NERDTreeUI.MarkupReg()
if currentNode.path.isDirectory
call currentNode.activate()
else
call currentNode.activate({'reuse': 'all', 'where': 'p'})
endif
return
endif
endif
endif
endfunction
" FUNCTION: s:handleMiddleMouse() {{{1
function! s:handleMiddleMouse()
" A middle mouse click does not automatically position the cursor as one
" would expect. Forcing the execution of a regular left mouse click here
" fixes this problem.
execute "normal! \<LeftMouse>"
let l:currentNode = g:NERDTreeFileNode.GetSelected()
if empty(l:currentNode)
call nerdtree#echoError('use the pointer to select a node')
return
endif
if l:currentNode.path.isDirectory
call l:currentNode.openExplorer()
else
call l:currentNode.open({'where': 'h'})
endif
endfunction
" FUNCTION: s:jumpToChild(direction) {{{2
" Args:
" direction: 0 if going to first child, 1 if going to last
function! s:jumpToChild(currentNode, direction)
if a:currentNode.isRoot()
return nerdtree#echo("cannot jump to " . (a:direction ? "last" : "first") . " child")
end
let dirNode = a:currentNode.parent
let childNodes = dirNode.getVisibleChildren()
let targetNode = childNodes[0]
if a:direction
let targetNode = childNodes[len(childNodes) - 1]
endif
if targetNode.equals(a:currentNode)
let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction)
if siblingDir != {}
let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0
let targetNode = siblingDir.getChildByIndex(indx, 1)
endif
endif
call targetNode.putCursorHere(1, 0)
call b:NERDTree.ui.centerView()
endfunction
" FUNCTION: nerdtree#ui_glue#invokeKeyMap(key) {{{1
"this is needed since I cant figure out how to invoke dict functions from a
"key map
function! nerdtree#ui_glue#invokeKeyMap(key)
call g:NERDTreeKeyMap.Invoke(a:key)
endfunction
" FUNCTION: s:jumpToFirstChild() {{{1
" wrapper for the jump to child method
function! s:jumpToFirstChild(node)
call s:jumpToChild(a:node, 0)
endfunction
" FUNCTION: s:jumpToLastChild() {{{1
" wrapper for the jump to child method
function! s:jumpToLastChild(node)
call s:jumpToChild(a:node, 1)
endfunction
" FUNCTION: s:jumpToParent(node) {{{1
" Move the cursor to the parent of the specified node. For a cascade, move to
" the parent of the cascade's highest node. At the root, do nothing.
function! s:jumpToParent(node)
let l:parent = a:node.parent
" If "a:node" represents a directory, back out of its cascade.
if a:node.path.isDirectory
while !empty(l:parent) && !l:parent.isRoot()
if index(l:parent.getCascade(), a:node) >= 0
let l:parent = l:parent.parent
else
break
endif
endwhile
endif
if !empty(l:parent)
call l:parent.putCursorHere(1, 0)
call b:NERDTree.ui.centerView()
else
call nerdtree#echo('could not jump to parent node')
endif
endfunction
" FUNCTION: s:jumpToRoot() {{{1
" moves the cursor to the root node
function! s:jumpToRoot()
call b:NERDTree.root.putCursorHere(1, 0)
call b:NERDTree.ui.centerView()
endfunction
" FUNCTION: s:jumpToNextSibling(node) {{{1
function! s:jumpToNextSibling(node)
call s:jumpToSibling(a:node, 1)
endfunction
" FUNCTION: s:jumpToPrevSibling(node) {{{1
function! s:jumpToPrevSibling(node)
call s:jumpToSibling(a:node, 0)
endfunction
" FUNCTION: s:jumpToSibling(currentNode, forward) {{{2
" moves the cursor to the sibling of the current node in the given direction
"
" Args:
" forward: 1 if the cursor should move to the next sibling, 0 if it should
" move back to the previous sibling
function! s:jumpToSibling(currentNode, forward)
let sibling = a:currentNode.findSibling(a:forward)
if !empty(sibling)
call sibling.putCursorHere(1, 0)
call b:NERDTree.ui.centerView()
endif
endfunction
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
" Open the Bookmark that has the specified name. This function provides the
" implementation for the ":OpenBookmark" command.
function! nerdtree#ui_glue#openBookmark(name)
try
let l:bookmark = g:NERDTreeBookmark.BookmarkFor(a:name)
catch /^NERDTree.BookmarkNotFoundError/
call nerdtree#echoError('bookmark "' . a:name . '" not found')
return
endtry
if l:bookmark.path.isDirectory
call l:bookmark.open(b:NERDTree)
else
call l:bookmark.open(b:NERDTree, {'where': 'p'})
endif
endfunction
" FUNCTION: s:openHSplit(target) {{{1
function! s:openHSplit(target)
call a:target.activate({'where': 'h'})
endfunction
" FUNCTION: s:openVSplit(target) {{{1
function! s:openVSplit(target)
call a:target.activate({'where': 'v'})
endfunction
" FUNCTION: s:openExplorer(node) {{{1
function! s:openExplorer(node)
call a:node.openExplorer()
endfunction
" FUNCTION: s:openInNewTab(target) {{{1
function! s:openInNewTab(target)
let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't'})
call l:opener.open(a:target)
endfunction
" FUNCTION: s:openInNewTabSilent(target) {{{1
function! s:openInNewTabSilent(target)
let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'stay': 1})
call l:opener.open(a:target)
endfunction
" FUNCTION: s:openNodeRecursively(node) {{{1
function! s:openNodeRecursively(node)
call nerdtree#echo("Recursively opening node. Please wait...")
call a:node.openRecursively()
call b:NERDTree.render()
redraw
call nerdtree#echo("Recursively opening node. Please wait... DONE")
endfunction
"FUNCTION: s:previewNodeCurrent(node) {{{1
function! s:previewNodeCurrent(node)
call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1})
endfunction
"FUNCTION: s:previewNodeHSplit(node) {{{1
function! s:previewNodeHSplit(node)
call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1})
endfunction
"FUNCTION: s:previewNodeVSplit(node) {{{1
function! s:previewNodeVSplit(node)
call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1})
endfunction
" FUNCTION: nerdtree#ui_glue#revealBookmark(name) {{{1
" put the cursor on the node associate with the given name
function! nerdtree#ui_glue#revealBookmark(name)
try
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
call targetNode.putCursorHere(0, 1)
catch /^NERDTree.BookmarkNotFoundError/
call nerdtree#echo("Bookmark isnt cached under the current root")
endtry
endfunction
" FUNCTION: s:refreshRoot() {{{1
" Reloads the current root. All nodes below this will be lost and the root dir
" will be reloaded.
function! s:refreshRoot()
call nerdtree#echo("Refreshing the root node. This could take a while...")
call b:NERDTree.root.refresh()
call b:NERDTree.render()
redraw
call nerdtree#echo("Refreshing the root node. This could take a while... DONE")
endfunction
" FUNCTION: s:refreshCurrent(node) {{{1
" refreshes the root for the current node
function! s:refreshCurrent(node)
let node = a:node
if !node.path.isDirectory
let node = node.parent
endif
call nerdtree#echo("Refreshing node. This could take a while...")
call node.refresh()
call b:NERDTree.render()
redraw
call nerdtree#echo("Refreshing node. This could take a while... DONE")
endfunction
" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1
function! nerdtree#ui_glue#setupCommands()
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
command! -n=? -complete=file -bar NERDTreeFind call s:findAndRevealPath('<args>')
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
endfunction
" Function: s:SID() {{{1
function s:SID()
if !exists("s:sid")
let s:sid = matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
endif
return s:sid
endfun
" FUNCTION: s:showMenu(node) {{{1
function! s:showMenu(node)
let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled())
call mc.showMenu()
endfunction
" FUNCTION: s:toggleIgnoreFilter() {{{1
function! s:toggleIgnoreFilter()
call b:NERDTree.ui.toggleIgnoreFilter()
endfunction
" FUNCTION: s:toggleShowBookmarks() {{{1
function! s:toggleShowBookmarks()
call b:NERDTree.ui.toggleShowBookmarks()
endfunction
" FUNCTION: s:toggleShowFiles() {{{1
function! s:toggleShowFiles()
call b:NERDTree.ui.toggleShowFiles()
endfunction
" FUNCTION: s:toggleShowHidden() {{{1
" toggles the display of hidden files
function! s:toggleShowHidden()
call b:NERDTree.ui.toggleShowHidden()
endfunction
" FUNCTION: s:toggleZoom() {{{1
function! s:toggleZoom()
call b:NERDTree.ui.toggleZoom()
endfunction
"FUNCTION: nerdtree#ui_glue#upDir(keepState) {{{1
"moves the tree up a level
"
"Args:
"keepState: 1 if the current root should be left open when the tree is
"re-rendered
function! nerdtree#ui_glue#upDir(keepState)
let cwd = b:NERDTree.root.path.str({'format': 'UI'})
if cwd ==# "/" || cwd =~# '^[^/]..$'
call nerdtree#echo("already at top dir")
else
if !a:keepState
call b:NERDTree.root.close()
endif
let oldRoot = b:NERDTree.root
if empty(b:NERDTree.root.parent)
let path = b:NERDTree.root.path.getParent()
let newRoot = g:NERDTreeDirNode.New(path, b:NERDTree)
call newRoot.open()
call newRoot.transplantChild(b:NERDTree.root)
let b:NERDTree.root = newRoot
else
let b:NERDTree.root = b:NERDTree.root.parent
endif
if g:NERDTreeChDirMode ==# 2
call b:NERDTree.root.path.changeToDir()
endif
call b:NERDTree.render()
call oldRoot.putCursorHere(0, 0)
endif
endfunction
" FUNCTION: s:upDirCurrentRootOpen() {{{1
function! s:upDirCurrentRootOpen()
call nerdtree#ui_glue#upDir(1)
endfunction
" FUNCTION: s:upDirCurrentRootClosed() {{{1
function! s:upDirCurrentRootClosed()
call nerdtree#ui_glue#upDir(0)
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

File diff suppressed because it is too large Load diff

View file

@ -1,346 +0,0 @@
" ============================================================================
" CLASS: Bookmark
"
" The Bookmark class serves two purposes:
" (1) It is the top-level prototype for new, concrete Bookmark objects.
" (2) It provides an interface for client code to query and manipulate the
" global list of Bookmark objects within the current Vim session.
" ============================================================================
let s:Bookmark = {}
let g:NERDTreeBookmark = s:Bookmark
" FUNCTION: Bookmark.activate(nerdtree) {{{1
function! s:Bookmark.activate(nerdtree, ...)
call self.open(a:nerdtree, a:0 ? a:1 : {})
endfunction
" FUNCTION: Bookmark.AddBookmark(name, path) {{{1
" Class method to add a new bookmark to the list, if a previous bookmark exists
" with the same name, just update the path for that bookmark
function! s:Bookmark.AddBookmark(name, path)
for i in s:Bookmark.Bookmarks()
if i.name ==# a:name
let i.path = a:path
return
endif
endfor
call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path))
endfunction
" FUNCTION: Bookmark.Bookmarks() {{{1
" Class method to get all bookmarks. Lazily initializes the bookmarks global
" variable
function! s:Bookmark.Bookmarks()
if !exists("g:NERDTreeBookmarks")
let g:NERDTreeBookmarks = []
endif
return g:NERDTreeBookmarks
endfunction
" FUNCTION: Bookmark.BookmarkExistsFor(name) {{{1
" class method that returns 1 if a bookmark with the given name is found, 0
" otherwise
function! s:Bookmark.BookmarkExistsFor(name)
try
call s:Bookmark.BookmarkFor(a:name)
return 1
catch /^NERDTree.BookmarkNotFoundError/
return 0
endtry
endfunction
" FUNCTION: Bookmark.BookmarkFor(name) {{{1
" Class method that returns the Bookmark object having the specified name.
" Throws "NERDTree.BookmarkNotFoundError" if no Bookmark is found.
function! s:Bookmark.BookmarkFor(name)
let l:result = {}
for l:bookmark in s:Bookmark.Bookmarks()
if l:bookmark.name ==# a:name
let l:result = l:bookmark
break
endif
endfor
if empty(l:result)
throw 'NERDTree.BookmarkNotFoundError: "' . a:name . '" not found'
endif
return l:result
endfunction
" FUNCTION: Bookmark.BookmarkNames() {{{1
" Class method to return an array of all bookmark names
function! s:Bookmark.BookmarkNames()
let names = []
for i in s:Bookmark.Bookmarks()
call add(names, i.name)
endfor
return names
endfunction
" FUNCTION: Bookmark.CacheBookmarks(silent) {{{1
" Class method to read all bookmarks from the bookmarks file initialize
" bookmark objects for each one.
"
" Args:
" silent - dont echo an error msg if invalid bookmarks are found
function! s:Bookmark.CacheBookmarks(silent)
if filereadable(g:NERDTreeBookmarksFile)
let g:NERDTreeBookmarks = []
let g:NERDTreeInvalidBookmarks = []
let bookmarkStrings = readfile(g:NERDTreeBookmarksFile)
let invalidBookmarksFound = 0
for i in bookmarkStrings
"ignore blank lines
if i != ''
let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
let path = fnamemodify(path, ':p')
try
let bookmark = s:Bookmark.New(name, g:NERDTreePath.New(path))
call add(g:NERDTreeBookmarks, bookmark)
catch /^NERDTree.InvalidArgumentsError/
call add(g:NERDTreeInvalidBookmarks, i)
let invalidBookmarksFound += 1
endtry
endif
endfor
if invalidBookmarksFound
call s:Bookmark.Write()
if !a:silent
call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.")
endif
endif
endif
endfunction
" FUNCTION: Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) {{{1
" Class method that indicates the relative position of two bookmarks when
" placed in alphabetical order by name. Case-sensitivity is determined by an
" option. Supports the "s:Bookmark.SortBookmarksList()" method.
function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark)
let l:result = 0
if g:NERDTreeBookmarksSort == 1
if a:firstBookmark.name <? a:secondBookmark.name
let l:result = -1
elseif a:firstBookmark.name >? a:secondBookmark.name
let l:result = 1
endif
elseif g:NERDTreeBookmarksSort == 2
if a:firstBookmark.name <# a:secondBookmark.name
let l:result = -1
elseif a:firstBookmark.name ># a:secondBookmark.name
let l:result = 1
endif
endif
return l:result
endfunction
" FUNCTION: Bookmark.ClearAll() {{{1
" Class method to delete all bookmarks.
function! s:Bookmark.ClearAll()
for i in s:Bookmark.Bookmarks()
call i.delete()
endfor
call s:Bookmark.Write()
endfunction
" FUNCTION: Bookmark.delete() {{{1
" Delete this bookmark. If the node for this bookmark is under the current
" root, then recache bookmarks for its Path object
function! s:Bookmark.delete()
call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self))
call s:Bookmark.Write()
endfunction
" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1
" Returns the tree node object associated with this Bookmark.
" Throws "NERDTree.BookmarkedNodeNotFoundError" if the node is not found.
"
" Args:
" searchFromAbsoluteRoot: boolean flag, search from the highest cached node
" if true and from the current tree root if false
function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot)
if a:searchFromAbsoluteRoot
let l:searchRoot = a:nerdtree.root.AbsoluteTreeRoot()
else
let l:searchRoot = a:nerdtree.root
endif
let l:targetNode = l:searchRoot.findNode(self.path)
if empty(l:targetNode)
throw 'NERDTree.BookmarkedNodeNotFoundError: node for bookmark "' . self.name . '" not found'
endif
return l:targetNode
endfunction
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1
" Class method that returns the tree node object for the Bookmark with the
" given name. Throws "NERDTree.BookmarkNotFoundError" if a Bookmark with the
" name does not exist. Throws "NERDTree.BookmarkedNodeNotFoundError" if a
" tree node for the named Bookmark could not be found.
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree)
let l:bookmark = s:Bookmark.BookmarkFor(a:name)
return l:bookmark.getNode(a:nerdtree, a:searchFromAbsoluteRoot)
endfunction
" FUNCTION: Bookmark.GetSelected() {{{1
" returns the Bookmark the cursor is over, or {}
function! s:Bookmark.GetSelected()
let line = getline(".")
let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '')
if name != line
try
return s:Bookmark.BookmarkFor(name)
catch /^NERDTree.BookmarkNotFoundError/
return {}
endtry
endif
return {}
endfunction
" FUNCTION: Bookmark.InvalidBookmarks() {{{1
" Class method to get all invalid bookmark strings read from the bookmarks
" file
function! s:Bookmark.InvalidBookmarks()
if !exists("g:NERDTreeInvalidBookmarks")
let g:NERDTreeInvalidBookmarks = []
endif
return g:NERDTreeInvalidBookmarks
endfunction
" FUNCTION: Bookmark.mustExist() {{{1
function! s:Bookmark.mustExist()
if !self.path.exists()
call s:Bookmark.CacheBookmarks(1)
throw "NERDTree.BookmarkPointsToInvalidLocationError: the bookmark \"".
\ self.name ."\" points to a non existing location: \"". self.path.str()
endif
endfunction
" FUNCTION: Bookmark.New(name, path) {{{1
" Create a new bookmark object with the given name and path object
function! s:Bookmark.New(name, path)
if a:name =~# ' '
throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name
endif
let newBookmark = copy(self)
let newBookmark.name = a:name
let newBookmark.path = a:path
return newBookmark
endfunction
" FUNCTION: Bookmark.open(nerdtree, [options]) {{{1
"Args:
"
"nerdtree: the tree to load open the bookmark in
"
"A dictionary containing the following keys (all optional):
" 'where': Specifies whether the node should be opened in new split/tab or in
" the previous window. Can be either 'v' (vertical split), 'h'
" (horizontal split), 't' (new tab) or 'p' (previous window).
" 'reuse': if a window is displaying the file then jump the cursor there
" 'keepopen': dont close the tree window
" 'stay': open the file, but keep the cursor in the tree win
"
function! s:Bookmark.open(nerdtree, ...)
let opts = a:0 ? a:1 : {}
if self.path.isDirectory && !has_key(opts, 'where')
call self.toRoot(a:nerdtree)
else
let opener = g:NERDTreeOpener.New(self.path, opts)
call opener.open(self)
endif
endfunction
" FUNCTION: Bookmark.openInNewTab(options) {{{1
" Create a new bookmark object with the given name and path object
function! s:Bookmark.openInNewTab(options)
call nerdtree#deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead')
call self.open(a:options)
endfunction
" FUNCTION: Bookmark.setPath(path) {{{1
" makes this bookmark point to the given path
function! s:Bookmark.setPath(path)
let self.path = a:path
endfunction
" FUNCTION: Bookmark.SortBookmarksList() {{{1
" Class method that sorts the global list of bookmarks alphabetically by name.
" Note that case-sensitivity is determined by a user option.
function! s:Bookmark.SortBookmarksList()
call sort(s:Bookmark.Bookmarks(), s:Bookmark.CompareBookmarksByName, s:Bookmark)
endfunction
" FUNCTION: Bookmark.str() {{{1
" Get the string that should be rendered in the view for this bookmark
function! s:Bookmark.str()
let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - len(self.name)
if &nu
let pathStrMaxLen = pathStrMaxLen - &numberwidth
endif
let pathStr = self.path.str({'format': 'UI'})
if len(pathStr) > pathStrMaxLen
let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen)
endif
return '>' . self.name . ' ' . pathStr
endfunction
" FUNCTION: Bookmark.toRoot(nerdtree) {{{1
" Set the root of the given NERDTree to the node for this Bookmark. If a node
" for this Bookmark does not exist, a new one is initialized.
function! s:Bookmark.toRoot(nerdtree)
if self.validate()
try
let l:targetNode = self.getNode(a:nerdtree, 1)
call l:targetNode.closeChildren()
catch /^NERDTree.BookmarkedNodeNotFoundError/
let l:targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree)
endtry
call a:nerdtree.changeRoot(l:targetNode)
endif
endfunction
" FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1
" Class method that makes the Bookmark with the given name the root of
" specified NERDTree.
function! s:Bookmark.ToRoot(name, nerdtree)
let l:bookmark = s:Bookmark.BookmarkFor(a:name)
call l:bookmark.toRoot(a:nerdtree)
endfunction
" FUNCTION: Bookmark.validate() {{{1
function! s:Bookmark.validate()
if self.path.exists()
return 1
else
call s:Bookmark.CacheBookmarks(1)
call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.")
return 0
endif
endfunction
" FUNCTION: Bookmark.Write() {{{1
" Class method to write all bookmarks to the bookmarks file
function! s:Bookmark.Write()
let bookmarkStrings = []
for i in s:Bookmark.Bookmarks()
call add(bookmarkStrings, i.name . ' ' . fnamemodify(i.path.str(), ':~'))
endfor
"add a blank line before the invalid ones
call add(bookmarkStrings, "")
for j in s:Bookmark.InvalidBookmarks()
call add(bookmarkStrings, j)
endfor
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,379 +0,0 @@
" ============================================================================
" CLASS: Creator
"
" This class is responsible for creating NERDTree instances. The new NERDTree
" may be a tab tree, a window tree, or a mirrored tree. In the process of
" creating a NERDTree, it sets up all of the window and buffer options and key
" mappings etc.
" ============================================================================
let s:Creator = {}
let g:NERDTreeCreator = s:Creator
" FUNCTION: s:Creator._bindMappings() {{{1
function! s:Creator._bindMappings()
"make <cr> do the same as the activate node mapping
nnoremap <silent> <buffer> <cr> :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode)<cr>
call g:NERDTreeKeyMap.BindAll()
command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark call nerdtree#ui_glue#openBookmark('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>', b:NERDTree)
command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call b:NERDTree.render()
command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) <bar> call b:NERDTree.render()
command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write()
endfunction
" FUNCTION: s:Creator._broadcastInitEvent() {{{1
function! s:Creator._broadcastInitEvent()
silent doautocmd User NERDTreeInit
endfunction
" FUNCTION: s:Creator.BufNamePrefix() {{{2
function! s:Creator.BufNamePrefix()
return 'NERD_tree_'
endfunction
" FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
function! s:Creator.CreateTabTree(name)
let creator = s:Creator.New()
call creator.createTabTree(a:name)
endfunction
" FUNCTION: s:Creator.createTabTree(a:name) {{{1
" name: the name of a bookmark or a directory
function! s:Creator.createTabTree(name)
let l:path = self._pathForString(a:name)
" Abort if an exception was thrown (i.e., if the bookmark or directory
" does not exist).
if empty(l:path)
return
endif
" Obey the user's preferences for changing the working directory.
if g:NERDTreeChDirMode != 0
call l:path.changeToDir()
endif
if g:NERDTree.ExistsForTab()
call g:NERDTree.Close()
call self._removeTreeBufForTab()
endif
call self._createTreeWin()
call self._createNERDTree(l:path, 'tab')
call b:NERDTree.render()
call b:NERDTree.root.putCursorHere(0, 0)
call self._broadcastInitEvent()
endfunction
" FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
function! s:Creator.CreateWindowTree(dir)
let creator = s:Creator.New()
call creator.createWindowTree(a:dir)
endfunction
" FUNCTION: s:Creator.createWindowTree(dir) {{{1
function! s:Creator.createWindowTree(dir)
try
let path = g:NERDTreePath.New(a:dir)
catch /^NERDTree.InvalidArgumentsError/
call nerdtree#echo("Invalid directory name:" . a:name)
return
endtry
"we want the directory buffer to disappear when we do the :edit below
setlocal bufhidden=wipe
let previousBuf = expand("#")
"we need a unique name for each window tree buffer to ensure they are
"all independent
exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName()
call self._createNERDTree(path, "window")
let b:NERDTree._previousBuf = bufnr(previousBuf)
call self._setCommonBufOptions()
call b:NERDTree.render()
call self._broadcastInitEvent()
endfunction
" FUNCTION: s:Creator._createNERDTree(path) {{{1
function! s:Creator._createNERDTree(path, type)
let b:NERDTree = g:NERDTree.New(a:path, a:type)
" TODO: This assignment is kept for compatibility reasons. Many other
" plugins use "b:NERDTreeRoot" instead of "b:NERDTree.root". Remove this
" assignment in the future.
let b:NERDTreeRoot = b:NERDTree.root
call b:NERDTree.root.open()
endfunction
" FUNCTION: s:Creator.CreateMirror() {{{1
function! s:Creator.CreateMirror()
let creator = s:Creator.New()
call creator.createMirror()
endfunction
" FUNCTION: s:Creator.createMirror() {{{1
function! s:Creator.createMirror()
"get the names off all the nerd tree buffers
let treeBufNames = []
for i in range(1, tabpagenr("$"))
let nextName = self._tabpagevar(i, 'NERDTreeBufName')
if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName)
call add(treeBufNames, nextName)
endif
endfor
let treeBufNames = self._uniq(treeBufNames)
"map the option names (that the user will be prompted with) to the nerd
"tree buffer names
let options = {}
let i = 0
while i < len(treeBufNames)
let bufName = treeBufNames[i]
let treeRoot = getbufvar(bufName, "NERDTree").root
let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName
let i = i + 1
endwhile
"work out which tree to mirror, if there is more than 1 then ask the user
let bufferName = ''
if len(keys(options)) > 1
let choices = ["Choose a tree to mirror"]
let choices = extend(choices, sort(keys(options)))
let choice = inputlist(choices)
if choice < 1 || choice > len(options) || choice ==# ''
return
endif
let bufferName = options[sort(keys(options))[choice-1]]
elseif len(keys(options)) ==# 1
let bufferName = values(options)[0]
else
call nerdtree#echo("No trees to mirror")
return
endif
if g:NERDTree.ExistsForTab() && g:NERDTree.IsOpen()
call g:NERDTree.Close()
endif
let t:NERDTreeBufName = bufferName
call self._createTreeWin()
exec 'buffer ' . bufferName
if !&hidden
call b:NERDTree.render()
endif
endfunction
" FUNCTION: s:Creator._createTreeWin() {{{1
" Inits the NERD tree window. ie. opens it, sizes it, sets all the local
" options etc
function! s:Creator._createTreeWin()
"create the nerd tree window
let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright "
let splitSize = g:NERDTreeWinSize
if !exists('t:NERDTreeBufName')
let t:NERDTreeBufName = self._nextBufferName()
silent! exec splitLocation . 'vertical ' . splitSize . ' new'
silent! exec "edit " . t:NERDTreeBufName
else
silent! exec splitLocation . 'vertical ' . splitSize . ' split'
silent! exec "buffer " . t:NERDTreeBufName
endif
setlocal winfixwidth
call self._setCommonBufOptions()
endfunction
" FUNCTION: s:Creator._isBufHidden(nr) {{{1
function! s:Creator._isBufHidden(nr)
redir => bufs
silent ls!
redir END
return bufs =~ a:nr . '..h'
endfunction
" FUNCTION: s:Creator.New() {{{1
function! s:Creator.New()
let newCreator = copy(self)
return newCreator
endfunction
" FUNCTION: s:Creator._nextBufferName() {{{2
" returns the buffer name for the next nerd tree
function! s:Creator._nextBufferName()
let name = s:Creator.BufNamePrefix() . self._nextBufferNumber()
return name
endfunction
" FUNCTION: s:Creator._nextBufferNumber() {{{2
" the number to add to the nerd tree buffer name to make the buf name unique
function! s:Creator._nextBufferNumber()
if !exists("s:Creator._NextBufNum")
let s:Creator._NextBufNum = 1
else
let s:Creator._NextBufNum += 1
endif
return s:Creator._NextBufNum
endfunction
" FUNCTION: s:Creator._pathForString(str) {{{1
" find a bookmark or adirectory for the given string
function! s:Creator._pathForString(str)
let path = {}
if g:NERDTreeBookmark.BookmarkExistsFor(a:str)
let path = g:NERDTreeBookmark.BookmarkFor(a:str).path
else
let dir = a:str ==# '' ? getcwd() : a:str
"hack to get an absolute path if a relative path is given
if dir =~# '^\.'
let dir = getcwd() . g:NERDTreePath.Slash() . dir
endif
let dir = g:NERDTreePath.Resolve(dir)
try
let path = g:NERDTreePath.New(dir)
catch /^NERDTree.InvalidArgumentsError/
call nerdtree#echo("No bookmark or directory found for: " . a:str)
return {}
endtry
endif
if !path.isDirectory
let path = path.getParent()
endif
return path
endfunction
" Function: s:Creator._removeTreeBufForTab() {{{1
function! s:Creator._removeTreeBufForTab()
let buf = bufnr(t:NERDTreeBufName)
"if &hidden is not set then it will already be gone
if buf != -1
"nerdtree buf may be mirrored/displayed elsewhere
if self._isBufHidden(buf)
exec "bwipeout " . buf
endif
endif
unlet t:NERDTreeBufName
endfunction
" FUNCTION: s:Creator._setCommonBufOptions() {{{1
function! s:Creator._setCommonBufOptions()
"throwaway buffer options
setlocal noswapfile
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal nowrap
setlocal foldcolumn=0
setlocal foldmethod=manual
setlocal nofoldenable
setlocal nobuflisted
setlocal nospell
if g:NERDTreeShowLineNumbers
setlocal nu
else
setlocal nonu
if v:version >= 703
setlocal nornu
endif
endif
iabc <buffer>
if g:NERDTreeHighlightCursorline
setlocal cursorline
endif
call self._setupStatusline()
call self._bindMappings()
setlocal filetype=nerdtree
endfunction
" FUNCTION: s:Creator._setupStatusline() {{{1
function! s:Creator._setupStatusline()
if g:NERDTreeStatusline != -1
let &l:statusline = g:NERDTreeStatusline
endif
endfunction
" FUNCTION: s:Creator._tabpagevar(tabnr, var) {{{1
function! s:Creator._tabpagevar(tabnr, var)
let currentTab = tabpagenr()
let old_ei = &ei
set ei=all
exec "tabnext " . a:tabnr
let v = -1
if exists('t:' . a:var)
exec 'let v = t:' . a:var
endif
exec "tabnext " . currentTab
let &ei = old_ei
return v
endfunction
" FUNCTION: s:Creator.ToggleTabTree(dir) {{{1
function! s:Creator.ToggleTabTree(dir)
let creator = s:Creator.New()
call creator.toggleTabTree(a:dir)
endfunction
" FUNCTION: s:Creator.toggleTabTree(dir) {{{1
" Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
" closed it is restored or initialized (if it doesnt exist)
"
" Args:
" dir: the full path for the root node (is only used if the NERD tree is being
" initialized.
function! s:Creator.toggleTabTree(dir)
if g:NERDTree.ExistsForTab()
if !g:NERDTree.IsOpen()
call self._createTreeWin()
if !&hidden
call b:NERDTree.render()
endif
call b:NERDTree.ui.restoreScreenState()
else
call g:NERDTree.Close()
endif
else
call self.createTabTree(a:dir)
endif
endfunction
" Function: s:Creator._uniq(list) {{{1
" returns a:list without duplicates
function! s:Creator._uniq(list)
let uniqlist = []
for elem in a:list
if index(uniqlist, elem) ==# -1
let uniqlist += [elem]
endif
endfor
return uniqlist
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,13 +0,0 @@
"CLASS: Event
"============================================================
let s:Event = {}
let g:NERDTreeEvent = s:Event
function! s:Event.New(nerdtree, subject, action, params) abort
let newObj = copy(self)
let newObj.nerdtree = a:nerdtree
let newObj.subject = a:subject
let newObj.action = a:action
let newObj.params = a:params
return newObj
endfunction

View file

@ -1,56 +0,0 @@
"CLASS: FlagSet
"============================================================
let s:FlagSet = {}
let g:NERDTreeFlagSet = s:FlagSet
"FUNCTION: FlagSet.addFlag(scope, flag) {{{1
function! s:FlagSet.addFlag(scope, flag)
let flags = self._flagsForScope(a:scope)
if index(flags, a:flag) == -1
call add(flags, a:flag)
end
endfunction
"FUNCTION: FlagSet.clearFlags(scope) {{{1
function! s:FlagSet.clearFlags(scope)
let self._flags[a:scope] = []
endfunction
"FUNCTION: FlagSet._flagsForScope(scope) {{{1
function! s:FlagSet._flagsForScope(scope)
if !has_key(self._flags, a:scope)
let self._flags[a:scope] = []
endif
return self._flags[a:scope]
endfunction
"FUNCTION: FlagSet.New() {{{1
function! s:FlagSet.New()
let newObj = copy(self)
let newObj._flags = {}
return newObj
endfunction
"FUNCTION: FlagSet.removeFlag(scope, flag) {{{1
function! s:FlagSet.removeFlag(scope, flag)
let flags = self._flagsForScope(a:scope)
let i = index(flags, a:flag)
if i >= 0
call remove(flags, i)
endif
endfunction
"FUNCTION: FlagSet.renderToString() {{{1
function! s:FlagSet.renderToString()
let flagstring = ""
for i in values(self._flags)
let flagstring .= join(i)
endfor
if len(flagstring) == 0
return ""
endif
return '[' . flagstring . ']'
endfunction

View file

@ -1,159 +0,0 @@
"CLASS: KeyMap
"============================================================
let s:KeyMap = {}
let g:NERDTreeKeyMap = s:KeyMap
"FUNCTION: KeyMap.All() {{{1
function! s:KeyMap.All()
if !exists("s:keyMaps")
let s:keyMaps = []
endif
return s:keyMaps
endfunction
"FUNCTION: KeyMap.FindFor(key, scope) {{{1
function! s:KeyMap.FindFor(key, scope)
for i in s:KeyMap.All()
if i.key ==# a:key && i.scope ==# a:scope
return i
endif
endfor
return {}
endfunction
"FUNCTION: KeyMap.BindAll() {{{1
function! s:KeyMap.BindAll()
for i in s:KeyMap.All()
call i.bind()
endfor
endfunction
"FUNCTION: KeyMap.bind() {{{1
function! s:KeyMap.bind()
" If the key sequence we're trying to map contains any '<>' notation, we
" must replace each of the '<' characters with '<lt>' to ensure the string
" is not translated into its corresponding keycode during the later part
" of the map command below
" :he <>
let specialNotationRegex = '\m<\([[:alnum:]_-]\+>\)'
if self.key =~# specialNotationRegex
let keymapInvokeString = substitute(self.key, specialNotationRegex, '<lt>\1', 'g')
else
let keymapInvokeString = self.key
endif
let premap = self.key == "<LeftRelease>" ? " <LeftRelease>" : " "
exec 'nnoremap <buffer> <silent> '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")<cr>'
endfunction
"FUNCTION: KeyMap.Remove(key, scope) {{{1
function! s:KeyMap.Remove(key, scope)
let maps = s:KeyMap.All()
for i in range(len(maps))
if maps[i].key ==# a:key && maps[i].scope ==# a:scope
return remove(maps, i)
endif
endfor
endfunction
"FUNCTION: KeyMap.invoke() {{{1
"Call the KeyMaps callback function
function! s:KeyMap.invoke(...)
let Callback = function(self.callback)
if a:0
call Callback(a:1)
else
call Callback()
endif
endfunction
"FUNCTION: KeyMap.Invoke() {{{1
"Find a keymapping for a:key and the current scope invoke it.
"
"Scope is determined as follows:
" * if the cursor is on a dir node then "DirNode"
" * if the cursor is on a file node then "FileNode"
" * if the cursor is on a bookmark then "Bookmark"
"
"If a keymap has the scope of "all" then it will be called if no other keymap
"is found for a:key and the scope.
function! s:KeyMap.Invoke(key)
"required because clicking the command window below another window still
"invokes the <LeftRelease> mapping - but changes the window cursor
"is in first
"
"TODO: remove this check when the vim bug is fixed
if !g:NERDTree.ExistsForBuf()
return {}
endif
let node = g:NERDTreeFileNode.GetSelected()
if !empty(node)
"try file node
if !node.path.isDirectory
let km = s:KeyMap.FindFor(a:key, "FileNode")
if !empty(km)
return km.invoke(node)
endif
endif
"try dir node
if node.path.isDirectory
let km = s:KeyMap.FindFor(a:key, "DirNode")
if !empty(km)
return km.invoke(node)
endif
endif
"try generic node
let km = s:KeyMap.FindFor(a:key, "Node")
if !empty(km)
return km.invoke(node)
endif
endif
"try bookmark
let bm = g:NERDTreeBookmark.GetSelected()
if !empty(bm)
let km = s:KeyMap.FindFor(a:key, "Bookmark")
if !empty(km)
return km.invoke(bm)
endif
endif
"try all
let km = s:KeyMap.FindFor(a:key, "all")
if !empty(km)
return km.invoke()
endif
endfunction
"FUNCTION: KeyMap.Create(options) {{{1
function! s:KeyMap.Create(options)
let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options))
"dont override other mappings unless the 'override' option is given
if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope']))
return
end
let newKeyMap = copy(self)
let newKeyMap.key = opts['key']
let newKeyMap.quickhelpText = opts['quickhelpText']
let newKeyMap.callback = opts['callback']
let newKeyMap.scope = opts['scope']
call s:KeyMap.Add(newKeyMap)
endfunction
"FUNCTION: KeyMap.Add(keymap) {{{1
function! s:KeyMap.Add(keymap)
call s:KeyMap.Remove(a:keymap.key, a:keymap.scope)
call add(s:KeyMap.All(), a:keymap)
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,180 +0,0 @@
"CLASS: MenuController
"============================================================
let s:MenuController = {}
let g:NERDTreeMenuController = s:MenuController
"FUNCTION: MenuController.New(menuItems) {{{1
"create a new menu controller that operates on the given menu items
function! s:MenuController.New(menuItems)
let newMenuController = copy(self)
if a:menuItems[0].isSeparator()
let newMenuController.menuItems = a:menuItems[1:-1]
else
let newMenuController.menuItems = a:menuItems
endif
return newMenuController
endfunction
"FUNCTION: MenuController.showMenu() {{{1
"start the main loop of the menu and get the user to choose/execute a menu
"item
function! s:MenuController.showMenu()
call self._saveOptions()
try
let self.selection = 0
let done = 0
while !done
redraw!
call self._echoPrompt()
let key = nr2char(getchar())
let done = self._handleKeypress(key)
endwhile
finally
call self._restoreOptions()
endtry
if self.selection != -1
let m = self._current()
call m.execute()
endif
endfunction
"FUNCTION: MenuController._echoPrompt() {{{1
function! s:MenuController._echoPrompt()
echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated"
echo "=========================================================="
for i in range(0, len(self.menuItems)-1)
if self.selection == i
echo "> " . self.menuItems[i].text
else
echo " " . self.menuItems[i].text
endif
endfor
endfunction
"FUNCTION: MenuController._current(key) {{{1
"get the MenuItem that is currently selected
function! s:MenuController._current()
return self.menuItems[self.selection]
endfunction
"FUNCTION: MenuController._handleKeypress(key) {{{1
"change the selection (if appropriate) and return 1 if the user has made
"their choice, 0 otherwise
function! s:MenuController._handleKeypress(key)
if a:key == 'j'
call self._cursorDown()
elseif a:key == 'k'
call self._cursorUp()
elseif a:key == nr2char(27) "escape
let self.selection = -1
return 1
elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j
return 1
else
let index = self._nextIndexFor(a:key)
if index != -1
let self.selection = index
if len(self._allIndexesFor(a:key)) == 1
return 1
endif
endif
endif
return 0
endfunction
"FUNCTION: MenuController._allIndexesFor(shortcut) {{{1
"get indexes to all menu items with the given shortcut
function! s:MenuController._allIndexesFor(shortcut)
let toReturn = []
for i in range(0, len(self.menuItems)-1)
if self.menuItems[i].shortcut == a:shortcut
call add(toReturn, i)
endif
endfor
return toReturn
endfunction
"FUNCTION: MenuController._nextIndexFor(shortcut) {{{1
"get the index to the next menu item with the given shortcut, starts from the
"current cursor location and wraps around to the top again if need be
function! s:MenuController._nextIndexFor(shortcut)
for i in range(self.selection+1, len(self.menuItems)-1)
if self.menuItems[i].shortcut == a:shortcut
return i
endif
endfor
for i in range(0, self.selection)
if self.menuItems[i].shortcut == a:shortcut
return i
endif
endfor
return -1
endfunction
"FUNCTION: MenuController._setCmdheight() {{{1
"sets &cmdheight to whatever is needed to display the menu
function! s:MenuController._setCmdheight()
let &cmdheight = len(self.menuItems) + 3
endfunction
"FUNCTION: MenuController._saveOptions() {{{1
"set any vim options that are required to make the menu work (saving their old
"values)
function! s:MenuController._saveOptions()
let self._oldLazyredraw = &lazyredraw
let self._oldCmdheight = &cmdheight
set nolazyredraw
call self._setCmdheight()
endfunction
"FUNCTION: MenuController._restoreOptions() {{{1
"restore the options we saved in _saveOptions()
function! s:MenuController._restoreOptions()
let &cmdheight = self._oldCmdheight
let &lazyredraw = self._oldLazyredraw
endfunction
"FUNCTION: MenuController._cursorDown() {{{1
"move the cursor to the next menu item, skipping separators
function! s:MenuController._cursorDown()
let done = 0
while !done
if self.selection < len(self.menuItems)-1
let self.selection += 1
else
let self.selection = 0
endif
if !self._current().isSeparator()
let done = 1
endif
endwhile
endfunction
"FUNCTION: MenuController._cursorUp() {{{1
"move the cursor to the previous menu item, skipping separators
function! s:MenuController._cursorUp()
let done = 0
while !done
if self.selection > 0
let self.selection -= 1
else
let self.selection = len(self.menuItems)-1
endif
if !self._current().isSeparator()
let done = 1
endif
endwhile
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,114 +0,0 @@
"CLASS: MenuItem
"============================================================
let s:MenuItem = {}
let g:NERDTreeMenuItem = s:MenuItem
"FUNCTION: MenuItem.All() {{{1
"get all top level menu items
function! s:MenuItem.All()
if !exists("s:menuItems")
let s:menuItems = []
endif
return s:menuItems
endfunction
"FUNCTION: MenuItem.AllEnabled() {{{1
"get all top level menu items that are currently enabled
function! s:MenuItem.AllEnabled()
let toReturn = []
for i in s:MenuItem.All()
if i.enabled()
call add(toReturn, i)
endif
endfor
return toReturn
endfunction
"FUNCTION: MenuItem.Create(options) {{{1
"make a new menu item and add it to the global list
function! s:MenuItem.Create(options)
let newMenuItem = copy(self)
let newMenuItem.text = a:options['text']
let newMenuItem.shortcut = a:options['shortcut']
let newMenuItem.children = []
let newMenuItem.isActiveCallback = -1
if has_key(a:options, 'isActiveCallback')
let newMenuItem.isActiveCallback = a:options['isActiveCallback']
endif
let newMenuItem.callback = -1
if has_key(a:options, 'callback')
let newMenuItem.callback = a:options['callback']
endif
if has_key(a:options, 'parent')
call add(a:options['parent'].children, newMenuItem)
else
call add(s:MenuItem.All(), newMenuItem)
endif
return newMenuItem
endfunction
"FUNCTION: MenuItem.CreateSeparator(options) {{{1
"make a new separator menu item and add it to the global list
function! s:MenuItem.CreateSeparator(options)
let standard_options = { 'text': '--------------------',
\ 'shortcut': -1,
\ 'callback': -1 }
let options = extend(a:options, standard_options, "force")
return s:MenuItem.Create(options)
endfunction
"FUNCTION: MenuItem.CreateSubmenu(options) {{{1
"make a new submenu and add it to global list
function! s:MenuItem.CreateSubmenu(options)
let standard_options = { 'callback': -1 }
let options = extend(a:options, standard_options, "force")
return s:MenuItem.Create(options)
endfunction
"FUNCTION: MenuItem.enabled() {{{1
"return 1 if this menu item should be displayed
"
"delegates off to the isActiveCallback, and defaults to 1 if no callback was
"specified
function! s:MenuItem.enabled()
if self.isActiveCallback != -1
return {self.isActiveCallback}()
endif
return 1
endfunction
"FUNCTION: MenuItem.execute() {{{1
"perform the action behind this menu item, if this menuitem has children then
"display a new menu for them, otherwise deletegate off to the menuitem's
"callback
function! s:MenuItem.execute()
if len(self.children)
let mc = g:NERDTreeMenuController.New(self.children)
call mc.showMenu()
else
if self.callback != -1
call {self.callback}()
endif
endif
endfunction
"FUNCTION: MenuItem.isSeparator() {{{1
"return 1 if this menuitem is a separator
function! s:MenuItem.isSeparator()
return self.callback == -1 && self.children == []
endfunction
"FUNCTION: MenuItem.isSubmenu() {{{1
"return 1 if this menuitem is a submenu
function! s:MenuItem.isSubmenu()
return self.callback == -1 && !empty(self.children)
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,197 +0,0 @@
"CLASS: NERDTree
"============================================================
let s:NERDTree = {}
let g:NERDTree = s:NERDTree
"FUNCTION: s:NERDTree.AddPathFilter() {{{1
function! s:NERDTree.AddPathFilter(callback)
call add(s:NERDTree.PathFilters(), a:callback)
endfunction
"FUNCTION: s:NERDTree.changeRoot(node) {{{1
function! s:NERDTree.changeRoot(node)
if a:node.path.isDirectory
let self.root = a:node
else
call a:node.cacheParent()
let self.root = a:node.parent
endif
call self.root.open()
"change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode ==# 2
call self.root.path.changeToDir()
endif
call self.render()
call self.root.putCursorHere(0, 0)
silent doautocmd User NERDTreeNewRoot
endfunction
"FUNCTION: s:NERDTree.Close() {{{1
"Closes the tab tree window for this tab
function! s:NERDTree.Close()
if !s:NERDTree.IsOpen()
return
endif
if winnr("$") != 1
if winnr() == s:NERDTree.GetWinNum()
call nerdtree#exec("wincmd p")
let bufnr = bufnr("")
call nerdtree#exec("wincmd p")
else
let bufnr = bufnr("")
endif
call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w")
close
call nerdtree#exec(bufwinnr(bufnr) . " wincmd w")
else
close
endif
endfunction
"FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1
"Closes the NERD tree window if the close on open option is set
function! s:NERDTree.CloseIfQuitOnOpen()
if g:NERDTreeQuitOnOpen && s:NERDTree.IsOpen()
call s:NERDTree.Close()
endif
endfunction
"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1
"Places the cursor at the top of the bookmarks table
function! s:NERDTree.CursorToBookmarkTable()
if !b:NERDTree.ui.getShowBookmarks()
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: s:NERDTree.CursorToTreeWin(){{{1
"Places the cursor in the nerd tree window
function! s:NERDTree.CursorToTreeWin()
call g:NERDTree.MustBeOpen()
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
endfunction
" Function: s:NERDTree.ExistsForBuffer() {{{1
" Returns 1 if a nerd tree root exists in the current buffer
function! s:NERDTree.ExistsForBuf()
return exists("b:NERDTree")
endfunction
" Function: s:NERDTree.ExistsForTab() {{{1
" Returns 1 if a nerd tree root exists in the current tab
function! s:NERDTree.ExistsForTab()
if !exists("t:NERDTreeBufName")
return
end
"check b:NERDTree is still there and hasn't been e.g. :bdeleted
return !empty(getbufvar(bufnr(t:NERDTreeBufName), 'NERDTree'))
endfunction
function! s:NERDTree.ForCurrentBuf()
if s:NERDTree.ExistsForBuf()
return b:NERDTree
else
return {}
endif
endfunction
"FUNCTION: s:NERDTree.ForCurrentTab() {{{1
function! s:NERDTree.ForCurrentTab()
if !s:NERDTree.ExistsForTab()
return
endif
let bufnr = bufnr(t:NERDTreeBufName)
return getbufvar(bufnr, "NERDTree")
endfunction
"FUNCTION: s:NERDTree.getRoot() {{{1
function! s:NERDTree.getRoot()
return self.root
endfunction
"FUNCTION: s:NERDTree.GetWinNum() {{{1
"gets the nerd tree window number for this tab
function! s:NERDTree.GetWinNum()
if exists("t:NERDTreeBufName")
return bufwinnr(t:NERDTreeBufName)
endif
return -1
endfunction
"FUNCTION: s:NERDTree.IsOpen() {{{1
function! s:NERDTree.IsOpen()
return s:NERDTree.GetWinNum() != -1
endfunction
"FUNCTION: s:NERDTree.isTabTree() {{{1
function! s:NERDTree.isTabTree()
return self._type == "tab"
endfunction
"FUNCTION: s:NERDTree.isWinTree() {{{1
function! s:NERDTree.isWinTree()
return self._type == "window"
endfunction
"FUNCTION: s:NERDTree.MustBeOpen() {{{1
function! s:NERDTree.MustBeOpen()
if !s:NERDTree.IsOpen()
throw "NERDTree.TreeNotOpen"
endif
endfunction
"FUNCTION: s:NERDTree.New() {{{1
function! s:NERDTree.New(path, type)
let newObj = copy(self)
let newObj.ui = g:NERDTreeUI.New(newObj)
let newObj.root = g:NERDTreeDirNode.New(a:path, newObj)
let newObj._type = a:type
return newObj
endfunction
"FUNCTION: s:NERDTree.PathFilters() {{{1
function! s:NERDTree.PathFilters()
if !exists('s:NERDTree._PathFilters')
let s:NERDTree._PathFilters = []
endif
return s:NERDTree._PathFilters
endfunction
"FUNCTION: s:NERDTree.previousBuf() {{{1
function! s:NERDTree.previousBuf()
return self._previousBuf
endfunction
function! s:NERDTree.setPreviousBuf(bnum)
let self._previousBuf = a:bnum
endfunction
"FUNCTION: s:NERDTree.render() {{{1
"A convenience function - since this is called often
function! s:NERDTree.render()
call self.ui.render()
endfunction

View file

@ -1,35 +0,0 @@
"CLASS: Notifier
"============================================================
let s:Notifier = {}
function! s:Notifier.AddListener(event, funcname)
let listeners = s:Notifier.GetListenersForEvent(a:event)
if listeners == []
let listenersMap = s:Notifier.GetListenersMap()
let listenersMap[a:event] = listeners
endif
call add(listeners, a:funcname)
endfunction
function! s:Notifier.NotifyListeners(event, path, nerdtree, params)
let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params)
for listener in s:Notifier.GetListenersForEvent(a:event)
call {listener}(event)
endfor
endfunction
function! s:Notifier.GetListenersMap()
if !exists("s:refreshListenersMap")
let s:refreshListenersMap = {}
endif
return s:refreshListenersMap
endfunction
function! s:Notifier.GetListenersForEvent(name)
let listenersMap = s:Notifier.GetListenersMap()
return get(listenersMap, a:name, [])
endfunction
let g:NERDTreePathNotifier = deepcopy(s:Notifier)

View file

@ -1,350 +0,0 @@
" ============================================================================
" CLASS: Opener
"
" The Opener class defines an API for "opening" operations.
" ============================================================================
let s:Opener = {}
let g:NERDTreeOpener = s:Opener
" FUNCTION: s:Opener._bufInWindows(bnum) {{{1
" [[STOLEN FROM VTREEEXPLORER.VIM]]
" Determine the number of windows open to this buffer number.
" Care of Yegappan Lakshman. Thanks!
"
" Args:
" bnum: the subject buffers buffer number
function! s:Opener._bufInWindows(bnum)
let cnt = 0
let winnum = 1
while 1
let bufnum = winbufnr(winnum)
if bufnum < 0
break
endif
if bufnum ==# a:bnum
let cnt = cnt + 1
endif
let winnum = winnum + 1
endwhile
return cnt
endfunction
" FUNCTION: Opener._checkToCloseTree(newtab) {{{1
" Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see
" if the tree should be closed now.
"
" Args:
" a:newtab - boolean. If set, only close the tree now if we are opening the
" target in a new tab. This is needed because we have to close tree before we
" leave the tab
function! s:Opener._checkToCloseTree(newtab)
if self._keepopen
return
endif
if (a:newtab && self._where == 't') || !a:newtab
call g:NERDTree.CloseIfQuitOnOpen()
endif
endfunction
" FUNCTION: s:Opener._firstUsableWindow() {{{1
" find the window number of the first normal window
function! s:Opener._firstUsableWindow()
let i = 1
while i <= winnr("$")
let bnum = winbufnr(i)
if bnum != -1 && getbufvar(bnum, '&buftype') ==# ''
\ && !getwinvar(i, '&previewwindow')
\ && (!getbufvar(bnum, '&modified') || &hidden)
return i
endif
let i += 1
endwhile
return -1
endfunction
" FUNCTION: Opener._gotoTargetWin() {{{1
function! s:Opener._gotoTargetWin()
if b:NERDTree.isWinTree()
if self._where == 'v'
vsplit
elseif self._where == 'h'
split
elseif self._where == 't'
tabnew
endif
else
call self._checkToCloseTree(1)
if self._where == 'v'
call self._newVSplit()
elseif self._where == 'h'
call self._newSplit()
elseif self._where == 't'
tabnew
elseif self._where == 'p'
call self._previousWindow()
endif
call self._checkToCloseTree(0)
endif
endfunction
" FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1
" Returns 0 if opening a file from the tree in the given window requires it to
" be split, 1 otherwise
"
" Args:
" winnumber: the number of the window in question
function! s:Opener._isWindowUsable(winnumber)
"gotta split if theres only one window (i.e. the NERD tree)
if winnr("$") ==# 1
return 0
endif
let oldwinnr = winnr()
call nerdtree#exec(a:winnumber . "wincmd p")
let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
let modified = &modified
call nerdtree#exec(oldwinnr . "wincmd p")
"if its a special window e.g. quickfix or another explorer plugin then we
"have to split
if specialWindow
return 0
endif
if &hidden
return 1
endif
return !modified || self._bufInWindows(winbufnr(a:winnumber)) >= 2
endfunction
" FUNCTION: Opener.New(path, opts) {{{1
" Instantiate a new NERDTreeOpener object.
" Args:
" a:path: the path object that is to be opened
" a:opts: a dictionary containing the following optional keys...
" 'where': specifies whether the node should be opened in new split, in
" a new tab or, in the last window; takes values "v", "h", or "t"
" 'reuse': if file is already shown in a window, jump there; takes values
" "all", "currenttab", or empty
" 'keepopen': boolean (0 or 1); if true, the tree window will not be closed
" 'stay': boolean (0 or 1); if true, remain in tree window after opening
function! s:Opener.New(path, opts)
let l:newOpener = copy(self)
let l:newOpener._keepopen = nerdtree#has_opt(a:opts, 'keepopen')
let l:newOpener._nerdtree = b:NERDTree
let l:newOpener._path = a:path
let l:newOpener._reuse = has_key(a:opts, 'reuse') ? a:opts['reuse'] : ''
let l:newOpener._stay = nerdtree#has_opt(a:opts, 'stay')
let l:newOpener._where = has_key(a:opts, 'where') ? a:opts['where'] : ''
call l:newOpener._saveCursorPos()
return l:newOpener
endfunction
" FUNCTION: Opener._newSplit() {{{1
function! s:Opener._newSplit()
" Save the user's settings for splitbelow and splitright
let savesplitbelow=&splitbelow
let savesplitright=&splitright
" 'there' will be set to a command to move from the split window
" back to the explorer window
"
" 'back' will be set to a command to move from the explorer window
" back to the newly split window
"
" 'right' and 'below' will be set to the settings needed for
" splitbelow and splitright IF the explorer is the only window.
"
let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l"
let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h"
let right= g:NERDTreeWinPos ==# "left"
let below=0
" Attempt to go to adjacent window
call nerdtree#exec(back)
let onlyOneWin = (winnr("$") ==# 1)
" If no adjacent window, set splitright and splitbelow appropriately
if onlyOneWin
let &splitright=right
let &splitbelow=below
else
" found adjacent window - invert split direction
let &splitright=!right
let &splitbelow=!below
endif
let splitMode = onlyOneWin ? "vertical" : ""
" Open the new window
try
exec(splitMode." sp ")
catch /^Vim\%((\a\+)\)\=:E37/
call g:NERDTree.CursorToTreeWin()
throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified."
catch /^Vim\%((\a\+)\)\=:/
"do nothing
endtry
"resize the tree window if no other window was open before
if onlyOneWin
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
call nerdtree#exec(there)
exec("silent ". splitMode ." resize ". size)
call nerdtree#exec('wincmd p')
endif
" Restore splitmode settings
let &splitbelow=savesplitbelow
let &splitright=savesplitright
endfunction
" FUNCTION: Opener._newVSplit() {{{1
function! s:Opener._newVSplit()
let l:winwidth = winwidth('.')
if winnr('$') == 1
let l:winwidth = g:NERDTreeWinSize
endif
call nerdtree#exec('wincmd p')
vnew
let l:currentWindowNumber = winnr()
" Restore the NERDTree to its original width.
call g:NERDTree.CursorToTreeWin()
execute 'silent vertical resize ' . l:winwidth
call nerdtree#exec(l:currentWindowNumber . 'wincmd w')
endfunction
" FUNCTION: Opener.open(target) {{{1
function! s:Opener.open(target)
if self._path.isDirectory
call self._openDirectory(a:target)
return
endif
call self._openFile()
endfunction
" FUNCTION: Opener._openFile() {{{1
function! s:Opener._openFile()
if self._reuseWindow()
return
endif
call self._gotoTargetWin()
if self._stay
silent call self._path.edit()
call self._restoreCursorPos()
return
endif
call self._path.edit()
endfunction
" FUNCTION: Opener._openDirectory(node) {{{1
function! s:Opener._openDirectory(node)
call self._gotoTargetWin()
if self._nerdtree.isWinTree()
call g:NERDTreeCreator.CreateWindowTree(a:node.path.str())
else
if empty(self._where)
call b:NERDTree.changeRoot(a:node)
elseif self._where == 't'
call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
else
call g:NERDTreeCreator.CreateWindowTree(a:node.path.str())
endif
endif
if self._stay
call self._restoreCursorPos()
endif
endfunction
" FUNCTION: Opener._previousWindow() {{{1
function! s:Opener._previousWindow()
if !self._isWindowUsable(winnr("#")) && self._firstUsableWindow() ==# -1
call self._newSplit()
else
try
if !self._isWindowUsable(winnr("#"))
call nerdtree#exec(self._firstUsableWindow() . "wincmd w")
else
call nerdtree#exec('wincmd p')
endif
catch /^Vim\%((\a\+)\)\=:E37/
call g:NERDTree.CursorToTreeWin()
throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified."
catch /^Vim\%((\a\+)\)\=:/
echo v:exception
endtry
endif
endfunction
" FUNCTION: Opener._restoreCursorPos() {{{1
function! s:Opener._restoreCursorPos()
call nerdtree#exec('normal ' . self._tabnr . 'gt')
call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w')
endfunction
" FUNCTION: Opener._reuseWindow() {{{1
" put the cursor in the first window we find for this file
"
" return 1 if we were successful
function! s:Opener._reuseWindow()
if empty(self._reuse)
return 0
endif
"check the current tab for the window
let winnr = bufwinnr('^' . self._path.str() . '$')
if winnr != -1
call nerdtree#exec(winnr . "wincmd w")
call self._checkToCloseTree(0)
return 1
endif
if self._reuse == 'currenttab'
return 0
endif
"check other tabs
let tabnr = self._path.tabnr()
if tabnr
call self._checkToCloseTree(1)
call nerdtree#exec('normal! ' . tabnr . 'gt')
let winnr = bufwinnr('^' . self._path.str() . '$')
call nerdtree#exec(winnr . "wincmd w")
return 1
endif
return 0
endfunction
" FUNCTION: Opener._saveCursorPos() {{{1
function! s:Opener._saveCursorPos()
let self._bufnr = bufnr("")
let self._tabnr = tabpagenr()
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,827 +0,0 @@
" ============================================================================
" CLASS: Path
"
" The Path class provides an abstracted representation of a file system
" pathname. Various operations on pathnames are provided and a number of
" representations of a given path name can be accessed here.
" ============================================================================
" This constant is used throughout this script for sorting purposes.
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
lockvar s:NERDTreeSortStarIndex
let s:Path = {}
let g:NERDTreePath = s:Path
" FUNCTION: Path.AbsolutePathFor(str) {{{1
function! s:Path.AbsolutePathFor(str)
let prependCWD = 0
if nerdtree#runningWindows()
let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)'
else
let prependCWD = a:str !~# '^/'
endif
let toReturn = a:str
if prependCWD
let toReturn = getcwd() . s:Path.Slash() . a:str
endif
return toReturn
endfunction
" FUNCTION: Path.bookmarkNames() {{{1
function! s:Path.bookmarkNames()
if !exists("self._bookmarkNames")
call self.cacheDisplayString()
endif
return self._bookmarkNames
endfunction
" FUNCTION: Path.cacheDisplayString() {{{1
function! s:Path.cacheDisplayString() abort
let self.cachedDisplayString = self.getLastPathComponent(1)
if self.isExecutable
let self.cachedDisplayString = self.cachedDisplayString . '*'
endif
let self._bookmarkNames = []
for i in g:NERDTreeBookmark.Bookmarks()
if i.path.equals(self)
call add(self._bookmarkNames, i.name)
endif
endfor
if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1
let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}'
endif
if self.isSymLink
let self.cachedDisplayString .= ' -> ' . self.symLinkDest
endif
if self.isReadOnly
let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']'
endif
endfunction
" FUNCTION: Path.changeToDir() {{{1
function! s:Path.changeToDir()
let dir = self.str({'format': 'Cd'})
if self.isDirectory ==# 0
let dir = self.getParent().str({'format': 'Cd'})
endif
try
execute "cd " . dir
call nerdtree#echo("CWD is now: " . getcwd())
catch
throw "NERDTree.PathChangeError: cannot change CWD to " . dir
endtry
endfunction
" FUNCTION: Path.compareTo() {{{1
"
" Compares this Path to the given path and returns 0 if they are equal, -1 if
" this Path is "less than" the given path, or 1 if it is "greater".
"
" Args:
" path: the path object to compare this to
"
" Return:
" 1, -1 or 0
function! s:Path.compareTo(path)
let thisPath = self.getLastPathComponent(1)
let thatPath = a:path.getLastPathComponent(1)
"if the paths are the same then clearly we return 0
if thisPath ==# thatPath
return 0
endif
let thisSS = self.getSortOrderIndex()
let thatSS = a:path.getSortOrderIndex()
"compare the sort sequences, if they are different then the return
"value is easy
if thisSS < thatSS
return -1
elseif thisSS > thatSS
return 1
else
if !g:NERDTreeSortHiddenFirst
let thisPath = substitute(thisPath, '^[._]', '', '')
let thatPath = substitute(thatPath, '^[._]', '', '')
endif
"if the sort sequences are the same then compare the paths
"alphabetically
let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath <? thatPath
if pathCompare
return -1
else
return 1
endif
endif
endfunction
" FUNCTION: Path.Create(fullpath) {{{1
"
" Factory method.
"
" Creates a path object with the given path. The path is also created on the
" filesystem. If the path already exists, a NERDTree.Path.Exists exception is
" thrown. If any other errors occur, a NERDTree.Path exception is thrown.
"
" Args:
" fullpath: the full filesystem path to the file/dir to create
function! s:Path.Create(fullpath)
"bail if the a:fullpath already exists
if isdirectory(a:fullpath) || filereadable(a:fullpath)
throw "NERDTree.CreatePathError: Directory Exists: '" . a:fullpath . "'"
endif
try
"if it ends with a slash, assume its a dir create it
if a:fullpath =~# '\(\\\|\/\)$'
"whack the trailing slash off the end if it exists
let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '')
call mkdir(fullpath, 'p')
"assume its a file and create
else
call s:Path.createParentDirectories(a:fullpath)
call writefile([], a:fullpath)
endif
catch
throw "NERDTree.CreatePathError: Could not create path: '" . a:fullpath . "'"
endtry
return s:Path.New(a:fullpath)
endfunction
" FUNCTION: Path.copy(dest) {{{1
"
" Copies the file/dir represented by this Path to the given location
"
" Args:
" dest: the location to copy this dir/file to
function! s:Path.copy(dest)
if !s:Path.CopyingSupported()
throw "NERDTree.CopyingNotSupportedError: Copying is not supported on this OS"
endif
call s:Path.createParentDirectories(a:dest)
if exists('g:NERDTreeCopyCmd')
let cmd_prefix = g:NERDTreeCopyCmd
else
let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd)
endif
let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(a:dest, self._escChars())
let success = system(cmd)
if v:shell_error != 0
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
endif
endfunction
" FUNCTION: Path.CopyingSupported() {{{1
"
" returns 1 if copying is supported for this OS
function! s:Path.CopyingSupported()
return exists('g:NERDTreeCopyCmd') || (exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd'))
endfunction
" FUNCTION: Path.copyingWillOverwrite(dest) {{{1
"
" returns 1 if copy this path to the given location will cause files to
" overwritten
"
" Args:
" dest: the location this path will be copied to
function! s:Path.copyingWillOverwrite(dest)
if filereadable(a:dest)
return 1
endif
if isdirectory(a:dest)
let path = s:Path.JoinPathStrings(a:dest, self.getLastPathComponent(0))
if filereadable(path)
return 1
endif
endif
endfunction
" FUNCTION: Path.createParentDirectories(path) {{{1
"
" create parent directories for this path if needed
" without throwing any errors if those directories already exist
"
" Args:
" path: full path of the node whose parent directories may need to be created
function! s:Path.createParentDirectories(path)
let dir_path = fnamemodify(a:path, ':h')
if !isdirectory(dir_path)
call mkdir(dir_path, 'p')
endif
endfunction
" FUNCTION: Path.delete() {{{1
"
" Deletes the file or directory represented by this path.
"
" Throws NERDTree.Path.Deletion exceptions
function! s:Path.delete()
if self.isDirectory
let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1})
let success = system(cmd)
if v:shell_error != 0
throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'"
endif
else
let success = delete(self.str())
if success != 0
throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'"
endif
endif
"delete all bookmarks for this path
for i in self.bookmarkNames()
let bookmark = g:NERDTreeBookmark.BookmarkFor(i)
call bookmark.delete()
endfor
endfunction
" FUNCTION: Path.displayString() {{{1
"
" Returns a string that specifies how the path should be represented as a
" string
function! s:Path.displayString()
if self.cachedDisplayString ==# ""
call self.cacheDisplayString()
endif
return self.cachedDisplayString
endfunction
" FUNCTION: Path.edit() {{{1
function! s:Path.edit()
exec "edit " . self.str({'format': 'Edit'})
endfunction
" FUNCTION: Path.extractDriveLetter(fullpath) {{{1
"
" If running windows, cache the drive letter for this path
function! s:Path.extractDriveLetter(fullpath)
if nerdtree#runningWindows()
if a:fullpath =~ '^\(\\\\\|\/\/\)'
"For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share
let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '')
let self.drive = substitute(self.drive, '/', '\', "g")
else
let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '')
endif
else
let self.drive = ''
endif
endfunction
" FUNCTION: Path.exists() {{{1
" return 1 if this path points to a location that is readable or is a directory
function! s:Path.exists()
let p = self.str()
return filereadable(p) || isdirectory(p)
endfunction
" FUNCTION: Path._escChars() {{{1
function! s:Path._escChars()
if nerdtree#runningWindows()
return " `\|\"#%&,?()\*^<>$"
endif
return " \\`\|\"#%&,?()\*^<>[]$"
endfunction
" FUNCTION: Path.getDir() {{{1
"
" Returns this path if it is a directory, else this paths parent.
"
" Return:
" a Path object
function! s:Path.getDir()
if self.isDirectory
return self
else
return self.getParent()
endif
endfunction
" FUNCTION: Path.getParent() {{{1
"
" Returns a new path object for this paths parent
"
" Return:
" a new Path object
function! s:Path.getParent()
if nerdtree#runningWindows()
let path = self.drive . '\' . join(self.pathSegments[0:-2], '\')
else
let path = '/'. join(self.pathSegments[0:-2], '/')
endif
return s:Path.New(path)
endfunction
" FUNCTION: Path.getLastPathComponent(dirSlash) {{{1
"
" Gets the last part of this path.
"
" Args:
" dirSlash: if 1 then a trailing slash will be added to the returned value for
" directory nodes.
function! s:Path.getLastPathComponent(dirSlash)
if empty(self.pathSegments)
return ''
endif
let toReturn = self.pathSegments[-1]
if a:dirSlash && self.isDirectory
let toReturn = toReturn . '/'
endif
return toReturn
endfunction
" FUNCTION: Path.getSortOrderIndex() {{{1
" returns the index of the pattern in g:NERDTreeSortOrder that this path matches
function! s:Path.getSortOrderIndex()
let i = 0
while i < len(g:NERDTreeSortOrder)
if self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i]
return i
endif
let i = i + 1
endwhile
return s:NERDTreeSortStarIndex
endfunction
" FUNCTION: Path._splitChunks(path) {{{1
" returns a list of path chunks
function! s:Path._splitChunks(path)
let chunks = split(a:path, '\(\D\+\|\d\+\)\zs')
let i = 0
while i < len(chunks)
"convert number literals to numbers
if match(chunks[i], '^\d\+$') == 0
let chunks[i] = str2nr(chunks[i])
endif
let i = i + 1
endwhile
return chunks
endfunction
" FUNCTION: Path.getSortKey() {{{1
" returns a key used in compare function for sorting
function! s:Path.getSortKey()
if !exists("self._sortKey")
let path = self.getLastPathComponent(1)
if !g:NERDTreeSortHiddenFirst
let path = substitute(path, '^[._]', '', '')
endif
if !g:NERDTreeCaseSensitiveSort
let path = tolower(path)
endif
if !g:NERDTreeNaturalSort
let self._sortKey = [self.getSortOrderIndex(), path]
else
let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path)
endif
endif
return self._sortKey
endfunction
" FUNCTION: Path.isUnixHiddenFile() {{{1
" check for unix hidden files
function! s:Path.isUnixHiddenFile()
return self.getLastPathComponent(0) =~# '^\.'
endfunction
" FUNCTION: Path.isUnixHiddenPath() {{{1
" check for unix path with hidden components
function! s:Path.isUnixHiddenPath()
if self.getLastPathComponent(0) =~# '^\.'
return 1
else
for segment in self.pathSegments
if segment =~# '^\.'
return 1
endif
endfor
return 0
endif
endfunction
" FUNCTION: Path.ignore(nerdtree) {{{1
" returns true if this path should be ignored
function! s:Path.ignore(nerdtree)
"filter out the user specified paths to ignore
if a:nerdtree.ui.isIgnoreFilterEnabled()
for i in g:NERDTreeIgnore
if self._ignorePatternMatches(i)
return 1
endif
endfor
for callback in g:NERDTree.PathFilters()
if {callback}({'path': self, 'nerdtree': a:nerdtree})
return 1
endif
endfor
endif
"dont show hidden files unless instructed to
if !a:nerdtree.ui.getShowHidden() && self.isUnixHiddenFile()
return 1
endif
if a:nerdtree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0
return 1
endif
return 0
endfunction
" FUNCTION: Path._ignorePatternMatches(pattern) {{{1
" returns true if this path matches the given ignore pattern
function! s:Path._ignorePatternMatches(pattern)
let pat = a:pattern
if strpart(pat,len(pat)-7) == '[[dir]]'
if !self.isDirectory
return 0
endif
let pat = strpart(pat,0, len(pat)-7)
elseif strpart(pat,len(pat)-8) == '[[file]]'
if self.isDirectory
return 0
endif
let pat = strpart(pat,0, len(pat)-8)
endif
return self.getLastPathComponent(0) =~# pat
endfunction
" FUNCTION: Path.isAncestor(path) {{{1
" return 1 if this path is somewhere above the given path in the filesystem.
"
" a:path should be a dir
function! s:Path.isAncestor(path)
if !self.isDirectory
return 0
endif
let this = self.str()
let that = a:path.str()
return stridx(that, this) == 0
endfunction
" FUNCTION: Path.isUnder(path) {{{1
" return 1 if this path is somewhere under the given path in the filesystem.
function! s:Path.isUnder(path)
if a:path.isDirectory == 0
return 0
endif
let this = self.str()
let that = a:path.str()
return stridx(this, that . s:Path.Slash()) == 0
endfunction
" FUNCTION: Path.JoinPathStrings(...) {{{1
function! s:Path.JoinPathStrings(...)
let components = []
for i in a:000
let components = extend(components, split(i, '/'))
endfor
return '/' . join(components, '/')
endfunction
" FUNCTION: Path.equals() {{{1
"
" Determines whether 2 path objects are "equal".
" They are equal if the paths they represent are the same
"
" Args:
" path: the other path obj to compare this with
function! s:Path.equals(path)
return self.str() ==# a:path.str()
endfunction
" FUNCTION: Path.New() {{{1
" The Constructor for the Path object
function! s:Path.New(path)
let newPath = copy(self)
call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path))
let newPath.cachedDisplayString = ""
let newPath.flagSet = g:NERDTreeFlagSet.New()
return newPath
endfunction
" FUNCTION: Path.Slash() {{{1
" Return the path separator used by the underlying file system. Special
" consideration is taken for the use of the 'shellslash' option on Windows
" systems.
function! s:Path.Slash()
if nerdtree#runningWindows()
if exists('+shellslash') && &shellslash
return '/'
endif
return '\'
endif
return '/'
endfunction
" FUNCTION: Path.Resolve() {{{1
" Invoke the vim resolve() function and return the result
" This is necessary because in some versions of vim resolve() removes trailing
" slashes while in other versions it doesn't. This always removes the trailing
" slash
function! s:Path.Resolve(path)
let tmp = resolve(a:path)
return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp
endfunction
" FUNCTION: Path.readInfoFromDisk(fullpath) {{{1
"
"
" Throws NERDTree.Path.InvalidArguments exception.
function! s:Path.readInfoFromDisk(fullpath)
call self.extractDriveLetter(a:fullpath)
let fullpath = s:Path.WinToUnixPath(a:fullpath)
if getftype(fullpath) ==# "fifo"
throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath
endif
let self.pathSegments = filter(split(fullpath, '/'), '!empty(v:val)')
let self.isReadOnly = 0
if isdirectory(a:fullpath)
let self.isDirectory = 1
elseif filereadable(a:fullpath)
let self.isDirectory = 0
let self.isReadOnly = filewritable(a:fullpath) ==# 0
else
throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath
endif
let self.isExecutable = 0
if !self.isDirectory
let self.isExecutable = getfperm(a:fullpath) =~# 'x'
endif
"grab the last part of the path (minus the trailing slash)
let lastPathComponent = self.getLastPathComponent(0)
"get the path to the new node with the parent dir fully resolved
let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent
"if the last part of the path is a symlink then flag it as such
let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath)
if self.isSymLink
let self.symLinkDest = s:Path.Resolve(fullpath)
"if the link is a dir then slap a / on the end of its dest
if isdirectory(self.symLinkDest)
"we always wanna treat MS windows shortcuts as files for
"simplicity
if hardPath !~# '\.lnk$'
let self.symLinkDest = self.symLinkDest . '/'
endif
endif
endif
endfunction
" FUNCTION: Path.refresh(nerdtree) {{{1
function! s:Path.refresh(nerdtree)
call self.readInfoFromDisk(self.str())
call g:NERDTreePathNotifier.NotifyListeners('refresh', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction
" FUNCTION: Path.refreshFlags(nerdtree) {{{1
function! s:Path.refreshFlags(nerdtree)
call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction
" FUNCTION: Path.rename() {{{1
"
" Renames this node on the filesystem
function! s:Path.rename(newPath)
if a:newPath ==# ''
throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath
endif
let success = rename(self.str(), a:newPath)
if success != 0
throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath
endif
call self.readInfoFromDisk(a:newPath)
for i in self.bookmarkNames()
let b = g:NERDTreeBookmark.BookmarkFor(i)
call b.setPath(copy(self))
endfor
call g:NERDTreeBookmark.Write()
endfunction
" FUNCTION: Path.str() {{{1
" Return a string representation of this Path object.
"
" Args:
" This function takes a single dictionary (optional) with keys and values that
" specify how the returned pathname should be formatted.
"
" The dictionary may have the following keys:
" 'format'
" 'escape'
" 'truncateTo'
"
" The 'format' key may have a value of:
" 'Cd' - a string to be used with ":cd" and similar commands
" 'Edit' - a string to be used with ":edit" and similar commands
" 'UI' - a string to be displayed in the NERDTree user interface
"
" The 'escape' key, if specified, will cause the output to be escaped with
" Vim's internal "shellescape()" function.
"
" The 'truncateTo' key shortens the length of the path to that given by the
" value associated with 'truncateTo'. A '<' is prepended.
function! s:Path.str(...)
let options = a:0 ? a:1 : {}
let toReturn = ""
if has_key(options, 'format')
let format = options['format']
if has_key(self, '_strFor' . format)
exec 'let toReturn = self._strFor' . format . '()'
else
throw 'NERDTree.UnknownFormatError: unknown format "'. format .'"'
endif
else
let toReturn = self._str()
endif
if nerdtree#has_opt(options, 'escape')
let toReturn = shellescape(toReturn)
endif
if has_key(options, 'truncateTo')
let limit = options['truncateTo']
if len(toReturn) > limit-1
let toReturn = toReturn[(len(toReturn)-limit+1):]
if len(split(toReturn, '/')) > 1
let toReturn = '</' . join(split(toReturn, '/')[1:], '/') . '/'
else
let toReturn = '<' . toReturn
endif
endif
endif
return toReturn
endfunction
" FUNCTION: Path._strForUI() {{{1
function! s:Path._strForUI()
let toReturn = '/' . join(self.pathSegments, '/')
if self.isDirectory && toReturn != '/'
let toReturn = toReturn . '/'
endif
return toReturn
endfunction
" FUNCTION: Path._strForCd() {{{1
" Return a string representation of this Path that is suitable for use as an
" argument to Vim's internal ":cd" command.
function! s:Path._strForCd()
return fnameescape(self.str())
endfunction
" FUNCTION: Path._strForEdit() {{{1
" Return a string representation of this Path that is suitable for use as an
" argument to Vim's internal ":edit" command.
function! s:Path._strForEdit()
" Make the path relative to the current working directory, if possible.
let l:result = fnamemodify(self.str(), ':.')
" On Windows, the drive letter may be removed by "fnamemodify()". Add it
" back, if necessary.
if nerdtree#runningWindows() && l:result[0] == s:Path.Slash()
let l:result = self.drive . l:result
endif
let l:result = fnameescape(l:result)
if empty(l:result)
let l:result = '.'
endif
return l:result
endfunction
" FUNCTION: Path._strForGlob() {{{1
function! s:Path._strForGlob()
let lead = s:Path.Slash()
"if we are running windows then slap a drive letter on the front
if nerdtree#runningWindows()
let lead = self.drive . '\'
endif
let toReturn = lead . join(self.pathSegments, s:Path.Slash())
if !nerdtree#runningWindows()
let toReturn = escape(toReturn, self._escChars())
endif
return toReturn
endfunction
" FUNCTION: Path._str() {{{1
" Return the absolute pathname associated with this Path object. The pathname
" returned is appropriate for the underlying file system.
function! s:Path._str()
let l:separator = s:Path.Slash()
let l:leader = l:separator
if nerdtree#runningWindows()
let l:leader = self.drive . l:separator
endif
return l:leader . join(self.pathSegments, l:separator)
endfunction
" FUNCTION: Path.strTrunk() {{{1
" Gets the path without the last segment on the end.
function! s:Path.strTrunk()
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
endfunction
" FUNCTION: Path.tabnr() {{{1
" return the number of the first tab that is displaying this file
"
" return 0 if no tab was found
function! s:Path.tabnr()
let str = self.str()
for t in range(tabpagenr('$'))
for b in tabpagebuflist(t+1)
if str == expand('#' . b . ':p')
return t+1
endif
endfor
endfor
return 0
endfunction
" FUNCTION: Path.WinToUnixPath(pathstr){{{1
" Takes in a windows path and returns the unix equiv
"
" A class level method
"
" Args:
" pathstr: the windows path to convert
function! s:Path.WinToUnixPath(pathstr)
if !nerdtree#runningWindows()
return a:pathstr
endif
let toReturn = a:pathstr
"remove the x:\ of the front
let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "")
"remove the \\ network share from the front
let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "")
"convert all \ chars to /
let toReturn = substitute(toReturn, '\', '/', "g")
return toReturn
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,646 +0,0 @@
" ============================================================================
" CLASS: TreeDirNode
"
" A subclass of NERDTreeFileNode.
"
" The 'composite' part of the file/dir composite.
" ============================================================================
let s:TreeDirNode = copy(g:NERDTreeFileNode)
let g:NERDTreeDirNode = s:TreeDirNode
" FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1
" Class method that returns the highest cached ancestor of the current root.
function! s:TreeDirNode.AbsoluteTreeRoot()
let currentNode = b:NERDTree.root
while currentNode.parent != {}
let currentNode = currentNode.parent
endwhile
return currentNode
endfunction
" FUNCTION: TreeDirNode.activate([options]) {{{1
function! s:TreeDirNode.activate(...)
let l:options = (a:0 > 0) ? a:1 : {}
call self.toggleOpen(l:options)
" Note that we only re-render the NERDTree for this node if we did NOT
" create a new node and render it in a new window or tab. In the latter
" case, rendering the NERDTree for this node could overwrite the text of
" the new NERDTree!
if !has_key(l:options, 'where') || empty(l:options['where'])
call self.getNerdtree().render()
call self.putCursorHere(0, 0)
endif
endfunction
" FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{1
" Adds the given treenode to the list of children for this node
"
" Args:
" -treenode: the node to add
" -inOrder: 1 if the new node should be inserted in sorted order
function! s:TreeDirNode.addChild(treenode, inOrder)
call add(self.children, a:treenode)
let a:treenode.parent = self
if a:inOrder
call self.sortChildren()
endif
endfunction
" FUNCTION: TreeDirNode.close() {{{1
" Mark this TreeDirNode as closed.
function! s:TreeDirNode.close()
" Close all directories in this directory node's cascade. This is
" necessary to ensure consistency when cascades are rendered.
for l:dirNode in self.getCascade()
let l:dirNode.isOpen = 0
endfor
endfunction
" FUNCTION: TreeDirNode.closeChildren() {{{1
" Recursively close any directory nodes that are descendants of this node.
function! s:TreeDirNode.closeChildren()
for l:child in self.children
if l:child.path.isDirectory
call l:child.close()
call l:child.closeChildren()
endif
endfor
endfunction
" FUNCTION: TreeDirNode.createChild(path, inOrder) {{{1
" Instantiates a new child node for this node with the given path. The new
" nodes parent is set to this node.
"
" Args:
" path: a Path object that this node will represent/contain
" inOrder: 1 if the new node should be inserted in sorted order
"
" Returns:
" the newly created node
function! s:TreeDirNode.createChild(path, inOrder)
let newTreeNode = g:NERDTreeFileNode.New(a:path, self.getNerdtree())
call self.addChild(newTreeNode, a:inOrder)
return newTreeNode
endfunction
" FUNCTION: TreeDirNode.displayString() {{{1
" Assemble and return a string that can represent this TreeDirNode object in
" the NERDTree window.
function! s:TreeDirNode.displayString()
let l:result = ''
" Build a label that identifies this TreeDirNode.
let l:label = ''
let l:cascade = self.getCascade()
for l:dirNode in l:cascade
let l:label .= l:dirNode.path.displayString()
endfor
" Select the appropriate open/closed status indicator symbol.
if l:cascade[-1].isOpen
let l:symbol = g:NERDTreeDirArrowCollapsible
else
let l:symbol = g:NERDTreeDirArrowExpandable
endif
let l:flags = l:cascade[-1].path.flagSet.renderToString()
let l:result = l:symbol . ' ' . l:flags . l:label
return l:result
endfunction
" FUNCTION: TreeDirNode.findNode(path) {{{1
" Will find one of the children (recursively) that has the given path
"
" Args:
" path: a path object
unlet s:TreeDirNode.findNode
function! s:TreeDirNode.findNode(path)
if a:path.equals(self.path)
return self
endif
if stridx(a:path.str(), self.path.str(), 0) ==# -1
return {}
endif
if self.path.isDirectory
for i in self.children
let retVal = i.findNode(a:path)
if retVal != {}
return retVal
endif
endfor
endif
return {}
endfunction
" FUNCTION: TreeDirNode.getCascade() {{{1
" Return an array of dir nodes (starting from self) that can be cascade opened.
function! s:TreeDirNode.getCascade()
if !self.isCascadable()
return [self]
endif
let vc = self.getVisibleChildren()
let visChild = vc[0]
return [self] + visChild.getCascade()
endfunction
" FUNCTION: TreeDirNode.getChildCount() {{{1
" Returns the number of children this node has
function! s:TreeDirNode.getChildCount()
return len(self.children)
endfunction
" FUNCTION: TreeDirNode.getChild(path) {{{1
" Returns child node of this node that has the given path or {} if no such node
" exists.
"
" This function doesnt not recurse into child dir nodes
"
" Args:
" path: a path object
function! s:TreeDirNode.getChild(path)
if stridx(a:path.str(), self.path.str(), 0) ==# -1
return {}
endif
let index = self.getChildIndex(a:path)
if index ==# -1
return {}
else
return self.children[index]
endif
endfunction
" FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{1
" returns the child at the given index
"
" Args:
" indx: the index to get the child from
" visible: 1 if only the visible children array should be used, 0 if all the
" children should be searched.
function! s:TreeDirNode.getChildByIndex(indx, visible)
let array_to_search = a:visible? self.getVisibleChildren() : self.children
if a:indx > len(array_to_search)
throw "NERDTree.InvalidArgumentsError: Index is out of bounds."
endif
return array_to_search[a:indx]
endfunction
" FUNCTION: TreeDirNode.getChildIndex(path) {{{1
" Returns the index of the child node of this node that has the given path or
" -1 if no such node exists.
"
" This function doesnt not recurse into child dir nodes
"
" Args:
" path: a path object
function! s:TreeDirNode.getChildIndex(path)
if stridx(a:path.str(), self.path.str(), 0) ==# -1
return -1
endif
"do a binary search for the child
let a = 0
let z = self.getChildCount()
while a < z
let mid = (a+z)/2
let diff = a:path.compareTo(self.children[mid].path)
if diff ==# -1
let z = mid
elseif diff ==# 1
let a = mid+1
else
return mid
endif
endwhile
return -1
endfunction
" FUNCTION: TreeDirNode._glob(pattern, all) {{{1
" Return a list of strings naming the descendants of the directory in this
" TreeDirNode object that match the specified glob pattern.
"
" Args:
" pattern: (string) the glob pattern to apply
" all: (0 or 1) if 1, include "." and ".." if they match "pattern"; if 0,
" always exclude them
"
" Note: If the pathnames in the result list are below the working directory,
" they are returned as pathnames relative to that directory. This is because
" this function, internally, attempts to obey 'wildignore' rules that use
" relative paths.
function! s:TreeDirNode._glob(pattern, all)
" Construct a path specification such that "globpath()" will return
" relative pathnames, if possible.
if self.path.str() == getcwd()
let l:pathSpec = ','
else
let l:pathSpec = fnamemodify(self.path.str({'format': 'Glob'}), ':.')
" On Windows, the drive letter may be removed by "fnamemodify()".
if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash()
let l:pathSpec = self.path.drive . l:pathSpec
endif
endif
let l:globList = []
" See ":h version7.txt" and ":h version8.txt" for details on the
" development of the "glob()" and "globpath()" functions.
if v:version > 704 || (v:version == 704 && has('patch654'))
let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0)
elseif v:version == 704 && has('patch279')
let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1)
elseif v:version > 702 || (v:version == 702 && has('patch051'))
let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore)
let l:globList = split(l:globString, "\n")
else
let l:globString = globpath(l:pathSpec, a:pattern)
let l:globList = split(l:globString, "\n")
endif
" If "a:all" is false, filter "." and ".." from the output.
if !a:all
let l:toRemove = []
for l:file in l:globList
let l:tail = fnamemodify(l:file, ':t')
" Double the modifier if only a separator was stripped.
if l:tail == ''
let l:tail = fnamemodify(l:file, ':t:t')
endif
if l:tail == '.' || l:tail == '..'
call add(l:toRemove, l:file)
if len(l:toRemove) == 2
break
endif
endif
endfor
for l:file in l:toRemove
call remove(l:globList, index(l:globList, l:file))
endfor
endif
return l:globList
endfunction
" FUNCTION: TreeDirNode.GetSelected() {{{1
" Returns the current node if it is a dir node, or else returns the current
" nodes parent
unlet s:TreeDirNode.GetSelected
function! s:TreeDirNode.GetSelected()
let currentDir = g:NERDTreeFileNode.GetSelected()
if currentDir != {} && !currentDir.isRoot()
if currentDir.path.isDirectory ==# 0
let currentDir = currentDir.parent
endif
endif
return currentDir
endfunction
" FUNCTION: TreeDirNode.getVisibleChildCount() {{{1
" Returns the number of visible children this node has
function! s:TreeDirNode.getVisibleChildCount()
return len(self.getVisibleChildren())
endfunction
" FUNCTION: TreeDirNode.getVisibleChildren() {{{1
" Returns a list of children to display for this node, in the correct order
"
" Return:
" an array of treenodes
function! s:TreeDirNode.getVisibleChildren()
let toReturn = []
for i in self.children
if i.path.ignore(self.getNerdtree()) ==# 0
call add(toReturn, i)
endif
endfor
return toReturn
endfunction
" FUNCTION: TreeDirNode.hasVisibleChildren() {{{1
" returns 1 if this node has any childre, 0 otherwise..
function! s:TreeDirNode.hasVisibleChildren()
return self.getVisibleChildCount() != 0
endfunction
" FUNCTION: TreeDirNode.isCascadable() {{{1
" true if this dir has only one visible child - which is also a dir
function! s:TreeDirNode.isCascadable()
if g:NERDTreeCascadeSingleChildDir == 0
return 0
endif
let c = self.getVisibleChildren()
return len(c) == 1 && c[0].path.isDirectory
endfunction
" FUNCTION: TreeDirNode._initChildren() {{{1
" Removes all childen from this node and re-reads them
"
" Args:
" silent: 1 if the function should not echo any "please wait" messages for
" large directories
"
" Return: the number of child nodes read
function! s:TreeDirNode._initChildren(silent)
"remove all the current child nodes
let self.children = []
let files = self._glob('*', 1) + self._glob('.*', 0)
if !a:silent && len(files) > g:NERDTreeNotificationThreshold
call nerdtree#echo("Please wait, caching a large dir ...")
endif
let invalidFilesFound = 0
for i in files
try
let path = g:NERDTreePath.New(i)
call self.createChild(path, 0)
call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {})
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
let invalidFilesFound += 1
endtry
endfor
call self.sortChildren()
if !a:silent && len(files) > g:NERDTreeNotificationThreshold
call nerdtree#echo("Please wait, caching a large dir ... DONE (". self.getChildCount() ." nodes cached).")
endif
if invalidFilesFound
call nerdtree#echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree")
endif
return self.getChildCount()
endfunction
" FUNCTION: TreeDirNode.New(path, nerdtree) {{{1
" Return a new TreeDirNode object with the given path and parent.
"
" Args:
" path: dir that the node represents
" nerdtree: the tree the node belongs to
function! s:TreeDirNode.New(path, nerdtree)
if a:path.isDirectory != 1
throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object."
endif
let newTreeNode = copy(self)
let newTreeNode.path = a:path
let newTreeNode.isOpen = 0
let newTreeNode.children = []
let newTreeNode.parent = {}
let newTreeNode._nerdtree = a:nerdtree
return newTreeNode
endfunction
" FUNCTION: TreeDirNode.open([options]) {{{1
" Open this directory node in the current tree or elsewhere if special options
" are provided. Return 0 if options were processed. Otherwise, return the
" number of new cached nodes.
function! s:TreeDirNode.open(...)
let l:options = a:0 ? a:1 : {}
" If special options were specified, process them and return.
if has_key(l:options, 'where') && !empty(l:options['where'])
let l:opener = g:NERDTreeOpener.New(self.path, l:options)
call l:opener.open(self)
return 0
endif
" Open any ancestors of this node that render within the same cascade.
let l:parent = self.parent
while !empty(l:parent) && !l:parent.isRoot()
if index(l:parent.getCascade(), self) >= 0
let l:parent.isOpen = 1
let l:parent = l:parent.parent
else
break
endif
endwhile
let self.isOpen = 1
let l:numChildrenCached = 0
if empty(self.children)
let l:numChildrenCached = self._initChildren(0)
endif
return l:numChildrenCached
endfunction
" FUNCTION: TreeDirNode.openAlong([opts]) {{{1
" recursive open the dir if it has only one directory child.
"
" return the level of opened directories.
function! s:TreeDirNode.openAlong(...)
let opts = a:0 ? a:1 : {}
let level = 0
let node = self
while node.path.isDirectory
call node.open(opts)
let level += 1
if node.getVisibleChildCount() == 1
let node = node.getChildByIndex(0, 1)
else
break
endif
endwhile
return level
endfunction
" FUNCTION: TreeDirNode.openExplorer() {{{1
" Open an explorer window for this node in the previous window. The explorer
" can be a NERDTree window or a netrw window.
function! s:TreeDirNode.openExplorer()
call self.open({'where': 'p'})
endfunction
" FUNCTION: TreeDirNode.openInNewTab(options) {{{1
unlet s:TreeDirNode.openInNewTab
function! s:TreeDirNode.openInNewTab(options)
call nerdtree#deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead')
call self.open({'where': 't'})
endfunction
" FUNCTION: TreeDirNode._openInNewTab() {{{1
function! s:TreeDirNode._openInNewTab()
tabnew
call g:NERDTreeCreator.CreateTabTree(self.path.str())
endfunction
" FUNCTION: TreeDirNode.openRecursively() {{{1
" Open this directory node and any descendant directory nodes whose pathnames
" are not ignored.
function! s:TreeDirNode.openRecursively()
silent call self.open()
for l:child in self.children
if l:child.path.isDirectory && !l:child.path.ignore(l:child.getNerdtree())
call l:child.openRecursively()
endif
endfor
endfunction
" FUNCTION: TreeDirNode.refresh() {{{1
function! s:TreeDirNode.refresh()
call self.path.refresh(self.getNerdtree())
"if this node was ever opened, refresh its children
if self.isOpen || !empty(self.children)
let files = self._glob('*', 1) + self._glob('.*', 0)
let newChildNodes = []
let invalidFilesFound = 0
for i in files
try
"create a new path and see if it exists in this nodes children
let path = g:NERDTreePath.New(i)
let newNode = self.getChild(path)
if newNode != {}
call newNode.refresh()
call add(newChildNodes, newNode)
"the node doesnt exist so create it
else
let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree())
let newNode.parent = self
call add(newChildNodes, newNode)
endif
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
let invalidFilesFound = 1
endtry
endfor
"swap this nodes children out for the children we just read/refreshed
let self.children = newChildNodes
call self.sortChildren()
if invalidFilesFound
call nerdtree#echoWarning("some files could not be loaded into the NERD tree")
endif
endif
endfunction
" FUNCTION: TreeDirNode.refreshFlags() {{{1
unlet s:TreeDirNode.refreshFlags
function! s:TreeDirNode.refreshFlags()
call self.path.refreshFlags(self.getNerdtree())
for i in self.children
call i.refreshFlags()
endfor
endfunction
" FUNCTION: TreeDirNode.refreshDirFlags() {{{1
function! s:TreeDirNode.refreshDirFlags()
call self.path.refreshFlags(self.getNerdtree())
endfunction
" FUNCTION: TreeDirNode.reveal(path) {{{1
" reveal the given path, i.e. cache and open all treenodes needed to display it
" in the UI
" Returns the revealed node
function! s:TreeDirNode.reveal(path, ...)
let opts = a:0 ? a:1 : {}
if !a:path.isUnder(self.path)
throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str()
endif
call self.open()
if self.path.equals(a:path.getParent())
let n = self.findNode(a:path)
if has_key(opts, "open")
call n.open()
endif
return n
endif
let p = a:path
while !p.getParent().equals(self.path)
let p = p.getParent()
endwhile
let n = self.findNode(p)
return n.reveal(a:path, opts)
endfunction
" FUNCTION: TreeDirNode.removeChild(treenode) {{{1
" Remove the given treenode from "self.children".
" Throws "NERDTree.ChildNotFoundError" if the node is not found.
"
" Args:
" treenode: the node object to remove
function! s:TreeDirNode.removeChild(treenode)
for i in range(0, self.getChildCount()-1)
if self.children[i].equals(a:treenode)
call remove(self.children, i)
return
endif
endfor
throw "NERDTree.ChildNotFoundError: child node was not found"
endfunction
" FUNCTION: TreeDirNode.sortChildren() {{{1
" Sort "self.children" by alphabetical order and directory priority.
function! s:TreeDirNode.sortChildren()
let CompareFunc = function("nerdtree#compareNodesBySortKey")
call sort(self.children, CompareFunc)
endfunction
" FUNCTION: TreeDirNode.toggleOpen([options]) {{{1
" Opens this directory if it is closed and vice versa
function! s:TreeDirNode.toggleOpen(...)
let opts = a:0 ? a:1 : {}
if self.isOpen ==# 1
call self.close()
else
if g:NERDTreeCascadeOpenSingleChildDir == 0
call self.open(opts)
else
call self.openAlong(opts)
endif
endif
endfunction
" FUNCTION: TreeDirNode.transplantChild(newNode) {{{1
" Replaces the child of this with the given node (where the child node's full
" path matches a:newNode's fullpath). The search for the matching node is
" non-recursive
"
" Arg:
" newNode: the node to graft into the tree
function! s:TreeDirNode.transplantChild(newNode)
for i in range(0, self.getChildCount()-1)
if self.children[i].equals(a:newNode)
let self.children[i] = a:newNode
let a:newNode.parent = self
break
endif
endfor
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,368 +0,0 @@
"CLASS: TreeFileNode
"This class is the parent of the TreeDirNode class and is the
"'Component' part of the composite design pattern between the treenode
"classes.
"============================================================
let s:TreeFileNode = {}
let g:NERDTreeFileNode = s:TreeFileNode
"FUNCTION: TreeFileNode.activate(...) {{{1
function! s:TreeFileNode.activate(...)
call self.open(a:0 ? a:1 : {})
endfunction
"FUNCTION: TreeFileNode.bookmark(name) {{{1
"bookmark this node with a:name
function! s:TreeFileNode.bookmark(name)
"if a bookmark exists with the same name and the node is cached then save
"it so we can update its display string
let oldMarkedNode = {}
try
let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1, self.getNerdtree())
catch /^NERDTree.BookmarkNotFoundError/
catch /^NERDTree.BookmarkedNodeNotFoundError/
endtry
call g:NERDTreeBookmark.AddBookmark(a:name, self.path)
call self.path.cacheDisplayString()
call g:NERDTreeBookmark.Write()
if !empty(oldMarkedNode)
call oldMarkedNode.path.cacheDisplayString()
endif
endfunction
"FUNCTION: TreeFileNode.cacheParent() {{{1
"initializes self.parent if it isnt already
function! s:TreeFileNode.cacheParent()
if empty(self.parent)
let parentPath = self.path.getParent()
if parentPath.equals(self.path)
throw "NERDTree.CannotCacheParentError: already at root"
endif
let self.parent = s:TreeFileNode.New(parentPath, self.getNerdtree())
endif
endfunction
"FUNCTION: TreeFileNode.clearBookmarks() {{{1
function! s:TreeFileNode.clearBookmarks()
for i in g:NERDTreeBookmark.Bookmarks()
if i.path.equals(self.path)
call i.delete()
end
endfor
call self.path.cacheDisplayString()
endfunction
"FUNCTION: TreeFileNode.copy(dest) {{{1
function! s:TreeFileNode.copy(dest)
call self.path.copy(a:dest)
let newPath = g:NERDTreePath.New(a:dest)
let parent = self.getNerdtree().root.findNode(newPath.getParent())
if !empty(parent)
call parent.refresh()
return parent.findNode(newPath)
else
return {}
endif
endfunction
"FUNCTION: TreeFileNode.delete {{{1
"Removes this node from the tree and calls the Delete method for its path obj
function! s:TreeFileNode.delete()
call self.path.delete()
call self.parent.removeChild(self)
endfunction
"FUNCTION: TreeFileNode.displayString() {{{1
"
"Returns a string that specifies how the node should be represented as a
"string
"
"Return:
"a string that can be used in the view to represent this node
function! s:TreeFileNode.displayString()
return self.path.flagSet.renderToString() . self.path.displayString()
endfunction
"FUNCTION: TreeFileNode.equals(treenode) {{{1
"
"Compares this treenode to the input treenode and returns 1 if they are the
"same node.
"
"Use this method instead of == because sometimes when the treenodes contain
"many children, vim seg faults when doing ==
"
"Args:
"treenode: the other treenode to compare to
function! s:TreeFileNode.equals(treenode)
return self.path.str() ==# a:treenode.path.str()
endfunction
"FUNCTION: TreeFileNode.findNode(path) {{{1
"Returns self if this node.path.Equals the given path.
"Returns {} if not equal.
"
"Args:
"path: the path object to compare against
function! s:TreeFileNode.findNode(path)
if a:path.equals(self.path)
return self
endif
return {}
endfunction
"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{1
"
"Finds the next sibling for this node in the indicated direction. This sibling
"must be a directory and may/may not have children as specified.
"
"Args:
"direction: 0 if you want to find the previous sibling, 1 for the next sibling
"
"Return:
"a treenode object or {} if no appropriate sibling could be found
function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction)
"if we have no parent then we can have no siblings
if self.parent != {}
let nextSibling = self.findSibling(a:direction)
while nextSibling != {}
if nextSibling.path.isDirectory && nextSibling.hasVisibleChildren() && nextSibling.isOpen
return nextSibling
endif
let nextSibling = nextSibling.findSibling(a:direction)
endwhile
endif
return {}
endfunction
"FUNCTION: TreeFileNode.findSibling(direction) {{{1
"
"Finds the next sibling for this node in the indicated direction
"
"Args:
"direction: 0 if you want to find the previous sibling, 1 for the next sibling
"
"Return:
"a treenode object or {} if no sibling could be found
function! s:TreeFileNode.findSibling(direction)
"if we have no parent then we can have no siblings
if self.parent != {}
"get the index of this node in its parents children
let siblingIndx = self.parent.getChildIndex(self.path)
if siblingIndx != -1
"move a long to the next potential sibling node
let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
"keep moving along to the next sibling till we find one that is valid
let numSiblings = self.parent.getChildCount()
while siblingIndx >= 0 && siblingIndx < numSiblings
"if the next node is not an ignored node (i.e. wont show up in the
"view) then return it
if self.parent.children[siblingIndx].path.ignore(self.getNerdtree()) ==# 0
return self.parent.children[siblingIndx]
endif
"go to next node
let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
endwhile
endif
endif
return {}
endfunction
"FUNCTION: TreeFileNode.getNerdtree(){{{1
function! s:TreeFileNode.getNerdtree()
return self._nerdtree
endfunction
"FUNCTION: TreeFileNode.GetRootForTab(){{{1
"get the root node for this tab
function! s:TreeFileNode.GetRootForTab()
if g:NERDTree.ExistsForTab()
return getbufvar(t:NERDTreeBufName, 'NERDTree').root
end
return {}
endfunction
"FUNCTION: TreeFileNode.GetSelected() {{{1
"gets the treenode that the cursor is currently over
function! s:TreeFileNode.GetSelected()
try
let path = b:NERDTree.ui.getPath(line("."))
if path ==# {}
return {}
endif
return b:NERDTree.root.findNode(path)
catch /^NERDTree/
return {}
endtry
endfunction
"FUNCTION: TreeFileNode.isVisible() {{{1
"returns 1 if this node should be visible according to the tree filters and
"hidden file filters (and their on/off status)
function! s:TreeFileNode.isVisible()
return !self.path.ignore(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.isRoot() {{{1
function! s:TreeFileNode.isRoot()
if !g:NERDTree.ExistsForBuf()
throw "NERDTree.NoTreeError: No tree exists for the current buffer"
endif
return self.equals(self.getNerdtree().root)
endfunction
"FUNCTION: TreeFileNode.New(path, nerdtree) {{{1
"Returns a new TreeNode object with the given path and parent
"
"Args:
"path: file/dir that the node represents
"nerdtree: the tree the node belongs to
function! s:TreeFileNode.New(path, nerdtree)
if a:path.isDirectory
return g:NERDTreeDirNode.New(a:path, a:nerdtree)
else
let newTreeNode = copy(self)
let newTreeNode.path = a:path
let newTreeNode.parent = {}
let newTreeNode._nerdtree = a:nerdtree
return newTreeNode
endif
endfunction
"FUNCTION: TreeFileNode.open() {{{1
function! s:TreeFileNode.open(...)
let opts = a:0 ? a:1 : {}
let opener = g:NERDTreeOpener.New(self.path, opts)
call opener.open(self)
endfunction
"FUNCTION: TreeFileNode.openSplit() {{{1
"Open this node in a new window
function! s:TreeFileNode.openSplit()
call nerdtree#deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.')
call self.open({'where': 'h'})
endfunction
"FUNCTION: TreeFileNode.openVSplit() {{{1
"Open this node in a new vertical window
function! s:TreeFileNode.openVSplit()
call nerdtree#deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.')
call self.open({'where': 'v'})
endfunction
"FUNCTION: TreeFileNode.openInNewTab(options) {{{1
function! s:TreeFileNode.openInNewTab(options)
echomsg 'TreeFileNode.openInNewTab is deprecated'
call self.open(extend({'where': 't'}, a:options))
endfunction
"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1
"Places the cursor on the line number this node is rendered on
"
"Args:
"isJump: 1 if this cursor movement should be counted as a jump by vim
"recurseUpward: try to put the cursor on the parent if the this node isnt
"visible
function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
let ln = self.getNerdtree().ui.getLineNum(self)
if ln != -1
if a:isJump
mark '
endif
call cursor(ln, col("."))
else
if a:recurseUpward
let node = self
while node != {} && self.getNerdtree().ui.getLineNum(node) ==# -1
let node = node.parent
call node.open()
endwhile
call self._nerdtree.render()
call node.putCursorHere(a:isJump, 0)
endif
endif
endfunction
"FUNCTION: TreeFileNode.refresh() {{{1
function! s:TreeFileNode.refresh()
call self.path.refresh(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.refreshFlags() {{{1
function! s:TreeFileNode.refreshFlags()
call self.path.refreshFlags(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.rename() {{{1
"Calls the rename method for this nodes path obj
function! s:TreeFileNode.rename(newName)
let newName = substitute(a:newName, '\(\\\|\/\)$', '', '')
call self.path.rename(newName)
call self.parent.removeChild(self)
let parentPath = self.path.getParent()
let newParent = self.getNerdtree().root.findNode(parentPath)
if newParent != {}
call newParent.createChild(self.path, 1)
call newParent.refresh()
endif
endfunction
"FUNCTION: TreeFileNode.renderToString {{{1
"returns a string representation for this tree to be rendered in the view
function! s:TreeFileNode.renderToString()
return self._renderToString(0, 0)
endfunction
"Args:
"depth: the current depth in the tree for this call
"drawText: 1 if we should actually draw the line for this node (if 0 then the
"child nodes are rendered only)
"for each depth in the tree
function! s:TreeFileNode._renderToString(depth, drawText)
let output = ""
if a:drawText ==# 1
let treeParts = repeat(' ', a:depth - 1)
if !self.path.isDirectory
let treeParts = treeParts . ' '
endif
let line = treeParts . self.displayString()
let output = output . line . "\n"
endif
"if the node is an open dir, draw its children
if self.path.isDirectory ==# 1 && self.isOpen ==# 1
let childNodesToDraw = self.getVisibleChildren()
if self.isCascadable() && a:depth > 0
let output = output . childNodesToDraw[0]._renderToString(a:depth, 0)
elseif len(childNodesToDraw) > 0
for i in childNodesToDraw
let output = output . i._renderToString(a:depth + 1, 1)
endfor
endif
endif
return output
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,521 +0,0 @@
"CLASS: UI
"============================================================
let s:UI = {}
let g:NERDTreeUI = s:UI
"FUNCTION: s:UI.centerView() {{{2
"centers the nerd tree window around the cursor (provided the nerd tree
"options permit)
function! s:UI.centerView()
if g:NERDTreeAutoCenter
let current_line = winline()
let lines_to_top = current_line
let lines_to_bottom = winheight(g:NERDTree.GetWinNum()) - current_line
if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold
normal! zz
endif
endif
endfunction
"FUNCTION: s:UI._dumpHelp {{{1
"prints out the quick help
function! s:UI._dumpHelp()
if self.getShowHelp()
let help = "\" NERDTree (" . nerdtree#version() . ") quickhelp~\n"
let help .= "\" ============================\n"
let help .= "\" File node mappings~\n"
let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
let help .= "\" <CR>,\n"
if self.nerdtree.isTabTree()
let help .= "\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
else
let help .= "\" ". g:NERDTreeMapActivateNode .": open in current window\n"
endif
if self.nerdtree.isTabTree()
let help .= "\" ". g:NERDTreeMapPreview .": preview\n"
endif
let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
let help .= "\" middle-click,\n"
let help .= "\" ". g:NERDTreeMapOpenSplit .": open split\n"
let help .= "\" ". g:NERDTreeMapPreviewSplit .": preview split\n"
let help .= "\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n"
let help .= "\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n"
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Directory node mappings~\n"
let help .= "\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n"
let help .= "\" ". g:NERDTreeMapActivateNode .": open & close node\n"
let help .= "\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n"
let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
let help .= "\" ". g:NERDTreeMapCloseDir .": close parent of node\n"
let help .= "\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n"
let help .= "\" current node recursively\n"
let help .= "\" middle-click,\n"
let help .= "\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n"
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Bookmark table mappings~\n"
let help .= "\" double-click,\n"
let help .= "\" ". g:NERDTreeMapActivateNode .": open bookmark\n"
let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
let help .= "\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n"
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Tree navigation mappings~\n"
let help .= "\" ". g:NERDTreeMapJumpRoot .": go to root\n"
let help .= "\" ". g:NERDTreeMapJumpParent .": go to parent\n"
let help .= "\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n"
let help .= "\" ". g:NERDTreeMapJumpLastChild .": go to last child\n"
let help .= "\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n"
let help .= "\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n"
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Filesystem mappings~\n"
let help .= "\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n"
let help .= "\" selected dir\n"
let help .= "\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n"
let help .= "\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n"
let help .= "\" but leave old root open\n"
let help .= "\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n"
let help .= "\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n"
let help .= "\" ". g:NERDTreeMapMenu .": Show menu\n"
let help .= "\" ". g:NERDTreeMapChdir .":change the CWD to the\n"
let help .= "\" selected dir\n"
let help .= "\" ". g:NERDTreeMapCWD .":change tree root to CWD\n"
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Tree filtering mappings~\n"
let help .= "\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n"
let help .= "\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n"
let help .= "\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n"
let help .= "\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n"
"add quickhelp entries for each custom key map
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Custom mappings~\n"
for i in g:NERDTreeKeyMap.All()
if !empty(i.quickhelpText)
let help .= "\" ". i.key .": ". i.quickhelpText ."\n"
endif
endfor
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Other mappings~\n"
let help .= "\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n"
let help .= "\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n"
let help .= "\" the NERDTree window\n"
let help .= "\" ". g:NERDTreeMapHelp .": toggle help\n"
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Bookmark commands~\n"
let help .= "\" :Bookmark [<name>]\n"
let help .= "\" :BookmarkToRoot <name>\n"
let help .= "\" :RevealBookmark <name>\n"
let help .= "\" :OpenBookmark <name>\n"
let help .= "\" :ClearBookmarks [<names>]\n"
let help .= "\" :ClearAllBookmarks\n"
silent! put =help
elseif !self.isMinimal()
let help ="\" Press ". g:NERDTreeMapHelp ." for help\n"
silent! put =help
endif
endfunction
"FUNCTION: s:UI.new(nerdtree) {{{1
function! s:UI.New(nerdtree)
let newObj = copy(self)
let newObj.nerdtree = a:nerdtree
let newObj._showHelp = 0
let newObj._ignoreEnabled = 1
let newObj._showFiles = g:NERDTreeShowFiles
let newObj._showHidden = g:NERDTreeShowHidden
let newObj._showBookmarks = g:NERDTreeShowBookmarks
return newObj
endfunction
"FUNCTION: s:UI.getPath(ln) {{{1
"Gets the full path to the node that is rendered on the given line number
"
"Args:
"ln: the line number to get the path for
"
"Return:
"A path if a node was selected, {} if nothing is selected.
"If the 'up a dir' line was selected then the path to the parent of the
"current root is returned
function! s:UI.getPath(ln)
let line = getline(a:ln)
let rootLine = self.getRootLineNum()
"check to see if we have the root node
if a:ln == rootLine
return self.nerdtree.root.path
endif
if line ==# s:UI.UpDirLine()
return self.nerdtree.root.path.getParent()
endif
let indent = self._indentLevelFor(line)
"remove the tree parts and the leading space
let curFile = self._stripMarkup(line)
let dir = ""
let lnum = a:ln
while lnum > 0
let lnum = lnum - 1
let curLine = getline(lnum)
let curLineStripped = self._stripMarkup(curLine)
"have we reached the top of the tree?
if lnum == rootLine
let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir
break
endif
if curLineStripped =~# '/$'
let lpindent = self._indentLevelFor(curLine)
if lpindent < indent
let indent = indent - 1
let dir = substitute (curLineStripped,'^\\', "", "") . dir
continue
endif
endif
endwhile
let curFile = self.nerdtree.root.path.drive . dir . curFile
let toReturn = g:NERDTreePath.New(curFile)
return toReturn
endfunction
"FUNCTION: s:UI.getLineNum(file_node){{{1
"returns the line number this node is rendered on, or -1 if it isnt rendered
function! s:UI.getLineNum(file_node)
"if the node is the root then return the root line no.
if a:file_node.isRoot()
return self.getRootLineNum()
endif
let totalLines = line("$")
"the path components we have matched so far
let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')]
"the index of the component we are searching for
let curPathComponent = 1
let fullpath = a:file_node.path.str({'format': 'UI'})
let lnum = self.getRootLineNum()
while lnum > 0
let lnum = lnum + 1
"have we reached the bottom of the tree?
if lnum ==# totalLines+1
return -1
endif
let curLine = getline(lnum)
let indent = self._indentLevelFor(curLine)
if indent ==# curPathComponent
let curLine = self._stripMarkup(curLine)
let curPath = join(pathcomponents, '/') . '/' . curLine
if stridx(fullpath, curPath, 0) ==# 0
if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/'
let curLine = substitute(curLine, '/ *$', '', '')
call add(pathcomponents, curLine)
let curPathComponent = curPathComponent + 1
if fullpath ==# curPath
return lnum
endif
endif
endif
endif
endwhile
return -1
endfunction
"FUNCTION: s:UI.getRootLineNum(){{{1
"gets the line number of the root node
function! s:UI.getRootLineNum()
let rootLine = 1
while getline(rootLine) !~# '^\(/\|<\)'
let rootLine = rootLine + 1
endwhile
return rootLine
endfunction
"FUNCTION: s:UI.getShowBookmarks() {{{1
function! s:UI.getShowBookmarks()
return self._showBookmarks
endfunction
"FUNCTION: s:UI.getShowFiles() {{{1
function! s:UI.getShowFiles()
return self._showFiles
endfunction
"FUNCTION: s:UI.getShowHelp() {{{1
function! s:UI.getShowHelp()
return self._showHelp
endfunction
"FUNCTION: s:UI.getShowHidden() {{{1
function! s:UI.getShowHidden()
return self._showHidden
endfunction
"FUNCTION: s:UI._indentLevelFor(line) {{{1
function! s:UI._indentLevelFor(line)
"have to do this work around because match() returns bytes, not chars
let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']')
" The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+
let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs'))
return leadChars / s:UI.IndentWid()
endfunction
"FUNCTION: s:UI.IndentWid() {{{1
function! s:UI.IndentWid()
return 2
endfunction
"FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1
function! s:UI.isIgnoreFilterEnabled()
return self._ignoreEnabled == 1
endfunction
"FUNCTION: s:UI.isMinimal() {{{1
function! s:UI.isMinimal()
return g:NERDTreeMinimalUI
endfunction
"FUNCTION: s:UI.MarkupReg() {{{1
function! s:UI.MarkupReg()
return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)'
endfunction
"FUNCTION: s:UI._renderBookmarks {{{1
function! s:UI._renderBookmarks()
if !self.isMinimal()
call setline(line(".")+1, ">----------Bookmarks----------")
call cursor(line(".")+1, col("."))
endif
if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2
call g:NERDTreeBookmark.SortBookmarksList()
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: s:UI.restoreScreenState() {{{1
"
"Sets the screen state back to what it was when nerdtree#saveScreenState was last
"called.
"
"Assumes the cursor is in the NERDTree window
function! s:UI.restoreScreenState()
if !has_key(self, '_screenState')
return
endif
exec("silent vertical resize " . self._screenState['oldWindowSize'])
let old_scrolloff=&scrolloff
let &scrolloff=0
call cursor(self._screenState['oldTopLine'], 0)
normal! zt
call setpos(".", self._screenState['oldPos'])
let &scrolloff=old_scrolloff
endfunction
"FUNCTION: s:UI.saveScreenState() {{{1
"Saves the current cursor position in the current buffer and the window
"scroll position
function! s:UI.saveScreenState()
let win = winnr()
call g:NERDTree.CursorToTreeWin()
let self._screenState = {}
let self._screenState['oldPos'] = getpos(".")
let self._screenState['oldTopLine'] = line("w0")
let self._screenState['oldWindowSize']= winwidth("")
call nerdtree#exec(win . "wincmd w")
endfunction
"FUNCTION: s:UI.setShowHidden(val) {{{1
function! s:UI.setShowHidden(val)
let self._showHidden = a:val
endfunction
"FUNCTION: s:UI._stripMarkup(line){{{1
"returns the given line with all the tree parts stripped off
"
"Args:
"line: the subject line
function! s:UI._stripMarkup(line)
let line = a:line
"remove the tree parts and the leading space
let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","")
"strip off any read only flag
let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","")
"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 line = substitute (line,' -> .*',"","") " remove link to
return line
endfunction
"FUNCTION: s:UI.render() {{{1
function! s:UI.render()
setlocal modifiable
"remember the top line of the buffer and the current line so we can
"restore the view exactly how it was
let curLine = line(".")
let curCol = col(".")
let topLine = line("w0")
"delete all lines in the buffer (being careful not to clobber a register)
silent 1,$delete _
call self._dumpHelp()
"delete the blank line before the help and add one after it
if !self.isMinimal()
call setline(line(".")+1, "")
call cursor(line(".")+1, col("."))
endif
if self.getShowBookmarks()
call self._renderBookmarks()
endif
"add the 'up a dir' line
if !self.isMinimal()
call setline(line(".")+1, s:UI.UpDirLine())
call cursor(line(".")+1, col("."))
endif
"draw the header line
let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
call setline(line(".")+1, header)
call cursor(line(".")+1, col("."))
"draw the tree
silent put =self.nerdtree.root.renderToString()
"delete the blank line at the top of the buffer
silent 1,1delete _
"restore the view
let old_scrolloff=&scrolloff
let &scrolloff=0
call cursor(topLine, 1)
normal! zt
call cursor(curLine, curCol)
let &scrolloff = old_scrolloff
setlocal nomodifiable
endfunction
"FUNCTION: UI.renderViewSavingPosition {{{1
"Renders the tree and ensures the cursor stays on the current node or the
"current nodes parent if it is no longer available upon re-rendering
function! s:UI.renderViewSavingPosition()
let currentNode = g:NERDTreeFileNode.GetSelected()
"go up the tree till we find a node that will be visible or till we run
"out of nodes
while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot()
let currentNode = currentNode.parent
endwhile
call self.render()
if currentNode != {}
call currentNode.putCursorHere(0, 0)
endif
endfunction
"FUNCTION: s:UI.toggleHelp() {{{1
function! s:UI.toggleHelp()
let self._showHelp = !self._showHelp
endfunction
" FUNCTION: s:UI.toggleIgnoreFilter() {{{1
" toggles the use of the NERDTreeIgnore option
function! s:UI.toggleIgnoreFilter()
let self._ignoreEnabled = !self._ignoreEnabled
call self.renderViewSavingPosition()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
" toggles the display of bookmarks
function! s:UI.toggleShowBookmarks()
let self._showBookmarks = !self._showBookmarks
if self.getShowBookmarks()
call self.nerdtree.render()
call g:NERDTree.CursorToBookmarkTable()
else
call self.renderViewSavingPosition()
endif
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowFiles() {{{1
" toggles the display of hidden files
function! s:UI.toggleShowFiles()
let self._showFiles = !self._showFiles
call self.renderViewSavingPosition()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowHidden() {{{1
" toggles the display of hidden files
function! s:UI.toggleShowHidden()
let self._showHidden = !self._showHidden
call self.renderViewSavingPosition()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleZoom() {{{1
" zoom (maximize/minimize) the NERDTree window
function! s:UI.toggleZoom()
if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
exec "silent vertical resize ". size
let b:NERDTreeZoomed = 0
else
exec "vertical resize"
let b:NERDTreeZoomed = 1
endif
endfunction
"FUNCTION: s:UI.UpDirLine() {{{1
function! s:UI.UpDirLine()
return '.. (up a dir)'
endfunction

View file

@ -1,40 +0,0 @@
" ============================================================================
" File: exec_menuitem.vim
" Description: plugin for NERD Tree that provides an execute file menu item
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
if exists("g:loaded_nerdtree_exec_menuitem")
finish
endif
let g:loaded_nerdtree_exec_menuitem = 1
call NERDTreeAddMenuItem({
\ 'text': '(!)Execute file',
\ 'shortcut': '!',
\ 'callback': 'NERDTreeExecFile',
\ 'isActiveCallback': 'NERDTreeExecFileActive' })
function! NERDTreeExecFileActive()
let node = g:NERDTreeFileNode.GetSelected()
return !node.path.isDirectory && node.path.isExecutable
endfunction
function! NERDTreeExecFile()
let treenode = g:NERDTreeFileNode.GetSelected()
echo "==========================================================\n"
echo "Complete the command to execute (add arguments etc):\n"
let cmd = treenode.path.str({'escape': 1})
let cmd = input(':!', cmd . ' ')
if cmd != ''
exec ':!' . cmd
else
echo "Aborted"
endif
endfunction

View file

@ -1,338 +0,0 @@
" ============================================================================
" File: fs_menu.vim
" Description: plugin for the NERD Tree that provides a file system menu
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
if exists("g:loaded_nerdtree_fs_menu")
finish
endif
let g:loaded_nerdtree_fs_menu = 1
"Automatically delete the buffer after deleting or renaming a file
if !exists("g:NERDTreeAutoDeleteBuffer")
let g:NERDTreeAutoDeleteBuffer = 0
endif
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
if has("gui_mac") || has("gui_macvim") || has("mac")
call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
endif
if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
if has("unix") || has("osx")
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})
else
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'})
endif
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
"prints out the given msg and, if the user responds by pushing 'y' then the
"buffer with the given bufnum is deleted
"
"Args:
"bufnum: the buffer that may be deleted
"msg: a message that will be echoed to the user asking them if they wish to
" del the buffer
function! s:promptToDelBuffer(bufnum, msg)
echo a:msg
if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
" 1. ensure that all windows which display the just deleted filename
" now display an empty buffer (so a layout is preserved).
" Is not it better to close single tabs with this file only ?
let s:originalTabNumber = tabpagenr()
let s:originalWindowNumber = winnr()
" Go to the next buffer in buffer list if at least one extra buffer is listed
" Otherwise open a new empty buffer
if v:version >= 800
let l:listedBufferCount = len(getbufinfo({'buflisted':1}))
elseif v:version >= 702
let l:listedBufferCount = len(filter(range(1, bufnr('$')), 'buflisted(v:val)'))
else
" Ignore buffer count in this case to make sure we keep the old
" behavior
let l:listedBufferCount = 0
endif
if l:listedBufferCount > 1
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif"
else
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif"
endif
exec "tabnext " . s:originalTabNumber
exec s:originalWindowNumber . "wincmd w"
" 3. We don't need a previous buffer anymore
exec "bwipeout! " . a:bufnum
endif
endfunction
"FUNCTION: s:promptToRenameBuffer(bufnum, msg){{{1
"prints out the given msg and, if the user responds by pushing 'y' then the
"buffer with the given bufnum is replaced with a new one
"
"Args:
"bufnum: the buffer that may be deleted
"msg: a message that will be echoed to the user asking them if they wish to
" del the buffer
function! s:promptToRenameBuffer(bufnum, msg, newFileName)
echo a:msg
if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
let quotedFileName = fnameescape(a:newFileName)
" 1. ensure that a new buffer is loaded
exec "badd " . quotedFileName
" 2. ensure that all windows which display the just deleted filename
" display a buffer for a new filename.
let s:originalTabNumber = tabpagenr()
let s:originalWindowNumber = winnr()
let editStr = g:NERDTreePath.New(a:newFileName).str({'format': 'Edit'})
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . editStr . "' | endif"
exec "tabnext " . s:originalTabNumber
exec s:originalWindowNumber . "wincmd w"
" 3. We don't need a previous buffer anymore
exec "bwipeout! " . a:bufnum
endif
endfunction
"FUNCTION: NERDTreeAddNode(){{{1
function! NERDTreeAddNode()
let curDirNode = g:NERDTreeDirNode.GetSelected()
let newNodeName = input("Add a childnode\n".
\ "==========================================================\n".
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
\ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
if newNodeName ==# ''
call nerdtree#echo("Node Creation Aborted.")
return
endif
try
let newPath = g:NERDTreePath.Create(newNodeName)
let parentNode = b:NERDTree.root.findNode(newPath.getParent())
let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree)
if empty(parentNode)
call b:NERDTree.root.refresh()
call b:NERDTree.render()
elseif parentNode.isOpen || !empty(parentNode.children)
call parentNode.addChild(newTreeNode, 1)
call NERDTreeRender()
call newTreeNode.putCursorHere(1, 0)
endif
catch /^NERDTree/
call nerdtree#echoWarning("Node Not Created.")
endtry
endfunction
"FUNCTION: NERDTreeMoveNode(){{{1
function! NERDTreeMoveNode()
let curNode = g:NERDTreeFileNode.GetSelected()
let newNodePath = input("Rename the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path for the node: \n" .
\ "", curNode.path.str(), "file")
if newNodePath ==# ''
call nerdtree#echo("Node Renaming Aborted.")
return
endif
try
let bufnum = bufnr("^".curNode.path.str()."$")
call curNode.rename(newNodePath)
call NERDTreeRender()
"if the node is open in a buffer, ask the user if they want to
"close that buffer
if bufnum != -1
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with a new file? (yN)"
call s:promptToRenameBuffer(bufnum, prompt, newNodePath)
endif
call curNode.putCursorHere(1, 0)
redraw
catch /^NERDTree/
call nerdtree#echoWarning("Node Not Renamed.")
endtry
endfunction
" FUNCTION: NERDTreeDeleteNode() {{{1
function! NERDTreeDeleteNode()
let currentNode = g:NERDTreeFileNode.GetSelected()
let confirmed = 0
if currentNode.path.isDirectory && currentNode.getChildCount() > 0
let choice =input("Delete the current node\n" .
\ "==========================================================\n" .
\ "STOP! Directory is not empty! To delete, type 'yes'\n" .
\ "" . currentNode.path.str() . ": ")
let confirmed = choice ==# 'yes'
else
echo "Delete the current node\n" .
\ "==========================================================\n".
\ "Are you sure you wish to delete the node:\n" .
\ "" . currentNode.path.str() . " (yN):"
let choice = nr2char(getchar())
let confirmed = choice ==# 'y'
endif
if confirmed
try
call currentNode.delete()
call NERDTreeRender()
"if the node is open in a buffer, ask the user if they want to
"close that buffer
let bufnum = bufnr("^".currentNode.path.str()."$")
if buflisted(bufnum)
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
call s:promptToDelBuffer(bufnum, prompt)
endif
redraw
catch /^NERDTree/
call nerdtree#echoWarning("Could not remove node")
endtry
else
call nerdtree#echo("delete aborted")
endif
endfunction
" FUNCTION: NERDTreeListNode() {{{1
function! NERDTreeListNode()
let treenode = g:NERDTreeFileNode.GetSelected()
if !empty(treenode)
if has("osx")
let stat_cmd = 'stat -f "%z" '
else
let stat_cmd = 'stat -c "%s" '
endif
let cmd = 'size=$(' . stat_cmd . shellescape(treenode.path.str()) . ') && ' .
\ 'size_with_commas=$(echo $size | sed -e :a -e "s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta") && ' .
\ 'ls -ld ' . shellescape(treenode.path.str()) . ' | sed -e "s/ $size / $size_with_commas /"'
let metadata = split(system(cmd),'\n')
call nerdtree#echo(metadata[0])
else
call nerdtree#echo("No information available")
endif
endfunction
" FUNCTION: NERDTreeListNodeWin32() {{{1
function! NERDTreeListNodeWin32()
let l:node = g:NERDTreeFileNode.GetSelected()
if !empty(l:node)
let l:save_shell = &shell
set shell&
if exists('+shellslash')
let l:save_shellslash = &shellslash
set noshellslash
endif
let l:command = 'DIR /Q '
\ . shellescape(l:node.path.str())
\ . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'
let l:metadata = split(system(l:command), "\n")
if v:shell_error == 0
call nerdtree#echo(l:metadata[0])
else
call nerdtree#echoError('shell command failed')
endif
let &shell = l:save_shell
if exists('l:save_shellslash')
let &shellslash = l:save_shellslash
endif
return
endif
call nerdtree#echo('node not recognized')
endfunction
" FUNCTION: NERDTreeCopyNode() {{{1
function! NERDTreeCopyNode()
let currentNode = g:NERDTreeFileNode.GetSelected()
let newNodePath = input("Copy the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path to copy the node to: \n" .
\ "", currentNode.path.str(), "file")
if newNodePath != ""
"strip trailing slash
let newNodePath = substitute(newNodePath, '\/$', '', '')
let confirmed = 1
if currentNode.path.copyingWillOverwrite(newNodePath)
call nerdtree#echo("Warning: copying may overwrite files! Continue? (yN)")
let choice = nr2char(getchar())
let confirmed = choice ==# 'y'
endif
if confirmed
try
let newNode = currentNode.copy(newNodePath)
if empty(newNode)
call b:NERDTree.root.refresh()
call b:NERDTree.render()
else
call NERDTreeRender()
call newNode.putCursorHere(0, 0)
endif
catch /^NERDTree/
call nerdtree#echoWarning("Could not copy node")
endtry
endif
else
call nerdtree#echo("Copy aborted.")
endif
redraw
endfunction
" FUNCTION: NERDTreeQuickLook() {{{1
function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
endif
endfunction
" FUNCTION: NERDTreeRevealInFinder() {{{1
function! NERDTreeRevealInFinder()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
call system("open -R '" . treenode.path.str() . "'")
endif
endfunction
" FUNCTION: NERDTreeExecuteFile() {{{1
function! NERDTreeExecuteFile()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
call system("open '" . treenode.path.str() . "'")
endif
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,223 +0,0 @@
" ============================================================================
" File: NERD_tree.vim
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
"
" SECTION: Script init stuff {{{1
"============================================================
if exists("loaded_nerd_tree")
finish
endif
if v:version < 700
echoerr "NERDTree: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!"
finish
endif
let loaded_nerd_tree = 1
"for line continuation - i.e dont want C in &cpo
let s:old_cpo = &cpo
set cpo&vim
"Function: s:initVariable() function {{{2
"This function is used to initialise a given variable to a given value. The
"variable is only initialised if it does not exist prior
"
"Args:
"var: the name of the var to be initialised
"value: the value to initialise var to
"
"Returns:
"1 if the var is set, 0 otherwise
function! s:initVariable(var, value)
if !exists(a:var)
exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'"
return 1
endif
return 0
endfunction
"SECTION: Init variable calls and other random constants {{{2
call s:initVariable("g:NERDTreeAutoCenter", 1)
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
call s:initVariable("g:NERDTreeNaturalSort", 0)
call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
call s:initVariable("g:NERDTreeChDirMode", 0)
call s:initVariable("g:NERDTreeCreatePrefix", "silent")
call s:initVariable("g:NERDTreeMinimalUI", 0)
if !exists("g:NERDTreeIgnore")
let g:NERDTreeIgnore = ['\~$']
endif
call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')
call s:initVariable("g:NERDTreeBookmarksSort", 1)
call s:initVariable("g:NERDTreeHighlightCursorline", 1)
call s:initVariable("g:NERDTreeHijackNetrw", 1)
call s:initVariable('g:NERDTreeMarkBookmarks', 1)
call s:initVariable("g:NERDTreeMouseMode", 1)
call s:initVariable("g:NERDTreeNotificationThreshold", 100)
call s:initVariable("g:NERDTreeQuitOnOpen", 0)
call s:initVariable("g:NERDTreeRespectWildIgnore", 0)
call s:initVariable("g:NERDTreeShowBookmarks", 0)
call s:initVariable("g:NERDTreeShowFiles", 1)
call s:initVariable("g:NERDTreeShowHidden", 0)
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
call s:initVariable("g:NERDTreeSortDirs", 1)
if !nerdtree#runningWindows() && !nerdtree#runningCygwin()
call s:initVariable("g:NERDTreeDirArrowExpandable", "▸")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾")
else
call s:initVariable("g:NERDTreeDirArrowExpandable", "+")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
endif
call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1)
if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
else
"if there isnt a * in the sort sequence then add one
if count(g:NERDTreeSortOrder, '*') < 1
call add(g:NERDTreeSortOrder, '*')
endif
endif
call s:initVariable("g:NERDTreeGlyphReadOnly", "RO")
if !exists('g:NERDTreeStatusline')
"the exists() crap here is a hack to stop vim spazzing out when
"loading a session that was created with an open nerd tree. It spazzes
"because it doesnt store b:NERDTree(its a b: var, and its a hash)
let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}"
endif
call s:initVariable("g:NERDTreeWinPos", "left")
call s:initVariable("g:NERDTreeWinSize", 31)
"init the shell commands that will be used to copy nodes, and remove dir trees
"
"Note: the space after the command is important
if nerdtree#runningWindows()
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ')
call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ')
call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ')
else
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ')
call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ')
endif
"SECTION: Init variable calls for key mappings {{{2
call s:initVariable("g:NERDTreeMapActivateNode", "o")
call s:initVariable("g:NERDTreeMapChangeRoot", "C")
call s:initVariable("g:NERDTreeMapChdir", "cd")
call s:initVariable("g:NERDTreeMapCloseChildren", "X")
call s:initVariable("g:NERDTreeMapCloseDir", "x")
call s:initVariable("g:NERDTreeMapDeleteBookmark", "D")
call s:initVariable("g:NERDTreeMapMenu", "m")
call s:initVariable("g:NERDTreeMapHelp", "?")
call s:initVariable("g:NERDTreeMapJumpFirstChild", "K")
call s:initVariable("g:NERDTreeMapJumpLastChild", "J")
call s:initVariable("g:NERDTreeMapJumpNextSibling", "<C-j>")
call s:initVariable("g:NERDTreeMapJumpParent", "p")
call s:initVariable("g:NERDTreeMapJumpPrevSibling", "<C-k>")
call s:initVariable("g:NERDTreeMapJumpRoot", "P")
call s:initVariable("g:NERDTreeMapOpenExpl", "e")
call s:initVariable("g:NERDTreeMapOpenInTab", "t")
call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T")
call s:initVariable("g:NERDTreeMapOpenRecursively", "O")
call s:initVariable("g:NERDTreeMapOpenSplit", "i")
call s:initVariable("g:NERDTreeMapOpenVSplit", "s")
call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode)
call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit)
call s:initVariable("g:NERDTreeMapPreviewVSplit", "g" . NERDTreeMapOpenVSplit)
call s:initVariable("g:NERDTreeMapQuit", "q")
call s:initVariable("g:NERDTreeMapRefresh", "r")
call s:initVariable("g:NERDTreeMapRefreshRoot", "R")
call s:initVariable("g:NERDTreeMapToggleBookmarks", "B")
call s:initVariable("g:NERDTreeMapToggleFiles", "F")
call s:initVariable("g:NERDTreeMapToggleFilters", "f")
call s:initVariable("g:NERDTreeMapToggleHidden", "I")
call s:initVariable("g:NERDTreeMapToggleZoom", "A")
call s:initVariable("g:NERDTreeMapUpdir", "u")
call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
call s:initVariable("g:NERDTreeMapCWD", "CD")
"SECTION: Load class files{{{2
call nerdtree#loadClassFiles()
" SECTION: Commands {{{1
"============================================================
call nerdtree#ui_glue#setupCommands()
" SECTION: Auto commands {{{1
"============================================================
augroup NERDTree
"Save the cursor position whenever we close the nerd tree
exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif"
"disallow insert mode in the NERDTree
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
augroup END
if g:NERDTreeHijackNetrw
augroup NERDTreeHijackNetrw
autocmd VimEnter * silent! autocmd! FileExplorer
au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand("<amatch>"))
augroup END
endif
" SECTION: Public API {{{1
"============================================================
function! NERDTreeAddMenuItem(options)
call g:NERDTreeMenuItem.Create(a:options)
endfunction
function! NERDTreeAddMenuSeparator(...)
let opts = a:0 ? a:1 : {}
call g:NERDTreeMenuItem.CreateSeparator(opts)
endfunction
function! NERDTreeAddSubmenu(options)
return g:NERDTreeMenuItem.Create(a:options)
endfunction
function! NERDTreeAddKeyMap(options)
call g:NERDTreeKeyMap.Create(a:options)
endfunction
function! NERDTreeRender()
call nerdtree#renderView()
endfunction
function! NERDTreeFocus()
if g:NERDTree.IsOpen()
call g:NERDTree.CursorToTreeWin()
else
call g:NERDTreeCreator.ToggleTabTree("")
endif
endfunction
function! NERDTreeCWD()
call NERDTreeFocus()
call nerdtree#ui_glue#chRootCwd()
endfunction
function! NERDTreeAddPathFilter(callback)
call g:NERDTree.AddPathFilter(a:callback)
endfunction
" SECTION: Post Source Actions {{{1
call nerdtree#postSourceActions()
"reset &cpo back to users setting
let &cpo = s:old_cpo
" vim: set sw=4 sts=4 et fdm=marker:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

View file

@ -1,82 +0,0 @@
let s:tree_up_dir_line = '.. (up a dir)'
syn match NERDTreeIgnore #\~#
exec 'syn match NERDTreeIgnore #\['.g:NERDTreeGlyphReadOnly.'\]#'
"highlighting for the .. (up dir) line at the top of the tree
execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
"quickhelp syntax elements
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1
syn match NERDTreeHelpTitle #" .*\~$#ms=s+2,me=e-1
syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1
syn match NERDTreeToggleOff #(off)#ms=e-3,me=e-1
syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeIgnore,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
"highlighting for sym links
syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile
syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile
syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir
"highlighing for directory nodes and file nodes
syn match NERDTreeDirSlash #/# containedin=NERDTreeDir
exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile'
exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile'
let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-')
exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#'
syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark
exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile'
"highlighting for readonly files
exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile'
syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile
syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir
syn match NERDTreeCWD #^[</].*$#
"highlighting for bookmarks
syn match NERDTreeBookmark # {.*}#hs=s+1
"highlighting for the bookmarks table
syn match NERDTreeBookmarksLeader #^>#
syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
hi def link NERDTreePart Special
hi def link NERDTreePartFile Type
hi def link NERDTreeExecFile Title
hi def link NERDTreeDirSlash Identifier
hi def link NERDTreeBookmarksHeader statement
hi def link NERDTreeBookmarksLeader ignore
hi def link NERDTreeBookmarkName Identifier
hi def link NERDTreeBookmark normal
hi def link NERDTreeHelp String
hi def link NERDTreeHelpKey Identifier
hi def link NERDTreeHelpCommand Identifier
hi def link NERDTreeHelpTitle Macro
hi def link NERDTreeToggleOn Question
hi def link NERDTreeToggleOff WarningMsg
hi def link NERDTreeLinkTarget Type
hi def link NERDTreeLinkFile Macro
hi def link NERDTreeLinkDir Macro
hi def link NERDTreeDir Directory
hi def link NERDTreeUp Directory
hi def link NERDTreeFile Normal
hi def link NERDTreeCWD Statement
hi def link NERDTreeOpenable Directory
hi def link NERDTreeClosable Directory
hi def link NERDTreeIgnore ignore
hi def link NERDTreeRO WarningMsg
hi def link NERDTreeBookmark Statement
hi def link NERDTreeFlags Number
hi def link NERDTreeCurrentNode Search

View file

@ -1,19 +0,0 @@
nginx.vim CHANGELOG
=====================
This file is used to list changes made in each version of the [nginx](https://github.com/chr4/nginx.vim) plugin for the [Vim](http://www.vim.org/) editor.
1.1.0
-----
- Do not highlight `SHA` ciphers, as usage as HMAC is still considered secure
1.0.1
-----
- Highlight `gzip on` as insecure (as it might be vulnerable to BREACH/ CRIME)
1.0.0
-----
- Initial release

View file

@ -1,675 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Vim plugin that highlights insecure SSL/TLS cipher suites and protocols.
Copyright (C) 2017 Chris Aumann
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
nginx.vim Copyright (C) 2017 Chris Aumann
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View file

@ -1,92 +0,0 @@
# nginx.vim
## Description
[Vim](http://www.vim.org/) plugin for [Nginx](http://www.nginx.org)
## Features
The plugin is based on the recent vim-plugin distributed with `nginx-1.12.0` and additionally features the following syntax improvements:
- Highlight IPv4 and IPv6 addresses
- Mark insecure `ssl_protocols` as errors
- Inline template syntax highlight for **ERB** and **Jinja**
- Inline syntax highlight for **LUA**
- Improve integer matching
- Syntax highlighting for `proxy_next_upstream` options
- Syntax highlighting for `sticky` options
- Syntax highlighting for `upstream` `server` options
- More to come!
Furthermore:
- Remove annoying delimiters, resulting in strange word-boundaries
*Note: Also check out [sslsecure.vim](https://github.com/chr4/sslsecure.vim): it supports highlighting insecure SSL/TLS cipher suites and protocols in all your files!*
## Screenshots
A `server` block with highlighting of insecure `ssl_protocol` options:
![nginx server block with SSL configuration](https://chr4.org/images/nginx_ssl.png)
An `upstream` block with highlighted options:
![nginx upstream configuration](https://chr4.org/images/nginx_upstream.png)
Embedded highlighting for ERB and Jinja templates:
![Embedded highlighting for ERB and Jinja templates](https://chr4.org/images/nginx_templating.png)
Embedded LUA syntax highlighting:
![Embedded LUA syntax highlighting](https://chr4.org/images/nginx_lua.png)
## Snippets
The plugin comes with useful snippets which can be accessed using e.g. [vim-snipmate](https://github.com/garbas/vim-snipmate).
Select a decent cipher for your requirements (all of them can provide [SSLLabs A+ ratings](https://www.ssllabs.com/ssltest/analyze.html))
- `ciphers-paranoid<tab>`: Even-more-secure ciphers (elliptic curves, no GCM), not compatible with IE < 11, OpenSSL-0.9.8, Safari < 7, Android != 4.4
- **`ciphers-modern<tab>`: High-security ciphers (elliptic curves), not compatible with IE < 11, OpenSSL-0.9.8, Safari < 7, Android < 4.4 (recommended)**
- `ciphers-compat<tab>`: Medium-security ciphers with good compatibility (No IE on WinXP) but TLSv1 and SHA required
- `ciphers-old<tab>`: Low-security ciphers (using weak DES and SHA ciphers, TLSv1), but compatible with everything but IE6 and Java6
- `ssl-options<tab>`: Bootstrap secure SSL options
Example:
```nginx
# High-security ciphers (elliptic curves), less compatibility
# No IE < 10, OpenSSL-0.9.8, Safari < 7, Android < 4.4
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
```
Or add a robots.txt file with `robots.txt<tab>`:
```nginx
# Tell bots to not index this site
location /robots.txt {
default_type text/plain;
return 200 'User-agent: *\nDisallow: /\n';
}
```
It also has auto-completion for location and server blocks with `location<tab>` resp. `server<tab>`, and [many more](https://github.com/chr4/nginx.vim/blob/master/snippets/nginx.snippets)!
- Add useful [snippets](https://github.com/chr4/nginx.vim/blob/master/snippets/nginx.snippets)
## References
- Based on the original `nginx-1.12.0/contrib/vim`
- IPv4 and IPv6 address highlighting, based on expressions found in [this forum post](http://vim.1045645.n5.nabble.com/IPv6-support-for-quot-dns-quot-zonefile-syntax-highlighting-td1197292.html)
- [Blog post](https://chr4.org/blog/2017/04/14/better-syntax-highlighting-and-snippets-for-nginx-in-vim/) introducing this plugin including some more examples
## Installation
Just plug it into your favorite Vim package manager:
```vim
" Plug
Plug 'chr4/nginx.vim'
" Dein.vim
call dein#add('chr4/nginx.vim')
" Vundle
Plugin 'chr4/nginx.vim'
```
Optionally, if you like [Jinja](http://jinja.pocoo.org/) template syntax highlighting, install `lepture/vim-jinja`, too.

View file

@ -1,5 +0,0 @@
au BufRead,BufNewFile *.nginx set ft=nginx
au BufRead,BufNewFile nginx*.conf set ft=nginx
au BufRead,BufNewFile *nginx.conf set ft=nginx
au BufRead,BufNewFile */etc/nginx/* set ft=nginx
au BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx

View file

@ -1 +0,0 @@
setlocal commentstring=#\ %s

View file

@ -1,11 +0,0 @@
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal indentexpr=
" cindent actually works for nginx' simple file structure
setlocal cindent
" Just make sure that the comments are not reset as defs would be.
setlocal cinkeys-=0#

View file

@ -1,166 +0,0 @@
# vim: ft=nginx
snippet l80
listen [::]:80 ipv6only=off;
$0
# Listen statements when using multiple http server blocks
snippet l80-multi
listen [::]:80 default_server;
listen 80 default_server;
$0
snippet l443
listen [::]:443 ipv6only=off ssl http2 default_server;
$0
# Listen statements when using multiple ssl server blocks
snippet l443-multi
listen [::]:443 ssl http2 default_server;
listen 443 ssl http2 default_server;
$0
# Cipher suites are taken and adapted from Mozilla's recommendations
# https://wiki.mozilla.org/Security/Server_Side_TLS
#
# Paranoid mode
snippet ciphers-paranoid
# Paranoid ciphers, 256bit minimum, prefer ChaCha20/ Poly1305, bad compatibility
# No Android 5+6 (4.4 works), Chrome < 51, Firefox < 49, IE < 11, Java 6-8, GoogleBot
ssl_protocols TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384';
$0
# Mozilla modern
snippet ciphers-modern
# High-security ciphers (elliptic curves), less compatibility
# No IE < 10, OpenSSL-0.9.8, Safari < 7, Android < 4.4
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
$0
# Mozilla intermediate (Removed DES for more security)
snippet ciphers-compat
# Medium-security ciphers with good compatibility (Weak: SHA)
# No IE on WinXP
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
$0
# Mozilla old (Removed DSS, HIGH, SEED for more security)
snippet ciphers-low
# Low-security ciphers (Weak: DES, SHA)
# No IE6, Java6
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:!SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!KRB5-DES-CBC3-SHA:!SRP:!DSS';
$0
snippet ssl-options
# SSL certificate
ssl_certificate /etc/nginx/certs/${4:www.example.com}.crt;
ssl_certificate_key /etc/nginx/certs/${5:www.example.com}.key;
# ssl_dhparam /etc/nginx/certs/dhparam.pem;
ssl_prefer_server_ciphers on;
ssl_stapling off;
ssl_stapling_verify off;
ssl_session_cache 'shared:SSL:10m';
ssl_session_tickets off;
# Enable HSTS (1 year) and some security options
add_header Strict-Transport-Security 'max-age=31536000 includeSubDomains; preload;';
$0
snippet security-headers
add_header X-Frame-Options 'DENY';
add_header X-Content-Type-Options 'nosniff';
add_header X-Frame-Options 'SAMEORIGIN';
add_header X-XSS-Protection '1; mode=block';
add_header X-Robots-Tag 'none';
add_header X-Download-Options 'noopen';
add_header X-Permitted-Cross-Domain-Policies 'none';
$0
snippet robots.txt
# Tell bots to not index this site
location /robots.txt {
default_type text/plain;
return 200 'User-agent: *\nDisallow: /\n';
}
$0
snippet basic-auth
auth_basic 'Restricted';
auth_basic_user_file ${1:/etc/nginx/htpasswd};
$0
snippet proxy_pass
proxy_pass_header Date;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://${1:backend};
$0
snippet php-fpm
location ~ \.php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass ${1:127.0.0.1:9000};
}
$0
snippet php-uwsgi
location ~ \.php$ {
include uwsgi_params;
uwsgi_max_temp_file_size 4096m;
uwsgi_modifier1 14;
uwsgi_read_timeout 900;
uwsgi_send_timeout 900;
uwsgi_pass ${1:unix:///run/uwsgi/php.sock};
}
$0
snippet redirect-ssl
location / {
return 301 https://$http_host$request_uri;
}
$0
snippet redirect-other
# Redirect other requested hosts
if ($host != '${1:DOMAIN}') {
return 301 https://${2:DOMAIN}$request_uri;
}
$0
snippet letsencrypt
listen [::]:80 ipv6only=off;
# Serve well-known path for letsencrypt
location /.well-known/acme-challenge {
root /etc/nginx/certs/acme;
default_type text/plain;
}
location / {
return 301 https://$http_host$request_uri;
}
$0
snippet cut-trailing-slash
rewrite ^/(.*)/$ $scheme://$http_host:$server_port/$1 permanent;
$0
snippet location
location ${1:/} {
${0:${VISUAL}}
}
snippet server
server {
${0:${VISUAL}}
}

File diff suppressed because it is too large Load diff

View file

@ -1,41 +0,0 @@
" ----- Emulate 'gf' but recognize :line format -----
function! GotoFile(w)
let curword = expand("<cfile>")
if (strlen(curword) == 0)
return
endif
let matchstart = match(curword, ':\d\+$')
if matchstart > 0
let pos = '+' . strpart(curword, matchstart+1)
let fname = strpart(curword, 0, matchstart)
else
let pos = ""
let fname = curword
endif
" check exists file.
if filereadable(fname)
let fullname = fname
else
" try find file with prefix by working directory
let fullname = getcwd() . '/' . fname
if ! filereadable(fullname)
" the last try, using current directory based on file opened.
let fullname = expand('%:h') . '/' . fname
endif
endif
" Open new window if requested
if a:w == "new"
new
endif
" Use 'find' so path is searched like 'gf' would
execute 'find ' . pos . ' ' . fname
endfunction
set isfname+=: " include colon in filenames
" Override vim commands 'gf', '^Wf', '^W^F'
nnoremap gf :call GotoFile("")<CR>
nnoremap <C-W>f :call GotoFile("new")<CR>
nnoremap <C-W><C-F> :call GotoFile("new")<CR>

View file

@ -1 +0,0 @@
/doc/tags

View file

@ -1,30 +0,0 @@
# rust.vim
## Description
This is a vim plugin provides [Rust][r] file detection and syntax highlighting.
It is synchronized daily to the vim support code in [rust-lang/rust][rr]'s
master branch via cronjob.
## Installation
### Using [Vundle][v]
1. Add `Plugin 'wting/rust.vim'` to `~/.vimrc`
2. `vim +PluginInstall +qall`
*Note:* Vundle will not automatically detect Rust files properly if `filetype
on` is executed before Vundle. Please check the [quickstart][vqs] for more
details.
### Using [Pathogen][p]
1. `cd ~/.vim/bundle`
2. `git clone https://github.com/wting/rust.vim.git`
[rr]: https://github.com/rust-lang/rust
[p]: https://github.com/tpope/vim-pathogen
[r]: https://en.wikipedia.org/wiki/Rust_language
[v]: https://github.com/gmarik/vundle
[vqs]: https://github.com/gmarik/vundle#quick-start

Some files were not shown because too many files have changed in this diff Show more