Ⅰ. 插件描述
omni completion for Lua plus few extrasⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/lua-omni'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/lua-omni'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/lua-omni'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/lua_omni
Ⅳ. 文档说明
This is my omni completion plugin for Lua. It works by scanning _G and parsing
Vim buffers. It's also possible to specify external text files with Lua names
paths (delimited with new line). It's a very useful feature when a module can
not be loaded or doesn't have iterable table exposed.
Nested tables are supported so you can type:
:lua foobar = {numbers = {one = 1, two = 2, three = 3}}
Then typing CTRL-X CTRL-O list of possible matches will open:
foobar.numbers.one
foobar.numbers.two
foobar.numbers.three
Actually you can use globbing "*" and "?" characters to speed up typing like:
f*tw CTRL-X CTRL-O
will output immediately:
foobar.numbers.two
Single word can be used as well:
three CTRL-X CTRL-O
will give:
foobar.numbers.three
Or even just "thr" will work too.
Another way use completion is without any asterisks like:
p.l.m CTRL-X CTRL-O
to get:
package.loaded.math
That is the new way of doing omni from this version. I've found it to be quicker
and more convenient than multiple hitting CTR-X CTRL-O.
Local variables completion works as before.
Some other functions are supported like listing defined Lua functions in
current buffer.
There are common Lua abbreviation defined in lua_omni.vim too.
Mappings:
CTRL-X CTRL-O
Calling the omni completion function.
<Leader>fl or <Plug>PrintFunctionList
Prints list of defined Lua functions in current buffer. They are listed in
ascending line numbers order. Luadoc titles (if defined) are showed too.
<Leader>lf or <Plug>WriteAndLuaFile
Just a shortcut to call:
:w
:luafile %
<Leader>sli or <Plug>SetLuaIabbrevs
Sets few common and useful insert mode abbreviations.
<Leader>cli or <Plug>ClearLuaIabbrevs
Clear any insert mode abbreviations set by previous shortcut.
lua_omni-settings
From 0.16 version there is support for external files with completion paths.
They can be specified via shell LUA_OMNI variable. Each file path should be
delimited by comma or semicolon. Additionally the same can done using Vim
b:lua_omni and g:lua_omni variables. The b: if exists will override g: however
shell LUA_OMNI will be read and used in all cases.
Format of completions files is very simple. Each line contains single Lua
path like:
foomodule.barPart
foomodule.barPart.spam
foomodule.barPart.spam.not
foomodule.barPart.spam.twice
foomodule.barPart.spam.multiply
foomodule.__inner
foomodule.__inner.foo
math2mod
math2mod.exp
math2mod.div
...
(and so on)
Order of lines is meaningless as results are sorted anyway.
You may try lapg.lua script to generate such completion list automatically.
From 0.17 version there is folding using foldexpr function. To enable it just
set foldenable option. It has configurable variables: g:lua_inner_folds and
b:lua_inner_folds. When set to 1 folding is nested. When not existent, or set
to other value than 1, folds will have one level only. Of course the b:
version will override the g:.
To regenerate folds use the zx or zX normal commands.
Though folding function try not to fold malformed blocks it depends on correct
order of opening/closing statements.