-
-
Notifications
You must be signed in to change notification settings - Fork 691
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
Allow snippet files for multiple dotted filetypes #889
Conversation
Sorry for the late reply. I do not follow your explanation and hence do not understand the usefulness of the feature you are proposing. I have a hunch that you could get to the same result using clever usage of priorities, but I am not sure. Could you spell out a concrete example with a few snippets and snippet files for me to get it? Either way, I hope we find another way of getting you what you need. The suggested fix changes the semantics of dotted filetypes away from the one Vim uses internally: now
I'd like to avoid adding additional semantics as much as possible, since they are confusing for Vim veterans. |
Imagine I have the following snippet for properties in ember.js projects:
This snippet only make sense for ember projects, and nothing else. There's no point in having it defined in the "javascript" filetype, because it doesn't work in plain javascript. Of course, how a "project" works is not something Vim understands. From what I see from the ultisnips documentation, one way to fix this would be to define a custom filetype, So what that means is, I can keep general javascript snippets and ember-specific snippets separated like this:
The problem is, I've also needed to work with coffeescript files. The snippets I need for ember.js while writing coffeescript are different than the ones I need for writing ember.js with javascript. The "prop" one would look like this:
So, I'd like to group them like this:
Unfortunately, I can't do that. I can't just have one
That's true, I hadn't realized it. I thought you could define a I do have an alternative idea: Could you expose a public API that would allow someone to define a file with snippets? I see that there's a function called This is basically how I used to do it with snipMate: https://github.com/AndrewRadev/Vimfiles/blob/3f162b52d571398ffecea4a41295093d538b1160/projects/ember.vim#L5-L6 What do you think? |
Thanks for the explanation. This might work:
This is basically the alternative idea you have been outlining above. Does this work? |
This works just fine! I should have come up with it myself, honestly, it seems pretty straightforward in hindsight :). Closing the PR, thank you very much for the help. |
This PR allows the creation of a
foo.bar.snippets
file that will get loaded for the combination filetype "foo.bar".As an example, I have "ruby" and "erb" snippet files that are general-purpose, for any ruby or erb file. For rails projects, I'd like to add a few more snippets to both of these filetypes, but the snippets are different in both. I could create a
rails.snippets
file that combines the two snippet sets, but it would be impossible to use the same trigger for different snippets.With this PR, I can create the files
rails.ruby.snippets
andrails.erb.snippets
and organize them properly. I have the same setup for javascript and coffeescript -- similar triggers generate different code, and different ember.js snippets need to be loaded depending on the language used.If there's an existing way of getting the same results, I don't mind using it and closing the PR. Also, I'm not an experienced python developer, so there may be a more sensible way of implementing that particular function. I'm open to any suggestions to change the code to fit the codebase better.