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

Several improvements. #906

Merged
merged 14 commits into from
May 31, 2023
Merged

Several improvements. #906

merged 14 commits into from
May 31, 2023

Conversation

L3MON4D3
Copy link
Owner

This has multiple more-or-less interdependent improvements, hence me doing this in one PR:

  • Snippet-filetype can be overridden via filetype-setting in context

    s({trig = "in lua", filetype = "lua"}, ...)

    will be added to lua even if it is in an add_snippets-call to another language.
    This may seem a bit weird at first, but is actually useful since it decouples
    the loaded filetype (language in package.json, "filetype.lua/snipmate")
    from the filetype of the added snippet. This allows doing something like
    grouping snippets by some property other than its filetype (for example all
    snippets for some framework together) which wasn't as nicely doable before
    (it was possible by splitting snippets by framework and filetype, but this is
    better).
    Also allows adding a single snippet to multiple filetypes via multisnippet.

  • Some performance/functional improvements for loaders.from_vscode. It's a bit
    cleaner now, uses multisnippet for multi-filetype/multi-trigger snippets
    (scope/prefix can have multiple entries), and does not deepcopy snippets, but
    uses duplicate_addable/expandable, a kind of thin wrapper around the
    original snippet which allows it to be added to multiple filetypes, without
    invalidate removing all snippets (kind of complicated :/).

  • Finally, support for loading .code-snippets standalone, without a package.json.

@L3MON4D3 L3MON4D3 mentioned this pull request May 29, 2023
@L3MON4D3 L3MON4D3 force-pushed the vscode-code-snippets-2 branch 2 times, most recently from 3fe39cb to 73dff88 Compare May 29, 2023 18:16
@L3MON4D3
Copy link
Owner Author

Alright, I think that should be it.
Anybody wanna look through these changes, now's the time :)

Useful for lsp-snippets which belong to multiple filetypes.
`.code-snippet`-cache is not compatible.
id is specified per-virtual-snippet (if there is a snippet which is
added, via multisnippet, to two filetypes X and Y, the snippet expanded
from filetype X will have an id different from that for filetype Y).
For inserting the same addable/expandable to multiple filetypes, without
deep-copying.
Maybe it should even exclusively consider load_ft_func-filetypes, since
the intent of the function, at least as I see it, is to add a snippet to
any filetype for this buffer, and thats exactly the association
load_ft_func is supposed to model.
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.

1 participant