Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1831,8 +1831,12 @@
"engines": {
"vscode": "^0.10.0"
},
"extensionPack": [
"ms-dotnettools.csharp",
"anysphere.csharp",
"muhammad-sammy.csharp"
],
"extensionDependencies": [
"ms-dotnettools.csharp"
],
"homepage": "http://ionide.io",
"icon": "images/logo.png",
Expand Down
30 changes: 29 additions & 1 deletion src/fsharp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ open Node.ChildProcess
let private logger =
ConsoleAndOutputChannelLogger(Some "Main", Level.DEBUG, Some defaultOutputChannel, Some Level.DEBUG)

let private requiredExtensions =
[ "ms-dotnettools.csharp" // VSCode C# extension
"anysphere.csharp" // Cursor C# extension
"muhammad-sammy.csharp" ] // Free/Libre C# extension

let private checkCSharpExtension () =
requiredExtensions
|> List.exists (fun extId -> extensions.getExtension extId |> Option.isSome)

type Api =
{ ProjectLoadedEvent: Event<DTO.Project>
BuildProject: DTO.Project -> JS.Promise<string>
Expand All @@ -33,7 +42,7 @@ let private activateLanguageServiceRestart (context: ExtensionContext) =
commands.registerCommand ("fsharp.restartLanguageService", restart |> objfy2)
|> context.Subscribe

let activate (context: ExtensionContext) : JS.Promise<Api> =
let private doActivate (context: ExtensionContext) : JS.Promise<Api> =
let solutionExplorer = "FSharp.enableTreeView" |> Configuration.get true

let showExplorer = "FSharp.showExplorerOnStartup" |> Configuration.get false
Expand Down Expand Up @@ -140,5 +149,24 @@ let activate (context: ExtensionContext) : JS.Promise<Api> =
logger.Error $"Error activating features: %A{e}"
Unchecked.defaultof<_>)

let activate (context: ExtensionContext) : JS.Promise<Api> =
// Check for C# extension at runtime
if not (checkCSharpExtension ()) then
let extensionList =
requiredExtensions
|> List.rev
|> function
| [] -> ""
| [ x ] -> x
| last :: rest ->
let restStr = rest |> List.rev |> String.concat ", "
$"{restStr} or {last}"

window.showErrorMessage ($"Ionide requires one of the following C# extensions to be installed: {extensionList}")
|> Promise.ofThenable
|> Promise.map (fun _ -> Unchecked.defaultof<_>)
else
doActivate context


let deactivate (disposables: Disposable[]) = LanguageService.stop ()