diff options
Diffstat (limited to '.config/micro/plug/go')
| -rw-r--r-- | .config/micro/plug/go/README.md | 10 | ||||
| -rw-r--r-- | .config/micro/plug/go/go.lua | 84 | ||||
| -rw-r--r-- | .config/micro/plug/go/help/go-plugin.md | 42 | ||||
| -rw-r--r-- | .config/micro/plug/go/repo.json | 37 |
4 files changed, 0 insertions, 173 deletions
diff --git a/.config/micro/plug/go/README.md b/.config/micro/plug/go/README.md deleted file mode 100644 index 8002e0e..0000000 --- a/.config/micro/plug/go/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Go Plugin for Micro - -This repository holds the Go plugin for micro. This plugin -has been updated for use with micro 2.0. - -Install by cloning this into your plug directory: - -``` -git clone https://github.com/micro-editor/go-plugin ~/.config/micro/plug/go-plugin -``` diff --git a/.config/micro/plug/go/go.lua b/.config/micro/plug/go/go.lua deleted file mode 100644 index d030316..0000000 --- a/.config/micro/plug/go/go.lua +++ /dev/null @@ -1,84 +0,0 @@ -VERSION = "2.0.2" - -local micro = import("micro") -local config = import("micro/config") -local shell = import("micro/shell") -local buffer = import("micro/buffer") - --- outside init because we want these options to take effect before --- buffers are initialized -config.RegisterCommonOption("go", "goimports", false) -config.RegisterCommonOption("go", "gofmt", true) - -function init() - config.MakeCommand("goimports", goimports, config.NoComplete) - config.MakeCommand("gofmt", gofmt, config.NoComplete) - config.MakeCommand("gorename", gorenameCmd, config.NoComplete) - - config.AddRuntimeFile("go", config.RTHelp, "help/go-plugin.md") - config.TryBindKey("F6", "command-edit:gorename ", false) -end - -function onSave(bp) - if bp.Buf:FileType() == "go" then - if bp.Buf.Settings["go.goimports"] then - goimports(bp) - elseif bp.Buf.Settings["go.gofmt"] then - gofmt(bp) - end - end - return true -end - -function gofmt(bp) - bp:Save() - local _, err = shell.RunCommand("gofmt -w " .. bp.Buf.Path) - if err ~= nil then - micro.InfoBar():Error(err) - return - end - - bp.Buf:ReOpen() -end - -function gorenameCmd(bp, args) - micro.Log(args) - if #args == 0 then - micro.InfoBar():Message("Not enough arguments") - else - bp:Save() - local buf = bp.Buf - if #args == 1 then - local c = bp.Cursor - local loc = buffer.Loc(c.X, c.Y) - local offset = buffer.ByteOffset(loc, buf) - local cmdargs = {"--offset", buf.Path .. ":#" .. tostring(offset), "--to", args[1]} - shell.JobSpawn("gorename", cmdargs, nil, renameStderr, renameExit, bp) - else - local cmdargs = {"--from", args[1], "--to", args[2]} - shell.JobSpawn("gorename", cmdargs, nil, renameStderr, renameExit, bp) - end - micro.InfoBar():Message("Renaming...") - end -end - -function renameStderr(err) - micro.Log(err) - micro.InfoBar():Message(err) -end - -function renameExit(output, args) - local bp = args[1] - bp.Buf:ReOpen() -end - -function goimports(bp) - bp:Save() - local _, err = shell.RunCommand("goimports -w " .. bp.Buf.Path) - if err ~= nil then - micro.InfoBar():Error(err) - return - end - - bp.Buf:ReOpen() -end diff --git a/.config/micro/plug/go/help/go-plugin.md b/.config/micro/plug/go/help/go-plugin.md deleted file mode 100644 index a4cdb33..0000000 --- a/.config/micro/plug/go/help/go-plugin.md +++ /dev/null @@ -1,42 +0,0 @@ -# Go Plugin - -The go plugin provides some extra niceties for using micro with -the Go programming language. The main thing this plugin does is -run `gofmt` and `goimports` for you automatically. If you would also -like automatically error linting, check out the `linter` plugin. -The plugin also provides `gorename` functionality. - -You can run - -``` -> gofmt -``` - -or - -``` -> goimports -``` - -To automatically run these when you save the file, use the following -options: - -* `gofmt`: run gofmt on file saved. Default value: `on` -* `goimports`: run goimports on file saved. Default value: `off` - -To use `gorename`, place your cursor over the variable you would like -to rename and enter the command `> gorename newName`. - -You also press F6 (the default binding) to open a prompt to rename. You -can rebind this in your `bindings.json` file with the action `go.gorename`. - -The go plugin also provides an interface for using `gorename` if you have -it installed. The gorename command behaves in two ways: - -* With one argument: `> gorename newname` will rename the identifier - under the cursor with the new name `newname`. - -* With two arguments: `> gorename oldname newname` will rename the old - identifier with the new one. This uses gorename's syntax for specifying - the old identifier, so please see `gorename --help` for the details - for how to specify the variable. diff --git a/.config/micro/plug/go/repo.json b/.config/micro/plug/go/repo.json deleted file mode 100644 index f4e914c..0000000 --- a/.config/micro/plug/go/repo.json +++ /dev/null @@ -1,37 +0,0 @@ -[{ - "Name": "go", - "Description": "Go language support (gofmt and goimports)", - "Tags": ["go", "golang"], - "Website": "https://github.com/micro-editor/go-plugin", - "Versions": [ - { - "Version": "2.0.2", - "Url": "https://github.com/micro-editor/go-plugin/archive/v2.0.2.zip", - "Require": { - "micro": ">=2.0.0" - } - }, - { - "Version": "2.0.1", - "Url": "https://github.com/micro-editor/go-plugin/archive/v2.0.1.zip", - "Require": { - "micro": ">=2.0.0-1" - } - }, - { - "Version": "2.0.0", - "Url": "https://github.com/micro-editor/go-plugin/archive/v2.0.0.zip", - "Require": { - "micro": ">=2.0.0-1" - } - }, - { - "Version": "1.0.1", - "Url": "https://github.com/micro-editor/go-plugin/archive/v1.0.1.zip", - "Require": { - "micro": ">=1.0.3 <2.0.0-1" - } - } - ] -}] - |
