Skip to content

bug: Issue when using Zen mode plugin. #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Krystian-KF opened this issue Aug 6, 2024 · 4 comments
Closed
1 task done

bug: Issue when using Zen mode plugin. #122

Krystian-KF opened this issue Aug 6, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Krystian-KF
Copy link

Neovim version (nvim -v)

0.11

Operating system

WSL 2

Terminal emulator / GUI

WezTerm

Describe the bug

When using Markdown together with Folke's Zen Mode, only the part of the document that is visible on the screen at the time of toggling the Zen mode is being styled, other parts of it will look like Render-Markdown is disabled.

image

Expected behavior

To have the whole file rendered.

Healthcheck output

render-markdown: require("render-markdown.health").check()

render-markdown.nvim [version] ~
- OK plugin 6.0.3
- OK neovim >= 0.10

render-markdown.nvim [configuration] ~
- OK valid

render-markdown.nvim [nvim-treesitter] ~
- OK installed
- OK markdown: parser installed
- OK markdown: highlight enabled
- OK markdown_inline: parser installed
- OK markdown_inline: highlight enabled
- WARNING latex: parser not installed
  - ADVICE:
    - Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

render-markdown.nvim [executables] ~
- WARNING latex2text: not installed
  - ADVICE:
    - Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

render-markdown.nvim [conflicts] ~
- OK headlines: not installed
- OK obsidian: not installed

image

Plugin configuration

return {
  {
    "MeanderingProgrammer/markdown.nvim",
    opts = {
      heading = {
        -- Turn on / off heading icon & background rendering
        enabled = true,
        sign = false,
        icons = { " 󰼏 ", " 󰼐 ", " 󰼑 ", " 󰼒 ", " 󰼓 ", " 󰼔 " },
        -- icons = { " 󰎥 ", " 󰎨 ", " 󰎫 ", " 󰎲 ", " 󰎯 ", " 󰎴 " },
        -- icons = { " 󰎤 ", " 󰎧 ", " 󰎪 ", " 󰎭 ", " 󰎱 ", " 󰎳 " },
        -- icons = { " 󰉫 ", " 󰉬 ", " 󰉭 ", " 󰉮 ", " 󰉯 ", " 󰉰 " },
        signs = { "" },
        position = "inline",
        width = "block",
      },
      dash = {
        width = 120,
      },
      link = {
        -- Turn on / off inline link icon rendering
        enabled = true,
        -- Inlined with 'image' elements
        image = "",
        -- Inlined with 'inline_link' elements
        hyperlink = "󰌷 ",
        -- Applies to the inlined icon
        highlight = "RenderMarkdownLink",
      },
      code = {
        left_pad = 0,
        position = "right",
        min_width = 120,
      },
      checkbox = {
        unchecked = {
          icon = "",
        },
        checked = {
          icon = "",
          highlight = "RenderMarkdownChecked",
        },
        custom = {
          incomplete = { raw = "[/]", rendered = "󰡕 ", highlight = "RenderMarkdownInfo" },
          todo = { raw = "[-]", rendered = "󰜺 ", highlight = "RenderMarkdownQuote" },
          rescheduled = { raw = "[>]", rendered = "󰦛 ", highlight = "RenderMarkdownInfo" },
          scheduled = { raw = "[<]", rendered = "", highlight = "RenderMarkdownChecked" },
          question = { raw = "[?]", rendered = "", highlight = "RenderMarkdownWarn" },
          important = { raw = "[!]", rendered = "", highlight = "RenderMarkdownError" },
          star = { raw = "[*]", rendered = "", highlight = "RenderMarkdownWarn" },
          quote = { raw = '["]', rendered = "󱀢 ", highlight = "RenderMarkdownUnchecked" },
          location = { raw = "[l]", rendered = "", highlight = "RenderMarkdownQuote" },
          bookmark = { raw = "[b]", rendered = "", highlight = "RenderMarkdownH6" },
          information = { raw = "[i]", rendered = "󰋼 ", highlight = "RenderMarkdownInfo" },
          amount = { raw = "[S]", rendered = "󱢐 ", highlight = "RenderMarkdownWarn" },
          idea = { raw = "[I]", rendered = "", highlight = "RenderMarkdownHint" },
          con = { raw = "[c]", rendered = "󰔒 ", highlight = "RenderMarkdownQuote" },
          pro = { raw = "[p]", rendered = "󰔔 ", highlight = "RenderMarkdownSuccess" },
        },
      },
      callout = {
        note = { raw = "[!NOTE]", rendered = "󰙏 Note", highlight = "RenderMarkdownInfo" },
        info = { raw = "[!INFO]", rendered = "󰋽 Info", highlight = "RenderMarkdownInfo" },
        todo = { raw = "[!TODO]", rendered = "󰗡 Todo", highlight = "RenderMarkdownInfo" },
        summary = { raw = "[!SUMMARY]", rendered = "󰨸 Summary", highlight = "RenderMarkdownHint" },
        abstract = { raw = "[!ABSTRACT]", rendered = "󰨸 Abstract", highlight = "RenderMarkdownHint" },
        tldr = { raw = "[!TLDR]", rendered = "󰨸 Tldr", highlight = "RenderMarkdownHint" },
        tip = { raw = "[!TIP]", rendered = "󰌶 Tip", highlight = "RenderMarkdownHint" },
        hint = { raw = "[!HINT]", rendered = "󰅾 Hint", highlight = "RenderMarkdownHint" },
        important = { raw = "[!IMPORTANT]", rendered = "󰅾 Important", highlight = "RenderMarkdownHint" },
        check = { raw = "[!CHECK]", rendered = "󰄬 Check", highlight = "RenderMarkdownSuccess" },
        done = { raw = "[!DONE]", rendered = "󰄬 Done", highlight = "RenderMarkdownSuccess" },
        success = { raw = "[!SUCCESS]", rendered = "󰄬 Success", highlight = "RenderMarkdownSuccess" },
        question = { raw = "[!QUESTION]", rendered = "󰘥 Question", highlight = "RenderMarkdownWarn" },
        help = { raw = "[!HELP]", rendered = "󰘥 Help", highlight = "RenderMarkdownWarn" },
        faq = { raw = "[!FAQ]", rendered = "󰘥 Faq", highlight = "RenderMarkdownWarn" },
        warning = { raw = "[!WARNING]", rendered = "󰀪 Warning", highlight = "RenderMarkdownQuote" },
        caution = { raw = "[!CAUTION]", rendered = "󰀪 Caution", highlight = "RenderMarkdownQuote" },
        attention = { raw = "[!ATTENTION]", rendered = "󰀪 Attention", highlight = "RenderMarkdownQuote" },
        failure = { raw = "[!FAILURE]", rendered = "󰅖 Failure", highlight = "RenderMarkdownError" },
        fail = { raw = "[!FAIL]", rendered = "󰅖 Fail", highlight = "RenderMarkdownError" },
        missing = { raw = "[!MISSING]", rendered = "󰅖 Missing", highlight = "RenderMarkdownError" },
        danger = { raw = "[!DANGER]", rendered = "󱐌 Danger", highlight = "RenderMarkdownError" },
        error = { raw = "[!ERROR]", rendered = "󱐌 Error", highlight = "RenderMarkdownError" },
        bug = { raw = "[!BUG]", rendered = "󰨰 Bug", highlight = "RenderMarkdownError" },
        example = { raw = "[!EXAMPLE]", rendered = "󰉹 Example", highlight = "RenderMarkdownH6" },
        quote = { raw = "[!QUOTE]", rendered = "󱆨 Quote", highlight = "RenderMarkdownUnchecked" },
      },
      quote = {
        repeat_linebreak = true,
      },
      pipe_table = {
        style = "normal",
        cell = "padded",
      },
    },
  },
}

