Closed clarfonthey closed 2 years ago
Small sidenote, smart_tabs
seems to be coming to editorconfig, so it might be interesting to support that as well ?
I added support for this in my setup by duplicating the editorconfig-load command and adding support for this extra property.
I'm sorry for taking so long to get to this; I've been going through my old PRs on GitHub and this one got left behind.
Another thing I'm thinking of, is that the name
autotab
may be a bit misleading into thinking that this enables automatic indentation, which it really doesn't. Maybe we could use something likeeconftab
or something like that? I'm not strictly opposed toautotab
though, as the readme clarifies it's use. Just thinking maybe it can be named more related to editorconfig somehow. Ideas?
In terms of the name, I think autoconfigtab
is a good compromise. I want to avoid specifically referencing editorconfig since technically this is just using existing settings that kakoune has, although editorconfig is the main use case.
Can you explain me how user would configure this feature to work for specific languages, defined in their
.editorconfig
?For example, I have this in my
.editorconfig
file:root = true [*.{c,cc,cpp,h,hpp,hh}] indent_style = tab [*.{rs,toml}] indent_style = space indent_size = 4
And in my
kakrc
I use these hooks:hook global WinSetOption filetype=rust expandtab hook global WinSetOption filetype=(c|cpp) smarttab
AFAIU, instead of specifying different hooks for
rust
andc
/cpp
filetypes, I would need to specify one that loads.editorconfig
and callsautotab
, right?
So, in this specific case, you'd choose:
hook global BufCreate .* {
editorconfig-load
set global aligntab false
autoconfigtab
}
I tried to modify the docs to be a bit clearer, specifically clarifying that you can replace noexpandtab
with smarttab
if you go with this option. expandtab
will always remain the same, however. As I mention in the last point in the README
, having alignment with tabs and indenting with spaces didn't really make sense to me, so, that use case just forces everything to spaces.
Small sidenote,
smart_tabs
seems to be coming to editorconfig, so it might be interesting to support that as well ? I added support for this in my setup by duplicating the editorconfig-load command and adding support for this extra property.
For right now at least, I don't want to cover this case, but it could definitely be added in the future. Although maybe in the future this would provide justification for including smarttab.kak's code in the main kakoune repo.
LGTM! Thanks!
This essentially provides "use what I have in editorconfig" behaviour.
Updated the readme as well to explain how users can take advantage of this. This is actually the biggest part of this PR, as the actual code is rather small.