MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.73k stars 38 forks source link

Checkboxes not rendering, and can't be modified in config #38

Closed johnend closed 4 months ago

johnend commented 5 months ago

Not sure if this is due to how I've set the plugin up, or something to do with the plugin itself, but the checkboxes aren't rendering in normal mode, and I can't overwrite them.

I have tried multiple options:

-- referencing global table
markdown.setup {
    checked = icons.ui.BoxChecked,
}

-- pasting character from Nerd Fonts cheatsheet
markdown.setup {
    checked = "󰄱",
}

markdown. because I'm using a pcall.

Also not sure if this only applies to the checkboxes or other things too. But based on the default config, and the one in the code, one of the above should work?

MeanderingProgrammer commented 5 months ago

Your config is slightly incorrect. The symbols for checkboxes are nested under the checkbox property.

So to set them do:

markdown.setup({
  checkbox = {
    checked = icons.ui.BoxChecked,
    unchecked = 'other_value',
  },
})

I'm not sure how to go about debugging them not being rendered in general. Is the plugin able to render anything? Do headings / lists work?

johnend commented 5 months ago

image

So most things work just fine, but the checkboxes, quotes and code blocks aren't showing as they do in the example in the README.

Maybe something to do with my config?

return {
  "MeanderingProgrammer/markdown.nvim",
  name = "render-markdown",
  ft = { "markdown" },
  dependencies = {
    "nvim-treesitter/nvim-treesitter",
  },
  config = function()
    local status_ok, markdown = pcall(require, "render-markdown")
    if not status_ok then
      print("Error loading plugin: render-markdown", markdown)
      return
    end

    markdown.setup {
      start_enabled = true,
      checkbox = {
        checked = icons.ui.BoxChecked,
      }
    }

    vim.api.nvim_create_autocmd("BufWinLeave", {
      pattern = "*.md",
      callback = function()
        vim.opt.colorcolumn = "120"
        vim.opt.textwidth = 120
      end,
    })

    vim.api.nvim_create_autocmd("BufWinEnter", {
      pattern = "*.md",
      callback = function()
        vim.opt.colorcolumn = "80"
        vim.opt.textwidth = 80
      end,
    })
  end,
}
MeanderingProgrammer commented 5 months ago

Where is the checkbox in the screenshot?

Is it the first line under the heading, can you show me the raw markdown?

I'm not sure what icons.ui.BoxChecked is meant to be, but if it's an x icon then everything seems to be working.

johnend commented 5 months ago

Yeah, the checkbox is on line 22. The icons.ui.BoxChecked is a reference to a Lua table that stores some Nerd Font icons in it (not an X). So not sure what is going on to be honest. Looks to me like there are some other things that aren't working from the screenshot (compared to what is in the repos examples too) like the code block and the quotes.

If I only have:

  markdown.setup {
      start_enabled = true,
    }

In my config the output looks the same, nothing actually changes when I change any of the values at all. Though I haven't tested the ones that are working as expected.

MeanderingProgrammer commented 5 months ago

Can you try a simplified configuration , just to rule out any gotchas there. Something like:

return {
  "MeanderingProgrammer/markdown.nvim",
  name = "render-markdown",
  dependencies = { "nvim-treesitter/nvim-treesitter" },
  config = function()
    require("render-markdown").setup({})
  end,
}

If the problem still persists after that can you run the checkhealth command: checkhealth render-markdown, see if that turns up any issues. You'll probably have some LaTeX related warnings, but those shouldn't impact any of this functionality.

After that I can work with you to generate some debug logs that can hopefully shed light on what's going on, but that's a little more involved.

johnend commented 5 months ago

Using the above and running checkhealth render-markdown I get the following output: image

And still see a blue X in place of a checkbox icon, it does't actually render anything for the empty checkbox at all. 🤔 image

MeanderingProgrammer commented 5 months ago

That all looks good, damn. Lets see if the logs can help.

Can you enable debug logs by updating the plugin config to:

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

Then create a new markdown file with the following content, just so I can compare my output to yours:

# Heading

- Item
  - Nested

> [!NOTE]
> A note

- [ ] Unchecked
- [x] Checked

Open the file, the plugin will try to render it, then close the file.

Then copy the output of the log file which will most likely be located at ~/.local/state/nvim/render-markdown.log, and paste the results here.

johnend commented 4 months ago

Weirdly, I removed the basic config, and uncommented my old one, and now it's working?

johnend commented 4 months ago

I actually have no idea why, but I have a suspicion that it might actually have been something to do with my terminal, rather than the plugin. I am using Kitty as had the Nerd Font symbols mapped to a symbol override, which was messing with a few things, and I believe it wasn't mapping everything correctly. Remove the symbols override and started using Monaspace from GitHub without the override, so maybe that was it? 🤦

However, it does look as though if you write: - [ ] without any content after it won't render the empty box or the filled one so perhaps it was something to do with that?

Sorry for wasting your time, and thanks for helping 😄

MeanderingProgrammer commented 4 months ago

No worries, always good to be aware of more possible issues! Will make a note to ask for terminal emulator in the future.

Problems with symbol mappings in Kitty / just maintaining them correctly was what got me to switch to Wezterm.

The - [ ] not rendering isn't an issue as much as it is how markdown behaves. If you don't include any text after the square brackets treesitter (at least for the current parser implementation) interprets it as an empty link rather than a checkbox, and since links are concealed an empty link will disappear. The - before the square brackets should still render a bullet point since it now gets interpreted as the start of a list.

So what I would expect you to see and what I see locally is - [ ] gets rendered as a bullet point followed by no text.

johnend commented 4 months ago

Actually just setting up WezTerm today! 😂

Pretty good that it comes with a Nerd Font built in too so you don't have to think about it at all.

All the config is working as expected now. Thanks again for all the help 😁