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

global indentation configuration #6652

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

nnym
Copy link

@nnym nnym commented Apr 8, 2023

Indentation can be configured globally as shown below.

[editor.indent]
tab-width = 4
unit = "t"

These settings are used when a buffer is loaded and an indentation style is not detected and override language-specific defaults. However, they can be overridden per language in languages.toml by setting indent.required = true.

[[language]]
name = "yaml"
indent = {tab-width = 2, unit = "  ", required = true}

Setting indent.required = false for a language in the user's language.toml requires setting indent.{tab-width,unit} too but I think that this is out of the scope of this patch given that the same happens when setting indent.tab-width or indent.unit only.
These changes should resolve #3159.

@nnym nnym force-pushed the master branch 4 times, most recently from a5acca9 to ed5b53b Compare June 18, 2023 10:25
@Jackojc
Copy link

Jackojc commented Oct 29, 2023

Would be nice to try and merge this

@XavierCS-dev
Copy link

Would really like this, annoying to have to keep setting it every time I open helix. It would be nice if there was some helix.rc or such so this wouldn't be a problem

@@ -695,7 +695,7 @@ roots = ["pyproject.toml", "setup.py", "poetry.lock", "pyrightconfig.json"]
comment-token = "#"
language-servers = [ "pylsp" ]
# TODO: pyls needs utf-8 offsets
indent = { tab-width = 4, unit = " " }
indent = { tab-width = 4, unit = " ", required = true }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
indent = { tab-width = 4, unit = " ", required = true }
indent = { tab-width = 4, unit = " " }

Python allows using hard tabs for indentation (and actually any amount of spaces works too), it only disallows ambiguous mixing (i.e. when semantics depend on a specific tab width)

Copy link
Author

@nnym nnym Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mark the indentation style as required because Python requires it; I did it in order to override the global setting for conformance with PEP 8.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think required should only be applied to languages that do not support using tabs (like Nim) or spaces (like Makefile); everything else is basically just your stylistic choice which shouldn't affect anyone else. I mean, that's exactly the reason for using tabs instead of spaces.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree—I use tabs in Python and everywhere else—but this felt right to me at the time. In any case, I'll leave the decision to the maintainers.

@oworope
Copy link
Contributor

oworope commented Aug 5, 2024

Any updates on this?

@nnym
Copy link
Author

nnym commented Aug 5, 2024

@oworope
Copy link
Contributor

oworope commented Aug 5, 2024

So this won't be merged for now? We have to wait for plugin system to be implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow setting indent globally
6 participants