Skip to content

Commit

Permalink
Warn user + show tooltips for syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Aug 11, 2010
1 parent dc640de commit b0b5800
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
10 changes: 5 additions & 5 deletions TODO.md
@@ -1,7 +1,7 @@
# The to-do list

* Right now the highlighting styles used by `luainspect.vim` are the same as those used by the SciTE plug-in and they don't work well on dark backgrounds. As soon as I get around to picking some alternate colors I'll include those in the plug-in.

* Bindings for other features of LuaInspect such as omni completion for in scope variables (including display of library function signatures).

* Document the g:lua_inspect_path option.
* Copy highlighting colors for dark backgrounds from luainspect/scite.lua.
* OMNI completion for in scope variables (including display of library function signatures).
* Fix improvised hack by using new `luainspect.signatures.value_signatures` table.
* Highlighting and tooltips for wrong parameter counts.
* Document g:lua_inspect_path option.
18 changes: 12 additions & 6 deletions luainspect.vim
@@ -1,8 +1,8 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 11, 2010
" Last Change: August 12, 2010
" URL: http://peterodding.com/code/vim/lua-inspect/
" Version: 0.3.3
" Version: 0.3.4
" License: MIT

" Support for automatic update using the GLVS plug-in.
Expand Down Expand Up @@ -86,7 +86,11 @@ endfunction

function! LuaInspectToolTip() " {{{2
let text = s:run_lua_inspect('tooltip', 0, 1)
return type(text) == type('') ? text : ''
if exists('b:luainspect_syntax_error')
return b:luainspect_syntax_error
else
return type(text) == type('') ? text : ''
endif
endfunction

function! s:run_lua_inspect(action, toggle, enabled) " {{{2
Expand All @@ -107,12 +111,14 @@ function! s:run_lua_inspect(action, toggle, enabled) " {{{2
let linenum = b:luainspect_output[1] + 0
let colnum = b:luainspect_output[2] + 0
let linenum2 = b:luainspect_output[3] + 0
" TODO Can we do something useful with this?!
" let message = b:luainspect_output[4]
let b:luainspect_syntax_error = b:luainspect_output[4]
let error_cmd = 'syntax match luaInspectSyntaxError /\%%>%il\%%<%il.*/ containedin=ALLBUT,lua*Comment*'
execute printf(error_cmd, linenum - 1, (linenum2 ? linenum2 : line('$')) + 1)
call xolox#warning("Syntax error around line %i: %s", linenum, b:luainspect_syntax_error)
return
elseif response == 'highlight'
endif
unlet! b:luainspect_syntax_error
if response == 'highlight'
call s:define_default_styles()
call s:clear_previous_matches()
call s:highlight_variables()
Expand Down
5 changes: 3 additions & 2 deletions luainspect4vim.lua
Expand Up @@ -3,7 +3,7 @@
This module is part of the luainspect.vim plug-in for the Vim text editor.
Author: Peter Odding <peter@peterodding.com>
Last Change: August 11, 2010
Last Change: August 12, 2010
URL: http://peterodding.com/code/vim/lua-inspect/
License: MIT
Expand Down Expand Up @@ -235,7 +235,8 @@ return function(src)
myprint(linenum)
myprint(colnum)
myprint(linenum2 or 0)
myprint(err or '')
-- Remove prefixed line number from error message because it's redundant.
myprint((err:gsub('^%d+:%s+', '')))
return
end
-- Now parse the source code using metalua to build an abstract syntax tree.
Expand Down

0 comments on commit b0b5800

Please sign in to comment.