Giter Site home page Giter Site logo

emacs-import-js's Introduction

MELPA

Running ImportJS in Emacs

  1. Install the importjs binary:
  • npm install import-js -g
  1. Configure ImportJS
  1. Install import-js.el for Emacs
  • Install via MELPA
  • Alternatively, Copy plugins/import-js.el into your Emacs load-path and add (require 'import-js) to your config. You will also need to install grizzl
  1. Run the import-js daemon
  • (M-x) run-import-js
  • The daemon will use watchman if installed to improve performance
  1. Import a file!
  • You can use something like (M-x) import-js-import with your cursor over the desired module

  • It will be helpful to bind import-js-import to an easy-to-use binding, such as:

    (define-prefix-command 'my-keymap)
    (global-set-key (kbd "s-a") 'my-keymap)
    (define-key my-keymap (kbd "a u") 'import-js-import)
    
  1. Go directly to a file
  • The ImportJS goto interface allows us to jump to a package
  • (M-x) import-js-goto will jump to the appropriate file found by ImportJS
  • This should also be bound to something useful: (global-set-key (kbd "<f4>") 'import-js-goto)
  1. Fix your imports
  • Optionally, you can configure ImportJS to fix your imports for you, adding unknown variables and removing unused imports. ImportJS uses eslint to find these variables.
  • eslint must be in your PATH.
  • eslint plugins must be installed for that specific version of eslint (if eslint is a global eslint, you may need to install the plugins globally)
  • Run with (M-x) import-js-fix
  • You can also configure import-js-fix to run on save: (add-hook 'after-save-hook 'import-js-fix)

Note on Node v6.1.0

I've had issues running import-js in Emacs on Node v6.1.0. Node >= v6.2.0 seems to work as expected.

emacs-import-js's People

Contributors

kevinkehl avatar lencioni avatar trotzig avatar

Watchers

 avatar  avatar

Forkers

thaenalpha

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.