ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Node​Requirer

by ganemone ALL

A Sublime Text 3 plugin for requiring modules.

Details

Installs

  • Total 23K
  • Win 12K
  • Mac 6K
  • Linux 5K
Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5
Windows 0 2 0 0 2 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 1
Mac 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
01234Jun 18Jun 15Jun 12Jun 9Jun 6Jun 3May 31May 28May 25May 22May 19May 16May 13May 10May 7Jun 18 Linux: 0 Mac: 0 Windows: 0Jun 17 Linux: 0 Mac: 0 Windows: 2Jun 16 Linux: 0 Mac: 0 Windows: 0Jun 15 Linux: 0 Mac: 0 Windows: 0Jun 14 Linux: 0 Mac: 0 Windows: 2Jun 13 Linux: 0 Mac: 0 Windows: 0Jun 12 Linux: 0 Mac: 0 Windows: 1Jun 11 Linux: 0 Mac: 0 Windows: 0Jun 10 Linux: 1 Mac: 0 Windows: 0Jun 9 Linux: 0 Mac: 0 Windows: 0Jun 8 Linux: 0 Mac: 1 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 1Jun 6 Linux: 0 Mac: 0 Windows: 0Jun 5 Linux: 0 Mac: 0 Windows: 1Jun 4 Linux: 0 Mac: 0 Windows: 0Jun 3 Linux: 0 Mac: 0 Windows: 0Jun 2 Linux: 0 Mac: 0 Windows: 0Jun 1 Linux: 1 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 0 Windows: 0May 30 Linux: 0 Mac: 0 Windows: 0May 29 Linux: 0 Mac: 0 Windows: 0May 28 Linux: 0 Mac: 0 Windows: 0May 27 Linux: 1 Mac: 1 Windows: 0May 26 Linux: 0 Mac: 0 Windows: 1May 25 Linux: 0 Mac: 0 Windows: 1May 24 Linux: 0 Mac: 0 Windows: 0May 23 Linux: 0 Mac: 0 Windows: 0May 22 Linux: 0 Mac: 1 Windows: 0May 21 Linux: 0 Mac: 1 Windows: 0May 20 Linux: 0 Mac: 0 Windows: 0May 19 Linux: 0 Mac: 0 Windows: 0May 18 Linux: 0 Mac: 0 Windows: 0May 17 Linux: 0 Mac: 1 Windows: 1May 16 Linux: 0 Mac: 0 Windows: 0May 15 Linux: 0 Mac: 0 Windows: 0May 14 Linux: 0 Mac: 0 Windows: 1May 13 Linux: 0 Mac: 0 Windows: 0May 12 Linux: 0 Mac: 0 Windows: 0May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 0 Mac: 0 Windows: 0May 9 Linux: 0 Mac: 0 Windows: 0May 8 Linux: 0 Mac: 0 Windows: 0May 7 Linux: 0 Mac: 0 Windows: 1May 6 Linux: 0 Mac: 0 Windows: 0May 5 Linux: 0 Mac: 0 Windows: 1Jun 18 Linux: 0 Mac: 0 Windows: 0Jun 17 Linux: 0 Mac: 0 Windows: 2Jun 16 Linux: 0 Mac: 0 Windows: 0Jun 15 Linux: 0 Mac: 0 Windows: 0Jun 14 Linux: 0 Mac: 0 Windows: 2Jun 13 Linux: 0 Mac: 0 Windows: 0Jun 12 Linux: 0 Mac: 0 Windows: 1Jun 11 Linux: 0 Mac: 0 Windows: 0Jun 10 Linux: 1 Mac: 0 Windows: 0Jun 9 Linux: 0 Mac: 0 Windows: 0Jun 8 Linux: 0 Mac: 1 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 1Jun 6 Linux: 0 Mac: 0 Windows: 0Jun 5 Linux: 0 Mac: 0 Windows: 1Jun 4 Linux: 0 Mac: 0 Windows: 0Jun 3 Linux: 0 Mac: 0 Windows: 0Jun 2 Linux: 0 Mac: 0 Windows: 0Jun 1 Linux: 1 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 0 Windows: 0May 30 Linux: 0 Mac: 0 Windows: 0May 29 Linux: 0 Mac: 0 Windows: 0May 28 Linux: 0 Mac: 0 Windows: 0May 27 Linux: 1 Mac: 1 Windows: 0May 26 Linux: 0 Mac: 0 Windows: 1May 25 Linux: 0 Mac: 0 Windows: 1May 24 Linux: 0 Mac: 0 Windows: 0May 23 Linux: 0 Mac: 0 Windows: 0May 22 Linux: 0 Mac: 1 Windows: 0May 21 Linux: 0 Mac: 1 Windows: 0May 20 Linux: 0 Mac: 0 Windows: 0May 19 Linux: 0 Mac: 0 Windows: 0May 18 Linux: 0 Mac: 0 Windows: 0May 17 Linux: 0 Mac: 1 Windows: 1May 16 Linux: 0 Mac: 0 Windows: 0May 15 Linux: 0 Mac: 0 Windows: 0May 14 Linux: 0 Mac: 0 Windows: 1May 13 Linux: 0 Mac: 0 Windows: 0May 12 Linux: 0 Mac: 0 Windows: 0May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 0 Mac: 0 Windows: 0May 9 Linux: 0 Mac: 0 Windows: 0May 8 Linux: 0 Mac: 0 Windows: 0May 7 Linux: 0 Mac: 0 Windows: 1May 6 Linux: 0 Mac: 0 Windows: 0May 5 Linux: 0 Mac: 0 Windows: 1Jun 18 Linux: 0 Mac: 0 Windows: 0Jun 17 Linux: 0 Mac: 0 Windows: 2Jun 16 Linux: 0 Mac: 0 Windows: 0Jun 15 Linux: 0 Mac: 0 Windows: 0Jun 14 Linux: 0 Mac: 0 Windows: 2Jun 13 Linux: 0 Mac: 0 Windows: 0Jun 12 Linux: 0 Mac: 0 Windows: 1Jun 11 Linux: 0 Mac: 0 Windows: 0Jun 10 Linux: 1 Mac: 0 Windows: 0Jun 9 Linux: 0 Mac: 0 Windows: 0Jun 8 Linux: 0 Mac: 1 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 1Jun 6 Linux: 0 Mac: 0 Windows: 0Jun 5 Linux: 0 Mac: 0 Windows: 1Jun 4 Linux: 0 Mac: 0 Windows: 0Jun 3 Linux: 0 Mac: 0 Windows: 0Jun 2 Linux: 0 Mac: 0 Windows: 0Jun 1 Linux: 1 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 0 Windows: 0May 30 Linux: 0 Mac: 0 Windows: 0May 29 Linux: 0 Mac: 0 Windows: 0May 28 Linux: 0 Mac: 0 Windows: 0May 27 Linux: 1 Mac: 1 Windows: 0May 26 Linux: 0 Mac: 0 Windows: 1May 25 Linux: 0 Mac: 0 Windows: 1May 24 Linux: 0 Mac: 0 Windows: 0May 23 Linux: 0 Mac: 0 Windows: 0May 22 Linux: 0 Mac: 1 Windows: 0May 21 Linux: 0 Mac: 1 Windows: 0May 20 Linux: 0 Mac: 0 Windows: 0May 19 Linux: 0 Mac: 0 Windows: 0May 18 Linux: 0 Mac: 0 Windows: 0May 17 Linux: 0 Mac: 1 Windows: 1May 16 Linux: 0 Mac: 0 Windows: 0May 15 Linux: 0 Mac: 0 Windows: 0May 14 Linux: 0 Mac: 0 Windows: 1May 13 Linux: 0 Mac: 0 Windows: 0May 12 Linux: 0 Mac: 0 Windows: 0May 11 Linux: 0 Mac: 0 Windows: 0May 10 Linux: 0 Mac: 0 Windows: 0May 9 Linux: 0 Mac: 0 Windows: 0May 8 Linux: 0 Mac: 0 Windows: 0May 7 Linux: 0 Mac: 0 Windows: 1May 6 Linux: 0 Mac: 0 Windows: 0May 5 Linux: 0 Mac: 0 Windows: 1

