diff options
Diffstat (limited to 'autoload')
| -rw-r--r-- | autoload/fzf_gitignore.vim | 41 | 
1 files changed, 41 insertions, 0 deletions
| diff --git a/autoload/fzf_gitignore.vim b/autoload/fzf_gitignore.vim new file mode 100644 index 00000000..7548130c --- /dev/null +++ b/autoload/fzf_gitignore.vim @@ -0,0 +1,41 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gitignore') == -1 + +scriptencoding utf-8 + +" Copyright (c) 2017-2020 Filip SzymaĆski. All rights reserved. +" Use of this source code is governed by an MIT license that can be +" found in the LICENSE file. + +function! s:template_sink(templates) abort +  try +    let l:lines = _fzf_gitignore_create(a:templates) +  catch /^Vim(\(let\|return\)):/ +    return +  endtry + +  new +  setlocal filetype=gitignore + +  call setline(1, l:lines) + +  $-2,$delete _ +  normal! gg +endfunction + +function! fzf_gitignore#run() abort +  try +    let l:opts = { +          \ 'source': _fzf_gitignore_get_all_templates(), +          \ 'sink*': function('s:template_sink'), +          \ 'options': '-m --prompt="Template> " --header="gitignore.io"' +          \ } +  catch /^Vim(\(let\|return\)):/ +    return +  endtry + +  call fzf#run(fzf#wrap(l:opts)) +endfunction + +" vim: ts=2 et sw=2 + +endif | 
