SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.55k stars 691 forks source link

[Feature Request] Subfolder in `filetype` snippets folder & Specific `extends` and `excludes` #1547

Closed pilgrimlyieu closed 1 year ago

pilgrimlyieu commented 1 year ago

Expected behavior:

I would like to classify for my snippets. For example, I will have some snippets in basic.snippets for basic markdownsyntax, some snippets with different types for math syntax, and some snippets for specific cases. And my expected structure is like below.

markdown
  ├─math
  │  ├─layout
  │  │  ├─annotation.snippets
  │  │  └─spacing.snippets
  │  ├─operators
  │  │  ├─big-operators.snippets
  │  │  └─binary-operators.snippets
  │  └─katex
  │     ├─a.snippets
  │     └─b.snippets
  ├─cases
  │  ├─changelog.snippets
  │  └─blog.snippets
  └─basic.snippets

And I would like to use math snippets in tex filetype, and I hope we could have a way likes below to achieve this.

extends markdown/math

Furthermore, the sub folder katex may not work in tex and I prefer to exclude them from markdown/math, so I have a preference to use

extends markdown/math
excludes markdown/math/katex

For specific snippets file

extends markdown/basic.snippets

I've read the documentation and searched the Internet, finding this seems haven't been achieved. As a result, I open this issue to make a feature request. Thanks anyway in advance!

Actual behavior:

Steps to reproduce

1. 2. 3.


SirVer commented 1 year ago

Excludes is really, really hard to get right I think. Extends is already supported, however it works on filetype basis and not on snippet files basis. Are you familiar with dotted filetypes? I use them all the time to extend the scope of my snippets and pull others in. So for example, you could have a filetype markdown_katex with corresponding snippets and if you want to use it in a markdown file, you simply define the filetype to be markdown.markdown_katex. Would that help you some?

pilgrimlyieu commented 1 year ago

Excludes is really, really hard to get right I think. Extends is already supported, however it works on filetype basis and not on snippet files basis. Are you familiar with dotted filetypes? I use them all the time to extend the scope of my snippets and pull others in. So for example, you could have a filetype markdown_katex with corresponding snippets and if you want to use it in a markdown file, you simply define the filetype to be markdown.markdown_katex. Would that help you some?

Thanks. I have a basic understanding of dotted filetypes. I've tried to avoid using it before since I thought it seemed to mess up the filetype, and was inconvenient to change(That means, I have to change original filetype markdown to something likes markdown.math). However, I'll look into this feature and have a try. Thanks!