Readme

Source
raw.​githubusercontent.​com

NodeRequirer - A Sublime Text 3 plugin for requiring node modules

Sublime Text 3

Click here to lend your support to: NodeRequirer Donations and make a donation at pledgie.com !

About

This is a Sublime Text 3 plugin allowing you to easily require node modules without having to worry about relative paths. It parses your project to allow you to require any local module or dependency listed in your package.json. In addition, it allows you to include node core modules.

Usage

ctrl+shift+i => RequireCommand

Provides a dropdown of local files, node core modules, and dependencies defined in package.json + bower.json SublimeRequirer will insert var {modulename} = require('/path/to/modulename.js').

ctrl+shift+e => RequireSpecificExportCommand

Provides same initial drop down as RequireCommand. After selecting a module, the plugin will attempt to parse the file or dependency to look for commonjs exports, and show a list of possible exports. The user may then select one or more exports to be required.

Example with single export selection:

var doSomething = require('../../utils/index.js').doSomething;

Example with multiple export selection:

var utils = require('../../utils/index.js');
var doSomething = utils.doSomething;
var doAnotherThing = utils.doAnotherThing;

Or with the destructuring option in preferences set to true…

var { doSomething, doAnotherThing } = require('../../utils/index.js');

ctrl+shift+o => RequireFromWordCommand

