# Miscellaneous auto-load Vim scripts
The vim-misc plug-in contains Vim scripts that are used by most of the [Vim
plug-ins I've written] [plugins] yet don't really belong with any single one of
the plug-ins. Basically it's an extended standard library of Vim script
functions that I wrote during the development of my Vim profile and plug-ins.
In the past these scripts were bundled with each plug-in, however that turned
out to be a maintenance nightmare for me. That's why the miscellaneous scripts
are now a proper plug-in with their own page on Vim Online.
Because the miscellaneous scripts are no longer bundled with my Vim plug-ins,
users are now required to install the miscellaneous scripts separately. This is
unfortunate for users who are upgrading from a previous release that did bundle
the miscellaneous scripts, but I don't see any way around this. Sorry!
## Installation
Please refer to the [installation instructions] [howto-install] on GitHub.
## Function documentation
Below is the documentation for the functions included in the miscellaneous
scripts. Anyone is free to use these functions in their own Vim profile and/or
plug-ins. I care about backwards compatibility so won't break it without a good
reason to do so.
For those who are curious: The function descriptions given below were extracted
from the source code of the miscellaneous scripts using the Python module
`vimdoctool.py` included in [vim-tools] [].
<!-- Start of generated documentation -->
The documentation of the 95 functions below was extracted from
19 Vim scripts on April 1, 2015 at 23:39.
### Asynchronous Vim script evaluation
The `xolox#misc#async#call()` function builds on top of `xolox#misc#os#exec()`
to support asynchronous evaluation of Vim scripts. The first (and for now
only) use case is my [vim-easytags][] plug-in which has a bunch of
conflicting requirements:
1. I want the [vim-easytags][] plug-in to be as portable as possible.
Ideally everything is implemented in Vim script because that's the only
thing I can rely on to be available for all potential users of the
plug-in!
2. Because of point one I've been forced to implement tags file reading,
parsing, (fold case) sorting and writing in Vim script. This is fine for
small tags files but once they grow to a couple of megabytes it becomes
annoying because Vim is unresponsive during tags file updates (key
presses are fortunately buffered due to Vim's input model but that
doesn't make it a nice user experience :-).
3. I could (and did in the past) come up with all sorts of hacks to speed
things up without switching away from Vim script, but none of them are
going to solve the fundamental problem that Vim's unresponsive hiccups
become longer as tags files grow larger.
By now it should be clear where this is heading: _Why not handle tags file
updates in a Vim process that runs in the background without blocking the
Vim process that the user is interacting with?_ It turns out that there are
quite a few details to take care of, but with those out of the way, it might
just work! I'm actually hoping to make asynchronous updates the default mode
in [vim-easytags][]. This means I need this functionality to be as
portable and robust as possible.
**Status:** This code has seen little testing so I wouldn't trust it too
much just yet. On the other hand, as I said, my intention is to make this
functionality as portable and robust as possible. You be the judge :-).
[vim-easytags]: http://peterodding.com/code/vim/easytags/
#### The `xolox#misc#async#call()` function
Call a Vim script function asynchronously by starting a hidden Vim process
in the background. Once the function returns the hidden Vim process
terminates itself. This function takes a single argument which is a
dictionary with the following key/value pairs:
- **function** (required): The name of the Vim function to call inside
the child process (a string). I suggest using an [autoload][] function
for this, see below.
- **arguments** (optional): A list of arguments to pass to the function.
This list is serialized to a string using [string()][] and deserialized
using [eval()][].
- **callback** (optional): The name of a Vim function to call in the
parent process when the child process has completed (a string).
- **clientserver** (optional): If this is true (1) the child process will
notify the parent process when it has finished (the default is true).
This works using Vim's client/server support which is not always
available. As a fall back Vim's [CursorHold][] automatic command is
also supported (although the effect is not quite as instantaneous :-).
This functionality is experimental and non trivial to use, so consider
yourself warned :-).
**Limitations**
I'm making this functionality available in [vim-misc][] because I think it
can be useful to other plug-ins, however if you are going to use it you
should be aware of the following limitations:
- Because of the use of multiple processes this functionality is only
suitable for 'heavy' tasks.
- The function arguments are serialized to a string which is passed to
the hidden Vim process as a command line argument, so the amount of
data you can pass will be limited by your operating environment.
- The hidden Vim process is explicitly isolated from the user in several
ways (see below for more details). This is to make sure that the hidden
Vim processes are fast and don't clobber the user's editing sessions in
any way.
**Changes to how Vim normally works**
You have to be aware that the hidden Vim process is initialized in a
specific way that is very different from your regular Vim editing
sessions:
- Your [vimrc][] file is ignored using the `-u NONE` command line option.
- Your [gvimrc][] file (if you even knew it existed ;-) is ignored using
the `-U NONE` command line option.
- Plug-in loading is skipped using the `--noplugin` command line option.
- Swap files (see [swap-file][]) are disabled using the `-n` command line
option. This makes sure asynchronous Vim processes don't disturb the
user's editing session.
- Your [viminfo][] file is ignored using the `-i NONE` command line
option. Just like with swap files this makes sure asynchronous Vim
processes don't disturb the user's editing session.
- No-compatible mode is enabled using the `-N` command line option
(usually the existence of your vimrc script would have achieved the
same effect but since we disable loading of your vimrc we need to spell
things out for Vim).
**Use an auto-load function**
The function you want to call is identified by its name which has to be
defined, but I just explained above that all regular initialization is
disabled for asynchronous Vim processes, so what gives? The answer is to
use an [autoload][] function. This should work fine because the
asynchronous Vim process 'inherits' the value of the ['runtimepath'][]
option from your editing session.
['runtimepath']: http://vimdoc.sourceforge.net/htmldoc/options.html#'runtimepath'
[autoload]: http://vimdoc.sourceforge.net/htmldoc/eval.html#autoload
[CursorHold]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#CursorHold
[eval()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#eval()
[gvimrc]: http://vimdoc.sourceforge.net/htmldoc/gui.html#gvimrc
[string()]: http://vimdoc.sourceforge.net/htmldoc/eval.html#string()
[swap-file]: http://vimdoc.sourceforge.net/htmldoc/recover.html#swap-file
[vim-misc]: http://peterodding.com/code/vim/misc/
[viminfo]: http://vimdoc.sourceforge.net/htmldoc/starting.html#viminfo
[vimrc]: http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc
#### The `xolox#misc#async#inside_child()` function
Entry point inside the hidden Vim process that runs in the background.
Invoked indirectly by `xolox#misc#async#call()` because it runs a command
similar to the following:
vim --cmd 'call xolox#misc#async#inside_child(...)'
This f
没有合适的资源?快使用搜索试试~ 我知道了~
杂项自动加载Vim脚本_Vim Script_下载.zip
共27个文件
vim:21个
md:2个
txt:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 167 浏览量
2023-04-22
16:09:39
上传
评论
收藏 67KB ZIP 举报
温馨提示
杂项自动加载Vim脚本_Vim Script_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
杂项自动加载Vim脚本_Vim Script_下载.zip (27个子文件)
vim-misc-master
doc
misc.txt 54KB
autoload
xolox
misc
option.vim 4KB
str.vim 2KB
cursorhold.vim 3KB
format.vim 2KB
list.vim 1KB
path.vim 10KB
tests.vim 15KB
test.vim 5KB
persist.vim 2KB
os.vim 12KB
version.vim 2KB
timer.vim 5KB
async.vim 13KB
buffer.vim 3KB
complete.vim 840B
escape.vim 2KB
perm.vim 5KB
echo.exe 8KB
open.vim 4KB
msg.vim 4KB
misc.vim 202B
addon-info.json 115B
plugin
xolox
misc.vim 527B
.gitignore 9B
README.md 40KB
INSTALL.md 2KB
共 27 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功