Skip to content

Commit

Permalink
Initial support for guru with :GoGuru
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed Mar 14, 2019
1 parent d63dc75 commit 9cfd55d
Show file tree
Hide file tree
Showing 15 changed files with 422 additions and 51 deletions.
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please see the [development section of the README](README.markdown#development).
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Please be sure to:

1. Include the output from `:GoDiag`; use `:GoDiag!` to copy it to the
clipboard.

2. Include a *minimal* vimrc to reproduce the issue, with other plugins disabled.

You will get better/faster answers if you spend 2 minutes including this
information!
25 changes: 25 additions & 0 deletions API.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Various common functions, or functions that don't have a place elsewhere.
gopher#has_debug(flag)
Report if the user enabled the given debug flag.

gopher#override_vimgo()
Override vim-go.


[motion.vim](autoload/gopher/motion.vim)
----------------------------------------
Expand Down Expand Up @@ -143,6 +146,17 @@ Utilities for working with Go files.
(if any).


[guru.vim](autoload/gopher/guru.vim)
------------------------------------
implement the :GoGuru command.

gopher#guru#complete(lead, cmdline, cursor)


gopher#guru#do(...)
TODO: commands need range: freevars


[diag.vim](autoload/gopher/diag.vim)
------------------------------------
Implement :GoDiag.
Expand Down Expand Up @@ -224,6 +238,7 @@ Utilities for working with the external programs and the OS.
order (hopefully).
TODO: Don't run multiple jobs that modify the buffer at the same time. For
some tools (like gorename) we need a global lock.
TODO: allow inspecting which jobs are running (in :GoDiag?)

gopher#system#job_wait(job)
Wait for a job to finish. Note that the exit_cb or close_cb may still be
Expand All @@ -241,3 +256,13 @@ Utilities for working with the external programs and the OS.
Join a list of commands to a string, escaping any shell meta characters.


[qf.vim](autoload/gopher/qf.vim)
--------------------------------
Utilities for working with the quickfix and location list.

gopher#qf#populate(out, efm, title)
Populate the quickfix list with the errors from out, parsed according to the
errorformat in efm.
If efm is an empty string "%f:%l:%c %m" will be used.


35 changes: 19 additions & 16 deletions FEATURES.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ Code insight
:GoCoverageClear :GoCoverage clear
:GoCoverageToggle :GoCoverage toggle

:GoCallees These are all guru commands, and can be used with :GoGuru
:GoCallers e.g. :GoGuru callers, :GoGuru whicherrs, etc.
:GoCallstack
:GoChannelPeers
:GoDescribe
:GoFreevars
:GoImplements
:GoPointsTo
:GoReferrers
:GoSameIds
:GoWhicherrs

:GoGuruScope :let gopher_guru_scope = '..' or :GoGuru -scope .. command

Debugger
--------

Expand Down Expand Up @@ -96,21 +110,9 @@ Other
Not implemented (yet)
---------------------

:GoCallees guru; should probably make one command for this:
:GoCallers :GoGuru callers, or :GoInfo callers
:GoCallstack
:GoChannelPeers
:GoDescribe
:GoFreevars
:GoGuruScope
:GoImplements
:GoPointsTo
:GoReferrers
:GoSameIds
:GoSameIdsAutoToggle
:GoSameIdsClear
:GoSameIdsToggle
:GoWhicherrs

:GoKeyify keyify
:GoFillStruct fillstruct
Expand All @@ -120,10 +122,11 @@ Not implemented (yet)
:GoModFmt go mod edit -fmt doesn't read from stdin so can't use formatprg
:GoAutoTypeInfoToggle Should probably be LSP feature?

:GoCoverageBrowser Not sure if it's worth having any of these?
:GoImport
:GoImportAs
:GoDrop
:GoImport :GoImport foo
:GoImportAs :GoImport foo alias or :GoImport foo:alias
:GoDrop :GoImport -rm foo

:GoCoverageBrowser Not sure if it's worth having these?
:GoPlay

N/A
Expand Down
15 changes: 7 additions & 8 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Overview of over commands:
- `:GoCoverage` – Highlight code coverage.
- `:GoRename` – Rename identifier under cursor.
- `:GoTags` – Add or remove struct tags
- `:GoGuru` – Get various information using the `guru` command.

See [FEATURES.markdown](FEATURES.markdown) for a translation of vim-go features.

Expand Down Expand Up @@ -168,8 +169,8 @@ gopher.vim stands.
Development
-----------

- It's probably good idea to open an issue first; I really don't like rejecting
PRs but I like accruing "bloat" even less.
- It's probably good idea to **open an issue first** for features or additions;
I really don't like rejecting PRs but I like accruing "bloat" even less.

- Please use [.editorconfig](.editorconfig) style settings;
[vim-editorconfig](https://github.com/sgur/vim-editorconfig) is a good plugin
Expand All @@ -180,16 +181,14 @@ Development
test suite should be as easy as `tvim test ./...` (`tvim lint ./...` for the
style checkers).

- see [API.markdown](API.markdown) for some API docs (only public functions are
documented in that file).

- Try to keep the public functions (`gopher#foo#do_something()`) as clean and
usable as possible; use `s:fun()` for internal stuff, unless you want to test
it in which case use Python's underscore style: `gopher#python#_private_()`.
See [API.markdown](API.markdown) for some API docs (only public functions are
documented in that file).

- Prefer `printf()` over string concatenation; e.g. `printf('x: %s', ['a
list'])` will work, whereas `'x: ' . ['a list']` will give you a useless
error.
- Prefer `printf()` over string concatenation; e.g. `printf('x: %s', [])` will
work, whereas `'x: ' . []` will give you a useless error.

- Use `gopher#error()` and `gopher#info()`; don't use `echom` or `echoerr`.

Expand Down
3 changes: 2 additions & 1 deletion autoload/gopher/coverage.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ call s:hi()

" Complete the special flags and some common flags people might want to use.
fun! gopher#coverage#complete(lead, cmdline, cursor) abort
return ['clear', 'toggle', '-run', '-race', '-tags']
return filter(['clear', 'toggle', '-run', '-race', '-tags'],
\ {i, v -> strpart(l:v, 0, len(a:lead)) is# a:lead})
endfun

" Apply or clear coverage highlights.
Expand Down
2 changes: 1 addition & 1 deletion autoload/gopher/diag.vim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fun! gopher#diag#do(to_clipboard) abort
else
let l:out = substitute('GOPATH=' . l:out, "\n", '; GOROOT=', '')
let l:state += s:indent(printf('%s; %s; GO111MODULE=%s', l:version, l:out,
\ $GO111MODULE is# '' ? '[unset]' : $GO111MODULE))
\ $GO111MODULE is# '' ? '(unset)' : $GO111MODULE))
endif

" gopher.vim version.
Expand Down
6 changes: 3 additions & 3 deletions autoload/gopher/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ endfun
" Get the package path for the file in the current buffer.
" TODO: cache results?
fun! gopher#go#package() abort
let [l:out, l:err] = gopher#system#run(['go', 'list', expand('%:p:h')])
if l:err
if gopher#str#has_suffix(l:out, 'cannot import absolute path')
let [l:out, l:err] = gopher#system#run(['go', 'list', expand('%:h')])
if l:err || l:out[0] is# '_'
if l:out[0] is# '_' || gopher#str#has_suffix(l:out, 'cannot import absolute path')
let l:out = 'cannot determine module path (outside GOPATH, no go.mod)'
endif
call gopher#error(l:out)
Expand Down
Loading

0 comments on commit 9cfd55d

Please sign in to comment.