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.
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.
To install using the Pathogen vim script do the following:
git clone https://github.com/JalaiAmitahl/maven-compiler.vim ~/.vim/bundle/
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/
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.
- 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
-
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
- The file detection script is to auto-detect the pom.xml file type and set the filetype and syntax values to pom
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.
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>
Copyright (c) Dan Taylor. Distributed under the same terms as Vim itself.