Open bartoszbinda opened 4 years ago
Thanks. Unfortunately at the moment, Eclipse IDE doesn't allow us to set formatting preferences per language (they're global). There is a bug open on that topic, but it's a bit stalled as there is no easy way to introduce and present such file-specific customization without adding a lot of confusion to extenders and users. Pragmatically, I think this kind of issue could happen with any editor, so maybe it's worth having this as an auto-edit from the language server which would turn tabs into spaces whenever document changes.
I opened https://github.com/redhat-developer/yaml-language-server/issues/244 to have the LS providing this.
Could we use this class: org.eclipse.jface.text.TabsToSpacesConverter and extension-point org.eclipse.ui.genericeditor.autoEditStrategies?
Could we use this class: org.eclipse.jface.text.TabsToSpacesConverter and extension-point org.eclipse.ui.genericeditor.autoEditStrategies?
We could but that would be suboptimal. The requirement to avoid spaces is true for all YAML files in any IDE, so it's better if it's directly handled by the language server, which does contain the language logic and is reusable across IDEs. We don't want Wild Web Developer to hold to much knowledge and logic about the language, it's better to have it directing enhancement to the most relevant places.
I have managed to use that class as above to replace tabs with spaces although it does not work when I select some text and then press tab. Is there an other mechanism for that?
upstream issue has been closed: https://github.com/redhat-developer/yaml-language-server/issues/244 Is therestill something to do on Wild Web Developer side?
Is therestill something to do on Wild Web Developer side?
I believe we need Wild Web Developer to enable it explicitly https://github.com/redhat-developer/yaml-language-server/blob/04bfdccaada7724469c76e3319a26d0a4b096de6/src/yamlSettings.ts#L29 in the LS settings
See also https://github.com/redhat-developer/yaml-language-server/pull/396#issuecomment-763444795 However, note that the codeAction to "fix" tabs to spaces should already be working.
This is basically blocked by https://github.com/redhat-developer/yaml-language-server/pull/396 on LS side and https://bugs.eclipse.org/bugs/show_bug.cgi?id=537154 on client side.
It's now 2024, any news on that? I get laughed at by my team for Eclipse adding tabs instead of sapces in YAML files. This is seriously one of the reasons why it's getting harder and harder to argue in favor of using Eclipse.
any news on that?
Not much, but contributions are welcome. Eclipse LSP4E still misses onTypeFormatting support, the former issue from bugzilla is now located at https://github.com/eclipse/lsp4e/issues/246 . Please consider contributing support for onTypeFormatting to LSP4E and this should then work out-of-box.
I get laughed at by my team for Eclipse adding tabs instead of sapces in YAML files.
I personally like to laugh at YAML for that.
I think the issue is a bit worse: when pasting from the clipboard (the original content is taken from another valid YAML file, so, without tabs), the editor inserts tabs instead of spaces... :(
when pasting from the clipboard (the original content is taken from another valid YAML file, so, without tabs), the editor inserts tabs instead of spaces... :(
Did you have the opportunity to investigate what is causing that? Anyway, enabling onTypeFormatting in LSP4E shouldn't be to hard to implement and would be a very welcome contribution that could suddently fix it all.
I'm afraid I'm unable to contribute.
What I tried was also to disable YAML formatting, but that didn't change anything.
I can only guess it's due to the preference for using tabs in general text editors, which the YAML seems to pick up when pasting. To be honest, I don't think it was like that in the past, but I'm not 100% sure...
According to this: https://yaml.org/spec/1.2/spec.html#id2777534 `In YAML block styles, structure is determined by indentation. In general, indentation is defined as a zero or more space characters at the start of a line.
To maintain portability, tab characters must not be used in indentation, since different systems treat tabs differently. Note that most modern editors may be configured so that pressing the tab key results in the insertion of an appropriate number of spaces.
The amount of indentation is a presentation detail and must not be used to convey content information.
Each node must be indented further than its parent node. All sibling nodes must use the exact same indentation level. However the content of each sibling node may be further indented independently..` Wild web developer allows us to use YAML files with tabs. https://imgur.com/58hVbWM Is there any change to do in generic editor to allows convering tabs to space?