Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better highlighting of selected variables

Previously the highlighting of the selected variable overruled the
regular highlighting which turned out to get annoying very quickly.
Now the plug-in respects DWIM by combining the two highlighting styles.
  • Loading branch information...
commit 026fdd42bca366b95a271c3b8c9fa78cbc17c0f9 1 parent b0b5800
@xolox authored
Showing with 14 additions and 6 deletions.
  1. +8 −3 luainspect.vim
  2. +6 −3 luainspect4vim.lua
View
11 luainspect.vim
@@ -2,7 +2,7 @@
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 12, 2010
" URL: http://peterodding.com/code/vim/lua-inspect/
-" Version: 0.3.4
+" Version: 0.3.5
" License: MIT
" Support for automatic update using the GLVS plug-in.
@@ -50,7 +50,7 @@ let s:groups['Param'] = 'guifg=#000040'
let s:groups['Local'] = 'guifg=#000080'
let s:groups['FieldDefined'] = 'guifg=#600000'
let s:groups['FieldUndefined'] = 'guifg=#c00000'
-let s:groups['SelectedVariable'] = 'Folded'
+let s:groups['SelectedVariable'] = 'CursorLine'
let s:groups['SyntaxError'] = 'SpellBad'
" (Automatic) command definitions. {{{1
@@ -232,11 +232,16 @@ function! s:clear_previous_matches() " {{{2
endfunction
function! s:highlight_variables() " {{{2
+ call clearmatches()
for line in b:luainspect_output[1:-1]
if s:check_output(line, '^\w\+\(\s\+\d\+\)\{3}$')
let [hlgroup, linenum, firstcol, lastcol] = split(line)
let pattern = s:highlight_position(linenum + 0, firstcol - 1, lastcol + 2)
- execute 'syntax match' hlgroup '/' . pattern . '/'
+ if hlgroup == 'luaInspectSelectedVariable'
+ call matchadd(hlgroup, pattern)
+ else
+ execute 'syntax match' hlgroup '/' . pattern . '/'
+ endif
endif
endfor
endfunction
View
9 luainspect4vim.lua
@@ -47,10 +47,13 @@ end
function actions.highlight(tokenlist, line, column)
local curvar = getcurvar(tokenlist, line, column)
for i, token in ipairs(tokenlist) do
- local kind
if curvar and curvar.ast.id == token.ast.id then
- kind = 'luaInspectSelectedVariable'
- elseif token.tag == 'Id' then
+ local l1, c1 = unpack(token.ast.lineinfo.first, 1, 2)
+ local l2, c2 = unpack(token.ast.lineinfo.last, 1, 2)
+ if l1 == l2 then myprint('luaInspectSelectedVariable ' .. l1 .. ' ' .. c1 .. ' ' .. c2) end
+ end
+ local kind
+ if token.tag == 'Id' then
if not token.ast.localdefinition then
if token.ast.definedglobal then
kind = 'luaInspectGlobalDefined'
Please sign in to comment.
Something went wrong with that request. Please try again.