Files
nexus/wiki/concepts/LSP-Language-Server-Protocol.md
2026-04-21 00:02:55 +08:00

33 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "LSP (Language Server Protocol)"
type: concept
tags: [protocol, code-intelligence, editor]
last_updated: 2026-04-20
---
## Definition
Language Server ProtocolLSP是微软提出的标准化协议为编辑器/IDE 提供编程语言特性支持(自动补全、跳转定义、悬停文档等),实现语言功能与编辑器的解耦。
## Core Features
- **文本文档同步**textDocument/didOpen、textDocument/didChange
- **代码导航**textDocument/definition、textDocument/references、textDocument/documentSymbol
- **代码补全**textDocument/completion
- **悬停文档**textDocument/hover
- **诊断信息**textDocument/publishDiagnostics
## LSP 3.17 Key Capabilities
- 能力协商机制initialize 阶段交换 serverCapabilities
- 完整生命周期管理initialize → initialized → shutdown → exit
- Workspace symbols 和 文件 URI 标准化
## Language Servers
- TypeScript: typescript-language-server
- PHP: intelephense, phpactor
- Go: gopls
- Rust: rust-analyzer
- Python: pyright, pylance
## Connections
- [[graphd]] ← 依赖使用 ← [[LSP (Language Server Protocol)]]
- [[LSP Client Orchestration]] ← 基于 ← [[LSP (Language Server Protocol)]]