vim-gradle


Ⅰ. 插件描述

Create, compile and manage your Gradle projects without leaving vim!

Ⅱ. 基本信息

创建日期:  2018-06-03
使用用户:  1
Github星:  2
插件作者:  Henrique

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'hdiniz/vim-gradle-may-fear-less'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

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

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'hdiniz/vim-gradle-may-fear-less'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'hdiniz/vim-gradle-may-fear-less'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

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

Ⅳ. 文档说明

Build Status

vim-gradle

Create, compile and manage your Gradle projects without leaving vim!

Installation

Plug 'hdiniz/vim-gradle'

The plugin will use your project's Gradle wrapper or fallback to a Gradle installation.
Some commands (:GradleInit [args], :GradleWrapper [args]) will require a Gradle installation.

Usage

By default, you Gradle project will be loaded you open vim under a Gradle project. See |autoload|.
When the project is detected, the :Gradle <args> command becomes available:

:Gradle compile

Erros detected during built populate vim's quickfix window:

:copen

Commands

:Gradle[!] {args}

Compiles the project passing {args} to the Gradle binary.
The build is started asynchronously and the output is
redirected to a output window.

quickfix errors are provided by the Gradle init script.

:GradleLoad

Manually loads the Gradle project based on current buffer or current directory. Use when autoloading is disabled. See g:vim_gradle_autoload

:GradleInit {args}

*Requires Gradle installation

Runs gradle init {args} on current directory.

:GradleWrapper {args}

*Requires Gradle installation

Runs gradle wrapper {args} on current directory.

Options

g:vim_gradle_autoload

Default: 1

When a new buffer is open search 'build.gradle' and 'build.gradle.kts' files up on the directory tree.

If disabled, projects can be loaded via :GradleLoad.

g:vim_gradle_enable_rtp

Default: 1

Allows vim-gradle to load additional gradle init script from vim-gradle extensions.

g:vim_gradle_bin

Default: ''

Absolute path to the Gradle binary. Used for out-of-project commands and projects without a Gradle Wrapper.
Overrides |g:vim_gradle_home| and $GRADLE_HOME.

g:vim_gradle_home

Default: ''

Absolute path to a Gradle installation. Used for out-of-project commands and projects without a Gradle Wrapper.
Overrides $GRADLE_HOME.

Airline

TODO: support airline parts on project files and compilation window

Extensions

Extensions can hook into Gradle init scripts by defining the function:

[plugin]/autoload/gradle/extensions/{extension_name}.vim

let s:gradle_folder_path = escape( expand( '<sfile>:p:h:h:h:h' ), '\' ) . '/gradle/'

function! gradle#extensions#{extension_name}#build_scripts()
    return [s:gradle_folder_path . 'extension_name.gradle']
endfunction

This can be used to define custom tasks and plugins on the project. The references scripts will load after the rootProject has been evaluated.

Java Extension Example

def errorListener = {
    def match = it =~ /([^:]+):(\d+):(\d*) (?:(e)rror|(w)arning): (.+)/
    if (match.size() > 0) {
        // Log to vim temp file
        vimLog("javac quickfix: $it")
        // Populate vim quickfix (type, file, line, column, message)
        vimQuickfix(match[0][5], match[0][1], match[0][2], match[0][3], match[0][6])
    }
} as StandardOutputListener

allprojects { project ->
    project.afterEvaluate {
        tasks.withType(JavaCompile).each {
            // Enable javac lint options
            it.options.compilerArgs << "-Xlint:all"
            // Capture javac stderr
            it.logging.addStandardErrorListener(errorListener)
        }
    }
}

License

MIT

添加新评论