Skip to content

rajasegar/pnpm-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

pnpm-mode

MELPA

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

Installation

Package Manager

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

Manual Installation

Start by cloning the pnpm-mode package repository:

$ git clone https://github.com/rajasegar/pnpm-mode.git /your/path/here

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

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

Configuration

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

(pnpm-mode)

Global Activation

The mode can be activated globally with:

(pnpm-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 pnpm-mode.

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

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

((nil
  (mode . pnpm)))

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

Now when you visit any file under the project directory, pnpm-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 pnpm-mode-keymap-prefix.

Usage

Command Keymap

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

command keymap description
pnpm-mode-npm-init n Initialize new project
pnpm-mode-pnpm-install i Install all project dependencies
pnpm-mode-pnpm-add s Add new project dependency
pnpm-mode-pnpm-add-dev d Add new project dev dependency
pnpm-mode-pnpm-remove u Remove project dependency
pnpm-mode-pnpm-list l List installed project dependencies
pnpm-mode-pnpm-run r Run project script
pnpm-mode-pnpm-test t Run project test script
pnpm-mode-visit-project-file v Visit project package.json file
? Display keymap commands

pnpm-mode-npm-init

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

pnpm-mode-pnpm-install

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

pnpm-mode-pnpm-add

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.

pnpm-mode-pnpm-add-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.

pnpm-mode-pnpm-remove

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.

pnpm-mode-pnpm-update

Running C-c n U in a project directory will updates packages to their latest version based on the specified range.

pnpm-mode-pnpm-test

Running C-c n t in a project directory will run the test script.

pnpm-mode-pnpm-list

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

pnpm-mode-pnpm-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.

pnpm-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 https://github.com/mojochao/npm-mode
Many thanks to Alen Gooch for his contribution.

About

An Emacs minor mode for working with NPM projects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published