lukas-reineke / headlines.nvim

This plugin adds horizontal highlights for text filetypes, like markdown, orgmode, and neorg.
MIT License
684 stars 27 forks source link

"Flickering" and missing headlines #41

Open refaelsh opened 2 years ago

refaelsh commented 2 years ago

Hard to describe in words, please see the attached screenshot, and then I will try to explain in words. Saw the screenshot? Great.

WhatsApp Image 2022-07-27 at 8 13 21 PM

  1. There are some headings missing, between lines 76 and 298. They are definitely there, I remember entering them and I can see them when doing cat file.org.
  2. Line 298, the background of the heading looks "garbled" on the left side.
  3. After line 311 there are some strange thingies.
  4. And many more strange "flickering" that are hard to describe in words.

Here the org file to reproduce it: https://pastebin.pl/view/6d3fc321.

Neovim version 0.7.2.

A requested, I am reopening this issue from here: https://github.com/nvim-orgmode/orgmode/issues/378.

lukas-reineke commented 2 years ago

For 2 and 3 please see what I wrote in the other ticket.

For 1, this is actually a bug in Neovim. I have reported it here https://github.com/neovim/neovim/issues/19557 I suspect it also causes 4

refaelsh commented 2 years ago

For 2 and 3 please see what I wrote in the other ticket.

I will do it asap today.

For 1, this is actually a bug in Neovim. I have reported it here neovim/neovim#19557 I suspect it also causes 4

Very interesting! It seems like something that should have been discovered as a bug in Neovim a long time ago, as soon as this feature was introduced in Neovim. Very interesting.

refaelsh commented 2 years ago
  1. This happens because your font does not support the default character for headlines.nvim. You can either change/patch your font, or use a different character.

I prefer to change the font I am using.

  1. Can you please provide a font name that you know that definitely works?
  2. I should change the font in my terminal settings, right? Not in Neovim, correct? This is what I currently have in my Alacritty config:
    font:
    normal:
    family: Consolas
    style: Regular
lukas-reineke commented 2 years ago

Yes, the font in the terminal. I am using the nerd font patched version of Fira Code. https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode

refaelsh commented 2 years ago

Yes, the font in the terminal. I am using the nerd font patched version of Fira Code. https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode

Interestingly, their README says that my terminal of choice, Alacritty, is not supported. Here is the link: https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode#terminal-compatibility-list.

Perhaps, maybe, you know of some other font that will work with headlines.nvim?

lukas-reineke commented 2 years ago

I think it's only the ligatures that won't work, alacritty just doesn't support those.

https://github.com/alacritty/alacritty/issues/50

You should still be able to use the font

refaelsh commented 2 years ago

This happens because your org headline highlight groups have a background color. https://github.com/akinsho/org-bullets.nvim uses that color for the bullets, but the background color of virtual text overwrites the highlight of the headline from headlines.nvim.

I am sorry, I don't understand any of it. Can you please explain it again using different words?

P.S.

your org headline highlight groups have a background color

  1. They do? Well, I don't know what I have in my init.vim that does that. It is the first time I am hearing the term org headline highlight groups.
  2. Wait, this plugin supposes to add the background color to the headlines, is it not?

As can be seen from the above, I am thoroughly confused :-)

refaelsh commented 2 years ago
  1. This happens because your font does not support the default character for headlines.nvim. You can either change/patch your font, or use a different character.
  1. I configured Alacritty to use Fira Code and problem number 3 still occurs.
  2. I just tried it with kitty without changing any setting (its the first time I installed kitty), and problem number 3 no longer exists. Interesting, it seems to be the fault lies with Alacritty?
lukas-reineke commented 2 years ago
  1. They do?

orgmode.nvim takes the colors from your colorsheme. So if that has background colors, it will have too.

  1. Wait, this plugin supposes to add the background color to the headlines, is it not?

It is. This is a bit complicated. You have the first level of highlights from your colorscheme. Then this plugin adds highlights to change the background color of the headline. But then, org-bullets adds the bullets to the headlines, and they have background color too. org-bullets has the highest priority, so it overwrites the background color from this plugin. To fix this, you have to remove the background highlight from those highlight groups.


I don't use Alacritty myself, it's possible it just can't display that character. You can still just use a different character, like the one I posted in the original issue.

refaelsh commented 2 years ago
  1. This happens because your font does not support the default character for headlines.nvim. You can either change/patch your font, or use a different character.

I've decided to permanently move to kitty+Fira Code, and problem number 3 is gone. Thank you :-)

refaelsh commented 2 years ago
for i = 1, 40, 1 do
    vim.cmd(string.format("highlight OrgHeadlineLevel%d guibg=NONE", i))
end

I did that, and problem number 2 still exists. Suggestions please :-)

lukas-reineke commented 2 years ago

Location matters, you need to do this after your colorscheme loads, but before org-bullets setup

refaelsh commented 2 years ago

Location matters, you need to do this after your colorscheme loads, but before org-bullets setup

Problem number 2 still remains, but much less in quantity. I will blame the Neovim bug you mentioned :-)

nyngwang commented 1 year ago

I also see some squares under the headings in my notes:

agoodshort commented 1 year ago

@nyngwang the squares are related to the font used in your terminal. Seems that FiraCode would work.

I personally use Nerd Font Hack and configured like this to get rid of the squares (using lazy.nvim):

return {
    "lukas-reineke/headlines.nvim",
    dependencies = "nvim-treesitter/nvim-treesitter",
    opts = {
        markdown = {
            fat_headline_lower_string = "▔",
        },
    },
}

@lukas-reineke Thanks for the plugin! May I suggest to mention the font "requirement" somewhere in the README.md?