~shabbyrobe/ctrlp-netrw.vim

d8275f59fab10a0fc92d74e096dcb74853a21e9f — shabbyrobe 8 years ago master
initial
3 files changed, 90 insertions(+), 0 deletions(-)

A README.md
A autoload/ctrlp/netrw.vim
A plugin/ctrlp-netrw.vim
A  => README.md +44 -0
@@ 1,44 @@
# ctrlp-netrw

This CtrlP extension allows you to open netrw in a specific directory. Works
only in Unix-like operating systems.

It is a modified version of Voronkovich Oleg's
[ctrlp-nerdtree.vim](https://github.com/voronkovich/ctrlp-nerdtree.vim) plugin.

## How to use

``` vim
:CtrlPNetrw
```

By default plugin ignore hidden directories. You change this by adding:

```vim
let g:ctrlp_netrw_show_hidden = 1
```

to your .vimrc

## Installation

### Using [pathogen](https://github.com/tpope/vim-pathogen)

``` sh
git clone git://github.com/shabbyrobe/ctrlp-netrw.vim ~/.vim/bundle/ctrlp-netrw.vim
```

### Using [vundle](https://github.com/gmarik/vundle)

Add to vimrc:

``` vim
Bundle 'shabbyrobe/ctrlp-netrw.vim'
```

## License

Copyright (c) Voronkovich Oleg, Blake Williams.  Distributed under the same
terms as Vim itself (in accordance with the license of `ctrlp-nerdtree.vim`).
See `:help license`.


A  => autoload/ctrlp/netrw.vim +45 -0
@@ 1,45 @@
if exists('g:loaded_ctrlp_netrw') && g:loaded_ctrlp_netrw
  finish
endif
let g:loaded_ctrlp_netrw = 1

let s:netrw_var = {
\  'init':   'ctrlp#netrw#init()',
\  'exit':   'ctrlp#netrw#exit()',
\  'accept': 'ctrlp#netrw#accept',
\  'lname':  'netrw',
\  'sname':  'netrw',
\  'type':   'path',
\  'sort':   0,
\}

if exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
  let g:ctrlp_ext_vars = add(g:ctrlp_ext_vars, s:netrw_var)
else
  let g:ctrlp_ext_vars = [s:netrw_var]
endif

function! ctrlp#netrw#init()
    if exists('g:ctrlp_netrw_show_hidden') && g:ctrlp_netrw_show_hidden == 1
        let cmd = "find -type d"
    else
        let cmd = "find -type d \\( -path '*/.*' -prune -o -print \\) | sed -e s@./@@"
    endif
    let paths = reverse(split(system(cmd),"\n"))
    return paths
endfunction

function! ctrlp#netrw#accept(mode, str)
  call ctrlp#exit()
  exec "e " . a:str
  echo a:str
endfunction

function! ctrlp#netrw#exit()
endfunction

let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
function! ctrlp#netrw#id()
  return s:id
endfunction


A  => plugin/ctrlp-netrw.vim +1 -0
@@ 1,1 @@
command! -n=* CtrlPNetrw call ctrlp#init(ctrlp#netrw#id())