Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions help/go-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`.
Expand All @@ -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.
7 changes: 7 additions & 0 deletions repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down