Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Why is Helix auto-formatting my CSS files on save?

+0
−0

Hi everyone,

I recently set up Helix and noticed that every time I save a CSS file, it gets automatically formatted. I didn’t enable any formatter for CSS in my configuration, only for Python. My languages.toml looks like this:

[[language]]
name = "python"
language-servers = ["ruff"]
auto-format = true
scope = "source.python"

[language-server.ruff]
command = "ruff"
args = ["server"]

[language.formatter]
command = "ruff"
args = ["format", "-"]

[[language]]
name = "css"
auto-format = false

Even with auto-format = false for CSS, Helix still reformats the file on save.

Does anyone know why this happens and how I can stop Helix from formatting CSS automatically?

Thanks!

Edit:

I think what’s happening is that Helix’s auto-formatting is kicking in. According to the Helix language support docs, CSS has "Auto Indent".

The reason it seems odd in my case is that I'm using Jinja templates, and Helix doesn’t fully recognize them.

I can toggle auto-formatting for the current buffer with:

:toggle-option auto-format

…but the choice is basically between:

  1. Never auto-format CSS.
  2. Figure out a way for Helix to auto-format Jinja templates properly.

So it’s less of a “bug” and more of an interaction between auto-indent and Helix’s limited template recognition.

History

0 comment threads

Sign up to answer this question »