{"id":24706,"date":"2019-07-24T23:00:08","date_gmt":"2019-07-24T23:00:08","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=24706"},"modified":"2019-07-24T23:28:36","modified_gmt":"2019-07-24T23:28:36","slug":"visual-studio-code-c-c-extension-july-2019-update","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/visual-studio-code-c-c-extension-july-2019-update\/","title":{"rendered":"Visual Studio Code C\/C++ Extension: July 2019 Update"},"content":{"rendered":"<p>The July 2019 update of the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.cpptools\">Visual Studio Code C\/C++ extension<\/a> is now available. This release includes many new features, including semantic colorization and improvements to the IntelliSense Configuration Settings Editor UI and IntelliSense cache. For a full list of this release\u2019s improvements, check out our <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/releases\/tag\/0.24.0\">release notes on GitHub<\/a>.<\/p>\n<h2>Semantic Colorization<\/h2>\n<p>Semantic colorization support has been one of the top asks on our GitHub repo for the past few years. We faced many challenges in creating support for semantic colorization for the C\/C++ extension since there is <a href=\"https:\/\/github.com\/microsoft\/vscode\/issues\/585\">no VS Code API for semantic source highlighting<\/a> and <a href=\"https:\/\/github.com\/microsoft\/language-server-protocol\/issues\/18\">no support for semantic colorization<\/a> in the <a href=\"https:\/\/github.com\/microsoft\/language-server-protocol\">VS Code language server protocol<\/a>. We also <a href=\"https:\/\/github.com\/Microsoft\/vscode\/issues\/32813\">can\u2019t access a theme\u2019s colors programmatically<\/a>, so this support was even more challenging to make possible. Luckily, we were able to devise a way to overcome these challenges by managing our own set of tokens and their ranges, using <a href=\"https:\/\/code.visualstudio.com\/api\/references\/vscode-api#window.createTextEditorDecorationType\">TextEditorDecorations<\/a>, and directly parsing theme files and VS Code settings to determine which colors to apply. With that, we are excited to share semantic colorization support!<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-24708\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-github-300x96.png\" alt=\"GitHub issue for semantic colorization with 108 upvotes since September 2016\" width=\"719\" height=\"230\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-github-300x96.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-github-768x246.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-github-1024x329.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-github.png 2019w\" sizes=\"(max-width: 719px) 100vw, 719px\" \/><\/p>\n<p>Semantic colorization support provides colorization to tokens even when they are out of context, thus providing colorization beyond that of syntax. For example, if you use a variable name outside of the place in which the variable is declared, you will see colorization:<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-24709\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-example-300x176.png\" alt=\"Box coloring in right side of screenshot where it is outside variable declaration\" width=\"735\" height=\"431\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-example-300x176.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-example-768x451.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-example-1024x601.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/semantic-example.png 1529w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/p>\n<p>In the above example, we see our struct is now colorized when it is defined as \u2018box\u2019 <em>and<\/em> when it is used in our main function.<\/p>\n<h3>Themes<\/h3>\n<p>The colors can be mapped using the existing support for theming and color customization in VS Code. Documentation on Theming in VS Code can be found\u00a0<a href=\"https:\/\/code.visualstudio.com\/docs\/getstarted\/themes\">here<\/a>. Colors are associated with\u00a0<a href=\"https:\/\/macromates.com\/manual\/en\/language_grammars#naming_conventions\">TextMate scopes<\/a>. You can read more about the C\/C++ extension IntelliSense tokens and scopes in our <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/blob\/master\/Documentation\/LanguageServer\/colorization.md#intellisense-tokens-and-scopes\">colorization documentation<\/a>.<\/p>\n<p>Many of the tokens recognized by IntelliSense do not directly map to existing scopes in VS Code&#8217;s default C\/C++ TextMate grammar, so those will not be colored by existing VS Code themes. You can customize your color settings in Visual Studio Code, however. There are two ways in which you can do this \u2013 via global settings or on a per-theme basis. Theme authors can also make use of these scopes when <a href=\"https:\/\/code.visualstudio.com\/api\/extension-guides\/color-theme#create-a-new-color-theme\">creating a new color theme<\/a>.<\/p>\n<h4>Customize Colors in Global Setting<\/h4>\n<p>In your settings.json file you can customize the colors for all themes by overriding the tokenColorCustomizations setting:<\/p>\n<pre class=\"lang:default decode:true\">    \"editor.tokenColorCustomizations\": {\r\n        \"textMateRules\": [\r\n            {\r\n                \"scope\": \"entity.name.type\",\r\n                \"settings\": {\r\n                    \"foreground\": \"#FF0000\",\r\n                    \"fontStyle\": \"italic bold underline\"\r\n                }\r\n            }\r\n        ]\r\n    }<\/pre>\n<h4>Customize Colors for a Theme<\/h4>\n<p>You can also customize colors on a per-theme basis. In this example, we override the Visual Studio Dark theme settings:<\/p>\n<pre class=\"lang:default decode:true \">\"editor.tokenColorCustomizations\": {\r\n        \"[Visual Studio Dark]\": {\r\n            \"textMateRules\": [\r\n                {\r\n                    \"scope\": \"entity.name.type\",\r\n                    \"settings\": {\r\n                        \"foreground\": \"#FF0000\",\r\n                        \"fontStyle\": \"italic bold underline\"\r\n                    }\r\n                }\r\n            ]    \r\n        }<\/pre>\n<p>&nbsp;<\/p>\n<p>We created <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/blob\/master\/Documentation\/LanguageServer\/colorization.md#customizing-colors-in-settings\">templates to customize Visual Studio Dark and Visual Studio Light themes<\/a> in our documentation for easier colorization customization.<\/p>\n<h2>IntelliSense Configuration settings editor UI<\/h2>\n<p>The goal of the settings editor UI is to provide an alternative interface to the c_cpp_properties.json file for configuring IntelliSense for the C\/C++ extension. The interface is simple and clear, and thus makes IntelliSense configuration easier to understand. Based on your feedback, we made a few improvements to the IntelliSense Configuration settings editor UI.<\/p>\n<h3>Select, Edit, and Add Configurations<\/h3>\n<p>There are a variety of reasons you may benefit from multiple IntelliSense configurations. For example, you may be using debug and release builds. In this case, having IntelliSense configured for debugging and release can improve your editing experience when switching between build types. To more easily get started with multiple configurations, we added an option to select the configuration you\u2019d like to work with:<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-24710\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-select-300x80.png\" alt=\"Select a configuration\" width=\"739\" height=\"197\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-select-300x80.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-select-768x204.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-select-1024x273.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-select.png 1345w\" sizes=\"(max-width: 739px) 100vw, 739px\" \/><\/p>\n<p>Further, you can edit the settings of the selected configuration:<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-24712\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-edit-300x114.png\" alt=\"Edit selected configuration\" width=\"737\" height=\"280\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-edit-300x114.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-edit-768x293.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-edit-1024x390.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-edit.png 1375w\" sizes=\"(max-width: 737px) 100vw, 737px\" \/><\/p>\n<p>Finally, you can add configurations via the settings editor UI:<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-24720\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-1-300x52.png\" alt=\"Add a configuration\" width=\"732\" height=\"127\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-1-300x52.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-1-768x133.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-1-1024x178.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-1.png 1331w\" sizes=\"(max-width: 732px) 100vw, 732px\" \/><\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-24721\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-then-select-1-300x107.png\" alt=\"select and edit the newly added configuration\" width=\"735\" height=\"262\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-then-select-1-300x107.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-then-select-1-768x274.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-then-select-1-1024x365.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-add-then-select-1.png 1353w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/p>\n<h3>List of Detected Compiler Paths<\/h3>\n<p>You can also now see a list of detected compiler paths in the UI under the \u201ccompiler path\u201d dropdown text field.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-24715\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-compiler-path-select-300x113.png\" alt=\"Select from compiler path list\" width=\"735\" height=\"277\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-compiler-path-select-300x113.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-compiler-path-select-768x289.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-compiler-path-select-1024x385.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/07\/config-compiler-path-select.png 1387w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/p>\n<p>We hope these improvements to the IntelliSense Configuration settings editor UI will help you more easily configure IntelliSense with the C\/C++ extension.<\/p>\n<h2>IntelliSense Cache<\/h2>\n<p>We introduced IntelliSense Caching in the <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/visual-studio-code-c-c-extension-march-2019-update\/\">C\/C++ extension March 2019 update<\/a>. The purpose of it is to cache header information to improve IntelliSense speed. We received a lot of feedback on the default size for IntelliSense caching via an <a href=\"https:\/\/github.com\/microsoft\/vscode-cpptools\/issues\/3347\">issue filed in our GitHub repo<\/a>. After a productive conversation, we devised a proposal for changes to the default path. We have improved this feature in the July 2019 update.<\/p>\n<h3>The Default Path<\/h3>\n<p>Previously, the default path for the IntelliSense cache was in the \u201c.vscode\u201d folder of the project workspace (${workspaceFolder}\/.vscode). Changing the default path enables us to address concerns of the cache on source control for the workspace folder. Furthermore, since the cache size limit is applied to a cache location, having one location reduces the overall disk space usage of the cache.<\/p>\n<p>Now, the default for the C_Cpp.intelliSenseCachePath setting is \u201c~\/.vscode-cpptools\u201d on Linux and macOS and \u201c%LocalAppData%\/Microsoft\/vscode-cpptools\u201d on Windows.<\/p>\n<p>Note, the extension will automatically remove any caches previously added to the ${workspaceFolder}\/.vscode folder if you were using the old IntelliSense cache path default.<\/p>\n<h2>Tell Us What You Think<\/h2>\n<p><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.cpptools\">Download the C\/C++ extension for Visual Studio Code<\/a>, give it a try, and let us know what you think. If you run into any issues, or have any suggestions, please report them on the <a href=\"https:\/\/github.com\/Microsoft\/vscode-cpptools\/issues\">Issues section of our GitHub repository<\/a>. Set the C_CppProperties.UpdateChannel in your Visual Studio Code settings to \u201cInsiders\u201d to get early builds of our extension.<\/p>\n<p>We can be reached via the comments below or via email (visualcpp@microsoft.com). You can also find our team \u2013 and me \u2013 on Twitter (<a href=\"https:\/\/twitter.com\/visualc\">@VisualC<\/a> or <a href=\"https:\/\/twitter.com\/tara_msft\">@tara_msft<\/a>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The July 2019 update of the Visual Studio Code C\/C++ extension is now available. This release includes many new features, including semantic colorization and improvements to the IntelliSense Configuration Settings Editor UI and IntelliSense cache. For a full list of this release\u2019s improvements, check out our release notes on GitHub. Semantic Colorization Semantic colorization support [&hellip;]<\/p>\n","protected":false},"author":1305,"featured_media":24709,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,230,275],"tags":[8,140,2342,2343,14,284,2261,66,276],"class_list":["post-24706","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","category-new-feature","category-visual-studio-code","tag-announcement","tag-c","tag-colorization","tag-configuration","tag-intellisense","tag-linux","tag-macos","tag-performance","tag-vscode"],"acf":[],"blog_post_summary":"<p>The July 2019 update of the Visual Studio Code C\/C++ extension is now available. This release includes many new features, including semantic colorization and improvements to the IntelliSense Configuration Settings Editor UI and IntelliSense cache. For a full list of this release\u2019s improvements, check out our release notes on GitHub. Semantic Colorization Semantic colorization support [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/24706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/1305"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=24706"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/24706\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/24709"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=24706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=24706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=24706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}