gocode

所属分类:编程语言基础
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-03-22 16:26:18
上 传 者sh-1993
说明:  Go编程语言的自动完成守护程序
(An autocompletion daemon for the Go programming language)

文件列表:
LICENSE (1073, 2023-03-22)
_gccgo/ (0, 2023-03-22)
_gccgo/package.go (16266, 2023-03-22)
_goremote/ (0, 2023-03-22)
_goremote/goremote.go (5890, 2023-03-22)
_testing/ (0, 2023-03-22)
_testing/DESC (3319, 2023-03-22)
_testing/all.bash (296, 2023-03-22)
_testing/run.py (2040, 2023-03-22)
_testing/run.rb (1161, 2023-03-22)
_testing/run.tcl (1441, 2023-03-22)
_testing/test.0001/ (0, 2023-03-22)
_testing/test.0001/cursor.47 (0, 2023-03-22)
_testing/test.0001/out.expected (1319, 2023-03-22)
_testing/test.0001/test.go.in (50, 2023-03-22)
_testing/test.0002/ (0, 2023-03-22)
_testing/test.0002/cursor.105 (0, 2023-03-22)
_testing/test.0002/out.expected (117, 2023-03-22)
_testing/test.0002/test.go.in (111, 2023-03-22)
_testing/test.0003/ (0, 2023-03-22)
_testing/test.0003/cursor.552 (0, 2023-03-22)
_testing/test.0003/out.expected (178, 2023-03-22)
_testing/test.0003/test.go.in (1378, 2023-03-22)
_testing/test.0004/ (0, 2023-03-22)
_testing/test.0004/cursor.1348 (0, 2023-03-22)
_testing/test.0004/out.expected (157, 2023-03-22)
_testing/test.0004/test.go.in (1376, 2023-03-22)
_testing/test.0005/ (0, 2023-03-22)
_testing/test.0005/b.go (389, 2023-03-22)
_testing/test.0005/cursor.327 (0, 2023-03-22)
_testing/test.0005/out.expected (135, 2023-03-22)
_testing/test.0005/test.go.in (327, 2023-03-22)
_testing/test.0006/ (0, 2023-03-22)
_testing/test.0006/b.go (389, 2023-03-22)
_testing/test.0006/cursor.286 (0, 2023-03-22)
... ...

