Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@volar/test-utils

Package Overview
Dependencies
Maintainers
0
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/test-utils

  • 2.4.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28K
increased by2.3%
Maintainers
0
Weekly downloads
 
Created
Source

@volar/test-utils

This module provides a simple way to start a language server and interact with it. It exports a function startLanguageServer which starts a language server and returns a handle to interact with it.

Usage

First, import the module and start the language server:

import { startLanguageServer } from '@volar/test-utils';

const serverHandle = startLanguageServer('path/to/server/module');

The startLanguageServer function takes the path to the server module as a string and optionally a current working directory as a string or URL.

The returned server handle provides several methods to interact with the language server:

  • initialize(rootUri: string, initializationOptions: InitializationOptions): Initializes the language server.
  • openTextDocument(fileName: string, languageId: string): Opens a text document.
  • openUntitledDocument(languageId: string, content: string): Opens an untitled text document.
  • closeTextDocument(uri: string): Closes a text document.
  • Various send*Request methods: Send language-related requests to the server.

For example, to open a text document and send a completion request:

await serverHandle.initialize('file:///path/to/workspace', {});
const document = await serverHandle.openTextDocument('path/to/file', 'typescript');
const completions = await serverHandle.sendCompletionRequest(document.uri, { line: 0, character: 0 });

FAQs

Package last updated on 14 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc