MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.39k stars 33 forks source link

Some parts like link, inline code and code block seem not to render properly. #28

Closed bickman closed 3 months ago

bickman commented 3 months ago

This is the exactly plugin I'm searching for and most of it's parts rendered great, however, some parts such as link, inline code and code block seems not to render properly. I use Neovim version 0.10.0 and both markdown and markdown inline are installed, here is the screenshot: 屏幕截图 2024-05-27 133327

MeanderingProgrammer commented 3 months ago

Inline code blocks look correct, they get a typically background highlight group ColorColumn associated with them. This is configurable through the highlights -> code setting.

Link behaviors are not impacted by this plugin, other than setting the conceal level. Their color is going to be determined by the version of the markdown parsers you have installed and your color scheme.

Code blocks in general are injected into the markdown and should use the highlighting of that language, assuming you have that language's Tree Sitter parser installed. In this case if you have the python parser installed you should get language specific highlighting. The exception to this is if your color scheme provides a foreground color to the ColorColumn highlight group. In my case only a guibg is provided to ColorColumn, if this differs for you you can change the highlight group through the configuration setting mentioned above, through the highlights -> code setting.

bickman commented 3 months ago

The highlight color is rendered alright, but some markdown elements are not hidden, I use the default setting: conceallevel=3, which should hide these elements by default.

MeanderingProgrammer commented 3 months ago

That is strange, this plugin should definitely be setting a higher conceallevel for markdown windows.

Do you have the same buffer open in multiple windows by chance? This can definitely cause the plugin to do strange things, including windows that are still open in the background.

If that's not the case will need to get a better idea of what's going on.

What is your configuration for this plugin? Mostly interested in if you are setting any values for the conceal parameter aside from the default.

Would also be helpful to get the conceal level value at various points in time.

Can you do the following:

1. With a fresh neovim session open a markdown file with this plugin enabled 2. Run the following command to get the conceal level value :lua vim.print(vim.opt.conceallevel:get()), will call this the rendered conceal level, make a note of if links are still not being concealed 3. Run the following command to disable the plugin :RenderMarkdownToggle 4. Again run the command to get the conceal level :lua vim.print(vim.opt.conceallevel:get()), will call this the default conceal level

Let me know what the values for the conceal levels are and if links are still not being concealed.

I added some more logging to the plugin to make this a little easier in a recent commit: https://github.com/MeanderingProgrammer/markdown.nvim/commit/9dde93a8e9b41cf87b0c22354e3b6f27220ecbb2.

Please update the plugin. Then set the log_level to debug, i.e.:

require('render-markdown').setup({
  log_level = 'debug',
})

Open some README that should have concealed links, like sample.md in this repo. And paste the output of the logfile, which you'll probably find at ~/.local/state/nvim/render-markdown.log. I really only need the first entry which will look something like:

2024-05-28 21:14:32 - DEBUG - {
  after = 3,
  before = 0,
  option = "conceallevel",
  opts = {
    scope = "local",
    win = 1000
  }
}
bickman commented 3 months ago

I use default markdown.nvim setting with lazy plugin manager, here is my lazy config: 屏幕截图 2024-05-29 120930 I don't set conceallevel value in neovim options, here is my neovim options settings: 屏幕截图 2024-05-29 121243 I just open the only file sample.md in neovim, and with RenderMarkdownToggle on, conceallevel=3, with RenderMarkdownToggle off, conceallevel=0, the value seems alright, here is the screenshot: on: 屏幕截图 2024-05-29 121600 off: 屏幕截图 2024-05-29 121624

MeanderingProgrammer commented 3 months ago

Interesting, in theory once the conceallevel property is set this should just work. The values seem correct to me and match my own.

I just noticed you're using a gui client, looks like this one (https://github.com/RMichelsen/Nvy), it could be that concealing isn't fully supported by the client.

bickman commented 3 months ago

I used windows terminal still the same. 屏幕截图 2024-05-29 125454

MeanderingProgrammer commented 3 months ago

Outside of this plugin, are you able to get concealing working with your setup?

I.e.

If the concealing is not working even then, then there's something conflicting with this behavior unrelated to anything this plugin is doing. Maybe its the color scheme, maybe another plugin is intervening somehow.

I'm honestly not sure, at that point it would be a painful process of disabling everything and slowly re-enabling plugins one at a time until it breaks again.

Unsure if there's a faster way to figure out what's happening.

If without this plugin the conceallevel does work, we can go from there.

bickman commented 3 months ago

It is the treesitter markdown and markdown_inline parser which are not actived.In Windows treesitter seems need extra config compared to linux. I have changed to linux, if there is no treesitter or markdown parser installed or actived, and it would show the same: some markdown elements are not hided. After activing the markdown parser, everything work alright.

bickman commented 3 months ago

By default the nvim-treesitter don't activate any modules, and I have to active the highlight module manually in treesitter config:

require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true,
  },
}

or :TSEnalbe highlight in command line. Only after activate the treesitter highlight module, the markdown and markdown_inline parser will take effect and this plugin will render everything alright. 屏幕截图 2024-05-29 160410

MeanderingProgrammer commented 3 months ago

Awesome, thanks for looking into that!

I updated the health check to validate that highlights are enabled: https://github.com/MeanderingProgrammer/markdown.nvim/commit/c1d9edc2f2690ef326bd8afbe7fc080412cbb224.