From d6479bbf0baeeedaa183c1f3e11679246ca20138 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 25 Sep 2020 00:07:37 +0200 Subject: Change gitignore provider --- README.md | 2 +- autoload/fzf_gitignore.vim | 41 ++++++++++++++++++++++ doc/fzf_gitignore.txt | 85 ++++++++++++++++++++++++++++++++++++++++++++++ ftplugin/gitignore.vim | 20 +++++++++++ packages.yaml | 2 +- syntax/gitignore.vim | 30 ++++++++++------ tests/extensions.vim | 2 +- 7 files changed, 169 insertions(+), 13 deletions(-) create mode 100644 autoload/fzf_gitignore.vim create mode 100644 doc/fzf_gitignore.txt create mode 100644 ftplugin/gitignore.vim diff --git a/README.md b/README.md index 8f9c4353..fcd206b8 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ If you need full functionality of any plugin, please use it directly with your p - [fsharp](https://github.com/ionide/Ionide-vim) - [gdscript](https://github.com/calviken/vim-gdscript3) - [git](https://github.com/tpope/vim-git) -- [gitignore](https://github.com/rdolgushin/gitignore.vim) +- [gitignore](https://github.com/fszymanski/fzf-gitignore) - [glsl](https://github.com/tikhomirov/vim-glsl) - [gmpl](https://github.com/maelvalais/gmpl.vim) - [gnuplot](https://github.com/vim-scripts/gnuplot-syntax-highlighting) 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 diff --git a/doc/fzf_gitignore.txt b/doc/fzf_gitignore.txt new file mode 100644 index 00000000..4d94748c --- /dev/null +++ b/doc/fzf_gitignore.txt @@ -0,0 +1,85 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gitignore') == -1 + +*fzf_gitignore.txt* Create useful .gitignore files for your project + +Author: Filip Szymański + +============================================================================== +CONTENTS *fzf-gitignore-contents* + + 1. Introduction |fzf-gitignore-introduction| + 2. Configuration |fzf-gitignore-configuration| + 3. Commands |fzf-gitignore-commands| + 4. Mappings |fzf-gitignore-mappings| + 5. License |fzf-gitignore-license| + 6. Bugs |fzf-gitignore-bugs| + 7. Contributing |fzf-gitignore-contributing| + +============================================================================== +INTRODUCTION *fzf-gitignore-introduction* + +fzf[1] interface for creating .gitignore files using the gitignore.io[2] API. + +Note: This plugin was inspired by helm-gitignore[3]. + +============================================================================== +CONFIGURATION *fzf-gitignore-configuration* + + *g:fzf_gitignore_no_maps* +Set this option to disable all key mappings. +> + let g:fzf_gitignore_no_maps = 1 +< +Default: Not defined (number) + + *g:fzf_gitignore_map* +Set this option to change the |(fzf-gitignore)| key mapping. +> + let g:fzf_gitignore_map = 'i' +< +Default: 'gi' (string) + +============================================================================== +COMMANDS *fzf-gitignore-commands* + + *:FzfGitignore* +Create .gitignore file. + +============================================================================== +MAPPINGS *fzf-gitignore-mappings* + + -----------------------------------+---------------------------------------- + Mapping | Description ~ + -----------------------------------+---------------------------------------- + (fzf-gitignore) | Create .gitignore file + -----------------------------------+---------------------------------------- + +============================================================================== +LICENSE *fzf-gitignore-license* + +MIT + +============================================================================== +BUGS *fzf-gitignore-bugs* + +If you find a bug please create an issue on GitHub. + +https://github.com/fszymanski/fzf-gitignore/issues + +============================================================================== +CONTRIBUTING *fzf-gitignore-contributing* + +Think you can make this plugin better? Awesome. Fork it on GitHub and create +a pull request. + +https://github.com/fszymanski/fzf-gitignore + +============================================================================== + +[1] https://github.com/junegunn/fzf +[2] https://www.gitignore.io/ +[3] https://github.com/jupl/helm-gitignore + + vim: tw=78 ts=8 ft=help norl + +endif diff --git a/ftplugin/gitignore.vim b/ftplugin/gitignore.vim new file mode 100644 index 00000000..d8cbadc5 --- /dev/null +++ b/ftplugin/gitignore.vim @@ -0,0 +1,20 @@ +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. + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +setlocal commentstring=#\ %s + +let b:undo_ftplugin = 'setlocal commentstring<' + +" vim: ts=2 et sw=2 + +endif diff --git a/packages.yaml b/packages.yaml index 4d9a7952..4c008303 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1884,7 +1884,7 @@ filetypes: - t --- name: gitignore -remote: rdolgushin/gitignore.vim +remote: fszymanski/fzf-gitignore filetypes: - name: gitignore filenames: diff --git a/syntax/gitignore.vim b/syntax/gitignore.vim index f83c098b..7a1a8e9c 100644 --- a/syntax/gitignore.vim +++ b/syntax/gitignore.vim @@ -1,23 +1,33 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gitignore') == -1 -" Vim syntax file -" Language: .gitignore -" Maintainer: Roman Dolgushin -" URL: http://github.com/rdolgushin/gitignore.vim +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. if exists('b:current_syntax') finish endif -if !exists('main_syntax') - let main_syntax = 'conf' -endif +" https://git-scm.com/docs/gitignore#_pattern_format +syntax keyword gitignoreTodo TODO FIXME XXX NOTE SEE contained +syntax match gitignoreComment '^#.*' contains=gitignoreTodo +syntax match gitignoreComment '\s#.*'ms=s+1 contains=gitignoreTodo +syntax match gitignoreNegation '^!' +syntax match gitignoreSeparator '/' +syntax match gitignoreWildcard '\(\\\)\@