Skip to content

Add a low-level LanguageServer.send example to the README - #172

Open
Puliuvarthi.Mahesh (MaheshPulivarthi18) wants to merge 1 commit into
microsoft:mainfrom
MaheshPulivarthi18:nightshift/89-add-a-more-low-level-languageserver-send
Open

Puliuvarthi.Mahesh (MaheshPulivarthi18) wants to merge 1 commit into
microsoft:mainfrom
MaheshPulivarthi18:nightshift/89-add-a-more-low-level-languageserver-send

Conversation

@MaheshPulivarthi18

Copy link
Copy Markdown

Closes #89.

SyncLanguageServer only wraps a few LSP requests, and the docs did not show how to issue any other request. This adds a short README section showing how to call lsp.language_server.server.send.<method> from synchronous code.

The example:

  • Builds the file URI from an absolute repository root and a relative file path.
  • Opens the file with open_file before sending the request.
  • Submits the coroutine to the server's event loop with asyncio.run_coroutine_threadsafe(..., lsp.loop) and waits with lsp.timeout.
  • Uses definition and declaration as the sample requests, through one shared helper rather than two copies.

The section also notes that send results are raw LSP JSON values rather than multilspy types, and that the exact result depends on the language server.

The example in the issue called send.declaration in both its definition and declaration functions; here definition and declaration are each called by name.

For reviewers: this is a docs-only change. The code sample has not been run against a live language server as part of this PR.

Documentation-only change (README.md).

Existing suites:

  • find tests/multilspy -ipath '*python*' -name 'test_*.py' | xargs .venv/bin/pytest -q --tb=short -p no:cacheprovider: passed

Show how to send LSP requests that SyncLanguageServer does not wrap by
calling language_server.server.send from the server's event loop.
Closes microsoft#89.

Generated by NightShift

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a more low-level LanguageServer.send example to the documentation

1 participant