zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.46k stars 3.12k forks source link

Outline/Symbol parity with VSCode #20964

Open deanrih opened 1 day ago

deanrih commented 1 day ago

Check for existing issues

Describe the feature

Zed and VSCode have outline/symbols and search/goto symbol functionality, however, the result from both are different using the same project, in this case a TypeScript project with Bun and ElysiaJS

Since ElysiaJS extensively uses callback for each route, I often need to go to each route by goto symbol, in VSCode i can do CMD+SHIFT+O/CTRL+SHIFT+O and /route-path which will bring me to the route, while in Zed it can't since the result of the outline/symbol list from both IDE is different, VSCode has more extensive symbols being listed, callbacks, local variables, etc. while Zed only seems to list top level symbols (correct me if i'm wrong)

for example consider following code

import Elysia from "elysia";

const app = new Elysia()
    .get("/", async ({ }) => {
        return "hello world";
    })
    .get("/foo", async ({ }) => {
        return "bar";
    })
    .post("/register", async ({ }) => {
        return {};
    })

in VSCode it will display these symbols

image

while in Zed it only shows one

image

Environment

Zed: v0.162.3 (Zed) OS: macOS 13.4.1 Memory: 8 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help present your vision of the feature

No response

xzbdmw commented 1 day ago

The difference is vscode query outline items using lsp documentSymbols while zed uses treesitter, language server's is often more detailed. The advantage of treesitter is you can custom queries as you like, but current zed seems not exposed it yet.

osiewicz commented 1 day ago

We do support using workspaceSymbols; I wonder if/how we could integrate documentSymbols with our tree-sitter queries.

xzbdmw commented 1 day ago

This article says it is by design.

In order to make the outline work this way and feel uniform across all of the languages that we support, we decided not to use the Language Server Protocol's version of this feature.

deanrih commented 12 hours ago

That is interesting, I guess I have to wait for the future for the possibility of this, for now my development speed is way lower using Zed (despite it is more responsive and faster in every other way), but it is understandable since Zed is fairly new and still in development, and my workflow uses a lot of mature feature of VSCode, but at least there's a workaround, using a Find/Search function for now