-- Mkdownflow plugin.
--   Allows to follow links, anchors, create links, and many more.
--   https://github.com/jakewvincent/mkdnflow.nvim

-- Keymaps for mkdnflow.
--   Table
vim.keymap.set({'n','x','v'}, '<leader>tf', '<cmd>MkdnTableFormat<CR>', {desc = 'Format table under cursor'})

return {
  {
    "jakewvincent/mkdnflow.nvim",
    ft = {
      'pandoc',
      'markdown'
    },
    lazy = true,
    config = function ()
      require('mkdnflow').setup({
        filetypes = {
          md = true,
          rmd = true,
          markdown = true,
          pandoc = true
        },
        perspective = {
          -- Ensure that paths are relative to the current file
          priority = "current"
        },
        links = {
          conceal = true,
        },
        new_file_template = {
          use_template = true,
          template = [[
---
title:
date: {{ date }}
id: {{ id }}
tags: []
---
]],
          placeholders = {
            before = {
              date = function ()
                return os.date("%Y-%m-%dT%H:%M:%S%z")
              end,
              id = function ()
                return os.date("%Y%m%d%H%M%S")
              end
            },
          }
        }
      })
    end
  }
}
