Visual Studio Extensibility - Custom Language Text Editor Settings












5















I'm trying to develop a language service within Visual Studio, and so far I've been able to implement a basic Tagger for highlights and spans:



enter image description here



However, I wanted to take it a step further and add my own section under 'Text Editor' so that I can maintain Tab settings, and the like for the language (shown below):
enter image description here



I'm finding it difficult to find resources for Visual Studio extensibility online, as there's a lot you can do but knowing where to start is often difficult. I'm also interested in custom project/item services, but have similar issues with finding a sample.



It's possible I'm close as it is (due to the custom taggers), I just don't know what to decorate the exported types with, or I've got a lot of underlying work to do. Direction appreciated.










share|improve this question























  • Were you able to manage the tab settings in a consistent manner for your own language? The accepted answer creates a custom option page, but obviously Visual Studio provides some kind of standard option page for setting them in a consistent style across all languages (all my pre-installed languages have the same option page like the one that is shown in your screenshot).

    – Michael Szvetits
    Jun 11 '17 at 23:35
















5















I'm trying to develop a language service within Visual Studio, and so far I've been able to implement a basic Tagger for highlights and spans:



enter image description here



However, I wanted to take it a step further and add my own section under 'Text Editor' so that I can maintain Tab settings, and the like for the language (shown below):
enter image description here



I'm finding it difficult to find resources for Visual Studio extensibility online, as there's a lot you can do but knowing where to start is often difficult. I'm also interested in custom project/item services, but have similar issues with finding a sample.



It's possible I'm close as it is (due to the custom taggers), I just don't know what to decorate the exported types with, or I've got a lot of underlying work to do. Direction appreciated.










share|improve this question























  • Were you able to manage the tab settings in a consistent manner for your own language? The accepted answer creates a custom option page, but obviously Visual Studio provides some kind of standard option page for setting them in a consistent style across all languages (all my pre-installed languages have the same option page like the one that is shown in your screenshot).

    – Michael Szvetits
    Jun 11 '17 at 23:35














5












5








5


1






I'm trying to develop a language service within Visual Studio, and so far I've been able to implement a basic Tagger for highlights and spans:



enter image description here



However, I wanted to take it a step further and add my own section under 'Text Editor' so that I can maintain Tab settings, and the like for the language (shown below):
enter image description here



I'm finding it difficult to find resources for Visual Studio extensibility online, as there's a lot you can do but knowing where to start is often difficult. I'm also interested in custom project/item services, but have similar issues with finding a sample.



It's possible I'm close as it is (due to the custom taggers), I just don't know what to decorate the exported types with, or I've got a lot of underlying work to do. Direction appreciated.










share|improve this question














I'm trying to develop a language service within Visual Studio, and so far I've been able to implement a basic Tagger for highlights and spans:



enter image description here



However, I wanted to take it a step further and add my own section under 'Text Editor' so that I can maintain Tab settings, and the like for the language (shown below):
enter image description here



I'm finding it difficult to find resources for Visual Studio extensibility online, as there's a lot you can do but knowing where to start is often difficult. I'm also interested in custom project/item services, but have similar issues with finding a sample.



It's possible I'm close as it is (due to the custom taggers), I just don't know what to decorate the exported types with, or I've got a lot of underlying work to do. Direction appreciated.







c# visual-studio-2013 dsl vs-extensibility






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 14 '15 at 5:05









Alexander MorouAlexander Morou

122114




122114













  • Were you able to manage the tab settings in a consistent manner for your own language? The accepted answer creates a custom option page, but obviously Visual Studio provides some kind of standard option page for setting them in a consistent style across all languages (all my pre-installed languages have the same option page like the one that is shown in your screenshot).

    – Michael Szvetits
    Jun 11 '17 at 23:35



















  • Were you able to manage the tab settings in a consistent manner for your own language? The accepted answer creates a custom option page, but obviously Visual Studio provides some kind of standard option page for setting them in a consistent style across all languages (all my pre-installed languages have the same option page like the one that is shown in your screenshot).

    – Michael Szvetits
    Jun 11 '17 at 23:35

















Were you able to manage the tab settings in a consistent manner for your own language? The accepted answer creates a custom option page, but obviously Visual Studio provides some kind of standard option page for setting them in a consistent style across all languages (all my pre-installed languages have the same option page like the one that is shown in your screenshot).

– Michael Szvetits
Jun 11 '17 at 23:35





