mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.99k stars 715 forks source link

Add -indent option to show-whitespace highlighter #5132

Closed topisani closed 7 months ago

topisani commented 7 months ago

image

A couple of semi-opinionated choices were made in this implementation:

  1. The guide is hidden in the first column.
  2. The indent guides are highlighted using a new WhitespaceIndent face.
  3. Nothing is done to continue the guide through empty lines. I believe this to be the correct approach, at least as long as it is kept as a part of the show-whitespaces highlighter. However some people's oppinion may differ, and if so, that could be implemented.
  4. The guides default to on, like the other show-whitespace options. Default character is "│".
  5. Spaces between the indent guides are currently highlighted as other spaces. Other reasonable options would be no replacement, -tabpad, or a similar -indentpad.
  6. Guides are disabled by passing -indent "".
  7. Indent guides are separate from tab highlighting.

Additionally, we could consider adding a separate face for the "current" indent level as many editors do, but this is a bit harder in kakoune because of multiple selections.

Closes #2323

Screwtapello commented 7 months ago

In a file where indentation is done with tabs, does the tab-highlighting or ident-highlighting win? What happens if tabstop and indentwidth are set to different values?

topisani commented 7 months ago

In a file where indentation is done with tabs, does the tab-highlighting or ident-highlighting win? What happens if tabstop and indentwidth are set to different values?

Indent guides currently only highlight leading spaces, according to indentwidth. So tab highlighting and indent highlighting never interact. If you want similar indent guides for tabs, they were always, and are still, possible using the tab highlighter. We could consider using this logic for both preceding tabs and spaces though, but as I see it, this is the most useful design, to still easily be able to differentiate tabs and spaces

mawww commented 7 months ago

Nice, my only comment is whether we need a separate WhitespaceIndent face, I suspect it not really necessary. I'll merge it as-is for now but might remove that face later on if I cant find a good justification for it.