Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@xolox authored
View
3  autoload/xolox/lua.vim
@@ -285,7 +285,7 @@ endfunction
function! s:addsignatures(entries)
for entry in a:entries
let signature = xolox#lua#getsignature(entry.word)
- if !empty(signature)
+ if !empty(signature) && signature != entry.word
let entry.menu = signature
endif
endfor
@@ -386,6 +386,7 @@ function! xolox#lua#getomnivariables(modules) " {{{1
let starttime = xolox#misc#timer#start()
let output = xolox#lua#dofile(s:omnicomplete_script, a:modules)
let variables = eval('[' . substitute(output, '\_s\+', ',', 'g') . ']')
+ call sort(variables, 1)
let msg = "%s: Collected %i variables for omni completion in %s"
call xolox#misc#timer#stop(msg, s:script, len(variables), starttime)
return variables
View
2  ftplugin/lua.vim
@@ -3,7 +3,7 @@
" Author: Peter Odding <peter@peterodding.com>
" Last Change: June 14, 2011
" URL: http://peterodding.com/code/vim/lua-ftplugin
-" Version: 0.6.5
+" Version: 0.6.6
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3625 1 :AutoInstall: lua.zip
View
23 misc/lua-ftplugin/omnicomplete.lua
@@ -25,11 +25,15 @@ local function isident(s)
return type(s) == 'string' and s:find('^[A-Za-z_][A-Za-z_0-9]*$') and not keywords[s]
end
-local function addmatch(output, word, kind, desc)
- print(string.format("{'word':'%s','kind':'%s','menu':'%s'}", word, kind, desc))
+local function addmatch(word, kind, desc)
+ if not desc then
+ print(string.format("{'word':'%s','kind':'%s'}", word, kind))
+ else
+ print(string.format("{'word':'%s','kind':'%s','menu':'%s'}", word, kind, desc))
+ end
end
-local function dump(table, path, cache, output)
+local function dump(table, path, cache)
local printed = false
for key, value in pairs(table) do
if isident(key) then
@@ -37,17 +41,17 @@ local function dump(table, path, cache, output)
local vtype = type(value)
if vtype == 'function' then
printed = true
- addmatch(output, path, 'f', path .. '()')
+ addmatch(path, 'f', path .. '()')
elseif vtype ~= 'table' then
printed = true
- addmatch(output, path, 'v', path)
+ addmatch(path, 'v', nil)
else
if vtype == 'table' and not cache[value] then
cache[value] = true
- if dump(value, path, cache, output) then
+ if dump(value, path, cache) then
printed = true
else
- addmatch(output, path, 'm', path .. '[]')
+ addmatch(path, 'm', path .. '[]')
end
end
end
@@ -56,6 +60,11 @@ local function dump(table, path, cache, output)
return printed
end
+-- Add keywords to completion candidates.
+for kw, _ in pairs(keywords) do
+ addmatch(kw, 'k', nil)
+end
+
-- Load installed modules.
-- XXX What if module loading has side effects? It shouldn't, but still...
for _, modulename in ipairs(arg) do
Please sign in to comment.
Something went wrong with that request. Please try again.