jscs.vim


Ⅰ. 插件描述

A vim plugin that wraps `jscs -x` into a `:Format` command

Ⅱ. 基本信息

创建日期:  2016-04-09
使用用户:  3
Github星:  2
插件作者:  vimlab

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

## jscs.vim

A vim plugin that wraps jscs -x into a :Format command, for use within Vim.
Can accept range or operate on the whole file.

Installation

  • First, you need jscs installed globally: npm install jscs -g
  • Extract the files and put them in your VIM directory (usually ~/.vim/)

If you don't have a preferred installation method, I recommend installing
vim-plug and using the following configuration:

Plug 'mklabs/jscs.vim', { 'do': 'npm i jscs -g' }

so that vim-plug takes care of installing jscs for you.

:Format

The single command exposed by this plugin.

Accepts a range and is usable in Visual mode.

Ex.

plugin.commandSync('Cmd', {
    range: '',
    nargs: '*',
}, function( nvim, args, range, cb ) {
    try {
        incrementCalls()
        nvim.setCurrentLine(
            fmt('Command: Called', numCalls, 'times, args:', args, 'range:', range),
            cb )
    } catch ( err ) {
        cb( err )
    }
})

Running :Format while run jscs in fix mode on the whole file and replace the current buffer with the result.

plugin.commandSync('Cmd', {
  range: '',
  nargs: '*',
}, function (nvim, args, range, cb) {
  try {
    incrementCalls();
    nvim.setCurrentLine(
        fmt('Command: Called', numCalls, 'times, args:', args, 'range:', range),
        cb);
  } catch (err) {
    cb(err);
  }
});

Configuration

The default configuration uses airbnb styleguide, you can change the configuration used by jscs with:

let g:jscs_config = "/path/to/.jscsrc"

添加新评论