close
Skip to content

feat(lsp): Implement document symbol outline#2298

Merged
ospencer merged 1 commit into
grain-lang:mainfrom
spotandjake:spotandjake-lsp-outline
Jun 30, 2025
Merged

feat(lsp): Implement document symbol outline#2298
ospencer merged 1 commit into
grain-lang:mainfrom
spotandjake:spotandjake-lsp-outline

Conversation

@spotandjake
Copy link
Copy Markdown
Member

@spotandjake spotandjake commented Jun 14, 2025

This adds the lsp symbol outline which makes it easier to navigate large files.

Screenshot 2025-06-14 at 6 20 23 PM Screenshot 2025-06-14 at 6 23 05 PM

@spotandjake spotandjake self-assigned this Jun 14, 2025
@spotandjake spotandjake added the lsp Issues related to the language server. label Jun 14, 2025
@spotandjake spotandjake force-pushed the spotandjake-lsp-outline branch from 5d42b53 to b014a7f Compare June 14, 2025 23:00
chore: Correct program outline loc

feat(lsp): Implement document symbol outline
@spotandjake spotandjake force-pushed the spotandjake-lsp-outline branch from b014a7f to 5855b09 Compare June 14, 2025 23:00
@spotandjake spotandjake marked this pull request as ready for review June 14, 2025 23:01
List.filter_map(
(bind: Typedtree.value_binding) => {
switch (bind.vb_pat.pat_desc) {
| TPatVar(ident, _) =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we at least have TPatConstraint? I might argue that we'd want to process every TPatVar that appears in a toplevel binding.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't TPatConstraint only appear under pat_extra?.

As per the others I would generally agree though I was thinking of leaving these for a small follow pr:

  • cases like let [x,y] = [() => void, () => void] in order to determine that x and y should have the kinds of functions I would have to start inspecting and breaking down the exp_type which seems a little complicated. Alternatively we could just say destructured items are of kind Variable.
  • I am not exactly sure what the range and selection ranges should be for destructured items.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TPatConstraint is just when the user writes a type annotation. I don't think looking at the type is too bad, really. If it's an arrow then you know it's a function, and it can be a variable otherwise. As for range, for the big one I'd just do the whole binding, and for the small one I'd do just the name.

Copy link
Copy Markdown
Member Author

@spotandjake spotandjake Jun 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TPatConstraint is under pat_extra though which means we don't need to look at right?
Screenshot 2025-06-14 at 8 34 40 PM

As per the other patterns what I really meant was two fold, patterns are recursive so I need to go down both the pattern and the type to figure out whats what i.e let [x,y] = [() => void, () => void] I need to start extracting the a from the list<a>, this isn't insanely difficult but it felt like a lot of complexity for the initial feature, this gets more complex when you consider you can have patterns like let [(x, y), (a, b)] = ... and other nested patterns, I am happy todo it though, I also don't know how well those selection ranges and ranges would work given vscodes symbol headers
Screenshot 2025-06-14 at 8 42 45 PM

For reference reasons lsp doesn't handle the nested patterns
Screenshot 2025-06-14 at 8 43 33 PM

I'm happy to add it if we really want it though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to start here.

Copy link
Copy Markdown
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really clean overall.

Copy link
Copy Markdown
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this @spotandjake!

@ospencer ospencer added this pull request to the merge queue Jun 30, 2025
Merged via the queue into grain-lang:main with commit e4caac2 Jun 30, 2025
12 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lsp Issues related to the language server.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants