搜索插件、代码仓与 APP 分类

插件详情v0.4.0

lsp_server_ce

Dart 语言的 Language Server Protocol 实现。此包可用于实现支持 Language Server Protocol 的服务器。

AndroidiOSLinuxmacOSWebWindows
近 30 天下载
6.4万
喜欢数
0
Pub 分数
130

安装插件

flutter pub add lsp_server_ce

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Dart 实现的 Language Server Protocol (LSP),使开发者能够构建语言服务器,为编辑器和 IDE 提供代码补全、诊断和重构等功能。该包支持所有主要平台,并可无缝集成到 Flutter 项目中。专为希望使用 LSP 标准扩展文本编辑器语言功能的工具作者设计。

适合场景

  • 为 Dart 或其他语言构建自定义语言服务器
  • 将高级代码智能集成到IDE中
  • 启用实时语法检查和建议
  • 使用丰富的语言功能创建编辑器扩展
  • 支持多平台开发工作流

主要特点

  • 完整的 LSP 规范兼容性
  • 跨平台支持(Android、iOS、Linux、macOS、Web、Windows)
  • 轻松集成到Flutter应用
  • 模块化设计,用于可扩展的语言服务器逻辑
  • 内置对 LSP 消息和通信协议的支持

适合对象

  • Dart 工具开发人员
  • IDE 插件创建者
  • 语言特性实现者
  • 代码分析工具构建者
  • 多平台开发团队

使用建议

  • 需要了解语言服务器协议
  • 可能需要额外设置以支持复杂的语言特性
  • 最适合熟悉服务器-客户端通信模式的开发者
  • 不直接用于终端用户应用程序
  • 依赖于编辑器兼容性的正确配置

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

LSP Server

This is a dart implementation of the Language Server Protocol and comes with all serializable objects defined in the specification (v3.17).

The interface also contains the event methods for Document synchronization as well as the Language Features.

Features

  • Life cycle methods

  • Language features

  • Generic registration of listeners for events and methods.

  • Generic methods to send events and requests

Getting started

To get a better understanding of how this work it can be useful to look at the official documentation and the similar implementations in node.

Full LSP spec definition.

LSP Guide for vscode.

LSP Example for vscode.

Usage

You can use any stream you want, stdio is commonly used and is easy to set up.

void main() async {
  // Create a connection that can read and write data to the LSP client.
  // Supply a readable and writable stream. In this case we are using stdio.
  // But you could use a socket connection or any other stream.
  var connection = Connection(stdin, stdout);

  // Register a listener for when the client initialzes the server.
  // You are suppose to respond with the capabilities of the server.
  // Some capabilities must be enabled by the client, you can see what the client
  // supports by inspecting the ClientCapabilities object, inside InitializeParams.
  connection.onInitialize((params) async {
    return InitializeResult(
      capabilities: ServerCapabilities(
        // In this example we are using the Full sync mode. This means the
        // entire document is sent in each change notification.
        textDocumentSync: const Either2.t1(TextDocumentSyncKind.Full),
      ),
    );
  });
}

Additional information

Who should use this? If you want to build a plugin for an editor that supports the LSP format, and you want to build the server in Dart, then this is the package for you. With this package you can implement features such as "linting", "go to reference", giving contextual information and more.

Todo

Implement the missing features from the protocol:

  • workspaces
  • window
  • notebook
  • client (dynamic capabilities)
  • trace

所属分类

依赖

依赖清单 8 项

源码仓库

使用此插件的项目

暂无相关数据。

所在榜单