Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Some fixes to s:sparkup handling in the Vim plugin #65

Merged
merged 8 commits into from

2 participants

@blueyed

No description provided.

@faceleg
Collaborator

Would you update your branch to the current master?

blueyed added some commits
@blueyed blueyed Do not add normal mode mappings for Vim.
Closes #35
85dc5ea
@blueyed blueyed Improve mapping for Vim, using <Plug> maps>
Add redirection through <Plug>SparkupExecute and <Plug>SparkupNext and
check if mappings are defined for them before assigning default maps.
e4a8b89
@blueyed blueyed Fix doc installation in "vim" Makefile task.
Copy README to 'doc' subdirectory and mark the header with asterisks.
The latter appears to be required for `:helptags` to pick it up.
0181e3c
@blueyed blueyed Use `inoremap` for calling Sparkup{,Next}().
This will make the mapping work properly with e.g.
`noremap : .`.

See rstacruz/sparkup#40 (comment)
6faebdb
@blueyed blueyed Use `return` instead of `finish` in a function 8d83643
@blueyed blueyed Use full path for s:sparkup
When determining `s:sparkup` the whole path should get used.
`findfile()` might return a relative path, so we use `fnamemodify(..,
':p')` to transform it into an absolute path.
3ace3d9
@blueyed blueyed Mention sparkup.py besides sparkup in the error message 700bd14
@blueyed blueyed Unset s:sparkup in case of error
Besides allowing for a re-detection on next invocation, it will prevent
and error from trying to execute an empty command.
dde6049
@faceleg faceleg merged commit dde6049 into rstacruz:master
@faceleg
Collaborator

Thanks :) :+1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 31, 2013
  1. @blueyed

    Do not add normal mode mappings for Vim.

    blueyed authored blueyed committed
    Closes #35
  2. @blueyed

    Improve mapping for Vim, using <Plug> maps>

    blueyed authored blueyed committed
    Add redirection through <Plug>SparkupExecute and <Plug>SparkupNext and
    check if mappings are defined for them before assigning default maps.
  3. @blueyed

    Fix doc installation in "vim" Makefile task.

    blueyed authored
    Copy README to 'doc' subdirectory and mark the header with asterisks.
    The latter appears to be required for `:helptags` to pick it up.
  4. @blueyed

    Use `inoremap` for calling Sparkup{,Next}().

    blueyed authored
    This will make the mapping work properly with e.g.
    `noremap : .`.
    
    See rstacruz/sparkup#40 (comment)
  5. @blueyed
  6. @blueyed

    Use full path for s:sparkup

    blueyed authored
    When determining `s:sparkup` the whole path should get used.
    `findfile()` might return a relative path, so we use `fnamemodify(..,
    ':p')` to transform it into an absolute path.
  7. @blueyed
  8. @blueyed

    Unset s:sparkup in case of error

    blueyed authored
    Besides allowing for a re-detection on next invocation, it will prevent
    and error from trying to execute an empty command.
This page is out of date. Refresh to see the latest.
Showing with 40 additions and 9 deletions.
  1. +3 −2 Makefile
  2. +37 −7 vim/ftplugin/html/sparkup.vim
View
5 Makefile
@@ -34,6 +34,7 @@ textmate:
#cp ${README} TextMate/sparkup-readme.txt
vim:
- mkdir -p vim/ftplugin/html
+ mkdir -p vim/ftplugin/html vim/doc
cp ${SPARKUP_PY} vim/ftplugin/html/sparkup.py
- #cp ${README} vim/sparkup-readme.txt
+ # Add asteriks to title, so it gets matched by `:helptags`
+ sed '1s/.*/*\0*/' ${README} > vim/doc/sparkup.txt
View
44 vim/ftplugin/html/sparkup.vim
@@ -17,6 +17,12 @@
"
" g:sparkupNextMapping (Default: '<c-n>') -
" 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 = '<c-e>'
@@ -26,10 +32,33 @@ if !exists('g:sparkupNextMapping')
let g:sparkupNextMapping = '<c-n>'
endif
-exec 'nnoremap <buffer> ' . g:sparkupExecuteMapping . ' :call <SID>Sparkup()<cr>'
-exec 'inoremap <buffer> ' . g:sparkupExecuteMapping . ' <c-g>u<Esc>:call <SID>Sparkup()<cr>'
-exec 'nnoremap <buffer> ' . g:sparkupNextMapping . ' :call <SID>SparkupNext()<cr>'
-exec 'inoremap <buffer> ' . g:sparkupNextMapping . ' <c-g>u<Esc>:call <SID>SparkupNext()<cr>'
+if !exists('g:sparkupMaps')
+ let g:sparkupMaps = 1
+endif
+
+if !exists('g:sparkupMapsNormal')
+ let g:sparkupMapsNormal = 0
+endif
+
+inoremap <buffer> <Plug>SparkupExecute <c-g>u<Esc>:call <SID>Sparkup()<cr>
+inoremap <buffer> <Plug>SparkupNext <c-g>u<Esc>:call <SID>SparkupNext()<cr>
+
+if g:sparkupMaps
+ if ! hasmapto('<Plug>SparkupExecute', 'i')
+ exec 'inoremap <buffer> ' . g:sparkupExecuteMapping . ' <Plug>SparkupExecute'
+ endif
+ if ! hasmapto('<Plug>SparkupNext', 'i')
+ exec 'inoremap <buffer> ' . g:sparkupNextMapping . ' <Plug>SparkupNext'
+ endif
+ if g:sparkupMapsNormal
+ if ! hasmapto('<Plug>SparkupExecute', 'n')
+ exec 'nnoremap <buffer> ' . g:sparkupExecuteMapping . ' :call <SID>Sparkup()<cr>'
+ endif
+ if ! hasmapto('<Plug>SparkupNext', 'n')
+ exec 'nnoremap <buffer> ' . g:sparkupNextMapping . ' :call <SID>SparkupNext()<cr>'
+ endif
+ endif
+endif
if exists('*s:Sparkup')
finish
@@ -45,13 +74,14 @@ function! s:Sparkup()
" sparkup.vim in the runtimepath.
if !executable(s:sparkup)
let paths = substitute(escape(&runtimepath, ' '), '\(,\|$\)', '/**\1', 'g')
- let s:sparkup = findfile('sparkup.py', paths)
+ let s:sparkup = fnamemodify(findfile('sparkup.py', paths), ':p')
if !filereadable(s:sparkup)
echohl WarningMsg
- echom 'Warning: could not find sparkup on your path or in your vim runtime path.'
+ echom 'Warning: could not find sparkup/sparkup.py on your path or in your vim runtime path.'
echohl None
- finish
+ unlet s:sparkup
+ return
endif
endif
let s:sparkup = '"' . s:sparkup . '"'
Something went wrong with that request. Please try again.