Closed Zeioth closed 1 month ago
Hmm, do you not set a conceallevel
? And by that I mean did you modify win_options -> conceallevel -> rendered
.
The square brackets should be hidden for all values of conceallevel
except for 0, which is why it is not an issue in any of the demos.
There's also the possibility that you have some custom highlights.scm
that is changing nvim-treesitter
default behavior for this: https://github.com/nvim-treesitter/nvim-treesitter/blob/63be47f203d3e9174fdac3872fb9766e5bcc5a11/queries/markdown_inline/highlights.scm#L77-L83
Probably the third option because I've tried markdown.nvim with the default opts and the issue remains. I'm gonna keep researching.
I've tried to delete all plugins except treesitter and markdown.nvim, then I've deleted all highlights and restarted nvim and the issue remain:
:lua for _, group in ipairs(vim.fn.getcompletion('', 'highlight')) do vim.cmd('highlight clear ' .. group) end
I've also deleted all custom vim.opt options, same result. I'm gonna try with a minfile.
@MeanderingProgrammer you should be able to repro with this minfile:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
{
"MeanderingProgrammer/markdown.nvim",
ft = { "markdown" },
dependencies = { "nvim-treesitter/nvim-treesitter" },
opts = {},
},
},
})
run nvim like:
nvim -u ~/minfile_path.lua
Then open the next markdown file:
# TODOS
> [!TODO] This todo renders broken
It will render like this:
Ah, here the problem is highlights need to be enabled for treesitter, the checkhealth
should also output that as an error.
If you run :checkhealth render-markdown
with your minimal config you should see this:
...
markdown.nvim [nvim-treesitter] ~
- OK installed
- OK markdown: parser installed
- ERROR markdown: highlight not enabled
- OK markdown_inline: parser installed
- ERROR markdown_inline: highlight not enabled
...
A more accurate minimal init taking into account things checked in checkhealth
would be:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
---@diagnostic disable-next-line: missing-fields
require("nvim-treesitter.configs").setup({
ensure_installed = { "markdown", "markdown_inline" },
highlight = { enable = true },
})
end,
},
{
"MeanderingProgrammer/markdown.nvim",
ft = { "markdown" },
dependencies = { "nvim-treesitter/nvim-treesitter" },
opts = {},
},
})
Does the above minimal init fix the issue?
@MeanderingProgrammer thank you so much that fixed it. The missing bit was:
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end,
It's weird because supposedly when you do opts = {}
in lazy (package manager) you don't manually have to call the setup function in config.
Every other treesitter feature was working as expected, the only feature missing was this.
Well it works now, that's what matters!
Huh, that is strange. Maybe it's it do with the setup function being under configs
, but even the LazyVim example seems to just use opts
: https://www.lazyvim.org/plugins/treesitter#nvim-treesitter. Maybe they have something special to make that work in the distro, who knows.
Glad it's working in either case :)
This PR fixes a little glitch I'm experiencing in my end.
Example markdown code
Pre-PR render → (You can see a
]
character is currently incorrectly displayed)Post-PR markdown
Note that two spaces are inserted by doing this.