Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a VSCode theme recognize C# interfaces?

I am trying to get a theme for Visual Studio Code working to what I want. Currently, I'm trying to use Obsidian working with C# rules, but I'm not sure which key word to use to override color customizations. VSCode does not seem to recognize interfaces as they're language specific.

"editor.tokenColorCustomizations": {
        "functions" :{
            "foreground": "#F1F2F3"
        },
        "interface": { //not valid
            "foreground": "#B48C8C"
        } 
    }

How can I get VSCode color customizations to recognize c# specific syntaxes?

like image 548
Premier Bromanov Avatar asked Nov 13 '17 20:11

Premier Bromanov


People also ask

How do I get C to work on VS Code?

1. We need to click on the extension button that displays a sidebar for downloading and installing the C/C++ extension in the visual studio code. In the sidebar, type C Extension. In this image, click on the Install button to install the C/C++ extension.

Can I compile C in Visual Studio?

The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.

How does Visual Studio choose language for code?

Press Ctrl+Shift+P to bring up the Command Palette then start typing "display" to filter and display the Configure Display Language command. Press Enter and a list of installed languages by locale is displayed, with the current locale highlighted.

How do I change the compiler path in VS Code?

In the Windows search bar, type 'settings' to open your Windows Settings. Search for Edit environment variables for your account. Choose the Path variable in your User variables and then select Edit. Select New and add the Mingw-w64 destination folder path to the system path.


1 Answers

editor.tokenColorCustomizations can use a number of values: comments, functions, keywords, numbers, strings, types and variables. If none of those work for you textMateRules is available as well. So you can do something like:

"editor.tokenColorCustomizations": {
    "textMateRules": [{
        "scope": "yourScopeHere",
        "settings": {
            "fontStyle": "italic",
            "foreground": "#C69650"
        }
    }]
   },

So you just have to figure out what scope you need for "interface".

For that, try CTRL-Shift-P and type scope: choose

Developer: Inspect Editor Tokens and Scopes  

and for whichever keyword is selected, like interface you will get a listing of its textmate scope. That should be inserted as the scope value above. [In my experience, it is more accurate to open the "Inspect TM Scopes" panel and then click a couple of items and then the one, like interface, that you want - the scope panel will remain open.] You can copy from the scopes panel.

You may need only the main scope listed, but if need to narrow its scope you can include the others listed in a comma-separated list in the scopes: ..., ..., ...

like image 134
Mark Avatar answered Oct 12 '22 12:10

Mark