diff --git a/go.lua b/go.lua index d030316..b987f00 100644 --- a/go.lua +++ b/go.lua @@ -3,7 +3,6 @@ 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 @@ -50,10 +49,9 @@ function gorenameCmd(bp, args) 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) + local where = buf.Path .. ":" .. tostring(c.Y+1) .. ":" .. tostring(c.X+1) + local cmdargs = {"rename", "-write", where, args[1]} + shell.JobSpawn("gopls", cmdargs, nil, renameStderr, renameExit, bp) else local cmdargs = {"--from", args[1], "--to", args[2]} shell.JobSpawn("gorename", cmdargs, nil, renameStderr, renameExit, bp) diff --git a/help/go-plugin.md b/help/go-plugin.md index a4cdb33..e318551 100644 --- a/help/go-plugin.md +++ b/help/go-plugin.md @@ -4,7 +4,7 @@ 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. +The plugin also provides `gopls rename`/`gorename` functionality. You can run @@ -30,8 +30,8 @@ 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: +The go plugin also provides an interface for using `gopls rename` if you +have `gopls` 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`. @@ -40,3 +40,6 @@ it installed. The gorename command behaves in two ways: 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. + + Note: `gorename` is deprecated. It doesn't work in the `main` package. + This functionality has been kept for backwards compatibility. diff --git a/repo.json b/repo.json index f4e914c..83972ba 100644 --- a/repo.json +++ b/repo.json @@ -4,6 +4,13 @@ "Tags": ["go", "golang"], "Website": "https://github.com/micro-editor/go-plugin", "Versions": [ + { + "Version": "3.0.0", + "Url": "https://github.com/micro-editor/go-plugin/archive/v3.0.0.zip", + "Require": { + "micro": ">=2.0.0" + } + }, { "Version": "2.0.2", "Url": "https://github.com/micro-editor/go-plugin/archive/v2.0.2.zip",