tpope / vim-liquid

Vim Liquid runtime files with Jekyll enhancements

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrectly detects pandoc markdown files as liquid

dylan-chong opened this issue · comments

Markdown files for use with pandoc can start with a YAML header, which starts with ---. This causes this plugin to think that the filetype is liquid.

Example document:

---
title: ENGR401 Assignment 1
author:
    - Dylan
date: \today{}
toc: false
---

# Introduction

Content

See line https://github.com/tpope/vim-liquid/blob/master/ftdetect/liquid.vim#L7

This is also an issue if you use Jekyll since files start with the same type of front matter (triple dashes with some properties inside of them) but the file names themselves end with .md.

This is primarily an issue for me because:

  1. None of the markdown snippets work since the filetype is liquid.

  2. I want to add a few custom vim-snippets that are specific to markdown but in order to get them to work I have to put them in a liquid snippets file. Technically this works but it's a little confusing since now a liquid snippet file has markdown snippets.

Jekyll does use Liquid; it's the reason I added this behavior to begin with. Setting the filetype to liquid.markdown might address your use case. As for pandoc, I don't know, maybe we limit this special case to _posts/?

Could this be done at the plugin level for Jekyll / Liquid? I wouldn't want to have to manually set the file type every time I open a Jekyll based blog post but at the same time I wouldn't want regular md files to be liquid.markdown either.

If you're saying it should live in a separate Jekyll plugin, then yes, ideally, but that in and of itself doesn't answer the question of how to distinguish between Jekyll, Pandoc, and other Markdown files with Yaml frontmatter.

Setting the file type to liquid.markdown breaks syntax highlighting for the whole file.

What would the process look like to get this to work? I thought it could be done in this plugin because you already have most of the logic in place.

For example, you have:

au BufNewFile,BufRead *.markdown,*.mkd,*.mkdn,*.md
      \ if getline(1) == '---' |
      \   let b:liquid_subtype = 'markdown' |
      \   set ft=liquid |
      \ endif

But the subtype doesn't fully set the ft to markdown because snippets still think it's a liquid file, even though it's markdown.

:set filetype=liquid.markdown looks fine to me. Do you have a Markdown plugin installed or are you using the built-in default?