Options and .editorconfig #330
-
I am looking for an example on how to use Options to create settings that can be overridden by values on a solution/project level based on an .editorconfig file. The idea is that the extension would look for an .editorconfig file and use its values or fallback to the defaults recorded under TOOLS > OPTIONS > ... |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Christo, |
Beta Was this translation helpful? Give feedback.
-
Thanks Robert, this is really helpful! |
Beta Was this translation helpful? Give feedback.
Christo,
.editorconfig settings are per folder and file type, options are global
if you want to combine these then you need to write some code that gets the defaults from the options page, and then based on a filename you can override the setting.
In our project we do it like this:
https://github.com/X-Sharp/XSharpPublic/blob/main/VisualStudio/LanguageService/Formatting/EditorConfigSettings.cs
The SourceCodeEditorSettings object is initialized with the settings from Tools/Options.
We initialize the settings from the filename passed to ReadSettings() and store the result as object in the ITextBufffer.Properties
collection