Skip to main content

snipsync

PyPI Version Build Status Code Coverage

Syncs your UltiSnips snippets to JetBrain IDE (see blog).

snipsync is based on UltiSnips to parse UltiSnips snippets and transforms them into JetBrains XML LiveTemplate syntax.

Usage

  • JetBrains must not be running during the update because is holds LiveTemplates in memory and saves them to disk at shutdown. So any external changes to LiveTemplates will be overwritten.
# sync Ultisnip snippets based on static configuration
snipsync auto-sync

# sync Ultisnip snippets based on CLI arguments
snipsync sync -c "Python" "~/dev/binx/vim-config/UltiSnips/python.snippets" "~/Library/Application Support/JetBrains/PyCharm2020.3/jba_config/templates/user.xml"

Configuration

Configuration File

  • static configuration allows you to set all relevant parameters via config file
  • if init = no then an existing user.xml LiveTemplate file will only be updated and existing LiveTemplates preserved
  • if init = yes a new user.xml LiveTemplate file will be created. This is the right option, if you want to have only UltiSnips snippet in your user.xml.

Example:

[DEFAULT]
#live_templates_path = ~/Library/Application Support/JetBrains/PyCharm2020.3/jba_config/templates
live_templates_path = ~/xxx
ultisnips_path = ~/dev/binx/vim-config/UltiSnips

[GLOBAL]
init = yes

[SNIP.SHELL]
ultisnips = %(ultisnips_path)s/sh.snippets
live_templates = %(live_templates_path)s/user.xml
live_templates_contexts = ["SHELL_SCRIPT", "Bash"]

[SNIP.PYTHON]
ultisnips = %(ultisnips_path)s/python.snippets
live_templates = %(live_templates_path)s/user.xml
live_templates_contexts = ["Python"]

Configuration Location

the configuration file's default location is:

  • Mac OS X: ~/Library/Application Support/snipsync
  • Mac OS X (POSIX): ~/.snipsync
  • Unix: ~/.config/snipsync
  • Unix (POSIX): ~/.snipsync

Attention: Your configuration paths will change with major JetBrain upgrades

Target Location of JetBrain LiveTemplates

In order to have the generated LiveTemplate user.xml file available in your JetBrains IDE, you need to provide the correct target directory for user defined snippets. This depends on your IDE configuration, i.e. when you have setting sync activated this would be:

If your settings are synchronized through JetBrains IDE Settings Sync plugin, these subfolders are located under jba_config in the configuration directory.

How does it work?

  • Creates/updates a user.xml live template file for intelij IDE from UltiSnip sources.
  • Overwrites existing user.xml.
  • Interprets UltiSnips syntax ${1}/${1:name} as Tabstop (variable to replace) and $1 (without brackets) as Mirror.

Limitations

  • Bespoke user-implemented Python functionality cannot be translated to LiveTemplate format
  • Nested Tabstop's are not translated correctly (but are valid Ultisnips syntax)

Gotchas

  • make sure that Tabstops use always the format: ${1:default}, curly brackets
  • make sure that Mirrors never use curly brackets: $1 instead of ${1} (would be interpreted as Tabstop)

Development

  • additionally, generated xml tags do not result in error, but are being overwritten when JetBrain app closes, so there is no way to extend the JetBrains XML format
  • for development install package locally with: pipenv install -e .
  • lexer.py, text.py, ultisnip.py are used from Ultisnips directly, so no tests are provided here

Changelog

  • 0.2.0 Check for latest JetBrain software to ensure that latest user.xml will be updated
  • 0.1.0 Increase test coverage, update documentation
  • 0.0.9 Inital release

...

BSD 3-Clause License

Copyright (c) 2021, sysid All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Metadata

Release files for snipsync 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snipsync 1.0.3
File Size Uploaded Provenance
snipsync-1.0.3.tar.gz 22.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for snipsync 1.0.3
File Interpreter ABI Platform
snipsync-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 46.4 kB

Release files / snipsync-1.0.3.tar.gz

Download URL snipsync-1.0.3.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f91bea39f94ff3f563f2cf0999124b30af87c0b60a6a07162d060f67e4a13130
BLAKE2b-256 checksum
How to use checksums
7849232a1f5dadda58d59a2c829c31869fab0dcd4d430a21ecddd2214b89bf8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.10

Release files / snipsync-1.0.3-py3-none-any.whl

Download URL snipsync-1.0.3-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5420cbc9ffafb01905046f48fb50a7a4a9d54ebd3241f4ba5cfc607f145c596d
BLAKE2b-256 checksum
How to use checksums
43addfa9e2a5e8dae6260e070b0e1cc98196bb3e1a82083ccab11069c4247fd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.10

Security for snipsync 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page