1

all is in the title... I did a ftplugin to live preview an html file (php and css also) with a browser, but now, when I open a markdown file, the browser opens too... I saw why: there is this line in the default ftplugin/markdown.vim:

runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim

so first question, why does markdown source html ftplugin ? It seems irrevelant for me, but perhaps there are good reasons that I'd be glad to know.

Then, is there a way not to source html ftplugins for markdown files ?

1
  • Only reason I can think of to load html is if you were rendering a preview... Apr 3, 2014 at 13:38

2 Answers 2

4

Markdown allows you to use inline HTML. From the spec:

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.

That explains the behavior of the filetype plugin.

Disabling this

It would be best if you could just disable the mentioned live preview; as this is probably triggered by an :autocmd BufWritePost <buffer> ..., you could probably disable it via something like this in your ~/.vim/after/ftplugin/markdown.vim:

:autocmd! BufWritePost <buffer>

To completely get rid of the HTML stuff, copy the $VIMRUNTIME/ftplugin/markdown.vim to your user's ~/.vim/ftplugin/markdown.vim, and delete / comment out the :runtime command. The b:did_ftplugin check will ensure that the original ftplugin, though still being sourced, does nothing.

3
  • Ok, I understand now :) I'll provide a blacklist to disable the plugin on some filtypes. thank you !
    – hl037_
    Apr 3, 2014 at 13:45
  • If this is a plugin, users may want to disable the live preview for some HTML buffers, too. The most flexible solution is via a b:BrowserLivePreviewEnabled buffer-local variable. You can set this by default, but if it's 0 skip the preview. Apr 3, 2014 at 14:04
  • Yes, It's already handled : there are function to activate and toggle the live preview and the preview : see vim.org/scripts/script.php?script_id=4908 for the plugin. But I have to document the browser now^^
    – hl037_
    Apr 3, 2014 at 14:50
0

You could add this at the top of your ~/.vim/ftplugin/html.vim:

if &ft=="markdown"
  finish
endif

this will prevent markdown files from processing the html settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.