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

lsp/completions: Implement a minimal completions provider #709

Merged
merged 8 commits into from May 16, 2024

Conversation

charlieegan3
Copy link
Member

Related to #646, but more work to do here so not to close.

here is a little demo of what is done:

Screen.Recording.2024-05-09.at.18.31.57.mov

@charlieegan3 charlieegan3 changed the title lip/completions: Implement a minimal completions provider lsp/completions: Implement a minimal completions provider May 9, 2024
Signed-off-by: Charlie Egan <charlie@styra.com>
Signed-off-by: Charlie Egan <charlie@styra.com>
Signed-off-by: Charlie Egan <charlie@styra.com>
@charlieegan3 charlieegan3 marked this pull request as ready for review May 15, 2024 12:23
We had been showing these in places where it'd not be suitable to use
them

Signed-off-by: Charlie Egan <charlie@styra.com>
Signed-off-by: Charlie Egan <charlie@styra.com>
Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

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

This is an awesome addition, and the refactoring was icing on the cake 👍 Just had a few comments, but I'd be happy to have it merged as is.

Thank you! 👏

}

path := uri.ToPath(clients.IdentifierGeneric, fileURI)
dir := filepath.Base(filepath.Dir(path))
Copy link
Member

Choose a reason for hiding this comment

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

I suppose a next iteration could look at more components of the path, and translate /regal/rules/bugs/ to regal.rules.bugs. But this is a great start!

Copy link
Member Author

Choose a reason for hiding this comment

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

One of the challenges here is that we'd need to know where to stop, this would require being told the workspace root. should we always suggest the longest path, or all three? e/g/ bugs, rules.bugs, and regal.rules.bugs?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that is indeed a challenge. I guess what we could do is to start from the first 3 (or so) characters that match, so if you have something like:

/Users/charlie/projects/regal/rules/bugs

And you typed in package reg it would base the suggestion from the first matching position in the string, which would be regal/rules/bugs in this case. But yeah, I'm sure there would be cases where it could get tricky.

Copy link
Member Author

Choose a reason for hiding this comment

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

Using the workspace root from the server's config feels like the right option here.

Do you think that we'd always want to suggest the longest package name we can, and that one only? I.e. only suggest regal.rules.bugs

If so, that might be worth doing as part of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me!

Copy link
Member Author

Choose a reason for hiding this comment

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

Screenshot 2024-05-16 at 11 18 39

See c163642

Copy link
Member

Choose a reason for hiding this comment

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

very nice!

internal/lsp/completions/providers/regov1.go Show resolved Hide resolved
internal/lsp/completions/providers/shared.go Outdated Show resolved Hide resolved
internal/lsp/completions/providers/package.go Show resolved Hide resolved
Signed-off-by: Charlie Egan <charlie@styra.com>
Signed-off-by: Charlie Egan <charlie@styra.com>
Signed-off-by: Charlie Egan <charlie@styra.com>
@charlieegan3 charlieegan3 merged commit 6a17d1d into main May 16, 2024
3 checks passed
@charlieegan3 charlieegan3 deleted the completions-provider branch May 16, 2024 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants