Giter Club home page Giter Club logo

lua_omni's Introduction

This is a mirror of http://www.vim.org/scripts/script.php?script_id=3331

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.

lua_omni's People

Contributors

rkowal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.