Refactor and clean up

This commit puts in place the ability for multiple views (splits).
This commit also removes the editor bindings so that all bindings can be
rebound by the user.
I also added some more comments

This fixes #109
This commit is contained in:
Zachary Yedidia
2016-05-28 11:32:09 -04:00
parent d9d0af4a99
commit e8d8da1443
9 changed files with 311 additions and 248 deletions

View File

@@ -6,25 +6,25 @@ if GetOption("gofmt") == nil then
end
function go_onSave()
if view.Buf.FileType == "Go" then
if views[mainView+1].Buf.FileType == "Go" then
if GetOption("goimports") then
go_goimports()
elseif GetOption("gofmt") then
go_gofmt()
end
view:ReOpen()
views[mainView+1]:ReOpen()
end
end
function go_gofmt()
local handle = io.popen("gofmt -w " .. view.Buf.Path)
local handle = io.popen("gofmt -w " .. views[mainView+1].Buf.Path)
local result = handle:read("*a")
handle:close()
end
function go_goimports()
local handle = io.popen("goimports -w " .. view.Buf.Path)
local handle = io.popen("goimports -w " .. views[mainView+1].Buf.Path)
local result = go_split(handle:read("*a"), ":")
handle:close()
end