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

Weird highlighting regarding scopes (lua) #893

Open
hersi97 opened this issue Jun 8, 2024 · 3 comments
Open

Weird highlighting regarding scopes (lua) #893

hersi97 opened this issue Jun 8, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@hersi97
Copy link

hersi97 commented Jun 8, 2024

Problem

Hi!
I'm sorry if this is intended behavior, but I figured I should ask.

If I have my cursor under a function scope, I don't get highlights for the scope, however if I have the cursor under a block under the function scope (if block, for block, function block), I do get highlights.

Interestingly the show_start and show_end underlining does not have this problem.

image
image
(Notice the 3rd indent highlight)

Steps to reproduce

-- min-init.lua
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/indent-blankline.nvim",
    config = function()
      local highlight = {
        "IndentLight1",
        "IndentLight2",
        "IndentLight3",
        "IndentBase1",
        "IndentBase2",
        "IndentBase3",
        "IndentDark1",
        "IndentDark2",
        "IndentDark3",
        "IndentDarker1",
        "IndentDarker2",
        "IndentDarker3",
      }

      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()
        vim.api.nvim_set_hl(0, "IndentLight1", { fg = "#AFC8FF" })
        vim.api.nvim_set_hl(0, "IndentLight2", { fg = "#C2B0FF" })
        vim.api.nvim_set_hl(0, "IndentLight3", { fg = "#A6FFFC" })
        vim.api.nvim_set_hl(0, "IndentBase1", { fg = "#82AAFF" })
        vim.api.nvim_set_hl(0, "IndentBase2", { fg = "#A084FF" })
        vim.api.nvim_set_hl(0, "IndentBase3", { fg = "#74FFFA" })
        vim.api.nvim_set_hl(0, "IndentDark1", { fg = "#527FDF" })
        vim.api.nvim_set_hl(0, "IndentDark2", { fg = "#7555E1" })
        vim.api.nvim_set_hl(0, "IndentDark3", { fg = "#40D9D4" })
        vim.api.nvim_set_hl(0, "IndentDarker1", { fg = "#2F5FC3" })
        vim.api.nvim_set_hl(0, "IndentDarker2", { fg = "#5433C7" })
        vim.api.nvim_set_hl(0, "IndentDarker3", { fg = "#1DB9B3" })
      end)

      require("ibl").setup({
        indent = {
          char = "",
          tab_char = "",
          highlight = highlight,
        },
        scope = {
          show_start = true,
          show_end = true,
          highlight = highlight,
        },
      })
    end,
  },
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require("nvim-treesitter.configs").setup({
        ensure_installed = { "lua" }, -- change this to the language you use
      })
    end,
  },
}, { root = "/tmp/lazy" })

image
image
image

Expected behavior

I expect the indent line highlight to be active while the cursor is anywhere under the scope.

Neovim version (nvim -v)

NVIM v0.10.0

@hersi97 hersi97 added the bug Something isn't working label Jun 8, 2024
@lukas-reineke
Copy link
Owner

I'm not sure I understand your problem.
In the first screenshot, you are in the opts function scope, and that is highlighted correctly.
In the second screenshot, you are in the hooks.register function scope, and that is highlighted correctly too.

Everything looks correct.

@hersi97
Copy link
Author

hersi97 commented Jun 14, 2024

Alright, yes, the highlights are correct.
I was confused, since I didn't know it would highlight the current scope with the first highlight color in the config.
I played around with it a bit and it's clear now, thanks!

Slight off-topic question, is there a way to tell ibl to highlight the current scope with a different color than the first one set in config.indent.highlight?

@lukas-reineke
Copy link
Owner

Ah I understand your problem now. Setting a list of highlights for scope is currently broken #860.
You can still set a different color from the normal highlights though.

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