vim-fetch


Ⅰ. 插件描述

Porting the nettuts-fetch plugin to Vim plugin - Fetch the latest version of remote files and zip / tar packages

Ⅱ. 基本信息

创建日期:  2011-12-28
使用用户:  4
Github星:  8
插件作者:  Mickael Daniel

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/mklabs/vim-fetch

Ⅳ. 文档说明

fetch.vim

Inspired by [nettuts-fetch][]. Porting the nettuts-fetch plugin to Vim plugin.

Fetch the latest version of remote files and zip / tar packages

Installation

Go through [pathogen][].

In addition, node is required and should be available in your path. It might
very well be reworked bit to only use vim script + curl / unzip / untar

  1. It was done this way as using a node script and JavaScript to hold
  2. bulk of the plugin functionality provides some advantages.

The node script may be wrapped in a little and simple cli tool, usable from the
console or integrated in other text-editors.

Usage

You'll only use two commands when working with Fetch. Fist, we need to
save some file references.

:FetchManage

To assign references to online asset files, we only need to create an object
like so (one will be pre-populated for you, that is the dictionary.json file
in this repo)

The :FetchManage command will open in the current buffer the assets
"dictionary".

{
  "jquery":             "http://code.jquery.com/jquery.min.js",
  "jquery-dev":         "http://code.jquery.com/jquery.js",
  "html5-boilerplate":  "http://github.com/h5bp/html5-boilerplate/tarball/master"
}

You can then edit these remote file, delete them or a new ones. This should be
valid json, the file is validated before saving. Once saved, the :Fetch
command and its completion should be updated right away.

Note

Unlike original nettuts fetch, I made the design decision of not
distinguishing files / and packages types of assets.

The script will do a best-guess based on the url and ending extension. If the
url includes a zipball or tarball (case of nodeload), then the remote files
is handled as a package and fetched / cached locally with proper extension.
Same for remote files ending with .zip or .tgz.

This should be improved to make an HEAD request prior to the local copy
application/octet-stream with attachment with .tgz or .zip files trigger the
package fetch.

For now, only .json files are supported. But in a near future, yaml or
even coffeescript / pure js may be too.

:Fetch

The :Fetch command reads the content of the remote assets dictionary
and provides you a command to "fetch them all".

The command should support a limited amount of completion.

:Fetch jquery
>> Fetch and dowload latest jquery minified version, putting it in ./assets/vendor/jquery.min.js

:Fetch html5-boilerplate
>> Fetch and dowload latest master version of h5bp, putting it in ./assets/vendor/h5bp

Going further

Sometimes you don't want a given file to be fetched at the default
location, but rather ./assets/js/libs when fetching jquery for
example.

Or maybe, you want to fetch h5bp package in the current working
directory directly.

You can do so by using this kind of syntax in the remote file
dictionary:

{
  "jquery":             "http://code.jquery.com/jquery.min.js (./assets/js/libs/jquery.min.js)",
  "jquery-dev":         "http://code.jquery.com/jquery.js (./assets/js/libs/jquery.js)",
  "html5-boilerplate":  "http://github.com/h5bp/html5-boilerplate/tarball/master (./)"
}

License & Acknowledgement

Some if not a big part of the vimscript code and function utilities come
either from [vim-rails][] (for the completion utilities), or [vim-rhubarb][]
(for the minimalist and awesome json parser / serializer).

[nettuts-fetch] for the original idea and Sublime Text 2 very handy plugin.

License: Same as Vim. See :help license.

添加新评论