node


Ⅰ. 插件描述

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

Ⅱ. 基本信息

创建日期:  2013-07-28
使用用户:  1655
Github星:  794
插件作者:  Andri Möll

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'moll/node'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'moll/node'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'moll/node'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/moll/vim-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 andri@dot.ee, tweet at @theml or create an issue online.

添加新评论