Skip to content
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

Flickering background in Quarto cells #75

Open
andy941 opened this issue Mar 16, 2024 · 3 comments
Open

Flickering background in Quarto cells #75

andy941 opened this issue Mar 16, 2024 · 3 comments

Comments

@andy941
Copy link

andy941 commented Mar 16, 2024

Hi,
I love the plugin, it makes a pleasure to work with Quarto files (I use it mainly for data science at work). I have an annoying issue where the cells background is unset in random amount of lines when another highlight is on, or that is what my debugging got me to. See below an example of the type of flickering I get:
normal highlight
image
broken by Illuminate (see the two lemur_residuals)
image
These are actually very sudden and I am not sure what they are related to (cursor is on a white space, maybe the IndentBlankline plugin?):
image

All this flickers constantly while moving the cursor around but I can't figure out why exactly. My guess is that happens when something else sets a background inside the cell? Disabling VimIlluminate for example solves that specific type of flickering.

Changing colorscheme to a default one does not help.

My headlines.nvim config:

require("headlines").setup({
	quarto = {
		query = vim.treesitter.query.parse(
			"markdown",
			[[
        (atx_heading [
          (atx_h1_marker)
          (atx_h2_marker)
          (atx_h3_marker)
          (atx_h4_marker)
          (atx_h5_marker)
          (atx_h6_marker)
        ] @headline)

        (thematic_break) @dash

        (fenced_code_block) @codeblock

        (block_quote_marker) @quote
        (block_quote (paragraph (inline (block_continuation) @quote)))
        (block_quote (paragraph (block_continuation) @quote))
        (block_quote (block_continuation) @quote)
      ]]
		),
		headline_highlights = { "Headline" },
		bullet_highlights = {
			"@text.title.1.marker.markdown",
			"@text.title.2.marker.markdown",
			"@text.title.3.marker.markdown",
			"@text.title.4.marker.markdown",
			"@text.title.5.marker.markdown",
			"@text.title.6.marker.markdown",
		},
		treesitter_language = "markdown",
		bullets = { "", "", "", "" },
		codeblock_highlight = "CodeBlock",
		dash_highlight = "Dash",
		dash_string = "-",
		quote_highlight = "Quote",
		quote_string = "",
		fat_headlines = true,
		fat_headline_upper_string = "",
		fat_headline_lower_string = "🬂",
	},
})

The code in the pictures:

#| label: plotting
#| echo: true
#| output-location: slide
#| message: false
#| fig-align: center
#| fig-alt: "Scatter plot of predicted and residual values for the fitted linear model."
library(reticulate)
library(ggplot2)
lemur_residuals <- py$lemur_data_py
ggplot(
  data = lemur_residuals,
  mapping = aes(
    x = Predicted,
    y = Residuals
  )
) +
  geom_point(colour = "#2F4F4F") +
  geom_hline(
    yintercept = 0,
    colour = "red"
  ) +
  theme(
    panel.background = element_rect(
      fill = "#eaf2f2",
      colour = "#eaf2f2"
    ),
    plot.background = element_rect(
      fill = "#eaf2f2",
      colour = "#eaf2f2"
    )
  )

Do you have an idea on what is going on?

@lukas-reineke
Copy link
Owner

I cannot reproduce this.

Can you use this template and steps to cause the issue?

local lazypath = "/tmp/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system { "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }
end
vim.opt.rtp:prepend(lazypath)
vim.opt.termguicolors = true

require("lazy").setup ({
    {
        "lukas-reineke/headlines.nvim",
        config = function()
            require("headlines").setup {}
        end,
    },
}, { root = "/tmp/lazy" })

@andy941
Copy link
Author

andy941 commented Mar 18, 2024

Still see a flickering in this very simple example:
image

only when the cursor is on one of the parenthesis.
I had to expand the minimal config a little bit to work with quarto:

local lazypath = "/tmp/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system { "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }
end
vim.opt.rtp:prepend(lazypath)
vim.opt.termguicolors = true

require("lazy").setup ({
	{
		"lukas-reineke/headlines.nvim",
		config = function()
			require("headlines").setup {
				quarto = {
					query = vim.treesitter.query.parse(
					"markdown",
					[[
					(atx_heading [
					(atx_h1_marker)
					(atx_h2_marker)
					(atx_h3_marker)
					(atx_h4_marker)
					(atx_h5_marker)
					(atx_h6_marker)
					] @headline)

					(thematic_break) @dash

					(fenced_code_block) @codeblock

					(block_quote_marker) @quote
					(block_quote (paragraph (inline (block_continuation) @quote)))
					(block_quote (paragraph (block_continuation) @quote))
					(block_quote (block_continuation) @quote)
					]]
					),
					headline_highlights = { "Headline" },
					bullet_highlights = {
						"@text.title.1.marker.markdown",
						"@text.title.2.marker.markdown",
						"@text.title.3.marker.markdown",
						"@text.title.4.marker.markdown",
						"@text.title.5.marker.markdown",
						"@text.title.6.marker.markdown",
					},
					treesitter_language = "markdown",
					bullets = { "", "", "", "" },
					codeblock_highlight = "CodeBlock",
					dash_highlight = "Dash",
					dash_string = "-",
					quote_highlight = "Quote",
					quote_string = "",
					fat_headlines = true,
					fat_headline_upper_string = "",
					fat_headline_lower_string = "🬂",
				},
			}
		end,
		dependencies = {"nvim-treesitter/nvim-treesitter"},
	},
}, { root = "/tmp/lazy" })

I can't reproduce the other bugs with the minimal config.

Let me know if this helps.

@andy941
Copy link
Author

andy941 commented Apr 12, 2024

@lukas-reineke
Any thoughts? Can I help with more tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants