OXY2DEV/markview.nvim

🐞 Bug: backward slash inside inline code within a table cell causes misalignment

ibhagwan opened this issue · 28 comments

Before reporting:

  • Ensure that the issue is reproducable on the main branch.
  • Ensure that there isn't an issue on this(either open or closed).

Problem:

Images will work best, consider the below aligned table:
IMG_2766

Due to the backward slash, will render as:
IMG_2765

Fantastic plug-in btw @OXY2DEV, ty for your hard work! very meticulous :)

Steps to reproduce the issue:

Use inline code within a table cell with \ in it.

Expected behavior:

No response

Neovim version:

0.10.2

Can you check if the issue still occurs in the dev branch?

Other bad things happen with the dev branch

cursor outside of table
IMG_2767
cursor on first line of table
IMG_2768

Btw, forgot to mention my setup call removes the inline code “corner padding”:

      require("markview").setup({
        hybrid_modes = { "n" },
        inline_codes = { corner_left = "", corner_right = "" },
      })

Btw, I just found another issue in the dev branch, regarding split toggle (which raises an exception on main branch).

  • Run :Markview splitToggle
  • Make the source markdown win (not the rendered one) only window with <C-w>o
  • Run :Markview splitToggle again:
    IMG_2770

Can open another issue for this if you’d like, just wasn’t sure since this is the dev branch.

Btw, I just found another issue in the dev branch, regarding split toggle (which raises an exception on main branch).

  • Run :Markview splitToggle
  • Make the source markdown win (not the rendered one) only window with <C-w>o
  • Run :Markview splitToggle again:
    IMG_2770

Can open another issue for this if you’d like, just wasn’t sure since this is the dev branch.

It should be fixed now.

Btw, forgot to mention my setup call removes the inline code “corner padding”:

      require("markview").setup({
        hybrid_modes = { "n" },
        inline_codes = { corner_left = "", corner_right = "" },
      })

I couldn't reproduce this.

Other bad things happen with the dev branch

cursor outside of table
IMG_2767
cursor on first line of table
IMG_2768

That happens when rendering fails.
What error message did you get?

If you are using a config and it goes away after removing the config.
You should also provide the config table.

Updated to the latest dev branch, here's the latest status:

  • :Markview splitToggle - solved.
  • There's a duplicate tag in the vimdoc help file when updating the dev branch:
    image

That happens when rendering fails.
What error message did you get?

No error messages and I get the same result on a different machine (with the same nvim config):
image

The odd thing is that my highlight links are cleared (the reason for the ugly red code blocks), even thought I have these right after setup.

The other odd thing is that if I leave the buffer and come back to it (even if I just open a simple fzf-lua float), the rendering is now fixed (but now requires set nowrap to look good?):
image

If you are using a config and it goes away after removing the config.
You should also provide the config table.

My config is on Github, relevant part is in https://github.com/ibhagwan/nvim-lua/blob/main/lua/plugins/init.lua:

  {
    "OXY2DEV/markview.nvim",
    enabled = true,
    branch = "dev",
    ft = "markdown",
    config = function()
      print("1")
      require("markview").setup({
        hybrid_modes = { "n" },
        inline_codes = { corner_left = "", corner_right = "" },
      })
      vim.api.nvim_set_hl(0, "MarkviewCode", { default = false, link = "MarkviewHeading5" })
      vim.api.nvim_set_hl(0, "MarkviewCodeInfo", { default = false, link = "MarkviewHeading5" })
      vim.api.nvim_set_hl(0, "MarkviewInlineCode", { default = false, link = "MarkviewHeading5" })
      vim.api.nvim_set_hl(0, "MarkviewIcon1", { default = false, link = "MarkviewHeading6" })
      vim.api.nvim_set_hl(0, "MarkviewIcon2", { default = false, link = "MarkviewHeading6" })
      vim.api.nvim_set_hl(0, "MarkviewIcon3", { default = false, link = "MarkviewHeading6" })
      vim.api.nvim_set_hl(0, "MarkviewIcon4", { default = false, link = "MarkviewHeading6" })
      vim.api.nvim_set_hl(0, "MarkviewIcon5", { default = false, link = "MarkviewHeading6" })
      vim.api.nvim_set_hl(0, "MarkviewIcon6", { default = false, link = "MarkviewHeading6" })
      print("2")
    end
  },

