You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@lukas-reineke would love to be able to add this to the wiki? or maybe add an examples section to the repo.
Spent a long time working this out:
Dynamic Background Stripes with indent-blankline.nvim
This guide explains how to set up alternating background stripes for indentation levels in Neovim using indent-blankline.nvim. The configuration dynamically adapts the background colors based on the active colorscheme, ensuring seamless integration with both dark and light themes.
Features
Dynamic Highlight Groups: Automatically adjusts colors for both dark and light themes.
Alternating Background Stripes: Provides subtle visual cues for nested indentation levels using background colors.
No Characters: Relies on background highlights instead of displaying visible characters, maintaining a clean and minimal aesthetic.
Dynamic Colorscheme Support: Automatically updates the colors when switching between themes.
Configuration
Lua Code
(lazyvim in a /plugins/indent-blank.lua
return {
{
"lukas-reineke/indent-blankline.nvim",
main="ibl",
event= { "BufReadPre", "BufNewFile" },
config=function()
-- Function to dynamically calculate colors based on the backgroundlocalfunctionsetup_highlight_groups()
localbackground=vim.o.background-- 'dark' or 'light'ifbackground=="dark" then-- Dark theme colorsvim.api.nvim_set_hl(0, "IndentStripe1", { bg="#1B2B34" }) -- Original dark backgroundvim.api.nvim_set_hl(0, "IndentStripe2", { bg="#232E38" }) -- Slightly lighterelse-- Light theme colorsvim.api.nvim_set_hl(0, "IndentStripe1", { bg="#FDF6E3" }) -- Light theme backgroundvim.api.nvim_set_hl(0, "IndentStripe2", { bg="#F6EFD9" }) -- Slightly darkerendend-- Set up highlight groups for the current colorschemesetup_highlight_groups()
-- Autocmd to update highlight groups when the colorscheme changesvim.api.nvim_create_autocmd("ColorScheme", {
callback=setup_highlight_groups,
})
-- Configure indent-blankline.nvimrequire("ibl").setup({
indent= {
highlight= { "IndentStripe1", "IndentStripe2" }, -- Alternating subtle backgroundschar="", -- No character, only background
},
whitespace= {
highlight= { "IndentStripe1", "IndentStripe2" },
remove_blankline_trail=false,
},
scope= { enabled=false },
})
end,
},
}
Dynamic Background Colors
The configuration dynamically detects the current theme using vim.o.background:
Dark Themes:
IndentStripe1: #1B2B34 (dark base color)
IndentStripe2: #232E38 (slightly lighter)
Light Themes:
IndentStripe1: #FDF6E3 (light base color)
IndentStripe2: #F6EFD9 (slightly darker)
The text was updated successfully, but these errors were encountered:
@lukas-reineke would love to be able to add this to the wiki? or maybe add an examples section to the repo.
Spent a long time working this out:
Dynamic Background Stripes with
indent-blankline.nvim
This guide explains how to set up alternating background stripes for indentation levels in Neovim using
indent-blankline.nvim
. The configuration dynamically adapts the background colors based on the active colorscheme, ensuring seamless integration with both dark and light themes.Features
Configuration
Lua Code
(lazyvim in a /plugins/indent-blank.lua
Dynamic Background Colors
The configuration dynamically detects the current theme using
vim.o.background
:IndentStripe1
:#1B2B34
(dark base color)IndentStripe2
:#232E38
(slightly lighter)IndentStripe1
:#FDF6E3
(light base color)IndentStripe2
:#F6EFD9
(slightly darker)The text was updated successfully, but these errors were encountered: