29

GitHub - mojochao/npm-mode: An Emacs minor mode for working with NPM projects.

 5 years ago
source link: https://github.com/mojochao/npm-mode
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

npm-mode

This is npm-mode, an Emacs minor mode for working with NPM projects.

Installation

Package Manager

The recommended way to install npm-mode is through the package manager and MELPA.

Manual Installation

Start by cloning the npm-mode package repository:

$ git clone https://github.com/mojochao/npm-mode.git /your/path/here

Finish by loading the npm-mode package in your emacs configuration:

(add-to-list 'load-path "/your/path/here/npm-mode")
(require 'npm-mode)

Configuration

The npm-mode package provides a minor mode which can be activated with:

(npm-mode)

Global Activation

The mode can be activated globally with:

(npm-global-mode)

Project Activation

The mode can be activated on a per-project basis using directory local variables by running add-dir-local-variable from the root directory of a project.

For example, visit the README.md file in the root directory of a project, and run M-x add-dir-local-variable. Emacs will prompt you for Mode or subdirectory:, to which you should enter nil.

Next, you will be prompted for Add directory-local variable:, to which you should enter mode.

Next, you will be prompted for Add mode with value:, to which you should enter npm-mode.

Next, you will be placed in a new .dir-locals.el buffer containing the directory local variables for the project, including the added npm-mode configuration.

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((nil
  (mode . npm)))

Finally, save the buffer contents with C-x C-s, and your project is configured for npm-mode.

Now when you visit any file under the project directory, npm-mode will be activated and its commands made available.

Command Keymap Prefix

The mode provides a command keymap, whose default C-c n prefix can be configured with M-x customize-variable npm-mode-keymap-prefix.

Usage

Command Keymap

Once npm-mode has been activated, its commands are accessed by the C-c n command prefix:

command keymap description npm-mode-npm-init n Initialize new project npm-mode-npm-install i Install all project dependencies npm-mode-npm-install-save s Add new project dependency npm-mode-npm-install-save-dev d Add new project dev dependency npm-mode-npm-uninstall u Remove project dependency npm-mode-npm-list l List installed project dependencies npm-mode-npm-run r Run project script npm-mode-visit-project-file v Visit project package.json file

? Display keymap commands

npm-mode-npm-init

Running C-c n n will create a new project in the current directory.

npm-mode-npm-install

Running C-c n i in a project directory will install all project dependencies.

npm-mode-npm-install-save

Running C-c n s in a project directory will prompt for the name of a package to install and will install it as a project dependency.

npm-mode-npm-install-save-dev

Running C-c n d in a project directory will prompt for the name of a to install and will install it as a project dev dependency.

npm-mode-npm-uninstall

Running C-c n u in a project directory will prompt for the name of a package to uninstall and will uninstall it and remove it from project dependencies.

npm-mode-npm-list

Running C-c n l in a project directory will list the project.

npm-mode-npm-run

Running C-c n r in a project directory will prompt for the name of a script to run and will run it. Completion support is provided.

npm-mode-visit-project-file

Running C-c n v in a project directory will visit the project file in a buffer.

Acknowledgements

This repo is a rewrite of a fork of https://github.com/AlexChesters/emacs-npm, and its history has been preserved. Many thanks to Alex for his contribution.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK