Open ttytm opened 10 months ago
The reason tabs_width
exists is not for tabs itself, but when you are breaking lines when they exceed line width. If there is no tab_width
it could get quite wonky when someone makes a billion scopes, but we act like the tab is just one space, but on the editor it is 4-8 spaces.
It's one of shortcomings of tabs, formatter is operating in an uncertain environment.
I still prefer having a config to get a compromise between pretending tabs is one space.
Would to hear your opinion on how to manage line breaking when odinfmt
uses tabs.
Example:
func :: proc() {
{
{
{
{
a := 2 //this would in spaces be 28, but 12 with tabs pretending the symbol is one space
}
}
}
}
}
This PR makes some minor fixes as the current setting unfortunately creates some confusion in the editor.
It wants to:
Fix shifting tab widths and misalignments when e.g., switching splits in VSCode or entering buffers in nvim. It also should fix not respecting a users tab width setting.![Screenshot_20230528_230737](https://github.com/vlang/v/assets/34311583/3d15c259-57a9-46de-923c-06746f9ac5ab)
This issue is due to specifying
indent_size
as an anti-setting for tabs. Unlike with spaces, specifying a width is not needed; one tab is always one indentation. Without it we'll get the benefit of increased accessibility and more developer friendliness, so any preferred indent width can be used or dynamically adapted to a given situation. If you check https://editorconfig.org/, you will also see# Tab indentation (no size specified)
.I would further suggest to move towards a more modern setting for indentation for odinfmt that takes either an int or
"tab"
as valueindendation=int|"tab"
. Like e.g. stylelint does https://stylelint.io/user-guide/rules/indentation#optionsExtend file support. Yaml unfortunately requires spaces, as my editor didn't behave properly when working on #264, so
.editorconfig
was extended to cover yaml files.