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

Feature request: Expose types of snippet globals for nicer development #1025

Open
MariaSolOs opened this issue Oct 2, 2023 · 7 comments
Open

Comments

@MariaSolOs
Copy link

When writing custom snippets, it would be really helpful to use type annotations for s, t, and other global snippet constructors for better editing support :)

@bew
Copy link
Contributor

bew commented Oct 2, 2023

Related #378 (but incomplete)

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Oct 3, 2023

Oh yeah, for sure!
As far as I understand, this would basically be whatever is in DOC.md, but as emmylua-annotation, so lua-language-server can parse it?
If so, I'd say there is a choice to make:

  • either just copy+transform what is currently in DOC.md to the source-files (which could be done relatively quickly, but having to keep both in sync manually seems suboptimal, and mistakes could happen), or
  • create a proper build-step for extracting these definitions and inserting them into DOC.md (initial setup seems much harder, but this seems cleaner at least)

I'd honestly be fine with either option since I don't really anticipate many major additions to luasnip, so the additional long-time-work induced by the first option may not outweigh one-time work and complexity introduced by the second one (though the second one may be fun to figure out)

Unfortunately, I really don't use annotations at all though, so my motivation for doing either is pretty low 😅

@MariaSolOs
Copy link
Author

@L3MON4D3 that's fair. I think that if no major API changes are predicted, then option 1 is fine.

Any reason why #378 hasn't been merged? Despite being incomplete, it's still an improvement.

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Oct 4, 2023

Only that it's marked as draft, and adding annotations for a small number of api-functions only seemed a bit weird.
But you're right, better that than nothing.
I'll look into getting it merged

@MariaSolOs
Copy link
Author

Sounds good. I think that splitting the work into smaller PRs will be less overwhelming than documenting the entire API at once (I think no one has the motivation for that hehe).

I’m also happy to help with this btw!

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Oct 4, 2023

Sounds good. I think that splitting the work into smaller PRs will be less overwhelming than documenting the entire API at once

Ah, yeah, probably also true :D

I’m also happy to help with this btw!

Yay, hoped for just that :P
Best wait until I'm done with #941 (shouldn't be long now), lots of changes to the files where api is defined in there

@UtkarshVerma
Copy link

Hi, I am also interested in this. Since the other PR is merged. Is there anything else blocking this?

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

No branches or pull requests

4 participants