aboutsummaryrefslogtreecommitdiff
path: root/modules/lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2011-09-26 18:11:57 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2011-09-26 18:11:57 -0400
commit8bcdb16e18641e1cea08ebb614d70d98a3c27426 (patch)
treeda922f622a6a03a875625f8905c3fbcb129e8aad /modules/lua
parentc2d73d4284cc5009128bc5fed68fcc5826336ea2 (diff)
downloadtextadept-8bcdb16e18641e1cea08ebb614d70d98a3c27426.tar.gz
textadept-8bcdb16e18641e1cea08ebb614d70d98a3c27426.zip
Lua code cleanup.
Diffstat (limited to 'modules/lua')
-rw-r--r--modules/lua/init.lua35
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.