private void InitializeRazorLSPTextBuffer(ITextBuffer textBuffer) { if (_lspEditorFeatureDetector.IsRemoteClient()) { // We purposefully do not set ClientName's in remote client scenarios because we don't want to boot 2 langauge servers (one for both host and client). // The ClientName controls whether or not an ILanguageClient instantiates. // We still change the content type for remote scenarios in order to enable our TextMate grammar to light up the Razor editor properly. textBuffer.ChangeContentType(_razorLSPContentType, editTag: null); } else { // ClientName controls if the LSP infrastructure in VS will boot when it detects our Razor LSP contennt type. If the property exists then it will; otherwise // the text buffer will be ignored by the LSP textBuffer.Properties.AddProperty(LanguageClientConstants.ClientNamePropertyKey, RazorLanguageServerClient.ClientName); // Initialize the buffer with editor options. InitializeOptions(textBuffer); textBuffer.ChangeContentType(_razorLSPContentType, editTag: null); // Must track the document after changing the content type so any LSPDocuments created understand they're being created for a Razor LSP document. _lspDocumentManager.TrackDocument(textBuffer); } }
private void InitializeRazorLSPTextBuffer(string filePath, ITextBuffer textBuffer) { if (_lspEditorFeatureDetector.IsRemoteClient()) { // We purposefully do not set ClientName's in remote client scenarios because we don't want to boot 2 langauge servers (one for both host and client). // The ClientName controls whether or not an ILanguageClient instantiates. // We still change the content type for remote scenarios in order to enable our TextMate grammar to light up the Razor editor properly. textBuffer.ChangeContentType(_razorLSPContentType, editTag: null); // Initialize the buffer with editor options. // Temporary: Ideally in remote scenarios, we should be using host's settings. // But we need this until that support is built. InitializeOptions(textBuffer); // Temporary: The guest needs to react to the host manually applying edits and moving the cursor. // This can be removed once the client starts supporting snippets. textBuffer.Properties.AddProperty(FilePathPropertyKey, filePath); textBuffer.ChangedHighPriority += RazorGuestBuffer_Changed; } else { // ClientName controls if the LSP infrastructure in VS will boot when it detects our Razor LSP contennt type. If the property exists then it will; otherwise // the text buffer will be ignored by the LSP textBuffer.Properties.AddProperty(LanguageClientConstants.ClientNamePropertyKey, RazorLanguageServerClient.ClientName); // Initialize the buffer with editor options. InitializeOptions(textBuffer); textBuffer.ChangeContentType(_razorLSPContentType, editTag: null); // Must track the document after changing the content type so any LSPDocuments created understand they're being created for a Razor LSP document. _lspDocumentManager.TrackDocument(textBuffer); } }
// Internal for testing internal void RazorBufferCreated(ITextBuffer textBuffer) { if (textBuffer is null) { throw new ArgumentNullException(nameof(textBuffer)); } // Initialize the buffer with editor options. // Temporary: Ideally in remote scenarios, we should be using host's settings. // But we need this until that support is built. InitializeOptions(textBuffer); if (!_lspEditorFeatureDetector.IsRemoteClient()) { // Renames on open files don't dispose buffer state so we need to separately monitor the buffer for document renames to ensure // we can tell the lsp document manager when state changes. MonitorDocumentForRenames(textBuffer); // Only need to track documents on a host because we don't do any extra work on remote clients. _lspDocumentManager.TrackDocument(textBuffer); } }
// Internal for testing internal void RazorBufferCreated(ITextBuffer textBuffer) { if (textBuffer is null) { throw new ArgumentNullException(nameof(textBuffer)); } if (!_lspEditorFeatureDetector.IsRemoteClient()) { // Renames on open files don't dispose buffer state so we need to separately monitor the buffer for document renames to ensure // we can tell the lsp document manager when state changes. MonitorDocumentForRenames(textBuffer); // Only need to track documents on a host because we don't do any extra work on remote clients. _lspDocumentManager.TrackDocument(textBuffer); } }
// Internal for testing internal void RazorBufferCreated(ITextBuffer textBuffer) { if (textBuffer is null) { throw new ArgumentNullException(nameof(textBuffer)); } // Initialize the buffer with editor options. // Temporary: Ideally in remote scenarios, we should be using host's settings. // But we need this until that support is built. InitializeOptions(textBuffer); if (!_lspEditorFeatureDetector.IsRemoteClient()) { // Only need to track documents on a host because we don't do any extra work on remote clients. _lspDocumentManager.TrackDocument(textBuffer); } }