Megaxela/QCodeEditor

EditorConfig Support

Opened this issue · 8 comments

This would probably be a bit of work, but would certainly be a nice-to-have. I think Qt supports this type of config file as well, so hopefully that'd reduce the required work.

In case anyone is unfamiliar, this is EditorConfig.

ouuan commented

I think it's easy to use QSettings and apply the settings to the editor by yourself.

Right, it supports the file format. But why have everyone else implement this feature instead of just adding it to the library?

ouuan commented

I think you mean providing a preference window, but your application may have a preference window, and it's strange to have two.

ouuan commented

I think using QSettings is not much harder than calling the responding functions like setTabReplaceSize(), so I believe you mean the preference window.

I don't mean having a preference window, I just mean a function like this:

QCodeEditor::loadEditorConfig(const char* filename) {
  /* here */
}

The file is not really a user settings file. It's dropped into git repositories to help consistency in the project's indentation style.

ouuan commented

Oh, is that something like .clang-format? Sorry for that, I didn't read https://editorconfig.org/. However, the name "EditorConfig" is really confusing.

ouuan commented

So (how) is EditorConfig better than Clang Format?

Yes, it's very similar to .clang-format. No worries!

I wouldn't say that it's better. I've only ever used clang-format passively, in a formatting script. EditorConfig is usually integrated into a code editor so that it actively maintains the indentations as they are written. I'm sure there's some plugins that support this from a .clang-format file, but I don't really use them.

If there's anything .editorconfig definitely does better than .clang-format, it's that it's much simpler and easier to put into an existing editor. Trying to integrate .clang-format, on the other hand, requires either supporting the many different versions of the clang libraries or implementing all the rules found in the .clang-format file.