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

Scope underline highlight is different from the char highlight. #686

Closed
nickp-real opened this issue Oct 3, 2023 · 15 comments
Closed

Scope underline highlight is different from the char highlight. #686

nickp-real opened this issue Oct 3, 2023 · 15 comments
Labels
bug Something isn't working

Comments

@nickp-real
Copy link

nickp-real commented Oct 3, 2023

Problem

I'm using Alacritty with Tmux with onedarkpro theme.

The scope underline highlight is not the same as the highlight, using it with rainbow-delimeter.nvim.
image
image

Steps to reproduce

ibl config

{
    "lukas-reineke/indent-blankline.nvim",
    dependencies = { "HiPhish/rainbow-delimiters.nvim" },
    event = { "BufReadPost", "BufNewFile" },
    main = "ibl",
    config = function(_, opts)
      local hooks = require("ibl.hooks")

      -- create the highlight groups in the highlight setup hook, so they are reset
      -- every time the colorscheme changes
      hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
        local colors = require("onedarkpro.helpers").get_colors()

        vim.api.nvim_set_hl(0, "RainbowWhite", { fg = colors.white })
        vim.api.nvim_set_hl(0, "RainbowViolet", { fg = colors.purple })
        vim.api.nvim_set_hl(0, "RainbowBlue", { fg = colors.blue })
        vim.api.nvim_set_hl(0, "RainbowGreen", { fg = colors.green })
        vim.api.nvim_set_hl(0, "RainbowYellow", { fg = colors.yellow })
        vim.api.nvim_set_hl(0, "RainbowOrange", { fg = colors.orange })
        vim.api.nvim_set_hl(0, "RainbowRed", { fg = colors.red })
        vim.api.nvim_set_hl(0, "RainbowCyan", { fg = colors.cyan })
      end)

      vim.g.rainbow_delimiters = { highlight = indent_highlight }
      require("ibl").setup(opts)

      hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
    end,
    opts = {
      -- indent = { highlight = indent_highlight },
      scope = {
        highlight = indent_highlight,
      },
    },
 },

onedarkpro config

return {
  "olimorris/onedarkpro.nvim",
  lazy = false,
  priority = 1000,
  config = function(_, opts)
    require("onedarkpro").setup(opts)
    vim.cmd.colorscheme("onedark")
  end,
  opts = {
    colors = {
      dark = {
        telescope_prompt = "require('onedarkpro.helpers').darken('bg', 1, 'onedark')",
        telescope_results = "require('onedarkpro.helpers').darken('bg', 4, 'onedark')", -- dark gray
        telescope_preview = "require('onedarkpro.helpers').darken('bg', 6, 'onedark')",
        telescope_selection = "require('onedarkpro.helpers').darken('bg', 8, 'onedark')",
      },
    }, -- Override default colors by specifying colors for 'onelight' or 'onedark' themes
    highlights = {
      TelescopeBorder = {
        fg = "${telescope_results}",
        bg = "${telescope_results}",
      },
      TelescopePromptBorder = {
        fg = "${telescope_prompt}",
        bg = "${telescope_prompt}",
      },
      TelescopePromptCounter = { fg = "${fg}" },
      TelescopePromptNormal = { fg = "${fg}", bg = "${telescope_prompt}" },
      TelescopePromptPrefix = {
        fg = "${purple}",
        bg = "${telescope_prompt}",
      },
      TelescopePromptTitle = {
        fg = "${telescope_prompt}",
        bg = "${purple}",
      },
      TelescopePreviewTitle = {
        fg = "${telescope_results}",
        bg = "${green}",
      },
      TelescopeResultsTitle = {
        fg = "${telescope_results}",
        bg = "${telescope_results}",
      },
      TelescopeMatching = { fg = "${blue}" },
      TelescopeNormal = { bg = "${telescope_results}" },
      TelescopeSelection = { bg = "${telescope_selection}" },
      TelescopePreviewNormal = { bg = "${telescope_preview}" },
      TelescopePreviewBorder = { fg = "${telescope_preview}", bg = "${telescope_preview}" },

      AlphaHeader = { fg = "${yellow}" },
      AlphaButtons = { fg = "${white}" },
      AlphaShortcut = { fg = "${blue}" },
      AlphaFooter = { fg = "${orange}" },

      NormalFloat = { bg = "${telescope_results}" },
      FloatBorder = { bg = "${telescope_results}", fg = "${gray}" },

      NavicText = { fg = "${fg}" },
    },
    -- plugins = {},
    styles = {
      types = "NONE",
      methods = "bold",
      numbers = "NONE",
      strings = "NONE",
      comments = "italic",
      keywords = "bold,italic",
      constants = "NONE",
      functions = "bold",
      operators = "NONE",
      variables = "NONE",
      parameters = "italic",
      conditionals = "italic",
      virtual_text = "NONE",
    },
    options = {
      cursorline = true, -- Use cursorline highlighting?
      transparency = true, -- Use a transparent background?
      terminal_colors = false, -- Use the colorscheme's colors for Neovim's :terminal?
      window_unfocused_color = false, -- When the window is out of focus, change the normal background?
    },
  },
}

