Code Monkey home page Code Monkey logo

sublime2yas's Introduction

Sublime2yas

SublimeText to YaSnippet / Emacs conversion

This is a script based on the old TextMate import script that ship(ped) with YASnippet for Emacs.

This script is focussed only on .sublime-snippet files, and ignores commands or macros or whatever else might exist in the SublimeText universe (I'm largely ignorant of it TBH.) What I do know is there's a lot of snippets I want to harvest from it and bring into Emacs, and I'll be hornswoggled if I'm going to do that mucky business by hand.

So instead here's a script which will take care of it, with a few extra bells and whistles thrown in for good measure.

Installation

gem install sublime2yas

Uninstall

gem uninstall sublime2yas

Usage

For help run sublime2yas --help from the command line on a single folder of SublimeText Snippets.

sublime2yas -d SublimeSnippetsFolder -o YasnippetsFolder

Process one folder at a time, if you want to process a whole tree of folders, you'll have to walk them using find or another weapon of choice.

I'd recommend you convert a folder at a time, not for any technical reason, but simply so that you can learn and use the snippets you're importing.

Options

Options:
    --snippet-dir, -d <s>:   Sublime-snippet directory
     --output-dir, -o <s>:   Output directory, use the major-mode name you are targeting as the containing folder's name, e.g.
                             snippets/major-mode
     --major-mode, -m <s>:   Explicit setting of major-mode if the folder name is different
   --parent-modes, -p <s>:   List of Yasnippet parent modes as a quoted string eg. "cc-mode,text-mode"
           --glob, -g <s>:   Specific snippet file (or glob) inside <snippet_dir>, default is *.sublime-snippet (default:
                             *.sublime-snippet)
  --snippet-group, -G <s>:   Yasnippet group: to use in generated snippets, eg. -G rails to add 'group: rails' to each snippet. They will
                             appear in submenu's on the major-mode Yasnippet menu
              --quiet, -q:   quiet output
                --doc, -c:   generate a quick reference in markdown format, listing the shortcut and description. Stored in the
                             --output-dir as QUICKREF.md
               --help, -h:   Show this message

Auto Quickref

When using the --doc or -c option a quick reference / cheatsheet is generated in the --output-dir as QUICKREF.md. See this example

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

sublime2yas's People

Contributors

jasonm23 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sublime2yas's Issues

Error with --doc: only works with absolute output path

I have an error when using the --doc option:

$ sublime2yas -d sublime-snippets-js/ -o yas-js/ -m js2-mode --doc
Attempting to convert 43 snippets...
...
/home/user/.rvm/gems/ruby-1.9.3-p327/gems/sublime2yas-0.1.0/bin/sublime2yas:135:in `initialize': No such file or directory - yas-js/QUICKREF.md (Errno::ENOENT)
        from /home/user/.rvm/gems/ruby-1.9.3-p327/gems/sublime2yas-0.1.0/bin/sublime2yas:135:in `open'
        from /home/user/.rvm/gems/ruby-1.9.3-p327/gems/sublime2yas-0.1.0/bin/sublime2yas:135:in `<top (required)>'
        from /home/user/.rvm/gems/ruby-1.9.3-p327/bin/sublime2yas:19:in `load'
        from /home/user/.rvm/gems/ruby-1.9.3-p327/bin/sublime2yas:19:in `<main>'
        from /home/user/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
        from /home/user/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'

However it works with a full path for -o:

$ sublime2yas -d sublime-snippets-js/ -o $PWD/yas-js/ -m js2-mode --doc

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.