" Sparkup " Installation: " Copy the contents of vim/ftplugin/ to your ~/.vim/ftplugin directory. " " $ cp -R vim/ftplugin ~/.vim/ftplugin/ " " Configuration: " g:sparkup (Default: 'sparkup') - " Location of the sparkup executable. You shouldn't need to change this " setting if you used the install option above. " " g:sparkupArgs (Default: '--no-last-newline') - " Additional args passed to sparkup. " " g:sparkupExecuteMapping (Default: '') - " Mapping used to execute sparkup. " " g:sparkupNextMapping (Default: '') - " Mapping used to jump to the next empty tag/attribute. " " g:sparkupMaps (Default: 1) - " Setup mappings? " " g:sparkupMapsNormal (Default: 0) - " Setup mappings for normal mode? if !exists('g:sparkupExecuteMapping') let g:sparkupExecuteMapping = '' endif if !exists('g:sparkupNextMapping') let g:sparkupNextMapping = '' endif if !exists('g:sparkupMaps') let g:sparkupMaps = 1 endif if !exists('g:sparkupMapsNormal') let g:sparkupMapsNormal = 0 endif inoremap SparkupExecute u:call Sparkup() inoremap SparkupNext u:call SparkupNext() if g:sparkupMaps if ! hasmapto('SparkupExecute', 'i') exec 'imap ' . g:sparkupExecuteMapping . ' SparkupExecute' endif if ! hasmapto('SparkupNext', 'i') exec 'imap ' . g:sparkupNextMapping . ' SparkupNext' endif if g:sparkupMapsNormal if ! hasmapto('SparkupExecute', 'n') exec 'nnoremap ' . g:sparkupExecuteMapping . ' :call Sparkup()' endif if ! hasmapto('SparkupNext', 'n') exec 'nnoremap ' . g:sparkupNextMapping . ' :call SparkupNext()' endif endif endif if exists('*s:Sparkup') finish endif function! s:Sparkup() if !exists('s:sparkup') let s:sparkup = exists('g:sparkup') ? g:sparkup : 'sparkup' if !executable(s:sparkup) " If g:sparkup is not configured (and/or not found in $PATH), " look for sparkup.vim in Vim's runtimepath. " XXX: quite expensive for a Pathogen-like environment (where &rtp is huge) let paths = substitute(escape(&runtimepath, ' '), '\(,\|$\)', '/**\1', 'g') let s:sparkup = fnamemodify(findfile('sparkup.py', paths), ':p') if !filereadable(s:sparkup) echohl WarningMsg echom 'Warning: could not find sparkup/sparkup.py on your path or in your vim runtime path.' echohl None unlet s:sparkup return endif endif let s:sparkup = '"' . s:sparkup . '"' " Workaround for windows, where the Python file cannot be executed via shebang if has('win32') || has('win64') let s:sparkup = 'python ' . s:sparkup endif endif " Build arguments list (not cached, g:sparkupArgs might change, also " &filetype, &expandtab etc) let sparkupArgs = exists('g:sparkupArgs') ? g:sparkupArgs : '--no-last-newline' " Pass '--xml' option, if 'xml' is used as filetype (default: none/'html') " NOTE: &filetype can contain multiple values, e.g. 'smarty.html' if index(split(&filetype, '\.'), 'xml') >= 0 let sparkupArgs .= ' --xml' endif " If the user's settings are to indent with tabs, do so! " TODO textmate version of this functionality if !&expandtab let sparkupArgs .= ' --indent-tabs' endif let sparkupCmd = s:sparkup . printf(' %s --indent-spaces=%s', sparkupArgs, &shiftwidth) exec '.!' . sparkupCmd call s:SparkupNext() endfunction function! s:SparkupNext() " 1: empty tag, 2: empty attribute, 3: empty line let n = search('><\/\|\(""\)\|^\s*$', 'Wp') if n == 3 startinsert! else execute 'normal l' startinsert endif endfunction