Expected behavior

Highlight to be the same.

Neovim version (nvim -v)

0.9.2

@nickp-real nickp-real added the bug Something isn't working label Oct 3, 2023
@lukas-reineke
Copy link
Owner

This is a limitation with your terminal. Not all terminals support underline with a different color.

@yalikebaz
Copy link

yalikebaz commented Oct 4, 2023

Which terminals are supported? Because I tried with both Kitty and iTerm2 (EXTREMELY popular terminals), and the above commenter tried with Alacritty and all of them behave as this issue described.

This issue should not be closed. If it's intended behaviour then this should be flagged a feature request instead, because supporting iTerm2/Alacritty/Kitty seems very basic.

@lukas-reineke
Copy link
Owner

lukas-reineke commented Oct 4, 2023

Kitty at least should work, that's what I use.

Tmux might mess with things, too. If you use tmux, try to add this in your tmux config.

set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'

This issue should not be closed. If it's intended behaviour then this should be flagged a feature request instead

There is nothing I can do about this. I just set the highlight group. If it doesn't work, it's not supported by your terminal, or your terminal is configured wrong.

@yalikebaz
Copy link

You're right!!! It IS tmux that's messing with it. If i go to a file without tmux the underline works correctly.
Unfortunately adding that snippet you posted didn't help, any other ideas?

@lukas-reineke
Copy link
Owner

There just was a discussion about this on Reddit as well, maybe something there works for you.

@yalikebaz
Copy link

In case anyone comes across this later - I managed to fix it by adding this to my tmux.conf (I'm using kitty):

set -g default-terminal "xterm-kitty"

@nickp-real
Copy link
Author

In case anyone using alacritty with tmux, try at this to your tmux config. It fixed for me.
set -as terminal-features ",alacritty:usstyle"
or
set -as terminal-features ",$TERM:usstyle"

@jackcogdill
Copy link

In case anyone using alacritty with tmux, try at this to your tmux config. It fixed for me. set -as terminal-features ",alacritty:usstyle" or set -as terminal-features ",$TERM:usstyle"

This worked for me but I had also had to upgrade Alacritty from version 10 to 12.

@fingergohappy
Copy link

fingergohappy commented Nov 23, 2023

I have the same problem as you. I'm using wezterm.According this document, This config can fix this problem.

env TERM=wezterm nvim code/xxx.c

OR

Add below config to .zshrc can fix this problem:

if [[ $TMUX != "" ]] then
    export TERM="tmux-256color"
else
    # export TERM="xterm-256color"
    export TERM="wezterm"
fi

@MannyFay
Copy link

MannyFay commented Feb 8, 2024

I have the same problem. My setup is:

  • macOS
  • Alacritty 13
  • tmux
  • treesitter (but highlighting is disabled)

Like above, I've added the line set -as terminal-features ",alacritty:usstyle" to my .tmux.conf. It doesn't work, so I've checked the behavior without tmux. Same problem.

If I understand @lukas-reineke correctly, the only point where it can come from by now is the color scheme, right?!?
I use my own very clean and simple color scheme and I very like IndentBlankline.

Does anybody has a hint for me, what the highlighting can be to discard the horizontal underlining (or set the color of it)? I've tried some (Line number included) but nothing has worked so far. The vertical indents are working and are awesome with changing the color depending on the scope :)

@lukas-reineke
Copy link
Owner

If I understand @lukas-reineke correctly, the only point where it can come from by now is the color scheme, right?!?

No, this is not even related to Neovim. It is a problem with your terminal / tmux and how they are configured.

Does anybody has a hint for me, what the highlighting can be to discard the horizontal underlining

If you just don't want to display the underlines at all, you can turn off :help ibl.config.scope.show_start and :help ibl.config.scope.show_end

@MannyFay
Copy link

MannyFay commented Feb 8, 2024

@lukas-reineke -> super cool:

  scope = {
    enabled            = true,   -- 'true': Highlight only the intended indentation and the current scope by an underline.
    show_start         = false,  -- Shows an underline on the first line of the scope.
    show_end           = false,  -- Shows an underline on the last line of the scope.
    show_exact_scope   = false,
    injected_languages = true,
  },

Made my day <3

...happy Karneval if you are one of those Karneval-people in Germany :-P

@cxwx
Copy link

cxwx commented Mar 29, 2024

does iterm2 support this feature?

@cxwx
Copy link

cxwx commented Apr 8, 2024

it seem the iterm2 and wezterm don't support this feature defaultly.
Can I make it done by change some configure in wezterm?

@ashb
Copy link

ashb commented May 1, 2024

it seem the iterm2 and wezterm don't support this feature defaultly. Can I make it done by change some configure in wezterm?

Yes, see https://wezfurlong.org/wezterm/faq.html?h=underline#how-do-i-enable-undercurl-curly-underlines (It's the same issue) -- in short you need the custom terminfo file and to set TERM=wezterm before launching nvim.

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

8 participants