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

Use sparkup on other file extensions / types #33

Open
devth opened this issue Jan 28, 2011 · 15 comments
Open

Use sparkup on other file extensions / types #33

devth opened this issue Jan 28, 2011 · 15 comments

Comments

@devth
Copy link

devth commented Jan 28, 2011

How would I wire this up to work in other file types, such as .mustache?

@bruvellu
Copy link

Same question here. I'm not managing to get it to work on filetype=htmldjango with Vim. Any clues? (on plain html works fine)

@bruvellu
Copy link

Ok, copying sparkup.py and sparkup.vim into a new folder ~/.vim/ftplugin/htmldjango worked around the issue. Sorry for the buzz...

@devth
Copy link
Author

devth commented Feb 18, 2011

Another thing that worked was to set the filetype for *.mustache to mustache.html
:set filetype=mustache.html

@millermedeiros
Copy link

to avoid copying files you can create new ftplugin files for each file type like:

" ftplugin/htmldjango.vim
runtime! ftplugin/html/sparkup.vim

or you can add an auto command to your .vimrc file (simpler):

augroup sparkup_types
  " Remove ALL autocommands of the current group.
  autocmd!
  " Add sparkup to new filetypes
  autocmd FileType mustache,php,htmldjango runtime! ftplugin/html/sparkup.vim
augroup END

I would fork the project and add the auto command to the sparkup plugin but I think this plugin was abandoned... (since the author isn't replying to any issue)

@kitmonisit
Copy link
Contributor

I tried the lines above but they cause recursive autocmd loops. Here's my solution in .vimrc

au FileType html set ft=htmldjango # sparkup is already loaded here due to the initial html filetype,
                                   # all we need now is the htmldjango (or htmljinja) syntax highlighting
au FileType htmldjango runtime! ftplugin/html/sparkup.vim # load sparkup if vim decides that the file is htmldjango

@millermedeiros
Copy link

@kitmonisit by using augroup and clearing the group before adding new commands (autocmd!) it is supposed to run the command only once when FileType matches one of the patterns, usually when you open the file or :set filetype=foo... - see: clearing groups

@kitmonisit
Copy link
Contributor

@millermedeiros Thanks for the resource! I pull my hair around Vim scripting :P

@rhardih
Copy link

rhardih commented Apr 30, 2012

@millermedeiros Tried pasting your snippet in my .vimrc but it causes an error for me:

Error detected while processing /Users/rene/.vimrc:
line   13:
E216: No such group or event: " Remove ALL autocommands for the current group.
Press ENTER or type command to continue

@millermedeiros
Copy link

@rhardih try moving the comment to another line and/or deleting it, that might be the problem. (I just updated the snippet)

@rhardih
Copy link

rhardih commented May 1, 2012

@millermedeiros Sweet, it was the comment. Works now.

@dwiprabowo
Copy link

hello, is it solved? sorry but, i have tried to write the code above at my _vimrc file but it didn't work in my *.tmpl file, anyone can help?

@faceleg
Copy link
Collaborator

faceleg commented Aug 22, 2013

Is it possible for someone to create a PR with this behaviour? I think it would be useful for the general populace.

@blueyed
Copy link
Contributor

blueyed commented Oct 7, 2013

There's an approach in @MarcWeber's fork, where you have a configuration variable to list the filetypes.
https://github.com/MarcWeber/sparkup

#33 (comment) should work.
Another approach is to create a symlink in the sparkup/ftplugin directory (there are a few already; won't work on Windows).

@gkop
Copy link

gkop commented Sep 22, 2015

I am using this very simple solution to enable sparkup in my jsx files:

autocmd FileType javascript.jsx runtime! ftplugin/html/sparkup.vim

@nathanielks
Copy link

@gkop this is exactly what I was looking for. thanks mate! 👍

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

10 participants