Confirmations

  • I have provided markdown text for any screenshots used in my description & understand that my issue will be closed if I have not

Additional information

I am not sure if this is an issue that can be addressed here or on Folke's Zen mode plugin side. If it is not related to Render-Markdown, feel free to close it and I will post it there.

@Krystian-KF Krystian-KF added the bug Something isn't working label Aug 6, 2024
@MeanderingProgrammer
Copy link
Owner

I'll need to play around with zen mode to see what's going on. I imagine it's not a problem in either plugin exactly. More how zen mode handles the window doesn't play nicely with how this plugin handles events.

@MeanderingProgrammer
Copy link
Owner

Ah, I know the issue. It's to do with how this plugin determines the window. We use the vim.fn.bufwinid method which returns the first window associated with a buffer. I didn't think this would be a problem since dealing with the same buffer in multiple windows seemed like an edge case.

However zen mode effectively triggers this exact situation, the underlying window remains open plus the new zen mode window.

From there we continue to use the old window hence the range to parse and the cursor are never correctly determined.

I'll work on a fix, might not have time to get to it today, probably tomorrow though.

MeanderingProgrammer added a commit that referenced this issue Aug 7, 2024
# Details

Issue: #122

When using zen mode plugin 2 instances of the same buffer are open in
different windows. However this plugin only picks up the first window,
thus interactions with the second window did nothing.

To fix this rather than using the `bufwinid` method to go from buffer
to window we now instead get the current window and pass that as input
to the update method along with the buffer. That way the buffer can be
associated with any number of windows but events will still apply to
whatever the active window is.
@MeanderingProgrammer
Copy link
Owner

Should be fixed in: 1c7b5ee

Update and LMK if it works!

@Krystian-KF
Copy link
Author

It does work.
That was speedy :)

Thank you so much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants