Does it support other markdown language?
mingsu opened this issue · comments
I use other markdown based files, such as rmarkdown (*.Rmd
), quarto (*.qmd
).
Is it possible to integrate this plugin into other markdown based languages?
I have tried to add filetype option, with no success, Thanks.
Using lazyvim
framework,
> cat lua/plugin/markdown.lua
return {
{
"nvim-treesitter/nvim-treesitter",
dependencies = { "tadmccorkle/markdown.nvim" },
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"markdown",
"markdown_inline", --[[ other parsers you need ]]
},
markdown = {
enable = true,
-- configuration here or nothing for defaults
},
filetypes = { md = true, rmd = true, qmd = true, markdown = true },
})
end,
},
}
@mingsu Does this plugin work for you with normal markdown (*.md
) files?
This plugin should work for the filetypes you mentioned (*.Rmd
and *.qmd
). It works for each of those filetypes with a minimal config:
Minimal init.lua
Use this config by launching Neovim with nvim -u ./init.lua
.
local function root(path)
local f = debug.getinfo(1, "S").source:sub(2)
return vim.fn.fnamemodify(f, ":p:h") .. "/.repro/" .. (path or "")
end
local function load(plugin)
local name = plugin:match(".*/(.*)")
local package_root = root("site/pack/deps/start/")
if not vim.loop.fs_stat(package_root .. name) then
print("Installing " .. plugin)
vim.fn.mkdir(package_root, "p")
vim.fn.system({
"git",
"clone",
"--depth=1",
"https://github.com/" .. plugin .. ".git",
package_root .. "/" .. name,
})
end
vim.cmd("packadd " .. name)
end
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.opt.runtimepath:append(root())
vim.opt.packpath = { root("site") }
load("nvim-treesitter/nvim-treesitter")
load("tadmccorkle/markdown.nvim")
if vim.api.nvim_get_commands({}).TSUpdateSync ~= nil then
vim.cmd("TSUpdateSync markdown markdown_inline")
require("nvim-treesitter.configs").setup({
ensure_installed = { "markdown", "markdown_inline" },
sync_install = true,
markdown = {
enable = true,
},
})
end
I also verified it works for both rmarkdown and quarto files when using lazy.nvim
as a plugin manager.
If configured as an nvim-treesitter
module as shown in your config, nvim-treesitter
will activate markdown.nvim
when the current filetype is registered for the markdown parser. You can see which filetypes are registered by running:
:lua vim.print(vim.treesitter.language.get_filetypes("markdown"))
Running this command with the minimal config above prints { "markdown", "pandoc", "rmd", "quarto" }
. If you don't get this output there may be another part of your configuration preventing markdown.nvim
from working with rmarkdown and quarto files.
Thanks for your kind reply and detailed answer. It works as expected.
No worries. Glad to hear it works as expected.