##
##  vim-plugin-misc.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_nerdtree        4.1.0-6-g7650cdc
%define       V_snipmate        0.83
%define       V_neocomplcache   5.2-56-g75b2c9d
%define       V_supertab        e716a65
%define       V_project         1.4.1
%define       V_taglist         45
%define       V_surround        v1.90-5-gd9e6bfd
%define       V_vcscommand      1.99.47

#   package information
Name:         vim-plugin-misc
Summary:      Vim Editor Plugins
URL:          http://www.vim.org/
Vendor:       Vim Community
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Editor
License:      Sharityware
Version:      0
Release:      20130414

#   list of sources
Source0:      https://download.github.com/scrooloose-nerdtree-%{V_nerdtree}.tar.gz
Source1:      http://download.openpkg.org/components/versioned/vim/snipmate-%{V_snipmate}.zip
Source2:      https://download.github.com/Shougo-neocomplcache-ver.%{V_neocomplcache}.tar.gz
Source3:      https://download.github.com/ervandew-supertab-%{V_supertab}.tar.gz
Source4:      http://download.openpkg.org/components/versioned/vim/project-%{V_project}.tar.gz
Source5:      http://download.sourceforge.net/vim-taglist/taglist_%{V_taglist}.zip
Source6:      http://vcscommand.googlecode.com/files/vcscommand-%{V_vcscommand}.zip
Source7:      https://download.github.com/tpope-vim-surround-%{V_surround}.tar.gz
Patch0:       vim-plugin-misc.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101
PreReq:       vim

%description
    This is a set of plugins for the Vim editor.

%track
    prog vim-plugin-misc:snipmate = {
        version   = %{V_snipmate}
        url       = http://download.openpkg.org/components/versioned/vim/
        regex     = snipmate-(__VER__)\.zip
    }
    prog vim-plugin-misc:project = {
        version   = %{V_project}
        url       = http://download.openpkg.org/components/versioned/vim/
        regex     = project-(__VER__)\.tar\.gz
    }
    prog vim-plugin-misc:vcscommand = {
        version   = %{V_vcscommand}
        url       = http://code.google.com/p/vcscommand/downloads/list
        regex     = vcscommand-(__VER__)\.zip
    }

%prep
    %setup -q -c
    %setup -q -T -D -c -n vim-plugin-misc-%{version}/snipmate -T -D -a 1
    %setup -q -T -D -a 2
    %setup -q -T -D -a 3
    %setup -q -T -D -c -n vim-plugin-misc-%{version}/project -T -D -a 4
    %setup -q -T -D -c -n vim-plugin-misc-%{version}/taglist -T -D -a 5
    %setup -q -T -D -c -n vim-plugin-misc-%{version}/vcscommand -a 6
    %setup -q -T -D -a 7
    %patch -p0

%build
    find . -name "*.orig" -print | xargs rm -f
    find . -name ".gitignore" -print | xargs rm -f
    find . -type f -print | xargs chmod 644

%install
    #   create installation area
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/vim

    #   install NERDtree plugin
    ( cd scrooloose-nerdtree-* && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   install SnipMate plugin
    ( cd snipmate && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   install NeoComplCache plugin
    ( cd Shougo-neocomplcache-* && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   install SuperTab plugin
    ( cd ervandew-supertab-* && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   install Project plugin
    ( cd project && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   install TagList plugin
    ( cd taglist && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   install Surround plugin
    ( cd tpope-vim-surround-* && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   install VCSCommand plugin
    ( cd vcscommand && %{l_tar} cf - . ) |\
    ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/vim && %{l_tar} xf - ) || exit $?

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

%post
    #   update Vim "helptags"
    $RPM_INSTALL_PREFIX/bin/vim -u NONE -esX \
        -c "helptags $RPM_INSTALL_PREFIX/lib/vim/doc" \
        -c "quit"