With the cursor on the desired variable, press ctrl+shift+o to have NodeRequirer import the corresponding module at the bottom of the current imports list. A fuzzy string matching algorithm similar to how Sublime Text filters lists on user input is used to select the best matching module to import. This is a new feature, and there still is some work to do on making it work perfectly in all scenarios.

Options

NodeRequirer exposes several useful plugin options for configuring aliases, import modes and quotes. These are available under Preferences -> Package Settings -> Node Require or search for NodeRequirer: Set plugin options

Example User Plugin Preferences

{
    // Type of quotes to use
    "quotes": "single || double",

    // Use 'var', 'const', or 'let' variable declarations
    "var": "var",

    // Use ES6 import format, when syntactically correct. Use detect to determine based on file buffer
    "import": "detect",

    // Whether to use ES6 import or require in detect mode when
    // the format could not be identified (e.g. when neither were used in file)
    "detect_prefer_import": true,

    "alias": {
        // <module name>: <variable name>
        "underscore": "_"
    },

    // Use object destructuring when assigning multiple exports
    "destructuring": false,

    // Use snippets when inserting require statements to allow
    // for easy variable name changing
    "snippet": true,
    // Directories to exclude when searching for files to require
    // The default directories excluded are [".git", "bower_components", "node_modules"]
    "exclude_dirs": [".git", "bower_components", "node_modules", "somerandom_directory"],
    // File patterns to include in searches. Basically does a substring search.
    // Default patterns:
    "importable_extensions": [
        // plain js
        "js", "jsx", "tsx",
        // css
        "css", "less", "scss",
        // images
        "svg", "jpg", "png", "gif",
        // templates
        "hbs", "html", "ejs",
        // schemas
        "yaml", "json", "xml"
    ]
}

Installation

Through Sublime Package Manager

  • Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X
  • type install, select Package Control: Install Package
  • type NodeRequirer, select NodeRequirer

Options

You can configure project aliases and quote options in the plugin options ctrl+shift+p and find NodeRequirer: Set Plugin Options

Manually

Make sure you use the right Sublime Text folder. For example, on OS X, packages for version 2 are in ~/Library/Application\ Support/Sublime\ Text\ 2, while version 3 is labeled ~/Library/Application\ Support/Sublime\ Text\ 3.

These are for Sublime Text 3:

Mac

git clone https://github.com/ganemone/NodeRequirer.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/NodeRequirer

Linux

git clone https://github.com/ganemone/NodeRequirer.git ~/.config/sublime-text-3/Packages/NodeRequirer

Windows

git clone https://github.com/ganemone/NodeRequirer.git "%APPDATA%/Sublime Text 3/Packages/NodeRequirer"