-
Notifications
You must be signed in to change notification settings - Fork 518
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
Highlight the content of fenced code blocks with specified language in that language. #93
Conversation
Code taken from https://github.com/xolox/vim-notes Has to be in plugin/mkd.vim, or the initial BufReadPost event doesn’t get fired. I don’t know why.
Avoids errors when including more than once, e.g. including vim twice causes errors
Hopefully temporarily, see preservim/vim-markdown#93
This is interesting. Does it work inside lists? :
|
E.g. ```vi was overriding ```vim
It does now! 😄 |
👍 |
1 similar comment
👍 |
👍 This is awesome. Although it seems to get messed up when the file is reloaded such as with |
Good spot. Reloading the buffer reset the syntax highlighting, but didn't reset the buffer variable cache of already applied syntaxes. Fixed! |
Is this ever getting merged in? |
I was thinking whether it's possible to get better syntax coloring inside long LaTeX equations. Maybe this could help by re-using whichever LaTeX syntax is available (?) |
I've tested and syntax highlight in fenced code blocks works. https://github.com/plasticboy/vim-markdown/blob/master/indent/markdown.vim#L22 |
I am creating fixes based on this patch. |
Merged. |
I noticed that syntax highlight is not working for bash code blocks. Test case (unable to paste it here): |
Try using
I did add a map into my local copy of this change, around this line, so you could add a map in your own |
How can I do that? I tried the following which didn't work: augroup bash
au!
au BufNewFile,BufRead *.sh,*.bash setlocal filetype=sh
augroup END It seems GFM (at least this comments here) support both |
@alexconst https://github.com/plasticboy/vim-markdown/blob/master/ftplugin/markdown.vim#L617 let s:filetype_dict = {
\ 'c++': 'cpp',
\ 'viml': 'vim',
\ 'bash': 'sh'
\ } |
@shirosaki any particular reason for the bash line not being included? Does it break anything? (if nobody else wants to do it) can I submit a PR with this change? |
@alexconst No. Just I didn't need that. I fixed that. |
Thanks! |
I can't set |
I think you can't do that. |
Can do. What do you think the behaviour should be - the global variable overriding the script-local one, or merging with it? |
I think overriding script-local one is OK since I'm not sure default mapping is useful or not. |
Based on the code from vim-notes, adds syntax highlighting for GFM code blocks. E.g.
is shown as syntax highlighted with the vim syntax highlighting.
This introduces a
plugin/mkd.vim
file. Putting this code inftplugin
meant that it didn't refresh the syntax onBufReadPost
.As per
contributing.md
:test\syntax.md
, you'll see the ruby block is highlighted.readme.md
hasn't been updated, as it doesn't require any configuration