1 module dls.protocol.interfaces.general; 2 3 import dls.protocol.definitions : MarkupKind; 4 import dls.protocol.interfaces.workspace : WorkspaceFolder; 5 import dls.util.constructor : Constructor; 6 import std.json : JSONValue; 7 import std.typecons : Nullable; 8 9 private class WithDynamicRegistration 10 { 11 Nullable!bool dynamicRegistration; 12 } 13 14 class InitializeParams 15 { 16 import dls.protocol.definitions : DocumentUri; 17 import dls.protocol.interfaces.workspace : WorkspaceFolder; 18 19 static enum Trace : string 20 { 21 off = "off", 22 messages = "messages", 23 verbose = "verbose" 24 } 25 26 static class InitializationOptions 27 { 28 static class LSPExtensions 29 { 30 } 31 32 LSPExtensions lspExtensions; 33 34 mixin Constructor!InitializationOptions; 35 } 36 37 Nullable!ulong processId; 38 Nullable!string rootPath; 39 Nullable!DocumentUri rootUri; 40 Nullable!InitializationOptions initializationOptions; 41 ClientCapabilities capabilities; 42 Nullable!Trace trace; 43 Nullable!(WorkspaceFolder[]) workspaceFolders; 44 45 mixin Constructor!InitializeParams; 46 } 47 48 class WorkspaceClientCapabilities 49 { 50 static class WorkspaceEdit 51 { 52 Nullable!bool documentChanges; 53 } 54 55 Nullable!bool applyEdit; 56 Nullable!WorkspaceEdit workspaceEdit; 57 Nullable!WithDynamicRegistration didChangeConfiguration; 58 Nullable!WithDynamicRegistration didChangeWatchedFiles; 59 Nullable!WithDynamicRegistration symbol; 60 Nullable!WithDynamicRegistration executeCommand; 61 Nullable!bool workspaceFolders; 62 Nullable!bool configuration; 63 } 64 65 class TextDocumentClientCapabilities 66 { 67 static class Synchronisation 68 { 69 Nullable!bool dynamicRegistration; 70 Nullable!bool willSave; 71 Nullable!bool willSaveWaitUntil; 72 Nullable!bool didSave; 73 } 74 75 static class Completion 76 { 77 static class CompletionItem 78 { 79 Nullable!bool snippetSupport; 80 Nullable!bool commitCharactersSupport; 81 Nullable!(MarkupKind[]) documentationFormat; 82 Nullable!bool deprecatedSupport; 83 } 84 85 static class CompletionItemKind 86 { 87 import dls.protocol.interfaces.text_document : CompletionItemKind; 88 89 Nullable!(CompletionItemKind[]) valueSet; 90 } 91 92 Nullable!bool dynamicRegistration; 93 Nullable!CompletionItem completionItem; 94 Nullable!CompletionItemKind completionItemKind; 95 Nullable!bool contextSupport; 96 } 97 98 static class Hover : WithDynamicRegistration 99 { 100 Nullable!(MarkupKind[]) contentFormat; 101 } 102 103 static class SignatureHelp : WithDynamicRegistration 104 { 105 static class SignatureInformation 106 { 107 Nullable!(MarkupKind[]) documentationFormat; 108 } 109 110 Nullable!SignatureInformation signatureHelp; 111 } 112 113 static class DocumentSymbol : WithDynamicRegistration 114 { 115 static class SymbolKind 116 { 117 import dls.protocol.interfaces.text_document : SymbolKind; 118 119 Nullable!(SymbolKind[]) valueSet; 120 } 121 122 Nullable!SymbolKind symbolKind; 123 } 124 125 Nullable!Synchronisation synchronisation; 126 Nullable!Completion completion; 127 Nullable!Hover hover; 128 Nullable!SignatureHelp signatureHelp; 129 Nullable!WithDynamicRegistration references; 130 Nullable!WithDynamicRegistration documentHighlight; 131 Nullable!DocumentSymbol documentSymbol; 132 Nullable!WithDynamicRegistration formatting; 133 Nullable!WithDynamicRegistration rangeFormatting; 134 Nullable!WithDynamicRegistration onTypeFormatting; 135 Nullable!WithDynamicRegistration definition; 136 Nullable!WithDynamicRegistration typeDefinition; 137 Nullable!WithDynamicRegistration implementation; 138 Nullable!WithDynamicRegistration codeAction; 139 Nullable!WithDynamicRegistration codeLens; 140 Nullable!WithDynamicRegistration documentLink; 141 Nullable!WithDynamicRegistration colorProvider; 142 Nullable!WithDynamicRegistration rename; 143 } 144 145 class ClientCapabilities 146 { 147 Nullable!WorkspaceClientCapabilities workspace; 148 Nullable!TextDocumentClientCapabilities textDocument; 149 Nullable!JSONValue experimental; 150 } 151 152 class InitializeResult 153 { 154 ServerCapabilities capabilities; 155 156 this(ServerCapabilities capabilities = new ServerCapabilities()) 157 { 158 this.capabilities = capabilities; 159 } 160 } 161 162 class InitializeErrorData 163 { 164 bool retry; 165 } 166 167 enum TextDocumentSyncKind 168 { 169 none = 0, 170 full = 1, 171 incremental = 2 172 } 173 174 private class OptionsBase 175 { 176 Nullable!bool resolveProvider; 177 178 this(Nullable!bool resolveProvider = Nullable!bool.init) 179 { 180 this.resolveProvider = resolveProvider; 181 } 182 } 183 184 class CompletionOptions : OptionsBase 185 { 186 Nullable!(string[]) triggerCharacters; 187 188 this(Nullable!bool resolveProvider = Nullable!bool.init, 189 Nullable!(string[]) triggerCharacters = Nullable!(string[]).init) 190 { 191 super(resolveProvider); 192 this.triggerCharacters = triggerCharacters; 193 } 194 } 195 196 class SignatureHelpOptions 197 { 198 Nullable!(string[]) triggerCharacters; 199 200 this(Nullable!(string[]) triggerCharacters = Nullable!(string[]).init) 201 { 202 this.triggerCharacters = triggerCharacters; 203 } 204 } 205 206 alias CodeLensOptions = OptionsBase; 207 208 class DocumentOnTypeFormattingOptions 209 { 210 string firstTriggerCharacter; 211 Nullable!(string[]) moreTriggerCharacter; 212 213 this(string firstTriggerCharacter = string.init, 214 Nullable!(string[]) moreTriggerCharacter = Nullable!(string[]).init) 215 { 216 this.firstTriggerCharacter = firstTriggerCharacter; 217 this.moreTriggerCharacter = moreTriggerCharacter; 218 } 219 } 220 221 alias DocumentLinkOptions = OptionsBase; 222 223 class ExecuteCommandOptions 224 { 225 string[] commands; 226 227 this(string[] commands = string[].init) 228 { 229 this.commands = commands; 230 } 231 } 232 233 class SaveOptions 234 { 235 Nullable!bool includeText; 236 237 this(Nullable!bool includeText = Nullable!bool.init) 238 { 239 this.includeText = includeText; 240 } 241 } 242 243 class ColorProviderOptions 244 { 245 } 246 247 class TextDocumentSyncOptions 248 { 249 Nullable!bool openClose; 250 Nullable!TextDocumentSyncKind change; 251 Nullable!bool willSave; 252 Nullable!bool willSaveWaitUntil; 253 Nullable!SaveOptions save; 254 255 this(Nullable!bool openClose = Nullable!bool.init, 256 Nullable!TextDocumentSyncKind change = Nullable!TextDocumentSyncKind.init, 257 Nullable!bool willSave = Nullable!bool.init, Nullable!bool willSaveWaitUntil = Nullable!bool.init, 258 Nullable!SaveOptions save = Nullable!SaveOptions.init) 259 { 260 this.openClose = openClose; 261 this.change = change; 262 this.willSave = willSave; 263 this.willSaveWaitUntil = willSaveWaitUntil; 264 this.save = save; 265 } 266 } 267 268 class StaticRegistrationOptions 269 { 270 Nullable!string id; 271 272 this(Nullable!string id = Nullable!string.init) 273 { 274 this.id = id; 275 } 276 } 277 278 class ServerCapabilities 279 { 280 static class Workspace 281 { 282 static class WorkspaceFolders 283 { 284 Nullable!bool supported; 285 Nullable!JSONValue changeNotifications; 286 287 this(Nullable!bool supported = Nullable!bool.init, 288 Nullable!JSONValue changeNotifications = Nullable!JSONValue.init) 289 { 290 this.supported = supported; 291 this.changeNotifications = changeNotifications; 292 } 293 } 294 295 Nullable!WorkspaceFolders workspaceFolders; 296 297 this(Nullable!WorkspaceFolders workspaceFolders = Nullable!WorkspaceFolders.init) 298 { 299 this.workspaceFolders = workspaceFolders; 300 } 301 } 302 303 Nullable!TextDocumentSyncOptions textDocumentSync; // TODO: add TextDocumentSyncKind compatibility 304 Nullable!bool hoverProvider; 305 Nullable!CompletionOptions completionProvider; 306 Nullable!SignatureHelpOptions signatureHelpProvider; 307 Nullable!bool definitionProvider; 308 Nullable!JSONValue typeDefinitionProvider; 309 Nullable!JSONValue implementationProvider; 310 Nullable!bool referencesProvider; 311 Nullable!bool documentHighlightProvider; 312 Nullable!bool documentSymbolProvider; 313 Nullable!bool workspaceSymbolProvider; 314 Nullable!bool codeActionProvider; 315 Nullable!CodeLensOptions codeLensProvider; 316 Nullable!bool documentFormattingProvider; 317 Nullable!bool documentRangeFormattingProvider; 318 Nullable!DocumentOnTypeFormattingOptions documentOnTypeFormattingProvider; 319 Nullable!bool renameProvider; 320 Nullable!DocumentLinkOptions documentLinkProvider; 321 Nullable!JSONValue colorProvider; 322 Nullable!ExecuteCommandOptions executeCommandProvider; 323 Nullable!Workspace workspace; 324 Nullable!JSONValue experimental; 325 } 326 327 class CancelParams 328 { 329 JSONValue id; 330 }