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

Generate source for loaded snippets. #826

Merged
merged 9 commits into from
May 1, 2023
Merged

Generate source for loaded snippets. #826

merged 9 commits into from
May 1, 2023

Conversation

L3MON4D3
Copy link
Owner

@L3MON4D3 L3MON4D3 commented Mar 16, 2023

This is essentially another approach at storing a snippets source, less generic than #719, and only focused on source, not general metadata.

Major differences:

  • store data per-snippet (map id -> data). I think this is the right approach because we can get the line a snippet is defined on for lua and snipmate, and I'd say that makes the additional required storage worth it
  • less generic. Can only store source for snippets, but not any metadata. I think this is fine, since I'm not sure what other metadata might be interesting. If I'm wrong, and there is more useful metadata to attach, we could implement source using a more generic interface, later.

I've also written a pretty cool consumer for the metadata:

1678964272.mp4

It finds the range of the snippet via treesitter for lua and vscode, and fully via attached source-data (we know start and end of the snippet-definition since we do the parsing fully ourselves, and can thus provide this info) for snipmate

Missing:

  • Documentation
  • Tests

@L3MON4D3 L3MON4D3 force-pushed the snip_source branch 2 times, most recently from 2a9a3bd to 6596e95 Compare May 1, 2023 20:33
(enabling lua is most likely a nop, since it is already available by
default in newer neovim-versions)
@L3MON4D3 L3MON4D3 merged commit a46ab6f into master May 1, 2023
@hinell
Copy link

hinell commented May 6, 2023

I think we need a better explanation on what's going on that video. Do you generate new snippet from a selection or jump to the snippet definition? I'm puzzled. 🙄

@L3MON4D3
Copy link
Owner Author

L3MON4D3 commented May 6, 2023

😅😅
I jump to the source of the current snippet

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.

2 participants