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

Enabling per-buffer or per-filetype #80

Open
kballenegger opened this issue Jan 29, 2015 · 11 comments
Open

Enabling per-buffer or per-filetype #80

kballenegger opened this issue Jan 29, 2015 · 11 comments

Comments

@kballenegger
Copy link

I'd like to have indent-guides only enabled for certain filetypes (those with significant whitespace). Right now, my configuration looks like this:

" indent-guide
let g:indent_guides_auto_colors = 0
hi clear IndentGuidesOdd
hi IndentGuidesEven ctermbg=235

autocmd FileType coffeescript :IndentGuidesEnable
autocmd FileType sass         :IndentGuidesEnable
autocmd FileType haml         :IndentGuidesEnable
autocmd FileType python       :IndentGuidesEnable

The problem is that indent-guides is enabled or disabled globally, and not per buffer, and refresh on buffer enter. Two potential solutions:

  1. Let indent-guide be enabled per-buffer, not globally. (This makes more sense to me anyway.) Then I can have the right autocmd set up for my use case.
  2. Let us specify a filetype inclusion whitelist, not an exclusion blacklist. I can't list every every file type I may ever want to edit with vim; but it's easy to list the ones I might want guides on.
@kballenegger
Copy link
Author

Is anybody interested in pointing me in the right direction for building this myself?

@davidosomething
Copy link

Can't you use bufenter and bufleave instead of filetype

@kballenegger
Copy link
Author

It doesn't really make a difference. The IndentGuideEnable command is global, it enables it for all buffers.

@kballenegger
Copy link
Author

Is this issue dead? This is still very much a problem for me day-to-day :(.

@Ron89
Copy link

Ron89 commented Apr 15, 2016

I think what @davidosomething mean is that you can setup BufEnter and BufLeave for your filetype that needs indent guide as a workaround. For example, if I want it ON only for Python:

augroup filetype_python
    autocmd!
    ...
    autocmd BufEnter * if &ft ==# 'python' | IndentGuidesEnable  | endif
    autocmd BufLeave * if &ft ==# 'python' | IndentGuidesDisable | endif
augroup END

So That the IndentGuide settings can be mostly confined to the active buffer's.

But I agree, this solution is cumbersome. And it looks weired when opening a buffer supposedly using IndentGuide and one not so side-by-side with split.

Is there any plan on making a alternative as @kballenegger suggested? It's a sensible request to me.

@nathanaelkane
Copy link
Collaborator

@Ron89 that looks similar to the indent_guides_exclude_filetypes option.

I don't mind the idea of the filetype whitelist behaviour that @kballenegger suggested, but I think it'd have to be a new option.

@Ron89
Copy link

Ron89 commented Apr 17, 2016

g:indent_guides_exclude_filetypes works fine for my need. Sorry for not being able to spot it myself in the documentation.

@nathanaelkane
Copy link
Collaborator

Please re-open if indent_guides_exclude_filetypes isn't sufficient.

@kballenegger
Copy link
Author

kballenegger commented Mar 15, 2017

Not sure how to re-open this, but I don't find indent_guides_exclude_filetypes to be sufficient. It's unreasonable to list every possible filetype in a blacklist when all you're looking is to enable it purely for a single filetype. That was mentioned in the original issue text as a suggestion:

Let us specify a filetype inclusion whitelist, not an exclusion blacklist. I can't list every every file type I may ever want to edit with vim; but it's easy to list the ones I might want guides on.

@nathanaelkane nathanaelkane reopened this Mar 15, 2017
@tshirtman
Copy link

Same here, i used BufEnter/BufLeave to toggle it, but when you have splits, going from one split to another disable it for the first split, would be better to enable it by filetype.

@rockandska
Copy link

A little bit old but I had similar needs as you @tshirtman / @kballenegger , i just pushed a PR who seems to satisfy my needs and think it should satisfy yours too.

Could you please confirm if it is the case ?

Regards,

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

No branches or pull requests

6 participants