hsnips icon indicating copy to clipboard operation
hsnips copied to clipboard

Feature Request: Allow multiple files per language to facilitate sharing of hsnips files separated by functionality

Open universemaster opened this issue 1 year ago • 2 comments

Many of the .hsnips files shared publicly on github are very long and with many different types of functionality.

I would like to seperate my .hsnips into categories such as:

  • Snippets that generate a single unicode character (greek, \textbf{.}, \mathcal{.}, mathfrak, operators, arrows, etc).
  • Tex snippets that automatically create Latex environments (in my case these are in markdown .hsnips file).
  • Snippets that generate common sentence structures, and common ways to begin sentences - separated into files for generic writing, and when writing math.
  • Snippets that autocorrect spacing (don't allow double space unless at start of line etc, balance spacing around operators, and balance the spacing around \text{})
  • Personal snippets that would either not benefit other people, or contain personal info (address, phone number, company etc).
  • Generic snippets worth sharing with others.
  • Useful global functions.
  • Snippets which autocorrect common misspellings.
  • Snippets which autocorrect british spelling to american spelling.
  • Snippets which autocorrect names and words with umlauts and other accents.

Currently hsnips allows one file per language:

The file should be named based on the language the snippets are meant for (e.g. latex.hsnips for snippets which will be available for LaTeX files). Additionally, you can create an all.hsnips file for snippets that should be available on all languages.

My feature request is to allow multiple files per language to facilitate sharing of hsnips files separated by functionality.

I possible way to achieve allow multiple files by language is to allow globbing of file names like this:

The end of the file names should be based on the language the snippets are meant for (e.g. xxxxxlatex.hsnips for snippets which will be available for LaTeX files). Additionally, you can create files that end with xxxxxall.hsnips for snippets that should be available on all languages.

Then, we would be able to create and share .hsnips files with file names that indicate the functionality. If globals from a different file are used, maybe the author should leave a comment to direct someone else to also use the other file?

The extension and repository could also list good files, or suggest that people search github like this.

I don't have time right now to do a pull request for this, but I suspect for someone familiar with the code base it won't be too difficult?

universemaster avatar Feb 15 '23 18:02 universemaster

Would this issue be solved by the feature proposed here? This way you could name your files however you want and use the main language file to include the relevant snippets.

draivin avatar Mar 07 '23 20:03 draivin

@draivin , yes, that would work well!

universemaster avatar Mar 07 '23 20:03 universemaster