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

Indent blankline v3 #612

Merged
merged 1 commit into from
Sep 28, 2023
Merged

Indent blankline v3 #612

merged 1 commit into from
Sep 28, 2023

Conversation

lukas-reineke
Copy link
Owner

@lukas-reineke lukas-reineke commented Sep 4, 2023

lua/ibl/init.lua Outdated Show resolved Hide resolved
@simonmandlik
Copy link

Hi, I'm getting the following selection behavior with default setup:

vip:

image

With master, I get

image

Is this intended?

Comment on lines +51 to +58
vim.api.nvim_create_autocmd("ColorScheme", {
group = group,
pattern = "*",
callback = function()
highlights.setup()
ibl.refresh_all()
end,
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a bit strict?

I cannot for example use a custom hlg, which is not set by the colorscheme itself.

minimal.lua:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

vim.cmd [[hi MyHLG guifg=red]]

-- install plugins
local plugins = {
    {
        "lukas-reineke/indent-blankline.nvim",
        branch = "v3",
        config = function()
            require("ibl").setup {
                indent = { highlight = "MyHLG" },
            }
        end
    },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd [[set termguicolors]]

Now when I run for example colorscheme default, it clears MyHLG, and when the autocommand runs it errors

Copy link
Owner Author

@lukas-reineke lukas-reineke Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use the HIGHLIGHT_SETUP hook, it's explained in the readme and the docs

https://github.com/lukas-reineke/indent-blankline.nvim/tree/v3#multiple-indent-colors

For the visual selection, I can't reproduce that. Please open an issue with steps to get there.

Copy link

@simonmandlik simonmandlik Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yes you are right. I just skimmed :h ibl.setup() (as recommended) and scrolled to config.indent. Out of curiosity — is there a reason why hooks are necessary here? None of other plugins I use with custom hl groups require that (tzachar/highlight-undo.nvim, winston0410/range-highlight.nvim, folke/flash.nvim to name a few), and their config is more concise.

About the highlighting — I'm not sure it is an "issue" per see, but side effect of how highlights are handled as well. Try this

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    "RRethy/nvim-base16",
    {
        "lukas-reineke/indent-blankline.nvim",
        branch = "v3",
        config = function()
            require("ibl").setup { }
        end
    },
}

require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd [[set termguicolors]]
vim.cmd [[colorscheme base16-dirtysea]]
vim.opt.background = "light"
vim.api.nvim_set_hl(0, "NonText",  { fg = "Gray", bg = "bg" })

Anyway, thanks for the hard work on this plugin!

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's not ideal, but I don't see a better way. Because there can be different colors for the indent guides, the scope, and the whitespace, I need to generate all combinations for all cases where they are used.

Otherwise, to have 3 colors each, the user would need to manually make 42 highlight groups. That would be much less user-friendly.
Even with just one color each, I still need to create 7 highlight groups.

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

Successfully merging this pull request may close these issues.

6 participants