Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make argcount warning highlight only function names

  • Loading branch information...
commit 22b75bcf657d4f55e48cce3801613ee3e3086af1 1 parent 9d3f187
Peter Odding authored
Showing with 19 additions and 3 deletions.
  1. +4 −1 TODO.md
  2. +15 −2 luainspect4vim.lua
5 TODO.md
View
@@ -5,4 +5,7 @@
* Check whether "core/SciTE: jump to definition now supports functions in different files." is interesting.
* Argument count warning tool tips are only shown for parts of the highlighted text. This might have been fixed in recent changes to LuaInspect.
* Bug: The plug-in sometimes warns `Invalid output from luainspect4vim.lua: 'This is an unknown table field.'`. Mixup between tool tip / highlight response parsing?!
- * Dynamic highlighting using `matchadd()` performs **very** poorly when multiple consecutive lines are highlighted as `SpellLocal` -- so poorly that Vim becomes pretty much unusable until the user disables dynamic highlighting using `:LuaInspect!` (e.g. try editing `luainspect/init.lua` using the Vim plug-in). For this reason I guess only the function names should be highlighted.
+
+# Known issues
+
+ * Dynamic highlighting using Vim's `matchadd()` function performs **very** poorly in large buffers -- so poorly that Vim becomes pretty much unusable until the user disables dynamic highlighting using `:LuaInspect!` (e.g. try editing `luainspect/scite.lua` using the Vim plug-in). I've since switched to highlighting only function names (instead of multiline call expressions) but that hasn't improved performance as much as I'd hoped...
17 luainspect4vim.lua
View
@@ -57,8 +57,21 @@ function actions.highlight(tokenlist, line, column, src) -- {{{1
if curvar and curvar.ast.id == token.ast.id then
dump(token, 'luaInspectSelectedVariable')
end
- if token.ast.note and token.ast.note:find '[Tt]oo%s+%w+%s+arguments' then
- dump(token, 'luaInspectWrongArgCount')
+ local ast = token.ast
+ if ast and (ast.seevalue or ast).note then
+ local hast = ast.seevalue or ast
+ if hast.tag == 'Call' then
+ hast = hast[1]
+ elseif hast.tag == 'Invoke' then
+ hast = hast[2]
+ end
+ local fpos, lpos = LA.ast_pos_range(hast, tokenlist)
+ local l1, c1 = LA.pos_to_linecol(fpos, src)
+ local l2, c2 = LA.pos_to_linecol(lpos, src)
+ -- TODO: A bit confusing is that LuaInspect seems to emit both zero-based
+ -- and one-based column numbers (i.e. offsets vs. indices) since the
+ -- included Metalua lexer was patched to fix a rare bug.
+ myprint(('luaInspectWrongArgCount %i %i %i %i'):format(l1, c1 - 1, l2, c2 - 1))
end
if token.tag == 'Id' then
if not token.ast.localdefinition then
Please sign in to comment.
Something went wrong with that request. Please try again.