diff options
author | 2011-09-26 18:11:57 -0400 | |
---|---|---|
committer | 2011-09-26 18:11:57 -0400 | |
commit | 8bcdb16e18641e1cea08ebb614d70d98a3c27426 (patch) | |
tree | da922f622a6a03a875625f8905c3fbcb129e8aad /modules/lua | |
parent | c2d73d4284cc5009128bc5fed68fcc5826336ea2 (diff) | |
download | textadept-8bcdb16e18641e1cea08ebb614d70d98a3c27426.tar.gz textadept-8bcdb16e18641e1cea08ebb614d70d98a3c27426.zip |
Lua code cleanup.
Diffstat (limited to 'modules/lua')
-rw-r--r-- | modules/lua/init.lua | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/modules/lua/init.lua b/modules/lua/init.lua index 843d55ac..8a7fb860 100644 --- a/modules/lua/init.lua +++ b/modules/lua/init.lua @@ -150,25 +150,22 @@ function goto_required() end end -events.connect(events.FILE_AFTER_SAVE, - function() -- show syntax errors as annotations - if buffer:get_lexer() == 'lua' then - local buffer = buffer - buffer:annotation_clear_all() - local text = buffer:get_text() - text = text:gsub('^#![^\n]+', '') -- ignore shebang line - local _, err = loadstring(text) - if err then - local line, msg = err:match('^.-:(%d+):%s*(.+)$') - if line then - buffer.annotation_visible = 2 - buffer:annotation_set_text(line - 1, msg) - buffer.annotation_style[line - 1] = 8 -- error style number - buffer:goto_line(line - 1) - end - end - end - end) +-- Show syntax errors as annotations. +events.connect(events.FILE_AFTER_SAVE, function() + if buffer:get_lexer() ~= 'lua' then return end + local buffer = buffer + buffer:annotation_clear_all() + local text = buffer:get_text():gsub('^#![^\n]+', '') -- ignore shebang line + local f, err = loadstring(text) + if f then return end + local line, msg = err:match('^.-:(%d+):%s*(.+)$') + if line then + buffer.annotation_visible = 2 + buffer:annotation_set_text(line - 1, msg) + buffer.annotation_style[line - 1] = 8 -- error style number + buffer:goto_line(line - 1) + end +end) --- -- Container for Lua-specific key commands. |