preservim / vim-indent-guides

A Vim plugin for visually displaying indent levels in code
MIT License
2.62k stars 162 forks source link

Disable Guides for Terminal Buffers #140

Closed atomdmac closed 4 years ago

atomdmac commented 4 years ago

I use ranger.vim with my setup and it looks like vim-indent-guides applies indent guides in ranger windows as well as normal buffers. Is there a way to disable vim-indent-guides for buffers that contain terminal applications?

Example

See the gray bars in the lower left. image

nathanaelkane commented 4 years ago

Try using the indent_guides_exclude_filetypes option and see if that works, e.g. let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']

Edit: This option is for targeting specific filetypes, but if those plugins set the filetype, this option should do the trick.

nathanaelkane commented 4 years ago

Alternatively, would this work?

if !has("gui")
  let g:indent_guides_enable_on_vim_startup = 0
endif
atomdmac commented 4 years ago

@nathanaelkane Thanks for the suggestions! I've tried the exclude_filetypes option but either it doesn't work or I'm just using the correct file type. (I've tried terminal and ranger as values).

I'm using the terminal version of VIM so I'm not sure if the !has("gui") check will work (as I believe it will always return true in my case).

atomdmac commented 4 years ago

Update: This isn't a perfect solution as it operates on all terminal buffers but it seems to work well enough for my use case:

au TermEnter * IndentGuidesDisable
au TermLeave * IndentGuidesEnable

If anyone knows how to narrow this down a bit more (ex. just to terminals containing ranger instances) that'd be pretty neat. Otherwise, this solution is probably good enough for me.

Closing this for now but please feel free to re-open if a better solution arises.