indent-blankline.nvim icon indicating copy to clipboard operation
indent-blankline.nvim copied to clipboard

Hide indent guides in visual mode

Open Unoqwy opened this issue 3 years ago • 10 comments

Hey! I've just switched from indent-guides.nvim to this plugin and one of the first thing I notice is the indent guides are displayed even in visual mode. Is there any way to hide them (lua branch)?

Unoqwy avatar Jun 28 '21 17:06 Unoqwy

No it's not possible.

Neovim has virt_text_hide which should allow this, but it's currently not working https://github.com/neovim/neovim/issues/14050#issuecomment-801536916

lukas-reineke avatar Jun 29 '21 03:06 lukas-reineke

Hm, virt_text_hide=true works in the neovim test suite, but only because col is always greater than 0. The reason why it doesn't work here is because col is 0 (if set to 1 it does, but of course everything is shifted and empty lines don't render virttext). Now why is this happening? No clue. I couldn't find any mention of column 0 affecting virttext options in the neovim issues so either they don't know it or I have failed at searching.

Unoqwy avatar Jun 29 '21 08:06 Unoqwy

You're right, it's only broken for col 0 You should comment that in the issue above, or make a new one

lukas-reineke avatar Jun 30 '21 01:06 lukas-reineke

Yeah, I created a new issue because it 's not really related to scrolling. See https://github.com/neovim/neovim/issues/14929. Also, I noticed you @mentioned bfredl in your issue after creating it, should we do the same here?

Unoqwy avatar Jun 30 '21 06:06 Unoqwy

bfredl wrote all of this virtual text code. He knows best how to fix it. Up to you if you want to tag him, he'll probably see it anyway.

lukas-reineke avatar Jun 30 '21 08:06 lukas-reineke

hey, everyone... I'm seeing this problem with block-visual (:help CTRL-V) with v3 and current options:

{
    indent = {
      char = '┆',
      highlight = {"…"}
    },
    scope = {show_start = false}
}

FelipeLema avatar Sep 29 '23 19:09 FelipeLema

ended up using the following snippet to turn on/off indent-blanklines when exiting/entering visual mode

local saca_de_enmedio_a_indent_blankline = vim.api.nvim_create_augroup("saca_de_enmedio_a_indent_blankline",
  {clear = true})
vim.api.nvim_create_autocmd("ModeChanged",
  {
    group = saca_de_enmedio_a_indent_blankline,
    pattern = "[vV\x16]*:*", -- visual → cualquier cosa
    command = "IBLEnable",
    desc = "Habilita indent-blanklines al salir de modo visual"
  })
vim.api.nvim_create_autocmd("ModeChanged",
  {
    group = saca_de_enmedio_a_indent_blankline,
    pattern = "*:[vV\x16]*", -- cualquier cosa → visual
    command = "IBLDisable",
    desc = "Deshabilita indent-blanklines al salir de modo visual"
  })

FelipeLema avatar Oct 26 '23 14:10 FelipeLema

This is a related question. How can I configure the plugin to never hide indent guides?

akoerner1 avatar Nov 17 '23 19:11 akoerner1

ended up using the following snippet to turn on/off indent-blanklines when exiting/entering visual mode

local saca_de_enmedio_a_indent_blankline = vim.api.nvim_create_augroup("saca_de_enmedio_a_indent_blankline",
  {clear = true})
vim.api.nvim_create_autocmd("ModeChanged",
  {
    group = saca_de_enmedio_a_indent_blankline,
    pattern = "[vV\x16]*:*", -- visual → cualquier cosa
    command = "IBLEnable",
    desc = "Habilita indent-blanklines al salir de modo visual"
  })
vim.api.nvim_create_autocmd("ModeChanged",
  {
    group = saca_de_enmedio_a_indent_blankline,
    pattern = "*:[vV\x16]*", -- cualquier cosa → visual
    command = "IBLDisable",
    desc = "Deshabilita indent-blanklines al salir de modo visual"
  })

This is perfect!

Here's an English version I made for myself 😅:

local indent_blankline_augroup = vim.api.nvim_create_augroup("indent_blankline_augroup", {clear = true})
vim.api.nvim_create_autocmd("ModeChanged", {
    group = indent_blankline_augroup,
    pattern = "[vV\x16]*:*",
    command = "IBLEnable",
    desc = "Enable indent-blankline when exiting visual mode"
})

vim.api.nvim_create_autocmd("ModeChanged", {
    group = indent_blankline_augroup,
    pattern = "*:[vV\x16]*",
    command = "IBLDisable",
    desc = "Disable indent-blankline when exiting visual mode"
})

ArjunSahlot avatar Jan 16 '24 05:01 ArjunSahlot