joeheyming / requirejs-emacs

Uses js2-mode to make Emacs interact with your RequireJS project
GNU General Public License v3.0
11 stars 2 forks source link

requirejs.el MELPA Build Status

Uses js2-mode to make Emacs interact with your RequireJS project. Provides requirejs-mode which is a minor mode for js2-mode.

Features:

Screenshot

requirejs-emacs

Installation

requirejs-emacs is available on MELPA.

You can install requirejs with the following command.

M-x package-install [RET] requirejs [RET]

Customization

The first argument to requirejs-add-alias is the path you want inside your define block, second argument is the parameter to put in the function declaration, the third argument is the path to the actual file (under requirejs-require-base)

Key mappings

I like to add requirejs-mode when in js2-mode:

 (add-hook 'js2-mode-hook
           '(lambda ()
              (requirejs-mode)
              ))

This provides the following keys: C-c s r => requirejs-sort-require-paths C-c a r => requirejs-add-to-define C-c r j => requirejs-jump-to-module

Snippets

When in requirejs-mode, we will expand def as a define([], function(){}) block.

You can customize this to add a header by overriding this variable with a function: requirejs-define-header-hook