ftdetect/genshi.vim -- Detects XML or HTML Genshi templates and sets
the Vim filetype accordingly
syntax/genshi.vim -- Syntax highlighting for Genshi XML or HTML
templates (based on Karl Guertin's Kid syntax file)
Syntax and detecting scripts for Genshi text templates are still needed
if anyone wants to help with that.
The files in "after/ftplugin" are snippets for use with snippetsEmu[1],
a work-alike to TextMate snippets.
With snippetsEmu and the Genshi snippets installed, typing any of the
Genshi attribute names followed by <Tab> will expand to define the
attribute.
For example "for<Tab>" will expand to:
py:for="<<>> in <<>>"<<>>
The "<<>>"s are placeholders which you fill in, then press <Tab> again
to move to the next one.
Snippets for the Genshi elements are prefixed with 'e'. So "eif<Tab>"
will expand to
<py:if test="<<>>">
<<>>
</py:if>
<<>>
Other snippets are defined as follows:
$ ${<<>>}
nspy xmlns:py=\"http://genshi.edgewall.org/\""
nsxi xmlns:py=\"http://www.w3.org/2001/XInclude\""
xinc <xi:include href="<<>>" />
Let me know if you have any other suggestions for snippets.
-- Matt Good
If you copied/pasted this line from source, you might want to
double-check it. ;]
> Let me know if you have any other suggestions for snippets.
I'm glad to see someone else doing vim customization. In particular,
thanks for doing genshi detection and syntax. I'd been holding off
until the syntax settled down a bit more. I'm currently using the kid
syntax/snippets in genshi and setting the file type using a
project.vim in= script.
I actually have my own set of snippets based on a hacked version of
snippetEmu 0.5.6 (and one based on a hacked/bugfixed 0.3 before that)
but I've never released the set. The interesting thing is that the
abbreviations are basically the same but I use {! and !} as start/end
tags. I like your start tag/end tag separation better than my hard
coded approach.
I was playing around with using vim functions as part of the
substitution to implement stuff like arguments processing, but I never
found a good use for it. I've pasted my set of Python snippets below.
My kid set is basically the same as yours but I define both short and
longer abbreviations (e.g. att, attr, attrs for py:attrs).
fun! PySmartElseColon()
if match(getline('.'), "^\s*else\s*$") == 0
return ":".Eatchar(':')
else
return ""
endif
endfun
Iabbr <buffer> for for {!item!} in {!collection!}:<CR>{!!}
Iabbr <buffer> fori for {!key!},{!value!} in {!collection!}.items():<CR>{!!}
Iabbr <buffer> fork for {!key!} in {!collection!}.keys():<CR>{!!}
Iabbr <buffer> forv for {!value!} in {!collection!}.values():<CR>{!!}
Iabbr <buffer> lc [{!x!} for {!x:substitute(@z,'\(.*\)\..*','\1','')!}
in {!collection!}]{!!}
Iabbr <buffer> lci [{!x!} for
{!x:substitute(@z,'\(.*\)\..*','\1','')!} in {!collection!} if
{!x:substitute(@z,'\(.*\)\..*','\1','')!}{!!}]{!!}
Iabbr <buffer> if if {!test!}:<CR>{!!}
Iabbr <buffer> elif elif {!test!}:<CR>{!!}
iabbr <buffer> else else<C-R>=PySmartElseColon()<CR>
Iabbr <buffer> ie {!x!} if {!test!} else {!!}
Iabbr <buffer> class class {!Foo!}({!object!}):<CR>{!!}
Iabbr <buffer> ga getattr({!object!},'{!name!}'{!!}){!!}
Iabbr <buffer> get get('{!name!}'{!k!}){!n!}{!i!}
Iabbr <buffer> s self.{!!}
Iabbr <buffer> def def {!funName!}(self{!:PyArgsList()!}):<CR>{!!}
Note that there's a mix of snippet and non-snippet abbreviations. In
particular, else and the namespaces are standard vim abbrs. The
functions do minimal stuff, the PySmartElseColon sticks the colon on
the else line if needed because I always forget it; the args function
prefixes the args with a ', '. I meant for it to do more like spacing
out the args and splitting them onto lines if the list was too long,
but I got lazy. The only other screwy thing is the list
comprehensions, which handle the case where 'x' is 'x.attr' correctly.
These are all older snippets format, so they're more for ideas than
anything else. I haven't kept up with snippets development. I keep
meaning to do SQLAlchemy customization but I've never gotten around to
it.
Spotted this post thanks to Google alerts. Excuse me butting in.
Karl Guertin wrote:
<snip>
> I actually have my own set of snippets based on a hacked version of
> snippetEmu 0.5.6 (and one based on a hacked/bugfixed 0.3 before that)
> but I've never released the set. The interesting thing is that the
> abbreviations are basically the same but I use {! and !} as start/end
> tags. I like your start tag/end tag separation better than my hard
> coded approach.
Version 1.0 of SnippetsEmu got released just before new year. If your
hacked up version includes any enhancements then please drop me a mail
or post them on the bug tracker (http://code.google.com/p/snippetsemu)
and I'll look at including them in 1.1.
> I was playing around with using vim functions as part of the
> substitution to implement stuff like arguments processing, but I never
> found a good use for it. I've pasted my set of Python snippets below.
> My kid set is basically the same as yours but I define both short and
> longer abbreviations (e.g. att, attr, attrs for py:attrs).
If either of you would like to mail me some snippet examples then I'd
be happy to include them in the 'official' bundles. The more the
merrier.
> These are all older snippets format, so they're more for ideas than
> anything else. I haven't kept up with snippets development. I keep
> meaning to do SQLAlchemy customization but I've never gotten around to
> it.
Old style should still work but the command 'Snippet' is recommended.
Functionally it is exactly the same as 'Iabbr <buffer>'. If you do get
any SQLAlchemy snippets written up then send them my way as well.
Regards,
Felix
Development blog: http://slipperysnippets.blogspot.com/
Post bugs here: http://code.google.com/p/snippetsemu