Coder Social home page Coder Social logo

yasmate's Introduction

yasmate

A ruby tool to convert textmate snippet bundles to yasnippet format.

These rails-centric conversions already bundled:

  • ruby-mode
  • html-mode
  • rails-mode

Make sure you cloned yasmate with the --recursive option to fetch submodules of the actual "tmbundles" maintained by the Textmate community. In yasmate's top dir:

gem install plist trollop        # two dependencies needed first
rake convert_bundles             # will convert ruby, rails and html bundles

Then, in your .emacs file

(add-to-list 'load-path "/path/to/yasnippet")
(require 'yasnippet)
;; use just the yasmate snippet collection
(setq yas-snippet-dirs '("~/.emacs.d/snippets" "/path/to/yasmate/snippets"))
(yas-global-mode 1)

Open some rails file (model, app, etc) and start using the textmate snippets.

How to convert foo.tmbundle

  1. Add a git submodule bundles/foo.tmbundle pointing to the tmbundle repo.

  2. Add a snippets/foo-mode directory, assuming foo-mode is the corresponding emacs major-mode.

  3. Run yasmate.rb -d bundles/foo.tmbundle -o snippets/foo-mode

That's it, your converted snippets now live under snippets/foo-mode

It messed up on snippet XYZ!!!

Yep, it's unlikely be perfect.

yasmate.rb has some rules for translating bits of Textmate syntax to yasnippet's embedded elisp syntax. I call these substitutions. For example, this is Textmate

${0:$TM_SELECTED_TEXT}

is this in yasnippet

${0:`yas-selected-text`}

Those builtin rules help a lot, but some textmate bundles have very specific substitutions that have to be added into the mix in a per-bundle fashion.

So there are these snippets/foo-mode/.yasmate-extra-substitutions.el files that help with that.

Here's how it works:

  1. you follow the steps I gave above

  2. you notice that yasmate.rb also created a snippets/foo-mode/.yasmate-unknown-substitutions.el file. You notice the unknown substitution for the snippet XYZ that didn't work

  3. you grab that bit, correct it, and paste it into a new snippets/foo-mode/.yasmate-extra-substitutions.el

The format of the substitution files sucks

Yep! It's very ... inventive. And wrong. They should be pure elisp files and yasmate.rb should be rewritten in emacs-lisp to spare the dependency on ruby.

yasmate's People

Contributors

joaotavora avatar iamarcel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.