Go-Notepad++

来源:互联网 发布:rational rose是否mac 编辑:程序博客网 时间:2024/06/06 03:08

本文暂停Go语法,而转向编辑器Notepad++。——工欲善其事,必先利其器。

参考资料

notepad++支持go语言高亮与go语言插件

安装GOnpp插件

在Notepad++中,选择菜单:插件/Plugin –> Plugin Manager –> Show Plugin Manager
在弹出的Plugin Manager对话框中,单看Available页面,选择Gonpp并Install即可。

GOnpp

下图是选中GOnpp时的描述信息:

GOnpp assists you writing Go-programms. It has code completion and function calltips (using gocode, see below) as well as direct interaction with the go command. Currently the following actions are implemented:
gocode complete -> ALT+O || gocode calltip -> ALT+P
go fmt -> ALT+F || go test -> ALT+T || go install -> ALT+I || go run -> ALT+R

Please note, that you must have the GO programming language installed on your computer to make use of GOnpp. You can get GO from http://golang.org/doc/install

To use the code-completion you need to have gocode installed and located either in your PATH or in GOROOT/bin. You can get gocode from https://github.com/nsf/gocode!
Author: tike
Source: https://github.com/tike/GOnpp
Homepage: https://github.com/tike/GOnpp
Latest update: 28.03.2014 (v1.2.0.0)
- gocode integration (complete with calltips)
- Thanks Mateusz!

19.02.2014 (v1.1.0.0)
- minor fixes, see git repo for details

24.01.2014 (v1.0.0.0 )
- inital release

试用

可以打开一个go文件,然后选择 插件 –> GOnpp –> go run,则会运行当前go文件,并打开一个go cmd output的窗口,显示运行结果。如此,可以在Notepad++编辑器中编辑、运行。

可试验其他的命令。

gocode

按照上面的说明,打开页面:https://github.com/nsf/gocode,执行了如下的命令,不过没有看到有什么效果。。。下记录在此。。。

User@Host MINGW32 /d/examples$ mkdir tempcUser@Host MINGW32 /d/examples$ cd tempUser@Host MINGW32 /d/examples/temp$ go get -u -ldflags -H=windowsgui github.com/nsf/gocodeUser@Host MINGW32 /d/examples/temp$ lltotal 0User@Host MINGW32 /d/examples/temp$

IDEsAndTextEditorPlugins

在Go安装目录下,有个文件:Go/misc/editors,其内容如下:

For information about plugins and other support for Go in editors and shells,
see this page on the Go Wiki:

https://golang.org/wiki/IDEsAndTextEditorPlugins

这个页面给出了各种编辑器支持Go的方法,找到Notepad++部分,如下:

Notepad++: Free source code editor for Windows.
- notepadplus-go Syntax highlighting, functions list panel (for code browsing), code completion for keywords & builtins.
- The GOnpp plugin (available via Notepad++’s built-in Plugin Manager) provides code completion (requires gocode), function calltips, goimports integration, and keyboard shortcuts for common go commands. [sources, binaries].
- GoAutocomplete is another code completion plugin.

Syntax Highlighting

页面地址:https://github.com/chai2010/notepadplus-go

从这个页面下载3个xml文件到本地(直接下载xml会有问题,自己找变通的法子即可),然后找到本地Notepad++的xml文件的位置。——和Windows OS相关,以作者的环境为例,是
C:\Users\MyUserName\AppData\Roaming\Notepad++

把网页上的userDefineLang.xml的内容拷贝到Notepad++的userDefineLang.xml对应位置。然后重启Notepad++,在 语言 菜单下面的最下面就可以看到go&goasm。选中,即可看到go文件语法高亮了。

Function List

接下来就是在Notepad++中显示Go文件的函数列表,如此就不用上下滚屏去睁大眼睛找目标函数了。

同样滴,替换functionList.xml。然后重启。——可能读者想到了,为什么不先修改完xml,然后直接重启一次呢?——的确可以。。。。

——如果在Notepad++的函数功能表中不能显示函数,那么可以Reload一下。

Keyword Auto-Completion

把Go.xml拷贝到如下目录:D:\Notepad++\plugins\APIs —— 根据自己的Notepad++安装目录选择,这个APIs下有各种语言的xml。

重启Notepad++。

效果图

这里就直接把https://github.com/chai2010/notepadplus-go的图借用过来:

screenshot.png

0 0
原创粉丝点击