VimPlugin: vim-go: Difference between revisions

From wikinotes
(Created page with "A standalone LSP setup for golang and vim.<br> includes several refactoring tools as well. = Documentation = <blockquote> {| class="wikitable" |- | <code>:h vim-go</code> || https://github.com/fatih/vim-go/blob/master/doc/vim-go.txt |- |} </blockquote><!-- Documentation --> = Install = <blockquote> <syntaxhighlight lang="vim"> Plug 'https://github.com/fatih/vim-go', { 'do': ':GoUpdateBinaries' } </syntaxhighlight> </blockquote><!-- Install --> = Configuration = <b...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
A standalone LSP setup for [[golang]] and vim.<br>
A standalone LSP setup for [[golang]] and vim.<br>
includes several refactoring tools as well.
includes several refactoring tools as well.
{{ NOTE |
this plugin is huge, I'm not sure I like it. It might be better to look at some implementations, and write only the features I want }}


= Documentation =
= Documentation =
Line 15: Line 18:
<syntaxhighlight lang="vim">
<syntaxhighlight lang="vim">
Plug 'https://github.com/fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'https://github.com/fatih/vim-go', { 'do': ':GoUpdateBinaries' }
</syntaxhighlight>
Executables Wanted (installed automatically, but useful if provisioning temp env)
<syntaxhighlight lang="bash">
go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
go install github.com/go-delve/delve/cmd/dlv@latest
go install github.com/kisielk/errcheck@latest
go install github.com/davidrjenni/reftools/cmd/fillstruct@master
go install github.com/rogpeppe/godef@latest
go install golang.org/x/tools/cmd/goimports@master
go install github.com/mgechev/revive@latest
go install golang.org/x/tools/gopls@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/fatih/gomodifytags@latest
go install golang.org/x/tools/cmd/gorename@master
go install github.com/jstemmer/gotags@master
go install golang.org/x/tools/cmd/guru@master
go install github.com/josharian/impl@main
go install honnef.co/go/tools/cmd/keyify@master
go install github.com/fatih/motion@latest
go install github.com/koron/iferr@master
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Install -->
</blockquote><!-- Install -->

Latest revision as of 13:00, 2 June 2023

A standalone LSP setup for golang and vim.
includes several refactoring tools as well.

NOTE:

this plugin is huge, I'm not sure I like it. It might be better to look at some implementations, and write only the features I want

Documentation

:h vim-go https://github.com/fatih/vim-go/blob/master/doc/vim-go.txt

Install

Plug 'https://github.com/fatih/vim-go', { 'do': ':GoUpdateBinaries' }

Executables Wanted (installed automatically, but useful if provisioning temp env)

go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
go install github.com/go-delve/delve/cmd/dlv@latest
go install github.com/kisielk/errcheck@latest
go install github.com/davidrjenni/reftools/cmd/fillstruct@master
go install github.com/rogpeppe/godef@latest
go install golang.org/x/tools/cmd/goimports@master
go install github.com/mgechev/revive@latest
go install golang.org/x/tools/gopls@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/fatih/gomodifytags@latest
go install golang.org/x/tools/cmd/gorename@master
go install github.com/jstemmer/gotags@master
go install golang.org/x/tools/cmd/guru@master
go install github.com/josharian/impl@main
go install honnef.co/go/tools/cmd/keyify@master
go install github.com/fatih/motion@latest
go install github.com/koron/iferr@master

Configuration

coc-go

coc-go and vim-go share a lot of functionality.
Generally, I prefer coc-go, so this disables a lot of vim-go's functionality.

let g:go_code_completion_enabled = 0
let g:go_code_completion_icase =0
let g:go_play_browser_command = $BROWSER.' %URL% &'

Usage

coc-go

Leaving out the parts I like from coc-go, vim-test.

:GoCoverage         " report test coverage, annotate your file
:GocoverageBrowser

:GoErrCheck!        " find unchecked errors in your package

:GoRename foo       " rename an identifier

:GoDebugStart       " open debug ui
:GoDebugStop        " close debug ui

:GoDebugBreakpoint  " toggle breakpoint on line
:GoDebugHalt        " stop debugging