4 ms·
LSP is designed to help editors, not AI agents, and provides query by cursor position. Treesitter supports query by symbol (find definition, usages, etc), and s
by HarHarVeryFunny 9mo ago
LSP is designed to help editors, not AI agents, and provides query by cursor position. Treesitter supports query by symbol (find definition, usages, etc), and so is much better suited to what an AI agent may want to do.
- esafak 9mo agoMy agent already uses LSP plugins, and the protocol supports querying by symbol: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol https://microsoft.github.io/language-server-protocol/specifi... https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspaceSymbol https://microsoft.github.io/language-server-protocol/specifi...
- HarHarVeryFunny 9mo agoThanks - I wasn't aware of that, although it still doesn't seem to be what would be most useful to an AI agent. For example, if the agent wants to modify a function, it may want to know all the places the function is called, which AFAIK Treesitter can provide directly, but it seems with LSP you'd have to use that DocumentSymbol API to process every source file to find the usages, since you're really searching by source file, not by symbol.
- esafak 9mo agoFor that I believe you could use textDocument/references: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_references https://microsoft.github.io/language-server-protocol/specifi...
- HarHarVeryFunny 9mo agoYes, but that one is position-based rather than name-based - I believe it's basically for an editor to ask about whatever is under the cursor.