I can't get Vscode to syntax-highlight or complete any C/C++ code.
I create a folder, opened it using code /path/to/my/folder
, have an empty CPP file. I'm trying exactly what the docs say, line by line. I've even pasted the exact code from the docs yet it's recognized as "Plain Text" and no completion nor coloring work:
Above is what my Vscode environment looks like, whereas Microsoft's documentation has nicely syntax highlighted, code-completing C/C++ file with the exact same steps that I did. In my instance, I don't even see C or C++ in list of languages to pick from and it is recognized as "Plain Text".
Here is my settings.json
:
{
"workbench.startupEditor": "newUntitledFile",
"explorer.confirmDelete": false,
"workbench.colorTheme": "Monokai",
"editor.codeLens": false,
"git.autofetch": true,
"git.enableSmartCommit": true,
"explorer.confirmDragAndDrop": false,
"git.confirmSync": false,
"window.title": "${activeFolderShort}/${activeEditorShort} (${activeFolderLong})",
"debug.console.fontSize": 10,
"keyboard.dispatch": "keyCode",
"editor.tabCompletion": "on",
"prettier.tabWidth": 4,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.fastScrollSensitivity": 3,
"typescript.tsserver.trace": "verbose",
"C_Cpp.intelliSenseEngine": "default",
"editor.tokenColorCustomizations": {
"[Monokai]": {
"keywords": "#ff4a5f",
"functions": "#99ff88",
"comments": "#80a090",
"textMateRules": [
{
"scope": "keyword.operator",
"settings": {
"foreground": "#ffaa66"
}
},
{
"scope": "entity.name.tag",
"settings": {
"foreground": "#ff3377",
"fontStyle": "bold"
}
},
{
"scope": "entity.other.attribute-name",
"settings": {
"foreground": "#44e855",
}
}
]
}
},
"workbench.colorCustomizations":{
"[Monokai]": {
"editorIndentGuide.background1": "#383838",
"editor.background": "#20201e",
"statusBar.background" : "#1A1A1A",
"statusBar.noFolderBackground" : "#212121",
"statusBar.debuggingBackground": "#263238",
},
},
"task.slowProviderWarning": [
"typescript"
],
"update.mode": "manual",
"typescript.updateImportsOnFileMove.enabled": "never",
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.maxTokenizationLineLength": 1000,
"terminal.integrated.fontSize": 9,
"editor.fontSize": 8,
"editor.minimap.renderCharacters": false,
"editor.minimap.maxColumn": 80,
"editor.minimap.enabled": false,
"editor.gotoLocation.multipleDefinitions": "goto",
"editor.gotoLocation.multipleDeclarations": "goto",
"editor.gotoLocation.multipleImplementations": "goto",
"editor.gotoLocation.multipleReferences": "goto",
"editor.gotoLocation.multipleTypeDefinitions": "goto",
"apc.activityBar": {
"size": 42,
"itemMargin": 2
},
"apc.sidebar.titlebar": {
"fontSize": 10
},
"apc.header": {
"fontSize": 10,
"height": 24,
},
"apc.stylesheet": {
".explorer-viewlet .mac": "font-size: 11px",
".debug-viewlet .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench .debug-hover-widget .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench .debug-viewlet .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench .debug-hover-widget .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench.mac .debug-viewlet .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench.mac .debug-hover-widget .monaco-list-row .expression":
"font-size: 10px !important",
".part.editor>.content .editor-group-container>.title .tabs-container>.tab, .tabs-and-actions-container": "height: 28px !important",
".monaco-icon-label": "font-size: 8pt",
".monaco-editor, .monaco-editor-background, .monaco-editor .inputarea.ime-input": "background-color: #1c1e1c"
},
"apc.listRow": {
"height": 18
},
"customizeUI.fontSizeMap": {
"window-title": "10px", // Window title font when using custom titlebar
"tab-title": "11px", // Used for editor tab titles
},
"customizeUI.listRowHeight": 18,
"customizeUI.stylesheet": {
".explorer-viewlet .mac": "font-size: 11px",
".debug-viewlet .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench .debug-hover-widget .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench .debug-viewlet .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench .debug-hover-widget .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench.mac .debug-viewlet .monaco-list-row .expression, body.row-height-lte20 .monaco-workbench.mac .debug-hover-widget .monaco-list-row .expression":
"font-size: 10px !important",
".part.editor>.content .editor-group-container>.title .tabs-container>.tab, .tabs-and-actions-container": "height: 28px !important",
".monaco-icon-label": "font-size: 8pt",
".monaco-editor, .monaco-editor-background, .monaco-editor .inputarea.ime-input": "background-color: #1c1e1c"
},
"emmet.showExpandedAbbreviation": "never",
"terminal.integrated.lineHeight": 0.8,
"color-highlight.languages": [
"*"
],
"editor.detectIndentation": false,
"debug.javascript.suggestPrettyPrinting": false,
"workbench.editor.decorations.badges": false,
"explorer.decorations.badges": false,
"react-native-tools.showUserTips": false,
"editor.accessibilitySupport": "off",
"react-native-tools.networkInspector.consoleLogsColorTheme": "Dark",
"debug.console.wordWrap": false,
"workbench.layoutControl.enabled": false,
"editor.unicodeHighlight.allowedCharacters": {
"‘": true,
"’": true
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"solidity.validationDelay": 500,
"debug.allowBreakpointsEverywhere": true,
"workbench.settings.enableNaturalLanguageSearch": false,
"explorer.compactFolders": false,
"window.restoreWindows": "all",
"editor.unicodeHighlight.includeStrings": false,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"terminal.explorerKind": "external",
"[css]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"files.associations": {
"*.css": "tailwindcss"
},
"eslint.runtime": "node",
"eslint.format.enable": true,
"workbench.editor.empty.hint": "hidden",
"git.openRepositoryInParentFolders": "always",
"solidity.telemetry": false,
"cmake.showOptionsMovedNotification": false
}
Please note that C_Cpp.intelliSenseEngine
setting wasn't there and it still wasn't working, I've added while trying to find a solution but it doesn't seem to make a difference.
I've also tried disabling all the extensions except C/C++ (and, in another instance, in addition to C/C++ also C/C++ Extension Pack) and restarting Vscode, but nothing changed.
What am I doing wrong?
I solved the problem by removing my ~/Library/Application Support/Code
and ~/.vscode/extensions
directories (I first tried the latter alone but didn't work, then I also removed the former). I don't know what was causing the issue, but I backed up my settings.json
from there, deleted everything, restarted Vscode, put settings.json
back, restarted Vscode, installed C/C++ extension (as all extensions also got deleted), and the issue got fixed. I can now see C++ in the language list and IntelliSense works perfectly.