public ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities) { var capabilities = new ServerCapabilities(); if (clientCapabilities is VSClientCapabilities vsClientCapabilities && vsClientCapabilities.SupportsVisualStudioExtensions) { capabilities = GetVSServerCapabilities(); } var commitCharacters = CompletionRules.Default.DefaultCommitCharacters.Select(c => c.ToString()).ToArray(); var triggerCharacters = _completionProviders.SelectMany( lz => CompletionHandler.GetTriggerCharacters(lz.Value)).Distinct().Select(c => c.ToString()).ToArray(); capabilities.DefinitionProvider = true; capabilities.RenameProvider = true; capabilities.ImplementationProvider = true; capabilities.CodeActionProvider = new CodeActionOptions { CodeActionKinds = new[] { CodeActionKind.QuickFix, CodeActionKind.Refactor } }; capabilities.CompletionProvider = new VisualStudio.LanguageServer.Protocol.CompletionOptions { ResolveProvider = true, AllCommitCharacters = commitCharacters, TriggerCharacters = triggerCharacters, }; capabilities.SignatureHelpProvider = new SignatureHelpOptions { TriggerCharacters = new[] { "(", "," } }; capabilities.DocumentSymbolProvider = true; capabilities.WorkspaceSymbolProvider = true; capabilities.DocumentFormattingProvider = true; capabilities.DocumentRangeFormattingProvider = true; capabilities.DocumentOnTypeFormattingProvider = new DocumentOnTypeFormattingOptions { FirstTriggerCharacter = "}", MoreTriggerCharacter = new[] { ";", "\n" } }; capabilities.ReferencesProvider = true; capabilities.FoldingRangeProvider = true; capabilities.ExecuteCommandProvider = new ExecuteCommandOptions(); capabilities.TextDocumentSync = new TextDocumentSyncOptions { Change = TextDocumentSyncKind.Incremental, OpenClose = true }; capabilities.HoverProvider = true; return(capabilities); }
public VSServerCapabilities GetCapabilities() { var commitCharacters = CompletionRules.Default.DefaultCommitCharacters.Select(c => c.ToString()).ToArray(); var triggerCharacters = _completionProviders.SelectMany( lz => CompletionHandler.GetTriggerCharacters(lz.Value)).Distinct().Select(c => c.ToString()).ToArray(); return(new VSServerCapabilities { DefinitionProvider = true, RenameProvider = true, ImplementationProvider = true, CodeActionProvider = new CodeActionOptions { CodeActionKinds = new[] { CodeActionKind.QuickFix, CodeActionKind.Refactor } }, CodeActionsResolveProvider = true, CompletionProvider = new LanguageServer.Protocol.CompletionOptions { ResolveProvider = true, AllCommitCharacters = commitCharacters, TriggerCharacters = triggerCharacters }, SignatureHelpProvider = new SignatureHelpOptions { TriggerCharacters = new[] { "(", "," } }, DocumentSymbolProvider = true, WorkspaceSymbolProvider = true, DocumentFormattingProvider = true, DocumentRangeFormattingProvider = true, DocumentOnTypeFormattingProvider = new DocumentOnTypeFormattingOptions { FirstTriggerCharacter = "}", MoreTriggerCharacter = new[] { ";", "\n" } }, OnAutoInsertProvider = new DocumentOnAutoInsertOptions { TriggerCharacters = new[] { "'", "/", "\n" } }, DocumentHighlightProvider = true, ReferencesProvider = true, ProjectContextProvider = true, SemanticTokensOptions = new SemanticTokensOptions { DocumentProvider = new SemanticTokensDocumentProviderOptions { Edits = true }, RangeProvider = true, Legend = new SemanticTokensLegend { TokenTypes = SemanticTokenTypes.AllTypes.Concat(SemanticTokensHelpers.RoslynCustomTokenTypes).ToArray(), TokenModifiers = new string[] { SemanticTokenModifiers.Static } } }, ExecuteCommandProvider = new ExecuteCommandOptions(), TextDocumentSync = new TextDocumentSyncOptions { Change = TextDocumentSyncKind.Incremental, OpenClose = true }, // Always support hover - if any LSP client for a content type advertises support, // then the liveshare provider is disabled. So we must provide for both C# and razor // until https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1106064/ is fixed // or we have different content types. HoverProvider = true, // Diagnostic requests are only supported from PullDiagnosticsInProcLanguageClient. SupportsDiagnosticRequests = false, }); }