GitHub Flavored Markdown Syntax Extension for Vim
This Vim plugin provides extra syntax highlight for GitHub Flavored Markdown. GitHub adds their extra features to Markdown. This plugin fills the gap between normal Markdown and GitHub Flavored Markdown.
Supports for below syntax are added:
And it also supports concealing emoji characters.
By default, this plugin is enabled for all
markdown filetype files.
If you want to enable these extra syntax highlights in specific file, you can use
g:gfm_syntax_enable_filetypes and sub filetypes.
Example: Only README.md enables extra highlight.
let g:gfm_syntax_enable_always = 0 let g:gfm_syntax_enable_filetypes = ['markdown.gfm'] autocmd BufRead,BufNew,BufNewFile README.md setlocal ft=markdown.gfm
If you want to highlight inner code block, standard syntax highlight support for Markdown already supports it.
let g:markdown_fenced_languages = ['cpp', 'ruby', 'json']
In above Example, C++, Ruby and JSON code blocks will be highlighted with their syntax highlight. Please note that enabling so many filetypes for code block may cause performance issue on highlighting.
If you want to support specific feature of GFM, you can control them to be highlighted by some variables.
If you want to use your favorite colors for syntax highlights, you can override highlight definitions. Below configration is an example where inline code will be highlighted with
autocmd ColorScheme * highlight link githubFlavoredMarkdownCode CursorLine
githubFlavoredMarkdownCode is a highlight rule for inline code. For other rules, please see after/syntax/markdown/gfm.vim. There are so many colorschemes for Vim. One syntax file can't consider all of them. If you feel some highlighting is not good, please customize by yourself.
Note: Standard markdown syntax highlight offers
markdownCode to highlight
inline codes, but they also highlight code blocks.
githubFlavoredMarkdownCode only highlights inline codes.
This plugin also supports concealing emojis using Vim's 'conceal' feature. When
g:gfm_syntax_emoji_conceal is set to
1, emojis such as
:dog: in will be displayed as real emoji like
:dog:) remains as is. Concealing happens only in non-current lines.
vim-flavored-markdown was created for the same purpose as this plugin, and it works well. But it does not match to my usecase in terms of below points.
- vim-flavored-markdown introduces new filetype
ghmarkdown. This is useful if you want to distinguish Markdown and GFM. Otherwise, it kills original
markdownfiletype. It means that many other plugins for
markdownfiletype are killed as well.
- Because vim-flavored-markdown is a fork of old version of vim-markdown, it lacks some improvements (e.g. code block highlight).
- vim-gfm-syntax supports more GFM syntax (e.g. checkbox), well-tested (with themis.vim), customizable (you can choose which syntax should be highlighted).
This plugin is distributed under the MIT License.