diff options
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -25,6 +25,10 @@ -- Be sure not to run commands that open another window with the same -- filetype, leading to an infinite loop. +local M = {} + +M.settings = {} + function execute(s, arg, arg2) if type(s) == "table" then for key, setting in pairs(s) do @@ -44,8 +48,8 @@ end -- Register events vis.events.subscribe(vis.events.INPUT, function() - if settings[vis.win.syntax] and settings[vis.win.syntax].INPUT then - execute(settings[vis.win.syntax].INPUT, nil) + if M.settings[vis.win.syntax] and M.settings[vis.win.syntax].INPUT then + execute(M.settings[vis.win.syntax].INPUT, nil) end end) @@ -60,8 +64,8 @@ for _, event in pairs(file_events) do vis.events.subscribe(vis.events[event], function(file, path) for win in vis:windows() do if win.file == file then - if settings[win.syntax] and settings[win.syntax][event] then - execute(settings[win.syntax][event], file, path) + if M.settings[win.syntax] and M.settings[win.syntax][event] then + execute(M.settings[win.syntax][event], file, path) end end end @@ -85,12 +89,15 @@ local win_events = { for _, event in pairs(win_events) do vis.events.subscribe(vis.events[event], function(win) - if settings[win.syntax] then - if settings[win.syntax][event] then - execute(settings[win.syntax][event], win) + if M.settings[win.syntax] == nil then return end + if M.settings[win.syntax] then + if M.settings[win.syntax][event] then + execute(M.settings[win.syntax][event], win) elseif event == "WIN_OPEN" then -- default event - execute(settings[win.syntax], win) + execute(M.settings[win.syntax], win) end end end) end + +return M |