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 ?

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
hl037_
  • 3,520
  • 1
  • 27
  • 58

2 Answers2

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.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Ok, I understand now :) I'll provide a blacklist to disable the plugin on some filtypes. thank you ! – hl037_ Apr 03 '14 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. – Ingo Karkat Apr 03 '14 at 14:04
  • Yes, It's already handled : there are function to activate and toggle the live preview and the preview : see http://www.vim.org/scripts/script.php?script_id=4908 for the plugin. But I have to document the browser now^^ – hl037_ Apr 03 '14 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.

builder-7000
  • 7,131
  • 3
  • 19
  • 43