Files
nexus/wiki/concepts/LSIF.md
2026-05-03 05:42:12 +08:00

40 lines
1.6 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: "LSIF"
type: concept
tags: ["LSP", "code-index", "semantic-index", "static-analysis", "pre-computed"]
sources: ["lsp-index-engineer.md"]
last_updated: 2026-04-29
---
## Definition
LSIFLanguage Server Index Format是一种标准化的预计算语义索引格式用于存储语言服务器已分析过的代码语义数据如符号定义、引用、继承关系等使代码智能工具无需实时运行 LSP 服务器即可提供导航功能。
## Core Mechanism
### 用途
- **离线索引**:项目提前构建 LSIF 索引CI/CD 阶段预先生成
- **冷启动加速**:无需等待 LSP 服务器初始化,立即提供代码导航
- **分发预索引数据**:发布 npm 包时附带已编译的 LSIF 索引
- **跨工具共享**同一索引可为多个工具IDE/CLI/API共用
### 索引内容
- 符号定义位置
- 符号引用关系
- 文档结构(文件树/大纲)
- Hover 文档内容
- 类型层次信息
### 与 nav.index.jsonl 的关系
LSIF 是 nav.index.jsonl 格式的导入/导出标准。graphd 支持:
- **导出**:将内存中的语义图谱导出为 LSIF 格式
- **导入**:将预先构建的 LSIF 索引加载到内存,加速启动
## Implementation Notes
LSP/Index Engineer 将 LSIF 视为 nav.index.jsonl 格式的上游标准,通过 LSIF 实现预计算语义数据的导入/导出。
## Connections
- [[LSIF]] ← is_standard_for ← [[SemanticCodeGraph]]
- [[LSIF]] ← can_be_imported_by ← [[GraphDaemon]]
- [[LSIF]] ← is_alternative_to ← [[IncrementalGraphUpdate]]
- [[LSIF]] ← exports ← [[nav.index.jsonl]]