From d05a6ec2cd96aa28743606b2c0926ef77fad6ea8 Mon Sep 17 00:00:00 2001 From: Maxim Likhachev Date: Wed, 13 Nov 2019 22:54:29 +0300 Subject: [PATCH] vim: ++fff.vim --- etc/soft/vim/vim/+plugins/fff.vim/LICENSE.md | 21 +++++++ etc/soft/vim/vim/+plugins/fff.vim/README.md | 66 ++++++++++++++++++++++ etc/soft/vim/vim/+plugins/fff.vim/autoload/fff.vim | 48 ++++++++++++++++ etc/soft/vim/vim/+plugins/fff.vim/plugin/fff.vim | 8 +++ etc/soft/vim/vimrc | 5 ++ 5 files changed, 148 insertions(+) create mode 100644 etc/soft/vim/vim/+plugins/fff.vim/LICENSE.md create mode 100644 etc/soft/vim/vim/+plugins/fff.vim/README.md create mode 100644 etc/soft/vim/vim/+plugins/fff.vim/autoload/fff.vim create mode 100644 etc/soft/vim/vim/+plugins/fff.vim/plugin/fff.vim diff --git a/etc/soft/vim/vim/+plugins/fff.vim/LICENSE.md b/etc/soft/vim/vim/+plugins/fff.vim/LICENSE.md new file mode 100644 index 0000000..222788b --- /dev/null +++ b/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. diff --git a/etc/soft/vim/vim/+plugins/fff.vim/README.md b/etc/soft/vim/vim/+plugins/fff.vim/README.md new file mode 100644 index 0000000..384f291 --- /dev/null +++ b/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 + + + +* [Installation](#installation) +* [Usage](#usage) + * [Command](#command) + * [Easy hotkey](#easy-hotkey) +* [Customization](#customization) + * [Split Size](#split-size) + * [Split Direction](#split-direction) + + + +## 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 +``` + +## 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" +``` diff --git a/etc/soft/vim/vim/+plugins/fff.vim/autoload/fff.vim b/etc/soft/vim/vim/+plugins/fff.vim/autoload/fff.vim new file mode 100644 index 0000000..e4c5772 --- /dev/null +++ b/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 diff --git a/etc/soft/vim/vim/+plugins/fff.vim/plugin/fff.vim b/etc/soft/vim/vim/+plugins/fff.vim/plugin/fff.vim new file mode 100644 index 0000000..b0ad8f0 --- /dev/null +++ b/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() diff --git a/etc/soft/vim/vimrc b/etc/soft/vim/vimrc index c12a08e..4540fc5 100644 --- a/etc/soft/vim/vimrc +++ b/etc/soft/vim/vimrc @@ -788,5 +788,10 @@ call neomake#configure#automake('w') " let g:neomake_open_list = 2 " }}} +" fff.vim {{{ +let g:fff#split = "30vnew" +let g:fff#split_direction = "nosplitbelow nosplitright" +" }}} + " }}}###########################################################################