Vimwiki: Markdown syntax not working if outside vimwiki path

Created on 28 Oct 2019  路  5Comments  路  Source: vimwiki/vimwiki

Problem

While syntax highlighting of markdown works for vimwiki files, files like README.md outside these directories are not highlighted properly.

Reproduce the issue

  1. Clone
cd /tmp
git clone https://github.com/vimwiki/testwikis
  1. Configure testwikis/minimal_vimrc as follows
call 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
  1. Open
vim -u testwikis/minimal_vimrc README.md

Compare it with opening vim followed by 2<leader>ww for vimwiki_markdown.

markdown

Most helpful comment

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

All 5 comments

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Vitruvia picture Vitruvia  路  5Comments

imbilltucker picture imbilltucker  路  5Comments

linuxcaffe picture linuxcaffe  路  3Comments

Ram-Z picture Ram-Z  路  4Comments

BSDxxxx picture BSDxxxx  路  3Comments