Set default indent for custom language plugin?
I've created a CustomCodeStyleSetting and both CodeStyleSettingsProvider and LanguageCodeStyleSettingsProvider. The custom CodeStyleSettingsPanel now sets the general indent for my language:
public class MyCodeStyleSettingsPanel extends CodeStyleAbstractPanel {
public void apply(CodeStyleSettings settings) {
MyCodeStyleSettings mySettings = settings.getCustomSettings(MyCodeStyleSettings.class);
mySettings.XYZ = getIntValue(myXyz);
// sync indent settings
CommonCodeStyleSettings.IndentOptions indentOptions = settings.getCommonSettings(MyLanguage.INSTANCE).getIndentOptions();
if (indentOptions != null)
indentOptions.INDENT_SIZE = indentOptions.CONTINUATION_INDENT_SIZE = mySettings.XYZ;
}
}
But how (and where) can I set the default indent for my language before the user opens the code style settings dialog for the first time?
Please sign in to leave a comment.
For reference - I think I found the solution.
Instead of LanguageCodeStyleSettings I'm using the FileIndentOptionsProvider extension point, this also handles the indent update of the custom settings:
I ended up using the following for my plugin, which seems to work:
Thanks for the alternative solution!