Skip to content
Closed
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
10 changes: 8 additions & 2 deletions Sources/SKOptions/SourceKitLSPOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
return .seconds(300)
}

/// Enable or disable registering inlay hints for the inlayHintProvider
public var enableInlayHints: Bool? = nil

public init(
swiftPM: SwiftPMOptions? = .init(),
fallbackBuildSystem: FallbackBuildSystemOptions? = .init(),
Expand All @@ -451,7 +454,8 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
swiftPublishDiagnosticsDebounceDuration: Double? = nil,
workDoneProgressDebounceDuration: Double? = nil,
sourcekitdRequestTimeout: Double? = nil,
semanticServiceRestartTimeout: Double? = nil
semanticServiceRestartTimeout: Double? = nil,
enableInlayHints: Bool? = nil
) {
self.swiftPM = swiftPM
self.fallbackBuildSystem = fallbackBuildSystem
Expand All @@ -471,6 +475,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
self.workDoneProgressDebounceDuration = workDoneProgressDebounceDuration
self.sourcekitdRequestTimeout = sourcekitdRequestTimeout
self.semanticServiceRestartTimeout = semanticServiceRestartTimeout
self.enableInlayHints = enableInlayHints
}

public init?(fromLSPAny lspAny: LSPAny?) throws {
Expand Down Expand Up @@ -531,7 +536,8 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
workDoneProgressDebounceDuration: override?.workDoneProgressDebounceDuration
?? base.workDoneProgressDebounceDuration,
sourcekitdRequestTimeout: override?.sourcekitdRequestTimeout ?? base.sourcekitdRequestTimeout,
semanticServiceRestartTimeout: override?.semanticServiceRestartTimeout ?? base.semanticServiceRestartTimeout
semanticServiceRestartTimeout: override?.semanticServiceRestartTimeout ?? base.semanticServiceRestartTimeout,
enableInlayHints: base.enableInlayHints
)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceKitLSP/SourceKitLSPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ extension SourceKitLSPServer {
if let semanticTokensOptions = server.semanticTokensProvider {
await registry.registerSemanticTokensIfNeeded(options: semanticTokensOptions, for: languages, server: self)
}
if let inlayHintProvider = server.inlayHintProvider, inlayHintProvider.isSupported {
if let inlayHintProvider = server.inlayHintProvider, inlayHintProvider.isSupported, options.enableInlayHints ?? true {
let options: InlayHintOptions
switch inlayHintProvider {
case .bool(true):
Expand Down
11 changes: 10 additions & 1 deletion Sources/sourcekit-lsp/SourceKitLSP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ struct SourceKitLSP: AsyncParsableCommand {
)
var experimentalFeatures: [String] = []

@Option(
name: .customLong("enable-inlay-hints"),
help: """
Enable or disable inlay hint responses
"""
)
var enableInlayHints: Bool = true

/// Maps The options passed on the command line to a `SourceKitLSPOptions` struct.
func commandLineOptions() -> SourceKitLSPOptions {
return SourceKitLSPOptions(
Expand Down Expand Up @@ -170,7 +178,8 @@ struct SourceKitLSP: AsyncParsableCommand {
defaultWorkspaceType: defaultWorkspaceType,
generatedFilesPath: generatedFilesPath,
backgroundIndexing: experimentalFeatures.contains("background-indexing"),
experimentalFeatures: Set(experimentalFeatures.compactMap(ExperimentalFeature.init))
experimentalFeatures: Set(experimentalFeatures.compactMap(ExperimentalFeature.init)),
enableInlayHints: enableInlayHints
)
}

Expand Down