• Stars
    star
    808
  • Rank 54,388 (Top 2 %)
  • Language
    Ruby
  • License
    Other
  • Created almost 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tools and environment to make Vim superb for developing with Node.js. Like Rails.vim for Node.

Node.vim

Build status

Tools to make Vim superb for developing with Node.js.
It's the Node equivalent of Rails.vim (vimscript #1567) and Rake.vim (vimscript #3669).

This is just the first release to get the nodes rolling. If you've collected great helpers and shortcuts that help you work with Node, please share them via email, Twitter or GitHub issues so we could incorporate them here, too! Thanks!

Tour

  • Use gf on paths or requires to open the same file Node.js would.
  • Use gf on require(".") to open ./index.js
  • Use gf on require("./dir") to open ./dir/index.js
  • Use gf on require("./foo") to open foo.js.
  • Use gf on require("./package") and have it open package.json.
  • Use gf on require("module") to open the module's main file (parsed for you from package.json).
  • Use gf on require("module/lib/utils") and open files inside the module.
  • Automatically sets the filetype to JavaScript for files with Node's shebang (#!).
  • Use [I etc. to look for a keyword in required files (Sets Vim's &include).
  • Use :Nedit to quickly edit any module, file in a module or your project file.
  • Use :Nopen to quickly edit any module and lcd to its directory.
  • Lets you even open Node's core modules. They're shown straight from Node's online repository without you having to download everything.
  • Node.vim itself is tested with a thorough automated integration test suite! No cowboy coding here!

Expect more to come soon and feel free to let me know what you're after!

PS. Node.vim is absolutely intended to work on Windows, but not yet tested there at all. If you could help, try it out and report issues, I'd be grateful!

Installing

The easiest and most modular way is to download this to ~/.vim/bundle:

mkdir -p ~/.vim/bundle/node

Using Git:

git clone https://github.com/moll/vim-node.git ~/.vim/bundle/node

Using Wget:

wget https://github.com/moll/vim-node/archive/master.tar.gz -O- | tar -xf- --strip-components 1 -C ~/.vim/bundle/node

Then prepend that directory to Vim's &runtimepath (or use Pathogen):

:set runtimepath^=~/.vim/bundle/node

Vundle

Or use Vundle:

:BundleInstall moll/vim-node

Using

Open any JavaScript file inside a Node project and you're all set.

  • Use gf inside require("...") to jump to source and module files.
  • Use [I on any keyword to look for it in the current and required files.
  • Use :Nedit module_name to edit the main file of a module.
  • Use :Nedit module_name/lib/foo to edit its lib/foo.js file.
  • Use :Nedit . to edit your Node projects main (usually index.js) file.

Want to customize settings for files inside a Node projects?

Use the Node autocommand. For example:

autocmd User Node if &filetype == "javascript" | setlocal expandtab | endif

Want <C-w>f to open the file under the cursor in a new vertical split?

<C-w>f by default opens it in a horizontal split. To have it open vertically, drop this in your vimrc:

autocmd User Node
  \ if &filetype == "javascript" |
  \   nmap <buffer> <C-w>f <Plug>NodeVSplitGotoFile |
  \   nmap <buffer> <C-w><C-f> <Plug>NodeVSplitGotoFile |
  \ endif

Viewing Node.js core modules

Open Vim in the directory of a Node.js project and use :Nedit with the name of the core module:

:Nedit http

This downloads a single file from the Node.js repository for your Node version through https://rawgit.com. If you'd like to change the base URL, set g:node_repository_url:

let node_repository_url = "https://example.com/nodejs/node"

License

Node.vim is released under a Lesser GNU Affero General Public License, which in summary means:

  • You can use this program for no cost.
  • You can use this program for both personal and commercial reasons.
  • You do not have to share your own program's code which uses this program.
  • You have to share modifications (e.g bug-fixes) you've made to this program.

For more convoluted language, see the LICENSE file.

About

Andri Möll authored this in SublemacslipseMate++.
Monday Calendar supported the engineering work.

If you find Node.vim needs improving or you've got a question, please don't hesitate to email me anytime at [email protected], tweet at @theml or create an issue online.

More Repositories

1

vim-bbye

Delete buffers and close files in Vim without closing your windows or messing up your layout. Like Bclose.vim, but rewritten and well maintained.
Vim Script
637
star
2

node-mitm

Intercept and mock outgoing Node.js network TCP connections and HTTP requests for testing. Intercepts and gives you a Net.Socket, Http.IncomingMessage and Http.ServerResponse to test and respond with. Super useful when testing code that hits remote servers.
JavaScript
635
star
3

json-stringify-safe

Like JSON.stringify, but doesn't throw on circular references
JavaScript
543
star
4

js-must

An assertion library for JavaScript and Node.js with a friendly BDD syntax (awesome.must.be.true()). It ships with many expressive matchers and is test runner and framework agnostic. Follows RFC 2119 with its use of MUST. Good stuff and well tested.
JavaScript
334
star
5

capistrano-rsync

Deploy with Rsync from any local (or remote) repository when using Capistrano. Capistrano v3 ready!
Ruby
125
star
6

js-ddl

Gets you a JSON Schema from PostgreSQL or SQLite3. Also supports arrays and default values. Use it for introspection or preparing your domain models like with Rails's Active Record.
JavaScript
68
star
7

js-fetch-defaults

Fetch API mixin to set a default base URL and options. Functional and immutable.
JavaScript
55
star
8

mina-rsync

Deploy with Rsync from any local (or remote) repository when using Mina.
Ruby
50
star
9

js-concert

An event library for JavaScript and Node.js that implements the observer pattern (a.k.a publish/subscribe). Similar to Node's EventEmitter and Backbone.Events, but independent, minimal and light-weight.
JavaScript
43
star
10

js-standard-error

Tiny JavaScript library that simplifies subclassing and inheriting from Error while keeping the correct name and stack. Also supports constructing from an object of properties. Saves you from boilerplate.
JavaScript
41
star
11

js-undersign

A JavaScript library for creating eIDAS compatible XAdES signatures, incl. support for OCSP, timestamps and ASIC-E. Works also with the Estonian Id-card, Mobile-Id and Smart-Id out of the box.
JavaScript
29
star
12

js-strange

Range object for JavaScript. Supports exclusive and infinite ranges. Stringifies to PostgreSQL compatible format.
JavaScript
26
star
13

node-pg-error

An error class for Node.js that parses PostgreSQL's ErrorResponse format and sets human readable field names. Works with node-pg, too.
JavaScript
22
star
14

sh-chnode

Change between installed Node versions in your current shell.
Shell
22
star
15

js-promise-defer

JavaScript Polyfill for Promise.defer. Uses the native ES6 Promise. Supports other Promises/A+ implementations.
JavaScript
22
star
16

js-standard-http-error

Standard HTTP error class for Node.js. Proper serialization, no bloat. Extensible.
JavaScript
19
star
17

js-element-from-point

A consistent cross-browser document.elementFromPoint function. Works around idiosyncracies of old WebKits et al.
Makefile
11
star
18

node-require-guard

Prevent files and modules being required more than once. Helps with auto-reloaders or test runners that insist.
JavaScript
9
star
19

js-oolong

Object utility library for JavaScript. Simple, tasteful and plentiful. Supports inherited properties.
JavaScript
8
star
20

js-hugml

An XML parsing and serializing library based on Google's GDATA and BadgerFish conventions. Supports namespaces.
JavaScript
7
star
21

js-j6pack

JavaScript library to render JSX to JavaScript and HTML on the web or on Node.js. Works with Express.js. No React dependency, no virtual DOM.
JavaScript
7
star
22

js-co-next

JavaScript function to use generators for request handlers and middleware. Calls next only if there was an error. Useful for Express routes.
JavaScript
7
star
23

js-internet-message

Library for JavaScript to parse and stringify RFC 822 ARPA Internet Text Messages. Useful format for messages with headers and body. Similar to HTTP.
JavaScript
6
star
24

js-sqlate

A tiny tagged template string function library for JavaScript to write SQL safely. Works with Mapbox's SQLite3 library, Brian Carlson's PostgreSQL library and others.
JavaScript
6
star
25

js-lazy-object

JavaScript library to define lazy properties on objects that are initialized once and only when accessed. Also known as a lazy initialization and cached/memoized getters.
JavaScript
6
star
26

js-medium-type

JavaScript library for parsing, stringifying and manipulating media types. Useful for content negotiation. Follows RFC2045, supports quoted parameters, all allowed characters etc.
JavaScript
5
star
27

js-kindof

A proper typeof that works with primitives, built-in value objects and those from other execution contexts.
JavaScript
5
star
28

js-syslog-protocol

Syslog (RFC 3164) parser. Works with RFC 3339/ISO 8601 timestamps.
JavaScript
5
star
29

nutikaitse

CSS
5
star
30

js-fetch-parse

Fetch API mixin to buffer and parse response bodies. Supports media type patterns for content type specific custom parsers.
JavaScript
4
star
31

node-selenium-dom

SeleniumDom.js is a mixin library for Node.js's Selenium WebDriver that adds **DOM methods** to Selenium's `WebDriver` and `WebElement`.
JavaScript
4
star
32

js-square-batman

A small JavaScript scheduling algorithm library. Useful for round-robin etc.
JavaScript
4
star
33

js-fetch-jsonify

Fetch API mixin for stringifying JSON and setting Content-Type if unset. Functional and immutable.
JavaScript
3
star
34

js-egal

Strict equality test (like ===) for JavaScript that handles both built-in and custom value objects (those with a valueOf function).
JavaScript
3
star
35

node-syslogh

Log to your system's Syslog from within Node.js. Provides simple native bindings to <syslog.h> and syslog(3). Works on Node v0.10 up to v4 and beyond.
C++
3
star
36

browserify-substitution-mass-confusion

Browserify plugin for substituting modules everywhere. It expands the package.json "browser" field to work for nested dependencies.
JavaScript
3
star
37

node-fetch-off

Fetch API polyfill and facade. Its request and response wrappers can be used separately: use fetch for request yet get back Node's Http.get response (IncomingMessage) for streaming.
JavaScript
2
star
38

js-internet-message-type

Library for JavaScript to parse RFC 822 ARPA Internet Text Messages types and bodies. Works well with InternetMessage.js.
JavaScript
2
star
39

exportjs

A tool that helps you publish and export your JavaScripts to other environments by wrapping them in an IIFE. Or UMD in the future.
JavaScript
1
star
40

js-fetch-error

A JavaScript library for an error class for use with the Fetch API.
JavaScript
1
star
41

js-soul

Soul.js is a simple yet extensible mutable model library for JavaScript.
JavaScript
1
star
42

js-descend

Function to set up an inherited class that calls its ancestor constructors automatically. Can also be attached to constructors.
JavaScript
1
star
43

js-fetch-throw

A JavaScript Fetch API mixin to throw FetchError when the request fails or response has an error.
JavaScript
1
star
44

node-flash-fiction

Flash messages middleware for Express/Connect with support for redirects and immediate use. Useful for informational or errors messages. Like Rails's Flash.
JavaScript
1
star
45

js-overstrike

A utility library in the style of Underscore.js with consistent inherited property handling, the simplest implementation and curation by yours truly.
JavaScript
1
star
46

js-fetch-formify

Fetch API mixin for urlencoding an object and setting Content-Type if unset. Functional and immutable.
JavaScript
1
star