-
Notifications
You must be signed in to change notification settings - Fork 14
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
Editor always indents with tabs, not spaces #58
Comments
@jalbr74 ndeed it is not supported. Your requirement is about formatting configuration. Today you can use Ctrl+Shift+F to format your ts file which uses tsserver which uses spaces instead of using tabs. So to resolve this issue:
@jalbr74 @piotrtomiak @micaelgallego @atsu85 what do you think about where we can save the format configuration.
I think I will start with an UI preferences. |
I wouldn't mind just editing an Eclipse plugin config file directly, if that would be easiest. I just looked in the JSDT config file: ... and saw the configuration parameter: "org.eclipse.wst.jsdt.ui.formatterprofiles" with the following values: Do you think it would make sense to add the file: "ts.eclipse.ide.ui.prefs", and add the parameter: "ts.eclipse.ide.ui.formatterprofiles" with the same values as JSDT?: I already tried it, and it didn't work. But do you think that would be good way to go, to at least get there quickly for now? |
@jalbr74 this file preference is managed with UI preferences. So I don't want to develop something that I will remove it. As I said, I will start to implement an UI preferences with the supported formatting of tsserver (like VSCode does). |
I have also thought about .editorconfig - that would embrace the concept of this plugin to allow sharing the project between Eclipse and other IDEs. But I understand that You'll also need to consider other factors, such as time to implement it. |
The big problem with .editorconfig' is that you can host it anywhere and you can have a format configuration different from 2 files which are not hosted in the same folder. And tsserver supports format option for the whole ts files of the project. You cannot have a format option for a file and and an another for an another file. I have suggsted to TypeScript team to support "formatOption" inside tsconfig.json at microsoft/TypeScript#8709 With that we could share configuration between IDE. So for the moment I will store preferences with standard Eclipse preferences. |
Yes I know, that in theory the user can add several .editorconfig files for the same project, but how often is it happening in practice? I'd still vote for .editorconfig file that is located next to tsconfig (the one in the root, if there are several tsconfig.json files and tsserver doesn't support different formatting for several tsconfig.json configurations). But to be honest, at this maturity level of this plugin, it really isn't important how You solve it - already having any kind of formatting support by the plugin by the plugin is good before the official release. Having the opportunity to configure it in any way just makes it great! |
@jalbr74 @atsu85 I have implemented editor+format options configuration. Once the following job https://opensagres.ci.cloudbees.com/job/typescript.java/138/ will be finished you will able to install typescript.java. To configure tabs, spaces, typescript format, you can do it with a classic preferences page: Please tell me if it is OK for you. See https://github.com/angelozerr/typescript.java/wiki/Editor-Features#formatting for more information. In the future I would like to support .editorconfig, but it's little hard since Eclipse doesn't support the capability to update preferences for a given editor (it's project preferences). See ncjones/editorconfig-eclipse#30 for more information. I hope @mickaelistria will have time to work about this issue. |
The default value should be to inherit the default setting for platform text IMO. Multiplying the options to override indentation seems nice but if every editor does that, it can become a terrible mess for end-users to figure out what to change. Rather than boolean, I'd rather see combo such as
|
@angelozerr Indenting has been working perfectly for me now. Thanks for the fix! |
@angelozerr, actually great place to store formatting preferences would be tslint.json. Tslint uses that file to lint typescript source files and in addition to checking for errors there are rules to check indent and other formatting rules related to whitespaces, linebreak style, no trailing whitespaces and many more. Using this file would have multiple benefits:
What do You think? |
Yes sure! @atsu85 please create a new issue with your idea. If we do that we must think which config to use (eclipse preferences, tslint, etc) |
@mickaelistria I have used the same config than TypeScript (and VSCode).
Yes I agree but never see that ? JSDT has her own config too.
I agree,I don't know if it's easy to inherit from platform text (and support changes too of this preference) Please create a new issue, thanks! |
I'm not sure if I'm doing something wrong, but I can't seem to get the TypeScript editor to indent with spaces. It always uses tab characters.
I've verified my preferences for General > Editors > Text Editors are set to "Insert spaces for tabs", but I still always get the tab character.
I've also verified that if I open a *.txt file using Open With > Other > JavaScript (Salsa) Editor, I always get tab characters.
Any idea what I can do differently?
The text was updated successfully, but these errors were encountered: