Skip to content

Commit

Permalink
Updated voodoo to highlight known table fields :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Aug 18, 2010
1 parent 035e58f commit 4126f67
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions luainspect4vim.lua
Expand Up @@ -11,6 +11,7 @@
local LI = require 'luainspect.init'
local LA = require 'luainspect.ast'
local LT = require 'luainspect.types'
local MAX_PREVIEW_KEYS = 20
local actions = {}
local myprint
Expand All @@ -37,12 +38,6 @@ local function getcurvar(tokenlist, line, column) -- {{{1
end
end
local function knownvarorfield(token) -- {{{1
local a = token.ast
local v = a.seevalue or a
return a.definedglobal or v.valueknown and v.value ~= nil
end
function actions.highlight(tokenlist, line, column, src) -- {{{1
local function dump(token, hlgroup)
local l1, c1 = unpack(token.ast.lineinfo.first, 1, 2)
Expand All @@ -69,7 +64,7 @@ function actions.highlight(tokenlist, line, column, src) -- {{{1
end
if token.tag == 'Id' then
if not token.ast.localdefinition then
dump(token, knownvarorfield(token) and 'luaInspectGlobalDefined' or 'luaInspectGlobalUndefined')
dump(token, token.ast.definedglobal and 'luaInspectGlobalDefined' or 'luaInspectGlobalUndefined')
elseif not token.ast.localdefinition.isused then
dump(token, 'luaInspectLocalUnused')
elseif token.ast.localdefinition.functionlevel < token.ast.functionlevel then
Expand All @@ -82,7 +77,12 @@ function actions.highlight(tokenlist, line, column, src) -- {{{1
dump(token, 'luaInspectLocal')
end
elseif token.ast.isfield then
dump(token, knownvarorfield(token) and 'luaInspectFieldDefined' or 'luaInspectFieldUndefined')
local a = token.ast
if a.definedglobal or not LT.istype[a.seevalue.value] and a.seevalue.value ~= nil then
dump(token, 'luaInspectFieldDefined')
else
dump(token, 'luaInspectFieldUndefined')
end
end
end
end
Expand Down

0 comments on commit 4126f67

Please sign in to comment.