Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate @mattboehm's work #13

Open
chadwhitacre opened this issue Aug 3, 2016 · 2 comments
Open

integrate @mattboehm's work #13

chadwhitacre opened this issue Aug 3, 2016 · 2 comments

Comments

@chadwhitacre
Copy link
Contributor

@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
@mattboehm
Copy link

Some work left to do to reach full support:

  • Bound simplates: detect syntax of regions based on extensions
  • Bound simplates: make 1st/2nd sections optional
  • Support more than three sections
  • Read speclines to determine syntax
  • Vendor in python, jinja, pystache, etc. syntax files or find another import mechanism

@chadwhitacre
Copy link
Contributor Author

What are we already doing in the existing simplate.vim? Is that work worth reusing, or do we start from scratch with what you've got?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants