Lost intellisense and squiggles

Viewed 147

For some reason, all my new projects created using dotnet no longer have intellisense or squiggles. However, if I open an old project, those still have intellisense and squiggles.

How do I get intellisense and squiggles in my new projects?

Using C# in VSC on Linux (Ubuntu 20.04).


VERSIONS

Visual Studio Code 1.60.0 C# for Cisual Studio Code (powered by OmniSharp) 1.23.15

dotnet --list-sdks 5.0.400 [/usr/share/dotnet/sdk]

dotnet --list-runtimes Microsoft.AspNetCore.App 5.0.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]


COMMAND USED

dotnet new console -o project_name

1 Answers

If you have a workspace and for some reason have multiple folders you may need to 'help' omnisharp a bit. I initially had a big project and added a solution for it further on - ending up with TWO workspace folders (one to a startup project and one to the solution). After composing that setup I experienced only the first project to have intellisense working.

Solution to get intellisense working was to make sure omnisharp worked its way from the solution instead of the project:

  1. Ctrl + Shift + p
  2. Write "OmniSharp: Select Project" and press Enter.
  3. Choose the solution workspace entry.

Inspiration gotten from 'swaner': https://github.com/OmniSharp/omnisharp-vscode/issues/1889

You can customize your IntelliSense experience in settings and key bindings.

The settings shown below are the default settings. You can change these settings in your settings.json file.

{
// Controls if quick suggestions should show up while typing
"editor.quickSuggestions": {
    "other": true,
    "comments": false,
    "strings": false
},

 // Controls whether suggestions should be accepted on commit characters. For example, in JavaScript, the semi-colon (`;`) can be a commit character that accepts a suggestion and types that character.
"editor.acceptSuggestionOnCommitCharacter": true,

// Controls if suggestions should be accepted on 'Enter' - in addition to 'Tab'. Helps to avoid ambiguity between inserting new lines or accepting suggestions. The value 'smart' means only accept a suggestion with Enter when it makes a textual change
"editor.acceptSuggestionOnEnter": "on",

// Controls the delay in ms after which quick suggestions will show up.
"editor.quickSuggestionsDelay": 10,

// Controls if suggestions should automatically show up when typing trigger characters
"editor.suggestOnTriggerCharacters": true,

// Controls if pressing tab inserts the best suggestion and if tab cycles through other suggestions
"editor.tabCompletion": "off",

// Controls whether sorting favours words that appear close to the cursor
"editor.suggest.localityBonus": true,

// Controls how suggestions are pre-selected when showing the suggest list
"editor.suggestSelection": "recentlyUsed",

// Enable word based suggestions
"editor.wordBasedSuggestions": true,

// Enable parameter hints
"editor.parameterHints.enabled": true,
}

Check that this two settings set correctly:

"editor.quickSuggestions": true,
"editor.suggestOnTriggerCharacters": true
Related