Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improve omni completion: support for keywords, less clutter

The description on the right hand side of the completion pop-up window
is now only shown when it has some useful information to convey. This
makes it easier to visually parse the pop-up window.
  • Loading branch information...
commit bfd570128a6890c6c2baa4f9043af9c41b1af363 1 parent 9e42b06
Peter Odding authored June 14, 2011
3  autoload/xolox/lua.vim
@@ -285,7 +285,7 @@ endfunction
285 285
 function! s:addsignatures(entries)
286 286
   for entry in a:entries
287 287
     let signature = xolox#lua#getsignature(entry.word)
288  
-    if !empty(signature)
  288
+    if !empty(signature) && signature != entry.word
289 289
       let entry.menu = signature
290 290
     endif
291 291
   endfor
@@ -386,6 +386,7 @@ function! xolox#lua#getomnivariables(modules) " {{{1
386 386
   let starttime = xolox#misc#timer#start()
387 387
   let output = xolox#lua#dofile(s:omnicomplete_script, a:modules)
388 388
   let variables = eval('[' . substitute(output, '\_s\+', ',', 'g') . ']')
  389
+  call sort(variables, 1)
389 390
   let msg = "%s: Collected %i variables for omni completion in %s"
390 391
   call xolox#misc#timer#stop(msg, s:script, len(variables), starttime)
391 392
   return variables
2  ftplugin/lua.vim
@@ -3,7 +3,7 @@
3 3
 " Author: Peter Odding <peter@peterodding.com>
4 4
 " Last Change: June 14, 2011
5 5
 " URL: http://peterodding.com/code/vim/lua-ftplugin
6  
-" Version: 0.6.5
  6
+" Version: 0.6.6
7 7
 
8 8
 " Support for automatic update using the GLVS plug-in.
9 9
 " GetLatestVimScripts: 3625 1 :AutoInstall: lua.zip
23  misc/lua-ftplugin/omnicomplete.lua
@@ -25,11 +25,15 @@ local function isident(s)
25 25
   return type(s) == 'string' and s:find('^[A-Za-z_][A-Za-z_0-9]*$') and not keywords[s]
26 26
 end
27 27
 
28  
-local function addmatch(output, word, kind, desc)
29  
-  print(string.format("{'word':'%s','kind':'%s','menu':'%s'}", word, kind, desc))
  28
+local function addmatch(word, kind, desc)
  29
+  if not desc then
  30
+    print(string.format("{'word':'%s','kind':'%s'}", word, kind))
  31
+  else
  32
+    print(string.format("{'word':'%s','kind':'%s','menu':'%s'}", word, kind, desc))
  33
+  end
30 34
 end
31 35
 
32  
-local function dump(table, path, cache, output)
  36
+local function dump(table, path, cache)
33 37
   local printed = false
34 38
   for key, value in pairs(table) do
35 39
     if isident(key) then
@@ -37,17 +41,17 @@ local function dump(table, path, cache, output)
37 41
       local vtype = type(value)
38 42
       if vtype == 'function' then
39 43
         printed = true
40  
-        addmatch(output, path, 'f', path .. '()')
  44
+        addmatch(path, 'f', path .. '()')
41 45
       elseif vtype ~= 'table' then
42 46
         printed = true
43  
-        addmatch(output, path, 'v', path)
  47
+        addmatch(path, 'v', nil)
44 48
       else
45 49
         if vtype == 'table' and not cache[value] then
46 50
           cache[value] = true
47  
-          if dump(value, path, cache, output) then
  51
+          if dump(value, path, cache) then
48 52
             printed = true
49 53
           else
50  
-            addmatch(output, path, 'm', path .. '[]')
  54
+            addmatch(path, 'm', path .. '[]')
51 55
           end
52 56
         end
53 57
       end
@@ -56,6 +60,11 @@ local function dump(table, path, cache, output)
56 60
   return printed
57 61
 end
58 62
 
  63
+-- Add keywords to completion candidates.
  64
+for kw, _ in pairs(keywords) do
  65
+  addmatch(kw, 'k', nil)
  66
+end
  67
+
59 68
 -- Load installed modules.
60 69
 -- XXX What if module loading has side effects? It shouldn't, but still...
61 70
 for _, modulename in ipairs(arg) do

0 notes on commit bfd5701

Please sign in to comment.
Something went wrong with that request. Please try again.