Skip to content

integrate @mattboehm's work #13

@chadwhitacre

Description

@chadwhitacre

@mattboehm sent me a simplate.vim in private email following a conversation at PyOhio:

I thought I'd take a stab at getting a vim syntax file working for aspen, since you mentioned it to me during PyOhio.

The attached file seems to cover the basic case (2 Python sections and 1 other section. I used html for convenience, but I suppose the actual default is a different templating language.) It requires that the syntax files for python/html be in the same directory so that it can import them.

It's somewhat hackish and extending this to support all possible simplate files would be a non-trivial effort. Still, hopefully if you choose to revisit this problem, my example provides some help.

It's worth noting that even if the syntax did work perfectly, other vim behavior that is filetype-specific (abbreviations, snippets, filetype-specific plugins, etc.) would not work out of the box. When people do want all this functionality in a file of mixed types, I usually point them towards https://github.com/chrisbra/NrrwRgn .

let main_syntax='simplate'
syntax include @Py <sfile>:p:h/python.vim
syntax include @Html <sfile>:p:h/html.vim
syntax region thirdBlock start=_\[---]_ end=_\%$_ contains=@Html
syntax region firstBlock start=_\%^_ end=/^\[---]/me=e-5 contains=@Py
syntax region secondBlock start=_^\[---]_ end=_^\[---]_me=e-5 contains=@Py nextgroup=thirdBlock

"syntax region firstBlock start=_\%^_ end=/^\[---]/re=e-5 contains=@Py
"syntax region secondBlock start=_\[---]_ end=_^\ze\[---]_ contains=@Py nextgroup=thirdBlock

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions