0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Zed】LSPのシンボルをアウトラインに表示する方法

0
Posted at

Tree-sitterとLSPのシンボル表示の違い

Zedのアウトライン系UIには現在、シンボルの取得元として2つの選択肢があります。

Tree-sitter(デフォルト)
Zedが独自に管理する outlines.scm の定義にしたがって、構文ツリーからシンボルを抽出します。modfn などのキーワードを含む広めの範囲でシンボルが認識されるため、視覚的にわかりやすい表示になります。ただし言語ごとに outlines.scm が整備されている必要があります。

LSP(オプション)
起動中のLanguage Serverが textDocument/documentSymbol リクエストに応答して返すシンボル情報を使用します。LSPが対応している言語であれば利用でき、Language Serverが実際に理解しているシンボル構造をそのままアウトラインに反映できます。

設定方法

デフォルトでは "document_symbols": "off" となっており、Tree-sitterが使用されます。
LSPのシンボル情報に切り替えるには、settings.jsonlanguages セクションで対象言語に "document_symbols": "on" を追加します。

{
  "languages": {
    "Rust": {
      "document_symbols": "on"
    }
  }
}

この設定を追加すると、Rustファイルを開いた際のパンくずリスト・アウトラインモーダル・アウトラインパネルすべてで、Tree-sitterではなくLSPのシンボル情報が表示されるようになります。

複数の言語に適用したい場合は、それぞれ記述します。

{
  "languages": {
    "Rust": {
      "document_symbols": "on"
    },
    "TypeScript": {
      "document_symbols": "on"
    }
  }
}

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?