-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Adding indenttabchar, indentspacechar and spacechar options #3760
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
base: master
Are you sure you want to change the base?
Conversation
22c9b6f
to
f2c18b2
Compare
f2c18b2
to
5acc8f4
Compare
5acc8f4
to
8b92972
Compare
default value: ` ` (space) | ||
|
||
* `indentspacechar`: same as `indenttabchar` except for spaces that are at | ||
locations that are divisible by `tabsize`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if tabsize
doesn't match the actual indentation used in the given file (which happens more often than not)? If my detectindent plugin is used, it tries to detect the actual indentation width and adjusts tabsize
accordingly, but this plugin is not even built-in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what the problem is here.
The user (or any plugins) can always change the tabsize
and the indentspacechar
will be displayed accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the default behavior is confusing. For example, the default value of tabsize
is 4, the user edits a file with 2-space indentation and doesn't bother changing the tabsize
value (because it doesn't matter to him), then the user sets this indentspacechar
option to highlight indentation, but only half of the indentation is highlighted.
I have no better suggestions right now, so I'm fine with it.
setting available in many other text editors. The color of this character is | ||
determined by the `indent-char` field in the current theme rather than the | ||
default text color. | ||
* `indenttabchar`: sets the indentation character for tabs. This will not be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is "indentation character for tabs"? AFAICS indenttabchar
does exactly what indentchar
currently does, i.e. simply displays all tabs, so why not call it just tabchar
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess technically they are the same? Since the tab character is always (displayed) aligned to tabsize
?
I can change it to tabsize
, I named it this ways just (trying) to be consistent to what it was called previously.
Do we need to deprecate It feels that by adding that many new options we are creating even more mess and confusion. Why not just add BTW another request in #431 (comment) was to display other non-printable characters, which is quite reasonable, so we might add another option e.g. |
Repurposing a setting would be confusing since the user is not expecting it unless they read the documentation. I guess if we want to truly do what the name says, we can have a setting
Okay, I will add that as well. |
It would be "backward compatible" in a sense: tabs would be still highlighted. Spaces at the position of tabs would become highlighted as well, but if the user changed the default value of
Let's not overcomplicate without real need. |
Okay, I see. But if I am fine to do it either way tbh. Just a question. The reason I deprecated Another reason is what if the user actually wants space (the default) instead of
Okay. |
Its primary role is to simply specify which character to use to visualize tabs. It is not primarily about indentation. What do we gain by making its name more verbose?
It doesn't need to be hidden, it can (and probably should) be documented as well. |
I know, but that's what it was called. That's why I said maybe we could have 2 settings for tabs, 1 act like
To be less confusing. The previous behavior of
I would prefer the behavior to be mentioned in the name rather that requiring the user to read the documentation (although they should be to be fair). This is gonna be my last attempt to see if we can stick to the current proposed names. |
Simple question: do we want an option that allows the user to simply display all tabs (no matter at the beginning, at the end or in the middle of a line)? If the answer is yes, why not call this option If what we want instead (or in addition) is an option that only displays tabs at the beginning of lines, then yes, it would make sense to name it |
That's what it does currently, both
That's why I was asking maybe if I should have Actually, maybe it is better if I rename the new options to the following:
Do you think this is better? |
What's the point of being consistent with it if you are deprecating it?
I'm not suggesting to implement it, I'm saying that if we wanted to implement it, then
Ok, I've just noticed that you already have Question (not a rhetorical one): are you going to use |
Yeah, I am, so that I can tell any hidden tabs in space-indented files. |
For that purpose, wouldn't |
True. I should probably turn that on as well. But they will still be different values, since I use The main thing here is we are mixing the ability to see tab character and indented blocks into a single option ( If we reuse If we are reusing I think it is good to have a new version/breaking changes message anyway for future breaking changes if any. Also if we need to account for a special case where Or we can avoid all of this headache by just having 4 options, |
To be clear, when I suggested reusing
This is a UI change, not an API change. The user is gonna notice it anyway. We've done such "breaking" UI changes before. It is less breaking than #3335, for example.
Because with the "extended" definition of indentation character (see my confusion above), any tab is an indent char, but not any space is... Anyway, screw that, yes, it would be messy. Now I think it's better to let
I'm almost fine with that, but... Think of what would be the most useful and pleasant behavior for the user. The user wants to see "indentation columns", displayed with the On the other hand... I've recalled once again that it's not that simple, since So, right now I'm inclined to agree that having 4 options
It still doesn't answer what to do with I don't think silently removing it from the documentation (what your PR seems to be doing) is an option. It seems we should just keep it, and say in its documentation that it is just an alias for |
Agree, but while we are at it...the |
If we're going to keep adding more of these maybe grouping them together under one setting would be better for discoverability? Similar to what vim does with |
Hm, good idea. |
I will need an example in order to implement grouping for the options. I am not following how I did say this PR addresses the issues but doesn't mean I am solving all of them completely (for instance #431 (comment) is asking for displaying a hex code, that's not gonna be done in this PR). I am open to ideas but don't want to get feature-creeped here 😅 I will try to implement the ideas mentioned here if relatively straightforward, if not it's better to have a dedicated PR for those features. The main goal for this PR (to me) is to have configurable indent characters for both space and tab indented files. |
Good point. Originally I was mildly opposed to doing something similar to vim's |
Something like I'm not sure what would be the name of this generic option though. |
I see. In this case, I will need to store these options as global variables (since we don't want to do string parsing in every display call) instead of getting it from the settings map. |
Hah, you are sure it would be slower than the settings map lookup? Especially considering how many times we do the settings map lookup in every display call? :D We are extremely wasteful there. See #3227 and #3228 (and #2970 for the background) (Just in case, I'm not saying we should not store those parsed settings.) |
|
Ah, I misread that comment, I thought it was just about displaying non-printable characters with some character... And I forgot that micro already does that, since a long time: 51ab8f9 + b793e9b |
Maybe or
Yes, that is ok, since we already show a replacement for non-displayable characters. Transforming them into their Unicode HEX would require more work unrelated to that. |
No, I meant parsing the value of
Right, I thought we were only grouping the indent + tab/space chars, or are we? If we are trying to group other characters as well like |
Well, it may slower than a single lookup of the settings map, but my point what that it is a drop in the ocean compared to the rest of the crap we do in every Anyway, nevermind.
The idea is that this option can be extensible.
These are not the only characters that we are displaying. We are displaying other, regular characters as well. It's not like we are hiding them, right? |
Anyway, my intent for This is one of the (few?) times where chatgpt is useful 😄 . Got a few more suggestions from it here:
Funny how it gave
Edit2: Or maybe |
That would be a pretty unconventional usage of the term "replace", especially in a text editor. At the moment my favorite is |
👍 |
Yep. |
This PR added the options of
indentspacechar
andspacechar
and movedindentchar
toindenttabchar
to avoid confusion.indenttabchar
will display the specified character when\t
is encountered.indentspacechar
will display the specified character when' '
is encountered attabsize
locationsspacechar
will display the specified character when' '
is encountered, butindentspacechar
takes precedence.Created this PR because I wanted the feature to view files with deeply nested blocks.
Gonna merge it to my own fork https://github.com/Neko-Box-Coder/micro-dev for whoever needs it while waiting for this to be merged.
This should address long-standing requests of #2539 , #2707 and #431
I am happy to revert the prompt message of telling user
indentchar
is deprecated, if people/maintainer finds it controversial.