Were you able to manage the tab settings in a consistent manner for your own language? The accepted answer creates a custom option page, but obviously Visual Studio provides some kind of standard option page for setting them in a consistent style across all languages (all my pre-installed languages have the same option page like the one that is shown in your screenshot).

– Michael Szvetits
Jun 11 '17 at 23:35












3 Answers
3






active

oldest

votes


















4





+50









I found this blog post it has a lot of Visual Studio Extension project samples. Among them there is one project called Options Page – VS 2013 I think this is what you are looking for:



Option page



For your specific case you should tweak the following attributes in the class (taken from the example) OptionsPagePackage.cs. Specifically these attributes:




  • ProvideOptionPageAttribute


  • ProvideProfileAttribute


Have "category" as second passed parameter (which correspond to the main category in the Tools menu).



[ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })] 
[ProvideProfileAttribute(typeof(OptionsPageGeneral), "Text Editor", "General Options", 100, 101, true, DescriptionResourceID = 100)]
[ProvideOptionPageAttribute(typeof(OptionsPageCustom), "Text Editor", "Custom", 100, 102, true, new string { "Change sample custom options (C#)" })]
[InstalledProductRegistration("Text Editor", "My Options Page (C#) Sample", "1.0")]
[Guid(GuidStrings.GuidPackage)]
public class OptionsPagePackageCS : Package
{
.....
}


The DescriptionResourceID (100,101,102 etc) are defined in the xml file VsPackage.resx and will be used by the vsix installer to insert the labels in the tools menu:



<data name="100" xml:space="preserve">
<value>My Managed Options (C#)</value>
<comment>Options category</comment>
</data>
<data name="101" xml:space="preserve">
<value>My Options</value>
<comment>General page</comment>
</data>
<data name="102" xml:space="preserve">
<value>Custom</value>
<comment>Custom page</comment>
</data>


This is my attempt:



enter image description here



Just be cautious as using an existing Category will overwrite the existing one. As you can see in the picture there are no options for all the other languages.



EDIT:



As pointed out by Alexander to avoid overwriting the existing configuration (if one wants to add his category to an existing one in the Tools menu) backslash must be added to the category parameter in the attributes mentioned above. For Example:



[ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })]


