Ultyas is a command-line tool that simplifies the process of converting code snippets from UltiSnips (Vim/Neovim) to YASnippet format (Emacs).
Transitioning from Vim/Neovim to Emacs can be difficult. Ultyas addresses this issue by offering a straightforward solution for converting your existing UltiSnips snippets into the YASnippet format.
Ultyas can be used for the following purposes:
- Migrating your snippets from UltiSnips to YASnippet format.
- Maintaining consistent snippets across both Vim/Neovim and Emacs. (For instance, the author of Ultyas effortlessly switches between Vim and Emacs depending on the machine and environment, ensuring that the same snippets are accessible in both editors.)
Here is how to install Ultyas locally to ~/.local/bin/ultyas
using pip:
pip install --user ultyas
The command above will install Ultyas in the local directory: ~/.local/bin/ultyas
.
To use Ultyas, simply run the command with the appropriate input and output files. Here is a basic example:
~/.local/bin/ultyas ~/.vim/UltiSnips/python.snippets -o ~/.emacs.d/snippets/python-mode/
This command takes an UltiSnips file python.snippets
and converts it to a directory that contains YASnippet snippets at ~/.emacs.d/snippets/python-mode/
.
usage: ultyas <file.snippets> -o <yasnippet-major-mode-dir>
A command-line tool for converting code snippets from UltiSnips to YASnippet format.
positional arguments:
ultisnips_file The UltiSnips .snippets file
(e.g. '~/.vim/UltiSnips/python.snippets')
options:
-h, --help show this help message and exit
-o YASNIPPET_DIR, --yasnippet-dir YASNIPPET_DIR
The YASnippet snippets major mode directory
(e.g. '~/.emacs.d/snippets/python-mode/')
-i {auto,fixed,nothing}, --yas-indent-line {auto,fixed,nothing}
Add one of the following comments to the YASnippet
snippets that will be generated:
"# expand-env: ((yas-indent-line 'fixed))" or
"# expand-env: ((yas-indent-line 'auto))".
-t CONVERT_TABS_TO, --convert-tabs-to CONVERT_TABS_TO
Convert the tabs that are in the generated
snippets to the string passed to this
option (Default: The indentation marker '$>')
-v, --verbose Verbose mode
-q, --quiet Quiet mode
Here is an example of an UltiSnips snippet that can be converted by Ultyas from the UltiSnips format to the Yasnippet format:
priority 50
snippet if
if ${1:True}:
${2:pass}
endsnippet
snippet for
for ${1:_} in ${2:[]}:
${3:pass}
endsnippet
snippet while
while ${1:True}:
${2:pass}
endsnippet
The ultyas
Emacs package has been written by James Cherti and is distributed under terms of the GNU General Public License version 3, or, at your choice, any later version.
Copyright (C) 2023-2024 James Cherti
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
Other Emacs packages by the same author:
- minimal-emacs.d: This repository hosts a minimal Emacs configuration designed to serve as a foundation for your vanilla Emacs setup and provide a solid base for an enhanced Emacs experience.
- vim-tab-bar.el: Make the Emacs tab-bar Look Like Vim’s Tab Bar.
- outline-indent.el: An Emacs package that provides a minor mode that enables code folding and outlining based on indentation levels for various indentation-based text files, such as YAML, Python, and other indented text files.
- easysession.el: Easysession is lightweight Emacs session manager that can persist and restore file editing buffers, indirect buffers/clones, Dired buffers, the tab-bar, and the Emacs frames (with or without the Emacs frames size, width, and height).
- elispcomp: A command line tool that allows compiling Elisp code directly from the terminal or from a shell script. It facilitates the generation of optimized .elc (byte-compiled) and .eln (native-compiled) files.
- tomorrow-night-deepblue-theme.el: The Tomorrow Night Deepblue Emacs theme is a beautiful deep blue variant of the Tomorrow Night theme, which is renowned for its elegant color palette that is pleasing to the eyes. It features a deep blue background color that creates a calming atmosphere. The theme is also a great choice for those who miss the blue themes that were trendy a few years ago.
- dir-config.el: Automatically find and evaluate .dir-config.el Elisp files to configure directory-specific settings.
- flymake-bashate.el: A package that provides a Flymake backend for the bashate Bash script style checker.
- flymake-ansible-lint.el: An Emacs package that offers a Flymake backend for ansible-lint.
- compile-angel.el: An Emacs package that automatically compiles Emacs loaded or saved Elisp libraries. This lightweight alternative to auto-compile not only compiles Elisp files loaded with load and require, but also handles deferred and autoloaded files.
- inhibit-mouse.el: A package that disables mouse input in Emacs, offering a simpler and faster alternative to the disable-mouse package.
- quick-sdcv.el: This package enables Emacs to function as an offline dictionary by using the sdcv command-line tool directly within Emacs.