zoukankan      html  css  js  c++  java
  • 把vim当做golang的IDE

    开始决定丢弃鼠标,所以准备用vim了。

    那么在vim里面如何搭建golang环境呢?

    git盛行之下,搭建vim环境是如此简单。

    而且vim搭建好了之后,基本上跟IDE没有差别。

    高亮、自动补全、自动格式化、查看定义跳转、语法检测等等等等, 简直是不要不要的:

    • Improved Syntax highlighting with items such as Functions, Operators, Methods.
    • Auto completion support via gocode
    • Better gofmt on save, which keeps cursor position and doesn't break your undo history
    • Go to symbol/declaration with :GoDef
    • Look up documentation with :GoDoc inside Vim or open it in browser
    • Automatically import packages via :GoImport or plug it into autosave
    • Compile your package with :GoBuild, install it with :GoInstall or test them with :GoTest (also supports running single tests via :GoTestFunc)
    • Quickly execute your current file/files with :GoRun
    • Automatic GOPATH detection based on the directory structure (i.e. gb projects, godep vendored projects)
    • Change or display GOPATH with :GoPath
    • Create a coverage profile and display annotated source code in browser to see which functions are covered with:GoCoverage
    • Call gometalinter with :GoMetaLinter, which invokes all possible linters (golint, vet, errcheck, deadcode, etc..) and shows the warnings/errors
    • Lint your code with :GoLint
    • Run your code through :GoVet to catch static errors
    • Advanced source analysis tools utilizing oracle, such as :GoImplements:GoCallees, and :GoReferrers
    • Precise type-safe renaming of identifiers with :GoRename
    • List all source files and dependencies
    • Unchecked error checking with :GoErrCheck
    • Integrated and improved snippets, supporting ultisnips or neosnippet
    • Share your current code to play.golang.org with :GoPlay
    • On-the-fly type information about the word under the cursor. Plug it into your custom vim function.
    • Go asm formatting on save
    • Tagbar support to show tags of the source code in a sidebar with gotags
    • Custom vim text objects such as a function or inner function list.
    • A async launcher for the go command is implemented for Neovim, fully async building and testing (beta).
    • Integrated with the Neovim terminal, launch :GoRun and other go commands in their own new terminal. (beta)
    • Alternate between implementation and test code with :GoAlternate

    安装起来也非常方便,只要一下三行代码:

    #下载安装
    git clone git@github.com:farazdagi/vim-go-ide.git ~/.vim_go_runtime sh ~/.vim_go_runtime/bin/install #运行 vim -u ~/.vimrc.go

    PS:

    a)这里要求vim 要开启lua  :  

    brew install vim --with-lua --override-system-vim

    b)如果需要类解析,需要转ctag

    --------------------

    2016-10-20补充

    如果把go升级到go1.7,这里的函数 auto-complete 会显示PANIC不能显示任何的系统库对应的函数和自定义的函数

    这里需要做一件事情,可以恢复

    ps aux | grep gocode
    
    #存在就干掉
    killall gocode
    
    #重启
    gocode

    或者采用以下方式

    gocode close && go get -u github.com/nsf/gocode

     参考这里:https://github.com/fatih/vim-go/issues/1015

    --------------------- 

    原文:http://farazdagi.com/blog/2015/vim-as-golang-ide/

    效果如下:

  • 相关阅读:
    Ubuntu12.04安装svn1.8
    [NOIP模拟测试3] 建造游乐园 题解(欧拉图性质)
    图论模板
    [bzoj3073] Journeys 题解(线段树优化建图)
    [bzoj3033]太鼓达人 题解(搜索)
    [NOIP2016]天天爱跑步 题解(树上差分) (码长短跑的快)
    [HNOI2015]菜肴制作 题解(贪心+拓扑)
    [SDOI2015]排序 题解 (搜索)
    [CQOI2011]放棋子 题解(dp+组合数学)
    [ZJOI2011]看电影(组合数学/打表+高精)
  • 原文地址:https://www.cnblogs.com/zhangqingping/p/5215071.html
Copyright © 2011-2022 走看看