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.
- 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"- static configuration allows you to set all relevant parameters via config file
- if
init = nothen an existinguser.xmlLiveTemplate file will only be updated and existing LiveTemplates preserved - if
init = yesa newuser.xmlLiveTemplate file will be created. This is the right option, if you want to have only UltiSnips snippet in youruser.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"]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
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:
- https://www.jetbrains.com/help/pycharm/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory
- https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs
If your settings are synchronized through JetBrains IDE Settings Sync plugin, these subfolders are located under jba_config in the configuration directory.
- Creates/updates a
user.xmllive 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.
- Bespoke user-implemented Python functionality cannot be translated to LiveTemplate format
- Nested Tabstop's are not translated correctly (but are valid Ultisnips syntax)
- make sure that Tabstops use always the format:
${1:default}, curly brackets - make sure that Mirrors never use curly brackets:
$1instead of${1}(would be interpreted as Tabstop)
- additionally, generated xml
tagsdo 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.pyare used from Ultisnips directly, so no tests are provided here
- 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
...