GithubHelp home page GithubHelp logo

lalohao / babylon-mode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xymostech/babylon-mode

0.0 3.0 0.0 7 KB

An emacs mode for highlighting JavaScript using the babylon parser

License: MIT License

Emacs Lisp 96.21% JavaScript 3.79%

babylon-mode's Introduction

Babylon mode (babylon-mode)

An emacs mode for highlighting JavaScript using the babylon parser

Instead of trying to re-implement a JS parser in elisp like js2-mode, or trying to parse JS and JSX using regexes like web-mode, we try to offload a bunch of the actual parsing work onto some code that we know actually works: babylon. Babylon is the parser that babel uses, so we can be very confident that it will successfully parse any JavaScript we throw at it! All we need to do is traverse the tree, highlight things that we want, and we're good to go.

Currently, this comes at the significant downside that it is painfully slow and very error-prone. But I'm working on it, and hopefully it will get to the point that it will be useful for other people.

Install

Clone this repo somewhere

% git clone https://github.com/xymostech/babylon-mode.git

Add the path to load-path in your .emacs.el:

(add-to-list 'load-path "/path/to/babylon-mode")

Then, add an autoload for loading babylon-mode, and optionally add babylon-mode to auto-mode-alist:

(autoload 'babylon-mode "babylon-mode" nil t)

(add-to-list 'auto-mode-alist '("\\.jsx$" . babylon-mode))
(add-to-list 'auto-mode-alist '("\\.js$" . babylon-mode))

Usage

Visit a .js or .jsx file, or manually run babylon-mode:

babylon-mode

Maintainer

  • xymostech

Contribute

This is the first large amount of elisp that I've written (aside from my .emacs.el), so I apologize for any elisp faux pas I have committed. If you find this useful and have any ideas for improvement, I'd love to hear! Issues pointing out how broken things currently are are probably not useful, because the whole thing is pretty broken.

In other words:

  • Ask questions in github issues
  • PRs are welcome, especially to improve the elisp, but huge code refactorings are not useful. I'm trying to learn elisp and continue working on this, so huge changes would put a damper on it.

License

MIT

babylon-mode's People

Contributors

xymostech avatar

Watchers

 avatar  avatar  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.