Language Server (LSP) not called for language features when used along with a Language Service

Sajith 11 Reputation points
2024-11-26T16:43:42.9933333+00:00

We have a Visual Studio extension that implements a custom code editor and a legacy Language Service.

  • Code editor is opened using IVSUIShell.CreateDocumentWindow.
  • Language Service is associated with this editor using Microsoft.VisualStudio.Editor.Implementation.TextDocData.SetLanguageServiceID

We also have a Language Server (LSP) implementation, that we are trying to use from this editor.

We have implemented a Language Client as in - https://learn.microsoft.com/en-us/visualstudio/extensibility/adding-an-lsp-extension?view=vs-2022

With this, only a few LSP messages are reaching the Language Server like - textDocument/didOpen, textDocument/didClose etc.

IntelliSense notifications like - textDocument/completion, textDocument/hover etc are not reaching the Language Server.

  • Microsoft.VisualStudio.Package.LanguageService.GetLanguagePreferences() is overridden in my Language Service implementation and returns false for IntelliSense properties.
  • Server capabilities returned from LSP - 'initialize' request correctly sets the IntelliSense features it supports.

This works correctly when the Language Server (LSP) is used with a local file (with the specified extension) - 'textDocument/completion' notification is received in LSP.

But when used with a code editor opened and a language service attached as described above, 'textDocument/completion' notification is not received in LSP server.

Any pointers on what could be the issue here will be greatly helpful.

Visual Studio Extensions
Visual Studio Extensions
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Extensions: A program or program module that adds functionality to or extends the effectiveness of a program.
235 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.