Ⅰ. 插件描述
A VIM maven compiler module / library.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'jalaiamitahl/maven-compiler'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'jalaiamitahl/maven-compiler'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'jalaiamitahl/maven-compiler'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/jalaiamitahl/maven-compiler.vim
Ⅳ. 文档说明
# Maven Compiler Setup for VIM
A pathogen installable module for VIM which readies VIM to be used as a Java development environment using the Maven build / dependency management system from Apache.
Installation
The Maven compiler setup can be installed in a few ways. The preferred method is by using Pathogen, but it can also be installed by unzipping the package to your ~/.vim/ directory.
Pathogen
To install using the Pathogen vim script do the following:
git clone https://github.com/JalaiAmitahl/maven-compiler.vim ~/.vim/bundle/Copy / Move
To install using the copy / move method, do the following in any directory:
if [ ! -d "~/.vim/ftdetect"]; then
mkdir ~/.vim/ftdetect
fi
if [ ! -d "~/.vim/compiler"]; then
mkdir ~/.vim/compiler
fi
if [ ! -d "~/.vim/syntax"]; then
mkdir ~/.vim/syntax
fi
git clone https://github.com/JalaiAmitahl/maven-compiler.vim
cp maven-compiler.vim/ftdetect/* ~/.vim/ftdetect/
cp maven-compiler.vim/compiler/* ~/.vim/compiler/
cp maven-compiler.vim/syntax/* ~/.vim/syntax/Contents
As a VIM module, this package contains the following:
- A syntax file containing highlighting rules for Maven's pom.xml files.
- A compiler file containing the compiler setup and error format setup.
- A file type detection script for pom.xml files to setup the filetype and syntax type for pom editing.
- A plugin to sort the quick fix list and strip duplicate and blank entries.
Component Notes
Syntax Script
- The syntax file currently hand codes / matches the full Maven POM notes.
- There are likely some tags which are handled in the proper Maven XSD that I have missed at this time. I will rectify that soon-ish.
To manually use the syntax script on a file not identified as a pom file:
` :set syntax=pom`
Compiler Script
- The compiler script catches and tosses plenty of information. This may be tweaked in the future.
- The build result line will be displayed.
- The quick fix window does not open by default. I need to determine how to fix this.
- To manually use the compiler on a java or pom.xml file:
:compiler mvn To use auto command to set the compiler any time a pom or java file is opened (assuming the pom ftdetect script is used):
autocommand Filetype java compiler mvn autocommand Filetype pom compiler mvn
File type detection script
- The file detection script is to auto-detect the pom.xml file type and set the filetype and syntax values to pom
Quick fix sort plugin
This script is based off of the script found here: Automatically Sort Quickfix List for VIM.
Modifications:
- Strip out any entries which don't have a text value.
Additional Info
Originally the compiler script set a few mappings, but these have been removed in the interest of not futzing with users settings. I now use autocmd to set the following on java file types:
- autocmd Filetype java no <F2> :make clean package<CR>
- autocmd Filetype java no <S-F2> :make clean package site site:stage<CR>
- autocmd Filetype java no <C-F2> :make clean<CR>
- autocmd Filetype java no <F3> :make
- autocmd Filetype java no <S-F3> :make clean deploy site site:stage site:deploy<CR>
License
Copyright (c) Dan Taylor. Distributed under the same terms as Vim itself.