Becomes:



 [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor\MyOptionPage","General", 100, 101, true, new string { "Change sample general options (C#)" })]


In that case MyOptionPage will be a child of Text Editor and it won't overwrite the existing configuration.



hope it helps.






share|improve this answer





















  • 1





    To overcome the issue of overwriting a category, I added a backslash after the 'Text Editor' and put 'OILexer' so the attributes became: [ProvideOptionPageAttribute(typeof(VSOilexerOptions), "Text Editor\OILexer", "General", 100, 101, true)]

    – Alexander Morou
    Mar 22 '15 at 5:40











  • Great! I'll add it to the answer

    – codingadventures
    Mar 22 '15 at 11:11











  • No problem. Do note: it was a speculative guess by the notion that there was no real hierarchical structure to the tree within the attributes. This 'backslash' doesn't appear to work beyond more than one level. So further backslashes only serve to disambiguate the item you define from others.

    – Alexander Morou
    Mar 22 '15 at 23:46



















0














The docs about creating user settings and options are under:



User Settings and Options



Basically your extension should provide also a package to provide a custom options page. The bind between the package and the options page location when using the Managed Package Framework (MPF) is done through the ProvideOptionPageAttribute, that receives the category name, page name, etc. See Creating Options Pages By Using Managed Package Framework Classes






share|improve this answer































    0














    There are two main things that are necessary to get a custom language to do what you want:



    1) Have a custom Option page under the Tools/Options/Text Editor/{CustomLanguage} which consists of the standard General, Scroll Bars, and Tabs dialog boxes for settings.



    2) You want the built-in code editor to automatically use your custom settings when editing content which is from your language. {CustomLanguage}.



    I had a bunch of package extensions that I created for QMBasic which is a multi-value language for the Pick-like database QM. I had intellisense with syntax coloring, brace matching, and auto completion providers working like a charm. I couldn't figure out why there were no option pages for my new custom "Content Type" that I referenced over and over again. It turns out the documentation and Visual Studio for that matter reference things like Content Type and Language Service and you assume they are the same but they aren't. The Content Type is used largely by the MEF part of Visual Studio to provide extension points which are used when editing a certain type of "Content Type" or Language in this case. It works great.



    Visual Studio will do all of these things fine without registering a "Language Service" which is the actual trick to get the custom option pages created AND get their values to be used by the editor. To get the custom option pages created for your language you simply need to generate a Guid for the language and then register it in your package definition. Like this.



    [ProvideLanguageService(QMBasicEditor.GuidList.guidQMBasicLanguageServiceIdString, "QMBasic", languageResourceID: 204, RequestStockColors = true, ShowDropDownOptions = true, ShowSmartIndent = true, DefaultToInsertSpaces = true)]


    And just like that Visual Studio will then create the General, Scroll Bars, and Tabs dialog pages for you on the Tools/Options/Text Editor/QMBasic section for me as well as persist the user settings in the Registry for you.



    You will find out however that the editor will NOT however use these new settings automatically. Visual Studio seems to make a distinction between Content Type and LanguageName which you see in the ProvideLanguageService definition above.



    I use an EditorFactory to produce my code editing windows for QMBasic and they are creating VSTextBuffers of Content Type "QMBasic".



    pTextBuffer  =_IVsEditorAdaptersFactoryService.CreateVsTextBufferAdapter(_IOleServiceProvider, _QMBasicContentType);


    which I thought would be enough but alas it is not. The IVSTextBuffer interface provides a nifty little helper method that you have to use called SetLanguageService that provides this magic. In my editor factory it was as simple as



    pTextBuffer.SetLanguageServiceID(GuidList.guidQMBasicLanguageServiceId);


    and that's all it took. The built-in code editor now uses the custom settings in the options pages like I expected.






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29045671%2fvisual-studio-extensibility-custom-language-text-editor-settings%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4





      +50









      I found this blog post it has a lot of Visual Studio Extension project samples. Among them there is one project called Options Page – VS 2013 I think this is what you are looking for:



      Option page



      For your specific case you should tweak the following attributes in the class (taken from the example) OptionsPagePackage.cs. Specifically these attributes:




      • ProvideOptionPageAttribute


      • ProvideProfileAttribute


      Have "category" as second passed parameter (which correspond to the main category in the Tools menu).



      [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })] 
      [ProvideProfileAttribute(typeof(OptionsPageGeneral), "Text Editor", "General Options", 100, 101, true, DescriptionResourceID = 100)]
      [ProvideOptionPageAttribute(typeof(OptionsPageCustom), "Text Editor", "Custom", 100, 102, true, new string { "Change sample custom options (C#)" })]
      [InstalledProductRegistration("Text Editor", "My Options Page (C#) Sample", "1.0")]
      [Guid(GuidStrings.GuidPackage)]
      public class OptionsPagePackageCS : Package
      {
      .....
      }


      The DescriptionResourceID (100,101,102 etc) are defined in the xml file VsPackage.resx and will be used by the vsix installer to insert the labels in the tools menu:



      <data name="100" xml:space="preserve">
      <value>My Managed Options (C#)</value>
      <comment>Options category</comment>
      </data>
      <data name="101" xml:space="preserve">
      <value>My Options</value>
      <comment>General page</comment>
      </data>
      <data name="102" xml:space="preserve">
      <value>Custom</value>
      <comment>Custom page</comment>
      </data>


      This is my attempt:



      enter image description here



      Just be cautious as using an existing Category will overwrite the existing one. As you can see in the picture there are no options for all the other languages.



      EDIT:



      As pointed out by Alexander to avoid overwriting the existing configuration (if one wants to add his category to an existing one in the Tools menu) backslash must be added to the category parameter in the attributes mentioned above. For Example:



      [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })]


      Becomes:



       [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor\MyOptionPage","General", 100, 101, true, new string { "Change sample general options (C#)" })]


      In that case MyOptionPage will be a child of Text Editor and it won't overwrite the existing configuration.



      hope it helps.






      share|improve this answer





















      • 1





        To overcome the issue of overwriting a category, I added a backslash after the 'Text Editor' and put 'OILexer' so the attributes became: [ProvideOptionPageAttribute(typeof(VSOilexerOptions), "Text Editor\OILexer", "General", 100, 101, true)]

        – Alexander Morou
        Mar 22 '15 at 5:40











      • Great! I'll add it to the answer

        – codingadventures
        Mar 22 '15 at 11:11











      • No problem. Do note: it was a speculative guess by the notion that there was no real hierarchical structure to the tree within the attributes. This 'backslash' doesn't appear to work beyond more than one level. So further backslashes only serve to disambiguate the item you define from others.

        – Alexander Morou
        Mar 22 '15 at 23:46
















      4





      +50









      I found this blog post it has a lot of Visual Studio Extension project samples. Among them there is one project called Options Page – VS 2013 I think this is what you are looking for:



      Option page



      For your specific case you should tweak the following attributes in the class (taken from the example) OptionsPagePackage.cs. Specifically these attributes:




      • ProvideOptionPageAttribute


      • ProvideProfileAttribute


      Have "category" as second passed parameter (which correspond to the main category in the Tools menu).



      [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })] 
      [ProvideProfileAttribute(typeof(OptionsPageGeneral), "Text Editor", "General Options", 100, 101, true, DescriptionResourceID = 100)]
      [ProvideOptionPageAttribute(typeof(OptionsPageCustom), "Text Editor", "Custom", 100, 102, true, new string { "Change sample custom options (C#)" })]
      [InstalledProductRegistration("Text Editor", "My Options Page (C#) Sample", "1.0")]
      [Guid(GuidStrings.GuidPackage)]
      public class OptionsPagePackageCS : Package
      {
      .....
      }


      The DescriptionResourceID (100,101,102 etc) are defined in the xml file VsPackage.resx and will be used by the vsix installer to insert the labels in the tools menu:



      <data name="100" xml:space="preserve">
      <value>My Managed Options (C#)</value>
      <comment>Options category</comment>
      </data>
      <data name="101" xml:space="preserve">
      <value>My Options</value>
      <comment>General page</comment>
      </data>
      <data name="102" xml:space="preserve">
      <value>Custom</value>
      <comment>Custom page</comment>
      </data>


      This is my attempt:



      enter image description here



      Just be cautious as using an existing Category will overwrite the existing one. As you can see in the picture there are no options for all the other languages.



      EDIT:



      As pointed out by Alexander to avoid overwriting the existing configuration (if one wants to add his category to an existing one in the Tools menu) backslash must be added to the category parameter in the attributes mentioned above. For Example:



      [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })]


      Becomes:



       [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor\MyOptionPage","General", 100, 101, true, new string { "Change sample general options (C#)" })]


      In that case MyOptionPage will be a child of Text Editor and it won't overwrite the existing configuration.



      hope it helps.






      share|improve this answer





















      • 1





        To overcome the issue of overwriting a category, I added a backslash after the 'Text Editor' and put 'OILexer' so the attributes became: [ProvideOptionPageAttribute(typeof(VSOilexerOptions), "Text Editor\OILexer", "General", 100, 101, true)]

        – Alexander Morou
        Mar 22 '15 at 5:40











      • Great! I'll add it to the answer

        – codingadventures
        Mar 22 '15 at 11:11











      • No problem. Do note: it was a speculative guess by the notion that there was no real hierarchical structure to the tree within the attributes. This 'backslash' doesn't appear to work beyond more than one level. So further backslashes only serve to disambiguate the item you define from others.

        – Alexander Morou
        Mar 22 '15 at 23:46














      4





      +50







      4





      +50



      4




      +50





      I found this blog post it has a lot of Visual Studio Extension project samples. Among them there is one project called Options Page – VS 2013 I think this is what you are looking for:



      Option page



      For your specific case you should tweak the following attributes in the class (taken from the example) OptionsPagePackage.cs. Specifically these attributes:




      • ProvideOptionPageAttribute


      • ProvideProfileAttribute


      Have "category" as second passed parameter (which correspond to the main category in the Tools menu).



      [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })] 
      [ProvideProfileAttribute(typeof(OptionsPageGeneral), "Text Editor", "General Options", 100, 101, true, DescriptionResourceID = 100)]
      [ProvideOptionPageAttribute(typeof(OptionsPageCustom), "Text Editor", "Custom", 100, 102, true, new string { "Change sample custom options (C#)" })]
      [InstalledProductRegistration("Text Editor", "My Options Page (C#) Sample", "1.0")]
      [Guid(GuidStrings.GuidPackage)]
      public class OptionsPagePackageCS : Package
      {
      .....
      }


      The DescriptionResourceID (100,101,102 etc) are defined in the xml file VsPackage.resx and will be used by the vsix installer to insert the labels in the tools menu:



      <data name="100" xml:space="preserve">
      <value>My Managed Options (C#)</value>
      <comment>Options category</comment>
      </data>
      <data name="101" xml:space="preserve">
      <value>My Options</value>
      <comment>General page</comment>
      </data>
      <data name="102" xml:space="preserve">
      <value>Custom</value>
      <comment>Custom page</comment>
      </data>


      This is my attempt:



      enter image description here



      Just be cautious as using an existing Category will overwrite the existing one. As you can see in the picture there are no options for all the other languages.



      EDIT:



      As pointed out by Alexander to avoid overwriting the existing configuration (if one wants to add his category to an existing one in the Tools menu) backslash must be added to the category parameter in the attributes mentioned above. For Example:



      [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })]


      Becomes:



       [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor\MyOptionPage","General", 100, 101, true, new string { "Change sample general options (C#)" })]


      In that case MyOptionPage will be a child of Text Editor and it won't overwrite the existing configuration.



      hope it helps.






      share|improve this answer















      I found this blog post it has a lot of Visual Studio Extension project samples. Among them there is one project called Options Page – VS 2013 I think this is what you are looking for:



      Option page



      For your specific case you should tweak the following attributes in the class (taken from the example) OptionsPagePackage.cs. Specifically these attributes:




      • ProvideOptionPageAttribute


      • ProvideProfileAttribute


      Have "category" as second passed parameter (which correspond to the main category in the Tools menu).



      [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })] 
      [ProvideProfileAttribute(typeof(OptionsPageGeneral), "Text Editor", "General Options", 100, 101, true, DescriptionResourceID = 100)]
      [ProvideOptionPageAttribute(typeof(OptionsPageCustom), "Text Editor", "Custom", 100, 102, true, new string { "Change sample custom options (C#)" })]
      [InstalledProductRegistration("Text Editor", "My Options Page (C#) Sample", "1.0")]
      [Guid(GuidStrings.GuidPackage)]
      public class OptionsPagePackageCS : Package
      {
      .....
      }


      The DescriptionResourceID (100,101,102 etc) are defined in the xml file VsPackage.resx and will be used by the vsix installer to insert the labels in the tools menu:



      <data name="100" xml:space="preserve">
      <value>My Managed Options (C#)</value>
      <comment>Options category</comment>
      </data>
      <data name="101" xml:space="preserve">
      <value>My Options</value>
      <comment>General page</comment>
      </data>
      <data name="102" xml:space="preserve">
      <value>Custom</value>
      <comment>Custom page</comment>
      </data>


      This is my attempt:



      enter image description here



      Just be cautious as using an existing Category will overwrite the existing one. As you can see in the picture there are no options for all the other languages.



      EDIT:



      As pointed out by Alexander to avoid overwriting the existing configuration (if one wants to add his category to an existing one in the Tools menu) backslash must be added to the category parameter in the attributes mentioned above. For Example:



      [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor","General", 100, 101, true, new string { "Change sample general options (C#)" })]


      Becomes:



       [ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"Text Editor\MyOptionPage","General", 100, 101, true, new string { "Change sample general options (C#)" })]


      In that case MyOptionPage will be a child of Text Editor and it won't overwrite the existing configuration.



      hope it helps.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 22 '15 at 11:15

























      answered Mar 22 '15 at 2:21









      codingadventurescodingadventures

      2,44721331




      2,44721331








      • 1





        To overcome the issue of overwriting a category, I added a backslash after the 'Text Editor' and put 'OILexer' so the attributes became: [ProvideOptionPageAttribute(typeof(VSOilexerOptions), "Text Editor\OILexer", "General", 100, 101, true)]

        – Alexander Morou
        Mar 22 '15 at 5:40











      • Great! I'll add it to the answer

        – codingadventures
        Mar 22 '15 at 11:11











      • No problem. Do note: it was a speculative guess by the notion that there was no real hierarchical structure to the tree within the attributes. This 'backslash' doesn't appear to work beyond more than one level. So further backslashes only serve to disambiguate the item you define from others.

        – Alexander Morou
        Mar 22 '15 at 23:46














      • 1





        To overcome the issue of overwriting a category, I added a backslash after the 'Text Editor' and put 'OILexer' so the attributes became: [ProvideOptionPageAttribute(typeof(VSOilexerOptions), "Text Editor\OILexer", "General", 100, 101, true)]

        – Alexander Morou
        Mar 22 '15 at 5:40











      • Great! I'll add it to the answer

        – codingadventures
        Mar 22 '15 at 11:11











      • No problem. Do note: it was a speculative guess by the notion that there was no real hierarchical structure to the tree within the attributes. This 'backslash' doesn't appear to work beyond more than one level. So further backslashes only serve to disambiguate the item you define from others.

        – Alexander Morou
        Mar 22 '15 at 23:46








      1




      1





      To overcome the issue of overwriting a category, I added a backslash after the 'Text Editor' and put 'OILexer' so the attributes became: [ProvideOptionPageAttribute(typeof(VSOilexerOptions), "Text Editor\OILexer", "General", 100, 101, true)]

      – Alexander Morou
      Mar 22 '15 at 5:40





      To overcome the issue of overwriting a category, I added a backslash after the 'Text Editor' and put 'OILexer' so the attributes became: [ProvideOptionPageAttribute(typeof(VSOilexerOptions), "Text Editor\OILexer", "General", 100, 101, true)]

      – Alexander Morou
      Mar 22 '15 at 5:40













      Great! I'll add it to the answer

      – codingadventures
      Mar 22 '15 at 11:11





      Great! I'll add it to the answer

      – codingadventures
      Mar 22 '15 at 11:11













      No problem. Do note: it was a speculative guess by the notion that there was no real hierarchical structure to the tree within the attributes. This 'backslash' doesn't appear to work beyond more than one level. So further backslashes only serve to disambiguate the item you define from others.

      – Alexander Morou
      Mar 22 '15 at 23:46





      No problem. Do note: it was a speculative guess by the notion that there was no real hierarchical structure to the tree within the attributes. This 'backslash' doesn't appear to work beyond more than one level. So further backslashes only serve to disambiguate the item you define from others.

      – Alexander Morou
      Mar 22 '15 at 23:46













      0














      The docs about creating user settings and options are under:



      User Settings and Options



      Basically your extension should provide also a package to provide a custom options page. The bind between the package and the options page location when using the Managed Package Framework (MPF) is done through the ProvideOptionPageAttribute, that receives the category name, page name, etc. See Creating Options Pages By Using Managed Package Framework Classes






      share|improve this answer




























        0














        The docs about creating user settings and options are under:



        User Settings and Options



        Basically your extension should provide also a package to provide a custom options page. The bind between the package and the options page location when using the Managed Package Framework (MPF) is done through the ProvideOptionPageAttribute, that receives the category name, page name, etc. See Creating Options Pages By Using Managed Package Framework Classes






        share|improve this answer


























          0












          0








          0







          The docs about creating user settings and options are under:



          User Settings and Options



          Basically your extension should provide also a package to provide a custom options page. The bind between the package and the options page location when using the Managed Package Framework (MPF) is done through the ProvideOptionPageAttribute, that receives the category name, page name, etc. See Creating Options Pages By Using Managed Package Framework Classes






          share|improve this answer













          The docs about creating user settings and options are under:



          User Settings and Options



          Basically your extension should provide also a package to provide a custom options page. The bind between the package and the options page location when using the Managed Package Framework (MPF) is done through the ProvideOptionPageAttribute, that receives the category name, page name, etc. See Creating Options Pages By Using Managed Package Framework Classes







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 18 '15 at 19:15









          Carlos QuinteroCarlos Quintero

          3,6721516




          3,6721516























              0














              There are two main things that are necessary to get a custom language to do what you want:



              1) Have a custom Option page under the Tools/Options/Text Editor/{CustomLanguage} which consists of the standard General, Scroll Bars, and Tabs dialog boxes for settings.



              2) You want the built-in code editor to automatically use your custom settings when editing content which is from your language. {CustomLanguage}.



              I had a bunch of package extensions that I created for QMBasic which is a multi-value language for the Pick-like database QM. I had intellisense with syntax coloring, brace matching, and auto completion providers working like a charm. I couldn't figure out why there were no option pages for my new custom "Content Type" that I referenced over and over again. It turns out the documentation and Visual Studio for that matter reference things like Content Type and Language Service and you assume they are the same but they aren't. The Content Type is used largely by the MEF part of Visual Studio to provide extension points which are used when editing a certain type of "Content Type" or Language in this case. It works great.



              Visual Studio will do all of these things fine without registering a "Language Service" which is the actual trick to get the custom option pages created AND get their values to be used by the editor. To get the custom option pages created for your language you simply need to generate a Guid for the language and then register it in your package definition. Like this.



              [ProvideLanguageService(QMBasicEditor.GuidList.guidQMBasicLanguageServiceIdString, "QMBasic", languageResourceID: 204, RequestStockColors = true, ShowDropDownOptions = true, ShowSmartIndent = true, DefaultToInsertSpaces = true)]


              And just like that Visual Studio will then create the General, Scroll Bars, and Tabs dialog pages for you on the Tools/Options/Text Editor/QMBasic section for me as well as persist the user settings in the Registry for you.



              You will find out however that the editor will NOT however use these new settings automatically. Visual Studio seems to make a distinction between Content Type and LanguageName which you see in the ProvideLanguageService definition above.



              I use an EditorFactory to produce my code editing windows for QMBasic and they are creating VSTextBuffers of Content Type "QMBasic".



              pTextBuffer  =_IVsEditorAdaptersFactoryService.CreateVsTextBufferAdapter(_IOleServiceProvider, _QMBasicContentType);


              which I thought would be enough but alas it is not. The IVSTextBuffer interface provides a nifty little helper method that you have to use called SetLanguageService that provides this magic. In my editor factory it was as simple as



              pTextBuffer.SetLanguageServiceID(GuidList.guidQMBasicLanguageServiceId);


              and that's all it took. The built-in code editor now uses the custom settings in the options pages like I expected.






              share|improve this answer






























                0














                There are two main things that are necessary to get a custom language to do what you want:



                1) Have a custom Option page under the Tools/Options/Text Editor/{CustomLanguage} which consists of the standard General, Scroll Bars, and Tabs dialog boxes for settings.



                2) You want the built-in code editor to automatically use your custom settings when editing content which is from your language. {CustomLanguage}.



                I had a bunch of package extensions that I created for QMBasic which is a multi-value language for the Pick-like database QM. I had intellisense with syntax coloring, brace matching, and auto completion providers working like a charm. I couldn't figure out why there were no option pages for my new custom "Content Type" that I referenced over and over again. It turns out the documentation and Visual Studio for that matter reference things like Content Type and Language Service and you assume they are the same but they aren't. The Content Type is used largely by the MEF part of Visual Studio to provide extension points which are used when editing a certain type of "Content Type" or Language in this case. It works great.



                Visual Studio will do all of these things fine without registering a "Language Service" which is the actual trick to get the custom option pages created AND get their values to be used by the editor. To get the custom option pages created for your language you simply need to generate a Guid for the language and then register it in your package definition. Like this.



                [ProvideLanguageService(QMBasicEditor.GuidList.guidQMBasicLanguageServiceIdString, "QMBasic", languageResourceID: 204, RequestStockColors = true, ShowDropDownOptions = true, ShowSmartIndent = true, DefaultToInsertSpaces = true)]


                And just like that Visual Studio will then create the General, Scroll Bars, and Tabs dialog pages for you on the Tools/Options/Text Editor/QMBasic section for me as well as persist the user settings in the Registry for you.



                You will find out however that the editor will NOT however use these new settings automatically. Visual Studio seems to make a distinction between Content Type and LanguageName which you see in the ProvideLanguageService definition above.



                I use an EditorFactory to produce my code editing windows for QMBasic and they are creating VSTextBuffers of Content Type "QMBasic".



                pTextBuffer  =_IVsEditorAdaptersFactoryService.CreateVsTextBufferAdapter(_IOleServiceProvider, _QMBasicContentType);


                which I thought would be enough but alas it is not. The IVSTextBuffer interface provides a nifty little helper method that you have to use called SetLanguageService that provides this magic. In my editor factory it was as simple as



                pTextBuffer.SetLanguageServiceID(GuidList.guidQMBasicLanguageServiceId);


                and that's all it took. The built-in code editor now uses the custom settings in the options pages like I expected.






                share|improve this answer




























                  0












                  0








                  0







                  There are two main things that are necessary to get a custom language to do what you want:



                  1) Have a custom Option page under the Tools/Options/Text Editor/{CustomLanguage} which consists of the standard General, Scroll Bars, and Tabs dialog boxes for settings.



                  2) You want the built-in code editor to automatically use your custom settings when editing content which is from your language. {CustomLanguage}.



                  I had a bunch of package extensions that I created for QMBasic which is a multi-value language for the Pick-like database QM. I had intellisense with syntax coloring, brace matching, and auto completion providers working like a charm. I couldn't figure out why there were no option pages for my new custom "Content Type" that I referenced over and over again. It turns out the documentation and Visual Studio for that matter reference things like Content Type and Language Service and you assume they are the same but they aren't. The Content Type is used largely by the MEF part of Visual Studio to provide extension points which are used when editing a certain type of "Content Type" or Language in this case. It works great.



                  Visual Studio will do all of these things fine without registering a "Language Service" which is the actual trick to get the custom option pages created AND get their values to be used by the editor. To get the custom option pages created for your language you simply need to generate a Guid for the language and then register it in your package definition. Like this.



                  [ProvideLanguageService(QMBasicEditor.GuidList.guidQMBasicLanguageServiceIdString, "QMBasic", languageResourceID: 204, RequestStockColors = true, ShowDropDownOptions = true, ShowSmartIndent = true, DefaultToInsertSpaces = true)]


                  And just like that Visual Studio will then create the General, Scroll Bars, and Tabs dialog pages for you on the Tools/Options/Text Editor/QMBasic section for me as well as persist the user settings in the Registry for you.



                  You will find out however that the editor will NOT however use these new settings automatically. Visual Studio seems to make a distinction between Content Type and LanguageName which you see in the ProvideLanguageService definition above.



                  I use an EditorFactory to produce my code editing windows for QMBasic and they are creating VSTextBuffers of Content Type "QMBasic".



                  pTextBuffer  =_IVsEditorAdaptersFactoryService.CreateVsTextBufferAdapter(_IOleServiceProvider, _QMBasicContentType);


                  which I thought would be enough but alas it is not. The IVSTextBuffer interface provides a nifty little helper method that you have to use called SetLanguageService that provides this magic. In my editor factory it was as simple as



                  pTextBuffer.SetLanguageServiceID(GuidList.guidQMBasicLanguageServiceId);


                  and that's all it took. The built-in code editor now uses the custom settings in the options pages like I expected.






                  share|improve this answer















                  There are two main things that are necessary to get a custom language to do what you want:



                  1) Have a custom Option page under the Tools/Options/Text Editor/{CustomLanguage} which consists of the standard General, Scroll Bars, and Tabs dialog boxes for settings.



                  2) You want the built-in code editor to automatically use your custom settings when editing content which is from your language. {CustomLanguage}.



                  I had a bunch of package extensions that I created for QMBasic which is a multi-value language for the Pick-like database QM. I had intellisense with syntax coloring, brace matching, and auto completion providers working like a charm. I couldn't figure out why there were no option pages for my new custom "Content Type" that I referenced over and over again. It turns out the documentation and Visual Studio for that matter reference things like Content Type and Language Service and you assume they are the same but they aren't. The Content Type is used largely by the MEF part of Visual Studio to provide extension points which are used when editing a certain type of "Content Type" or Language in this case. It works great.



                  Visual Studio will do all of these things fine without registering a "Language Service" which is the actual trick to get the custom option pages created AND get their values to be used by the editor. To get the custom option pages created for your language you simply need to generate a Guid for the language and then register it in your package definition. Like this.



                  [ProvideLanguageService(QMBasicEditor.GuidList.guidQMBasicLanguageServiceIdString, "QMBasic", languageResourceID: 204, RequestStockColors = true, ShowDropDownOptions = true, ShowSmartIndent = true, DefaultToInsertSpaces = true)]


                  And just like that Visual Studio will then create the General, Scroll Bars, and Tabs dialog pages for you on the Tools/Options/Text Editor/QMBasic section for me as well as persist the user settings in the Registry for you.



                  You will find out however that the editor will NOT however use these new settings automatically. Visual Studio seems to make a distinction between Content Type and LanguageName which you see in the ProvideLanguageService definition above.



                  I use an EditorFactory to produce my code editing windows for QMBasic and they are creating VSTextBuffers of Content Type "QMBasic".



                  pTextBuffer  =_IVsEditorAdaptersFactoryService.CreateVsTextBufferAdapter(_IOleServiceProvider, _QMBasicContentType);


                  which I thought would be enough but alas it is not. The IVSTextBuffer interface provides a nifty little helper method that you have to use called SetLanguageService that provides this magic. In my editor factory it was as simple as



                  pTextBuffer.SetLanguageServiceID(GuidList.guidQMBasicLanguageServiceId);


                  and that's all it took. The built-in code editor now uses the custom settings in the options pages like I expected.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 2 at 21:38

























                  answered Jan 1 at 22:00









                  jrstokkajrstokka

                  11




                  11






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29045671%2fvisual-studio-extensibility-custom-language-text-editor-settings%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                      Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

                      A Topological Invariant for $pi_3(U(n))$