Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document symbols could include local definitions #3628

Open
michaelpj opened this issue Jun 8, 2023 · 4 comments
Open

Document symbols could include local definitions #3628

michaelpj opened this issue Jun 8, 2023 · 4 comments
Labels
level: easy The issue is suited for beginners type: enhancement New feature or request ZuriHac This issue is suitable for ZuriHac Hacking sessions

Comments

@michaelpj
Copy link
Collaborator

At the moment we include all the "top-level" stuff. But we could include local definitions as well. The thing that would be awkward is reflecting nested scopes, but often they are also associated with a symbol.

It might also be rather noisy, but arguably that's a client problem? e.g. things should be shown collapsed by default, if you open up a function, sure you get lots of stuff.

Examples to think about:

f x = g x
  where 
    g = ...

f x = 
  let g = ..
  in g x

f x =
   -- awkward nesting and shadowing
   let g = let g = ... in g
   in g x

f x = do
    -- nest g inside res? what if we discarded the result?
   res <- let g = ... in g x
   pure res
@michaelpj michaelpj added type: enhancement New feature or request status: needs triage level: easy The issue is suited for beginners ZuriHac This issue is suitable for ZuriHac Hacking sessions and removed status: needs triage labels Jun 8, 2023
@wz1000
Copy link
Collaborator

wz1000 commented Jun 8, 2023

We have an interval map in Development.IDE.Spans.LocalBindings that could be used to implement this

@sgillespie
Copy link
Contributor

Hi, I've been hacking at this, and here's an example of how it looks in emacs with eglot:

ss-20240522-213934

The markup itself looks like this:

* * *
Local bindings:

```haskell
hf :: HieASTs a
rm :: RefMap a
<-- Snip -->
prettyNames :: [Text]

```
* * *

How is this?

@michaelpj
Copy link
Collaborator Author

I'm a little confused about where you're adding this? I thought the idea was to put it into the document symbols, so it would show up in the outline, or similar?

@sgillespie
Copy link
Contributor

Thanks for responding, I completely misunderstood the description. Will attempt to add it to textDocument/documentSymbol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level: easy The issue is suited for beginners type: enhancement New feature or request ZuriHac This issue is suitable for ZuriHac Hacking sessions
Projects
Development

No branches or pull requests

3 participants