While syntax highlighting of markdown works for vimwiki files, files like README.md outside these directories are not highlighted properly.
cd /tmp
git clone https://github.com/vimwiki/testwikis
testwikis/minimal_vimrc as followscall plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug'
Plug 'vimwiki/vimwiki', {'branch': 'dev'}
call plug#end()
set runtimepath+=
set nocompatible
filetype plugin indent on
syntax enable
" default syntax
let vimwiki_default = {}
let vimwiki_default.path = '/tmp/testwikis/vimwiki'
let vimwiki_default.path_html = ''
let vimwiki_default.syntax = 'default'
let vimwiki_default.ext = '.wiki'
let vimwiki_default.name = 'DefaultSyntax'
" markdown syntax - https://github.github.com/gfm/
let vimwiki_markdown = {}
let vimwiki_markdown.path = '/tmp/testwikis/markdown'
let vimwiki_markdown.path_html = ''
let vimwiki_markdown.syntax = 'markdown'
let vimwiki_markdown.ext = '.md'
let vimwiki_markdown.name = 'MarkdownSyntax'
" mediawiki syntax - https://www.mediawiki.org/wiki/Help:Formatting
let vimwiki_mediawiki = {}
let vimwiki_mediawiki.path = '/tmp/testwikis/mediawiki'
let vimwiki_mediawiki.path_html = ''
let vimwiki_mediawiki.syntax = 'mediawiki'
let vimwiki_mediawiki.ext = '.mw'
let vimwiki_mediawiki.name = 'MediaWikiSyntax'
" register the 3 wikis
let g:vimwiki_list = [vimwiki_default, vimwiki_markdown, vimwiki_mediawiki]
:VimwikiShowVersion
Branch: dev
Revision: 2411266
Date: 2019-10-28 05:05:03 -0600
vim -u testwikis/minimal_vimrc README.md
Compare it with opening vim followed by 2<leader>ww for vimwiki_markdown.
A good workaround for now is described here:
let g:vimwiki_global_ext = 0
Which sets filetype=markdown in directories other than vimwiki. Related: #730
Vimwiki is using the default vimwiki syntax which won't look correct for markdown files. You need to register the extensions with something like let g:vimwiki_ext2syntax = {'.md': 'markdown', '.markdown': 'markdown'}. Does that fix the syntax highlighting?
From the help file:
An extension that is registered with Vimwiki can trigger creation of a
|vimwiki-temporary-wiki| with the associated syntax. File extensions used in
|g:vimwiki_list| are automatically registered with Vimwiki using the default
syntax.
That is again a workaround. I don't really mind if vimwiki forces .md files to be of filetype=vimwiki. However what I don't understand is why syntax highlighting does not work in other directories.
It does work, it just defaults to the 'vimwiki default syntax' which doesn't look correct for files that are written in markdown instead of the vimwiki specific syntax. We should probably set some default extension mappings for markdown files so the behavior is more what users would expect.
@ashwinvis Do you want to test if the defaults give you more expected behavior?
Most helpful comment
A good workaround for now is described here:
Which sets
filetype=markdownin directories other than vimwiki. Related: #730