## An autocompletion daemon for the Go programming language **IMPORTANT: This project is not maintained anymore, consider using https://pkg.go.dev/golang.org/x/tools/gopls, a tool which provides similar functionality and more, created and maintained by Go team.** Gocode is a helper tool which is intended to be integrated with your source code editor, like vim, neovim and emacs. It provides several advanced capabilities, which currently includes: - Context-sensitive autocompletion It is called *daemon*, because it uses client/server architecture for caching purposes. In particular, it makes autocompletions very fast. Typical autocompletion time with warm cache is 30ms, which is barely noticeable. Also watch the [demo screencast](https://nosmileface.dev/images/gocode-demo.swf). ![Gocode in vim](https://nosmileface.dev/images/gocode-screenshot.png) ![Gocode in emacs](https://nosmileface.dev/images/emacs-gocode.png) ### Setup 1. You should have a correctly installed Go compiler environment and your personal workspace ($GOPATH). If you have no idea what **$GOPATH** is, take a look [here](http://golang.org/doc/code.html). Please make sure that your **$GOPATH/bin** is available in your **$PATH**. This is important, because most editors assume that **gocode** binary is available in one of the directories, specified by your **$PATH** environment variable. Otherwise manually copy the **gocode** binary from **$GOPATH/bin** to a location which is part of your **$PATH** after getting it in step 2. Do these steps only if you understand why you need to do them: `export GOPATH=$HOME/goprojects` `export PATH=$PATH:$GOPATH/bin` 2. Then you need to get the appropriate version of the gocode, for 6g/8g/5g compiler you can do this: `go get -u github.com/nsf/gocode` (-u flag for "update") Windows users should consider doing this instead: `go get -u -ldflags -H=windowsgui github.com/nsf/gocode` That way on the Windows OS gocode will be built as a GUI application and doing so solves hanging window issues with some of the editors. 3. Next steps are editor specific. See below. ### Vim setup #### Vim manual installation Note: As of go 1.5 there is no $GOROOT/misc/vim script. Suggested installation is via [vim-go plugin](https://github.com/fatih/vim-go). In order to install vim scripts, you need to fulfill the following steps: 1. Install official Go vim scripts from **$GOROOT/misc/vim**. If you did that already, proceed to the step 2. 2. Install gocode vim scripts. Usually it's enough to do the following: 2.1. `vim/update.sh` **update.sh** script does the following: #!/bin/sh mkdir -p "$HOME/.vim/autoload" mkdir -p "$HOME/.vim/ftplugin/go" cp "${0%/*}/autoload/gocomplete.vim" "$HOME/.vim/autoload" cp "${0%/*}/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go" 2.2. Alternatively, you can create symlinks using symlink.sh script in order to avoid running update.sh after every gocode update. **symlink.sh** script does the following: #!/bin/sh cd "${0%/*}" ROOTDIR=`pwd` mkdir -p "$HOME/.vim/autoload" mkdir -p "$HOME/.vim/ftplugin/go" ln -s "$ROOTDIR/autoload/gocomplete.vim" "$HOME/.vim/autoload/" ln -s "$ROOTDIR/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go/" 3. Make sure vim has filetype plugin enabled. Simply add that to your **.vimrc**: `filetype plugin on` 4. Autocompletion should work now. Use `` for autocompletion (omnifunc autocompletion). #### Using Vundle in Vim Add the following line to your **.vimrc**: `Plugin 'nsf/gocode', {'rtp': 'vim/'}` And then update your packages by running `:PluginInstall`. #### Using vim-plug in Vim Add the following line to your **.vimrc**: `Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' }` And then update your packages by running `:PlugInstall`. #### Other Alternatively take a look at the vundle/pathogen friendly repo: https://github.com/Blackrush/vim-gocode. ### Neovim setup #### Neovim manual installation Neovim users should also follow `Vim manual installation`, except that you should goto `gocode/nvim` in step 2, and remember that, the Neovim configuration file is `~/.config/nvim/init.vim`. #### Using Vundle in Neovim Add the following line to your **init.vim**: `Plugin 'nsf/gocode', {'rtp': 'nvim/'}` And then update your packages by running `:PluginInstall`. #### Using vim-plug in Neovim Add the following line to your **init.vim**: `Plug 'nsf/gocode', { 'rtp': 'nvim', 'do': '~/.config/nvim/plugged/gocode/nvim/symlink.sh' }` And then update your packages by running `:PlugInstall`. ### Emacs setup In order to install emacs script, you need to fulfill the following steps: 1. Install [auto-complete-mode](http://www.emacswiki.org/emacs/AutoComplete) 2. Copy **emacs/go-autocomplete.el** file from the gocode source distribution to a directory which is in your 'load-path' in emacs. 3. Add these lines to your **.emacs**: (require 'go-autocomplete) (require 'auto-complete-config) (ac-config-default) Also, there is an alternative plugin for emacs using company-mode. See `emacs-company/README` for installation instructions. If you're a MacOSX user, you may find that script useful: https://github.com/purcell/exec-path-from-shell. It helps you with setting up the right environment variables as Go and gocode require it. By default it pulls the PATH, but don't forget to add the GOPATH as well, e.g.: ``` (when (memq window-system '(mac ns)) (exec-path-from-shell-initialize) (exec-path-from-shell-copy-env "GOPATH")) ``` ### Options You can change all available options using `gocode set` command. The config file uses json format and is usually stored somewhere in **~/.config/gocode** directory. On windows it's stored in the appropriate AppData folder. It's suggested to avoid modifying config file manually, do that using the `gocode set` command. `gocode set` lists all options and their values. `gocode set

近期下载者

相关文件


收藏者