Ⅰ. 插件描述
Minimal, asynchronous quickfix commands for Vim 8.0Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'foxik/vim-makejob-hands-off'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'foxik/vim-makejob-hands-off'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'foxik/vim-makejob-hands-off'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/foxik/vim-makejob
Ⅳ. 文档说明
# Vim MakeJob
This is a plugin for folks who think that Vim's quickfix feature is
great, but who don't like how calls to :make and :grep freeze the
- MakeJob implements asynchronous versions of the builtin
- in just a couple hundred lines of Vimscript.
Goals
- Implement a minimal solution for asynchronous
:makeand:grep.
No unnecessary features. - Let Vim be Vim. Use
makeprganderrorformatto configure
:MakeJoband the analogous grep options for:GrepJob. Use the
Quickfix or Location List window to view findings.
- Complete feature parity with
:makeand:grepper the steps
outlined in:help quickfix.autowrite,QuickFixCmdPreand
QuickFixCmdPost, and the bang operator work as expected.
Requirements
Vim compiled with +job, +channel, and of course +quickfix.
Installation
Pathogen
cd ~/.vim/bundle git clone https://github.com/djmoch/vim-makejob.git
Plug.vim
Plug 'djmoch/vim-makejob'
Most other plugin managers will resemble one of these two.
Usage
The Short Version
Vim has :make and :grep. Replace those calls with :MakeJob and:GrepJob. A buffer will open showing the command output, which will
be parsed into the Quickfix or LocationList window when the job
- Bask in your newfound freedom to do as you please in Vim
- MakeJob runs.
If MakeJob reports findings, use :copen to view the Quickfix window
(in the case of :MakeJob), and likewise :lopen to open the LocationList
for :LmakeJob. If the current buffer is showing the output of a
running MakeJob, or if it spawned a running MakeJob, then <C-c> stops
- There's also
:MakeJobStopto stop an arbitrary MakeJob (with - completion).
Speaking of :LmakeJob, all of the LocationList complements to the
Quickfix commands are there with _MakeJob_, bringing the full list of
commands to:
:MakeJob:MakeJobStop:LmakeJob:GrepJob:LgrepJob:GrepaddJob:LgrepaddJob
All of which work like their builtin counterparts. Those last two are
admittedly a bit longer than we would probably like, but if you grep a
lot you'll probably want to set a mapping for it anyway (see below).
The Less Short Version
Users of Syntastic may not be aware that Vim offers many of the same
features out of the box. Here's a brief rundown.
With no prior configuration, :make will run the make program with no
arguments, and populate the Quickfix list with any errors the process
- It's possible to change that behavior in one of two ways.
The hard way is to manually use:set makeprgto change the program
something else, and then use :set errorformat to configure the
format of the errors to look for. This gets pretty hairy, and so
we're all better off trying to avoid this in favor of the easy way:
compiler plugins. Using a compiler plugin easy (ex: :compiler javac),
they abstract away the work of remembering the errorformat, they're
extendable, and many are already included in Vim. MakeJob uses the
same compiler plugins users of Vim will be familiar with.
It's also possible to use theafter/ftplugin folder to automatically
configure compilers on a per-file-type basis. An example of that trick
would be to add the following to ~/.vim/after/ftplugin/python.vim:
compiler pylint
Add that and you're good to go for Python files (assuming you have a
pylint compiler which hey, if you need one I've [got you
covered](http://github.com/djmoch/vim-compiler)).
Additionally, if you'd like MakeJob to run a linter automatically when
you write a file, then something like the following in your .vimrc
will to the trick.
autocmd! BufWritePost * :LmakeJob! %<CR>
For more granular control, you can set this trigger on a per-file-type
basis with something like the following:
autocmd! BufWritePost *.py :LmakeJob! %<CR>
Grep is a powerful way to search through a directory structure for a
- I use it all the time, which is why I've added the following
- to my
.vimrc:
nnoremap <Leader>g :GrepJob!<Space>
Finally, if you find the preview windows distracting or otherwise
disruptive to your workflow, you can hide it with the following, global
setting:
let g:makejob_hide_preview_window = 1
Gotchas
If
grepprgis set to'internal', then Vim uses its own builtin grep- This still works when you call
:GrepJob, but not
asynchronously.
- This still works when you call
For simplicity, only one instance of a given executable can run at
- You can run
makeandpylint, but you can't run two - of
makesimultaneously.
- You can run
Vim Documentation
Part of the goal of MakeJob is to minimize the size of the plugin by
using features Vim already offers whenever possible. To that end, if
any of what foregoing discussion doesn't make sense, then take a look at
the help documentation in Vim. Of particular interest will probably
be the following:
:h make:h makeprg:h errorformat:h compiler:h quickfix
License
MIT - See the LICENSE file for more information