Browse Source

vim: ++fff.vim

Maxim Likhachev 6 years ago
parent
commit
d05a6ec2cd
  1. 21
      etc/soft/vim/vim/+plugins/fff.vim/LICENSE.md
  2. 66
      etc/soft/vim/vim/+plugins/fff.vim/README.md
  3. 48
      etc/soft/vim/vim/+plugins/fff.vim/autoload/fff.vim
  4. 8
      etc/soft/vim/vim/+plugins/fff.vim/plugin/fff.vim
  5. 5
      etc/soft/vim/vimrc

21
etc/soft/vim/vim/+plugins/fff.vim/LICENSE.md

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Dylan Araps
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.

66
etc/soft/vim/vim/+plugins/fff.vim/README.md

@ -0,0 +1,66 @@
# fff.vim
A plugin for vim/neovim which allows you to use [**`fff`**](https://github.com/dylanaraps/fff) as a file opener.
## Table of Contents
<!-- vim-markdown-toc GFM -->
* [Installation](#installation)
* [Usage](#usage)
* [Command](#command)
* [Easy hotkey](#easy-hotkey)
* [Customization](#customization)
* [Split Size](#split-size)
* [Split Direction](#split-direction)
<!-- vim-markdown-toc -->
## Installation
Using [vim-plug](https://github.com/junegunn/vim-plug):
```vim
Plug 'dylanaraps/fff.vim'
```
Then run `:PlugUpdate`
## Usage
### Command
```vim
" Open in current directory.
:F
" Open in ~/dotfiles (or other path)
:F ~/dotfiles
```
### Easy hotkey
```vim
" Open fff on press of 'f'
nnoremap f :F<CR>
```
## Customization
### Split Size
Default: `let g:fff#split = "10new"`
```vim
# Vertical split (NERDtree style).
let g:fff#split = "30vnew"
```
### Split Direction
Default: `let g:fff#split_direction = "splitbelow splitright"`
```vim
# Open split on the left side (NERDtree style).
let g:fff#split_direction = "nosplitbelow nosplitright"
```

48
etc/soft/vim/vim/+plugins/fff.vim/autoload/fff.vim

@ -0,0 +1,48 @@
" fff.vim
let g:fff#split = get(g:, 'fff#split', '10new')
let g:fff#split_direction = get(g:, 'fff#split_direction',
\ 'splitbelow splitright')
function! fff#open_file(...)
let tmp_file = $XDG_CACHE_HOME
if !isdirectory(tmp_file)
let tmp_file = $HOME . "/.cache"
endif
let tmp_file .= "/fff/opened_file"
let tmp_file = fnameescape(tmp_file)
bd!
if filereadable(tmp_file)
let file_data = readfile(tmp_file)
execute delete(tmp_file)
else
return
endif
if filereadable(file_data[0])
execute "e " . file_data[0]
endif
endfunction
function! fff#Run(command)
execute 'setlocal' . ' ' . g:fff#split_direction
execute g:fff#split
execute 'setlocal nonumber'
execute 'setlocal norelativenumber'
if has('nvim')
call termopen('fff -p ' . a:command,
\ {'on_exit': function('fff#open_file') })
startinsert
else
let buffer = term_start([&shell, &shellcmdflag, 'fff -p ' . a:command],
\ {'curwin': 1, 'exit_cb': function('fff#open_file')})
if !has('patch-8.0.1261')
call term_wait(buffer, 20)
endif
endif
endfunction

8
etc/soft/vim/vim/+plugins/fff.vim/plugin/fff.vim

@ -0,0 +1,8 @@
" fff.vim
if exists('g:loaded_fff')
finish
endif
let g:loaded_fff = 1
command! -nargs=* -complete=dir F call fff#Run(<q-args>)

5
etc/soft/vim/vimrc

@ -788,5 +788,10 @@ call neomake#configure#automake('w')
" let g:neomake_open_list = 2 " let g:neomake_open_list = 2
" }}} " }}}
" fff.vim {{{
let g:fff#split = "30vnew"
let g:fff#split_direction = "nosplitbelow nosplitright"
" }}}
" }}}########################################################################### " }}}###########################################################################

Loading…
Cancel
Save