Both 1 and 2 are printed when I enter a markdown file so something is clearing my custom highlight links in the dev branch (which doesn't happen on main).

The wrap issue seems to also happen on the main branch, it seems that my window width is sufficient (see vim.o.columns in the screencast) yet it only displays properly when I widen the screen over 135 columns:
Peek 2024-12-03 07-40

No error messages and I get the same result on a different machine (with the same nvim config):

Well, You definitely have something in your config that is changing the conceallevel.

If the issue goes away after moving the cursor, changing modes & running :Markview, then it's something in your config.

The odd thing is that my highlight links are cleared (the reason for the ugly red code blocks), even thought I have these right after setup.

This can happen if you are loading you colorscheme after markview.

The wrap issue seems to also happen on the main branch, it seems that my window width is sufficient

It's an issue with Neovim. When wrapping lines Neovim doesn't consider hidden text. So, your width is 2x of what you see.

That's why it gets wrapped like that.

My config is on Github, relevant part is in

I can't reproduce the 1st bug with your config 🙁.
rec

Well, You definitely have something in your config that is changing the conceallevel.

Did a search and removed all conceallevel from my config, anywhere, issue still remains.

This can happen if you are loading you colorscheme after markview.

Not sure if that's the case, first this doesn't happen on main and also I loaded the plugin only on ft = "markdown" so it definitely loads after the colorscheme.

I tried changing it to lazy=false and load the colorscheme after and the linked highlights get cleared which results in this:
image

Searching for the highlights MarkviewCode, MarkviewInlineCode shows (all) were cleared
image

However, when I lazy load (meaning it's def after the colorscheme), something seems to reset my highlights to default:
image

It's an issue with Neovim. When wrapping lines Neovim doesn't consider hidden text. So, your width is 2x of what you see.
That's why it gets wrapped like that.

Understood

I can't reproduce the 1st bug with your config 🙁.

Ty for your hard work @OXY2DEV! sorry for this mess of an issue.

I'm not sure what is the "1st bug" anymore as I managed to complicate this issue beyond repair :-)

Let me try and make sense again, the OP/title issue is solved in dev, the only 2 issues remaining are the "startup" issues:

  • Highlight links that seem to get redefined on plugin load
  • Bad rendering of tables on the first load only

Ok, did the same "experiment" with main.

lazy=true, highlights get redefined but none are missing:
image

ft="markdown", hl links remain intact (cell misalignment still exists on main as expected):
image

However, when I lazy load (meaning it's def after the colorscheme), something seems to reset my highlights to default:

I think I figured out the issue.

Your colorscheme probably has a @markup.heading, this gets picked up by MarkviewPalette5, this gets linked by MarkviewHeading5.

And you are linking to MarkviewHeading5, so it's doing what it should.

Can you check what color @markup.heading has?

Your colorscheme probably has a @markup.heading, this gets picked up by MarkviewPalette5, this gets linked by MarkviewHeading5.

Correct!
image

And you are linking to MarkviewHeading5, so it's doing what it should.

Not sure I get this part, was something changed in this regard between main/dev?

MarkviewHeading5

image

Apparently, I accidentally deleted the autocmd responsible for setting the highlights 💀.

Let me fix that real quick.

Apparently, I accidentally deleted the autocmd responsible for setting the highlights 💀.

Let me fix that real quick.

Although not a big deal you're bound to get some issue about the duplicate tag in the vimdoc (rename nvim-o-highlight_groups):
image

That's the old documentation.

I am writing the new one at the moment.

The highlight groups issue should be fixed now.

Just noticing another issue with dev, see this weirdness with the link icons:
Peek 2024-12-03 08-43

The highlight groups issue should be fixed now.

Updated to latest dev:
image

The initial render issue seems to be fixed now, however, there's another issue with the unconcealing of tables, the first/last border lines remain visible (doesn't happen on main):
image

I have to relink to the new MarkviewPallete groups now so the colors are ugly as hell

the first/last border lines remain visible

This is fixed now.

This is fixed now.

Updated:
image

Now getting exceptions:
image

These happen with each move of the cursor.

These happen with each move of the cursor.

I can't really fix it without seeing what is even causing the bug.

The best I can guess is there's something in the heading of the table that's causing the issue.

Do you have a link to the file causing the issue?

Do you have a link to the file causing the issue?

It's fzf-lua's README.

Btw, is there a single highlight I can change in my colorscheme that will derive better results for the generated MarkviewPallete background colors? I'm using bluz71/vim-nightfly-colors and the default generated theme has almost all highlights with high contrast red background, to fix it I have to pretty much relink all the highlights with background:
image

I found the issue.

Turns out the color space conversation function is buggy.

Let me fix that.

Color issues has been fixed!
Screenshot_2024-12-04-12-16-42-161_com termux-edit

All the bugs should be fixed now

Ty @OXY2DEV, the highlight groups look much better now:
image

Much appreciate your hard work on this!