-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Background color indentation guides to be a single char wide #950
Comments
There is. You can set the highlight group for both the indentation, and the whitespace. The background color example in the readme sets it for the whitespace, you can just switch it to the indentation. This should do what you want. require("ibl").setup {
indent = {
highlight = "ColorColumn",
},
} |
The reason for my interest on this one char width feature is this: I would like to display the require("ibl").setup {
indent = {
highlight = "ColorColumn",
char = " "
},
scope = {
enabled = false
}
} I could change the char for the indent to match ...
char = "·"
... |
I see. It's currently not supported to display different indent characters for blank vs non-blank lines, out of the box. You can use a hook to make this yourself local hooks = require "ibl.hooks"
hooks.register(hooks.type.VIRTUAL_TEXT, function(_, bufnr, row, virt_text)
local text = vim.api.nvim_buf_get_text(bufnr, row, 0, row, -1, {})[1]
if #text == 0 then
for _, vt in ipairs(virt_text) do
vt[1] = " "
end
end
return virt_text
end) There might be edge cases, and maybe the performance won't be the best. I'll think about adding a native option for this. |
Thank you, for the code and for considering implementing the capability into the plugin. The hook you provided achieves the behavior I'm looking for. I'll keep using it for some time to see if this indentation guide style grows on me. |
FWIW I've used this indentation style since my last comment in this issue and yes, it has grown on me. I have not been bothered by the performance of the hook, so at least for me the hook is enough. |
Problem
The background color indentation guides occupy the full indent depth. For exampe, if the code is indented at 4 spaces, as in the screenshot below, then the background color has a width of 4 characters.
The problem I see with this behavior is that the required alternation of highlight groups, such as "CursorColumn" and "Whitespace" as per the README.md, results in some indentations of the same type of structure not being highlighted, which is confusing at least for me.
Expected behavior
There exists some way to configure the background color indentation guides to look as in the image below. That is to say, the indentation guides are drawn using a single background color of width 1 char and starting where the indent begins.
I created the image using https://github.com/preservim/vim-indent-guides. Although vim-indent-guides is able to achieve the look I want, the plugin has issues such as not being able to show the background color on blank lines and it repeats the indentation guide on line continuations.
Thx for this plugin :) If you feel this is out of scope or too niche, feel free to close.
The text was updated successfully, but these errors were encountered: