vim-liquid icon indicating copy to clipboard operation
vim-liquid copied to clipboard

Incorrectly detects pandoc markdown files as liquid

Open dylan-chong opened this issue 6 years ago • 7 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

dylan-chong avatar Apr 07 '19 23:04 dylan-chong

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.

nickjj avatar Apr 16 '19 16:04 nickjj

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/?

tpope avatar Apr 20 '19 23:04 tpope

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.

nickjj avatar Apr 20 '19 23:04 nickjj

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.

tpope avatar Apr 21 '19 04:04 tpope

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.

nickjj avatar Apr 21 '19 11:04 nickjj

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

tpope avatar Apr 21 '19 17:04 tpope

I am using this plugin: https://github.com/plasticboy/vim-markdown

nickjj avatar Apr 21 '19 17:04 nickjj