Ⅰ. 插件描述
A vim plugin for Android development when building with Gradle.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'meonlol/vim-grand'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'meonlol/vim-grand'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'meonlol/vim-grand'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/meonlol/vim-grand
Ⅳ. 文档说明
Vim-Grand - a Gradle Android plugin for the vim editor
This is a Vim plugin for Android development using Gradle as a build system,
supporting Robolectric Unit Testing. It is based on the excellent
hsanson/vim-android plugin, except
that it is written mostly in ruby, is unit tested, and exclusively supports
the Gradle build system. If you'd like to use ant/maven, or don't need
unit-testing, maybe hsanson's plugin will do the trick.
NOTICE:
Since I'm no longer working with Android professionally, and the scale of the
java projects I am currently working on is way to mutch for Javacomplete, I'm
not using the plugin right now. The plugin is therefor currently in hiatus.
Pull requests are welcome though.
Requirements
- Ruby 1.9.3+
- Android SDK installed with the $ANDROID_HOME environment variable set.
- Gradle 2.0+ (?) or a gradle wrapper in the project.
- exuberant-ctags for the
GrandTagscommand. - scrooloose/syntastic for syntax
checking. meonlol/javacomplete For code
- My fork might still litter your :messages window a bit, but at
- it works.
Recommended
- Tim Pope's Dispatch vim-grand will
run the appropriate commands through it, so vim doesn't get blocked. Highly
recommended.
- YouCompleteMe for managing
additional autocompletion features.
Installation
If you don't use one already, install a package manager plugin like Pathogen
or Vundle. It makes installing as simple as:
Vundle:
- Add the line
Plugin 'hsanson/vim-android'to your .vimrc - Call
:so %on the updated .vimrc to reload it. - Run
:PluginInstallto let vundle install it for you.
Pathogen:
Copy and past into the terminal:
cd ~/.vim/bundle
git clone git://github.com/tpope/vim-fugitive.git
vim -u NONE -c "helptags vim-fugitive/doc" -c q
Features
:GrandSetup Sets up all the project paths for javacomplete and syntastic.
When used in combination with the grand.gradle script, all paths defined in
your build.gradle will also be used for autocompletion and syntax checking.
:GrandTags Generates a tags file in the background using exuberant-ctags.
This way you can jump to classes (even Androids source files) simply by
pressing CTRL-].
:GrandInstall Installs your project on all connected devices (you'll still
have to manually start the app. It's in the TODO list).
Setup
Output Paths
To have the plugin know what dependencies you have in your project, add this
line to your build.gradle file:
apply from: 'https://raw.githubusercontent.com/meonlol/vim-grand/master/grand.gradle'When you now call ./gradlew outputPaths on the commandline, a text file is
generated containing gradle's paths. Every time GrandSetup is called, this
file is parsed for new paths. So if you change a dependency in build.gradle
run the 'outputPaths' command again and vim-grand will know about it.
Customize paths
If javacomplete gets slow, it might have to many paths to search. Open the.grand_source_paths file and customize what paths are to be used where,
according to the following rules:
- some/path # Path is ignored
c some/other/path # Used for completion javacomplete only
s some/jar.jar # Used for syntastic only
+ some/sources # Used everywhere
Additional setup for a pleasant experience
These tweaks and mappings for in you .vimrc will make you happy.
Update tags on save
"Run GrandCtags command every time you save a java file
autocmd BufWritePost *.java silent! GrandCtagsRun tests using vim-dispatch
"Use vim-dispatch to run gradleTest when you press <leader>ua
autocmd FileType java nnoremap <leader>ua :w<bar>Dispatch gradle test -q<CR>Output formatting
The formatting of the gradles test output is really messy. I'll try and improve
this soon, but in the mean time, you can use [this
gist](https://gist.github.com/meonlol/c5e84ca21a768fd76a7d) to make it
look acceptable.
Running one test
Don't want to run all the tests every time? The robolectric plugin does not
support that yet. You can add [this little
gist](https://gist.github.com/meonlol/3f222f8687073c46cd64) to your
build.gradle under robolectric {}. Then you can call `gradle test -q
-Dclasses=AwesomeTestClass` from the commandline, or you could use this mapping
from vim:
"This runs the robolectric test for the current buffer with <leader>uc
autocmd FileType java nnoremap <leader>uc :w<bar>Dispatch gradle test -q -Dclasses=%:t:r<CR>TODO:
- [ ] Some refactoring (project not clean)
- [ ] add vimdocs
- [ ] GradleInstall should also launch app
[ ] Integrated testing with jumpable test results
- [ ] build using Dispatch
- [ ] parse test-result xml to build quickfix
Contributing
Please do! You know the drill. Just
issue and
pull.
License
Copyright (c) Leon Moll. Distributed under the same terms as Vim itself.
See :help license.