sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
812 stars 80 forks source link

[Blocked by Atom] Ability to apply corresponding settings for code blocks in Markdown #237

Closed AlexWayfer closed 4 years ago

AlexWayfer commented 4 years ago

Hello!

I have a kind of suggestion: in Markdown files we have code blocks. And Atom highlight them correctly. And we often have code blocks inside Markdown. And often indentation of Markdown itself and code in Markdown blocks are different. For example, Markdown should has 4-spaces indentation, and Ruby should 2-spaces. And it's uncomfortable, because with 4-spaces for Markdown we have the same in Ruby code blocks.

Some list:

1.  Intent it with 4 spaces,
    because it's community standard.
2.  And indent Ruby with 2 spaces,
    because it's also community style.

```ruby
module Foo
  class Bar
    def baz
      2 + 2
    end
  end
end
```

Involved .editorconfig-files

root = true

[*.rb]
indent_style = space
indent_size = 2

[*.md]
indent_size = 4

Directory structure

README.md
Alhadis commented 4 years ago

This is beyond Atom's capabilities. For this package to support such a feature, we'd have to hack the core indentation mechanics, which is well outside its responsibility. Consider filing an issue upstream instead.

AlexWayfer commented 4 years ago

For this package to support such a feature, we'd have to hack the core indentation mechanics, which is well outside its responsibility.

atom-editorconfig already hacks indentation, changing it on the fly, does not it?

This is beyond Atom's capabilities.

Is it in Atom's capabilities to give atom-editorconfig the grammar of code where is cursor now?

Alhadis commented 4 years ago

atom-editorconfig already hacks indentation, changing it on the fly, does not it?

No, it modifies the settings that an editor is configured with when opened or saving to a file. I'm talking about the physical command that's executed when pressing TAB, as well as any part of the API that reads an editor's configured indentation width.

Is it in Atom's capabilities to give atom-editorconfig the grammar of code where is cursor now?

It is, but Atom doesn't support scoping editor-settings to specific blocks — only the entire editor. Syntax highlighting and scoped configuration are two separate things (although they arguably shouldn't be).

AlexWayfer commented 4 years ago

OK, I've created https://github.com/atom/atom/issues/20402 and updated the title of this issue.

You can close if you want to, until upstream issue is not resolved. Or you can leave it open to track.

Alhadis commented 4 years ago

I'll close it for now. Feel free to ping me here if there's any progress upstream.

AlexWayfer commented 4 years ago

Does the response in upstream help?

Alhadis commented 4 years ago

No, it doesn't. Scoped settings (or at least editor.tabLength) aren't respected in embedded code-blocks; I suspect @UziTech may have misunderstood the issue.

UziTech commented 4 years ago

But are they supposed to be respected?

UziTech commented 4 years ago

according to the documentation and my test in https://github.com/atom/atom/issues/20402#issuecomment-584652561 they are respected. It is only displaying the tab length that isn't working correctly.

Alhadis commented 4 years ago

And what about maximum line-length and indent style?

UziTech commented 4 years ago

looking at Atom's text editor source code it looks like it is only possible to set these setting per editor not per scope.

I think this should be possible and was the original idea behind scoped settings.