aboutsummaryrefslogtreecommitdiff
path: root/gofmt.lua
diff options
context:
space:
mode:
authorrxi <rxi@users.noreply.github.com>2020-04-23 20:49:37 +0100
committerrxi <rxi@users.noreply.github.com>2020-04-23 20:49:37 +0100
commit676f04945010aeb2ae71325bf2d1d6f336a5e162 (patch)
tree31b2e18df5e84fbc731840e5f1b28c974eea868a /gofmt.lua
parent9049e189d49440939192874d54af15a21eebbafb (diff)
downloadlite-xl-plugins-676f04945010aeb2ae71325bf2d1d6f336a5e162.tar.gz
lite-xl-plugins-676f04945010aeb2ae71325bf2d1d6f336a5e162.zip
Moved all plugins to `plugins` dir
Diffstat (limited to 'gofmt.lua')
-rw-r--r--gofmt.lua49
1 files changed, 0 insertions, 49 deletions
diff --git a/gofmt.lua b/gofmt.lua
deleted file mode 100644
index 11c90b9..0000000
--- a/gofmt.lua
+++ /dev/null
@@ -1,49 +0,0 @@
-local core = require "core"
-local command = require "core.command"
-local keymap = require "core.keymap"
-
-local function exec(cmd)
- local fp = io.popen(cmd, "r")
- local res = fp:read("*a")
- local success = fp:close()
- return res:gsub("%\n$", ""), success
-end
-
-local function get_cmd_text(cmd, doc)
- local active_filename = doc and system.absolute_path(doc.filename or "")
- return exec(string.format("%s %s", cmd, active_filename))
-end
-
-local function update_doc(cmd, doc)
- local text, success = get_cmd_text(cmd, doc)
- if success == nil then
- local err_text = "Command '%s' not found in the system"
- core.error(string.format(err_text, cmd))
- return
- end
-
- local sel = { doc:get_selection() }
- doc:remove(1, 1, math.huge, math.huge)
- doc:insert(1, 1, text)
- doc:set_selection(table.unpack(sel))
-end
-
-command.add("core.docview", {
- ["gofmt:gofmt"] = function()
- update_doc("gofmt", core.active_view.doc)
- end,
-
- ["gofmt:goimports"] = function()
- update_doc("goimports", core.active_view.doc)
- end,
-
- ["gofmt:goreturns"] = function()
- update_doc("goreturns", core.active_view.doc)
- end,
-})
-
-keymap.add {
- ["ctrl+i"] = "gofmt:gofmt",
- ["ctrl+h"] = "gofmt:goimports",
- ["ctrl+u"] = "gofmt:goreturns",
-}