From be38044b9d143101fb5cbde130cd87cf8fc9192e Mon Sep 17 00:00:00 2001 From: Billie Cleek Date: Mon, 18 Mar 2024 10:39:41 -0700 Subject: [PATCH] guru: drop guru support Guru has been removed from golang.org/x/tools/cmd/guru as described in https://docs.google.com/document/d/1_Y9xCEMj5S-7rv2ooHpZNH15JgRT5iM742gJkw5LtmQ/edit#heading=h.ojv16z1d1gas. --- autoload/go/config.vim | 22 -- autoload/go/guru.vim | 467 -------------------------------------- autoload/go/guru_test.vim | 19 -- autoload/go/referrers.vim | 5 +- autoload/go/tool.vim | 4 +- doc/vim-go.txt | 193 +--------------- ftplugin/go/commands.vim | 13 -- ftplugin/go/mappings.vim | 10 - plugin/go.vim | 1 - 9 files changed, 13 insertions(+), 721 deletions(-) delete mode 100644 autoload/go/guru.vim delete mode 100644 autoload/go/guru_test.vim diff --git a/autoload/go/config.vim b/autoload/go/config.vim index f0f13d56bb..ec70b26751 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -141,28 +141,6 @@ function! go#config#InfoMode() abort return get(g:, 'go_info_mode', 'gopls') endfunction -function! go#config#GuruScope() abort - let scope = get(g:, 'go_guru_scope', []) - - if !empty(scope) - " strip trailing slashes for each path in scope. bug: - " https://github.com/golang/go/issues/14584 - let scopes = go#util#StripTrailingSlash(scope) - endif - - return scope -endfunction - -function! go#config#SetGuruScope(scope) abort - if empty(a:scope) - if exists('g:go_guru_scope') - unlet g:go_guru_scope - endif - else - let g:go_guru_scope = a:scope - endif -endfunction - function! go#config#EchoCommandInfo() abort return get(g:, 'go_echo_command_info', 1) endfunction diff --git a/autoload/go/guru.vim b/autoload/go/guru.vim deleted file mode 100644 index a1893dbaee..0000000000 --- a/autoload/go/guru.vim +++ /dev/null @@ -1,467 +0,0 @@ -" guru.vim -- Vim integration for the Go guru. - -" don't spam the user when Vim is started in Vi compatibility mode -let s:cpo_save = &cpo -set cpo&vim - -" guru_cmd returns a dict that contains the command to execute guru. args -" is dict with following options: -" mode : guru mode, such as 'implements' -" format : output format, either 'plain' or 'json' -" needs_scope : if 1, adds the current package to the scope -" selected : if 1, means it's a range of selection, otherwise it picks up the -" offset under the cursor -" example output: -" {'cmd' : ['guru', '-json', 'implements', 'demo/demo.go:#66']} -function! s:guru_cmd(args) range abort - "if !go#package#InGOPATH() - "return {'err': 'guru only supports packages within GOPATH'} - "endif - let mode = a:args.mode - - let format = a:args.format - let needs_scope = a:args.needs_scope - let selected = a:args.selected - let postype = get(a:args, 'postype', 'cursor') - - let result = {} - - "return with a warning if the binary doesn't exist - let bin_path = go#path#CheckBinPath("guru") - if empty(bin_path) - return {'err': "bin path not found"} - endif - - " start constructing the command - let cmd = [bin_path, '-tags', go#config#BuildTags()] - - if &modified - let result.stdin_content = go#util#archive() - call add(cmd, "-modified") - endif - - " enable outputting in json format - if format == "json" - call add(cmd, "-json") - endif - - let scopes = go#config#GuruScope() - if empty(scopes) - " some modes require scope to be defined (such as callers). For these we - " choose a sensible setting, which is using the current file's package - if needs_scope - let pkg = go#package#ImportPath() - if pkg == -1 - return {'err': "current directory is not inside of a valid GOPATH"} - endif - let scopes = [pkg] - endif - endif - - " Add the scope. - if !empty(scopes) - " guru expect a comma-separated list of patterns. - let l:scope = join(scopes, ",") - let result.scope = l:scope - call extend(cmd, ["-scope", l:scope]) - endif - - if postype == 'balloon' - let pos = printf("#%s", go#util#Offset(v:beval_lnum, v:beval_col)) - else - let pos = printf("#%s", go#util#OffsetCursor()) - if selected != -1 - " means we have a range, get it - let pos1 = go#util#Offset(line("'<"), col("'<")) - let pos2 = go#util#Offset(line("'>"), col("'>")) - let pos = printf("#%s,#%s", pos1, pos2) - endif - endif - - let l:filename = fnamemodify(expand("%"), ':p:gs?\\?/?') . ':' . pos - call extend(cmd, [mode, l:filename]) - - let result.cmd = cmd - return result -endfunction - -" sync_guru runs guru in sync mode with the given arguments -function! s:sync_guru(args) abort - let result = s:guru_cmd(a:args) - if has_key(result, 'err') - call go#util#EchoError(result.err) - return -1 - endif - - if !has_key(a:args, 'disable_progress') - if a:args.needs_scope - call go#util#EchoProgress("analysing with scope ". result.scope . - \ " (see ':help go-guru-scope' if this doesn't work)...") - elseif a:args.mode !=# 'what' - " the query might take time, let us give some feedback - call go#util#EchoProgress("analysing ...") - endif - endif - - " run, forrest run!!! - if has_key(l:result, 'stdin_content') - let [l:out, l:err] = go#util#Exec(l:result.cmd, l:result.stdin_content) - else - let [l:out, l:err] = go#util#Exec(l:result.cmd) - endif - - if has_key(a:args, 'custom_parse') - call a:args.custom_parse(l:err, l:out, a:args.mode) - else - call s:parse_guru_output(l:err, l:out, a:args.mode) - endif - - return l:out -endfunc - -" async_guru runs guru in async mode with the given arguments -function! s:async_guru(args) abort - let result = s:guru_cmd(a:args) - if has_key(result, 'err') - call go#util#EchoError(result.err) - return - endif - - let state = { - \ 'mode': a:args.mode, - \ 'parse' : get(a:args, 'custom_parse', funcref("s:parse_guru_output")) - \ } - - " explicitly bind complete to state so that within it, self will - " always refer to state. See :help Partial for more information. - let state.complete = function('s:complete', [], state) - - let opts = { - \ 'statustype': get(a:args, 'statustype', a:args.mode), - \ 'for': '_', - \ 'errorformat': "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m", - \ 'complete': state.complete, - \ } - - if has_key(a:args, 'disable_progress') - let opts.statustype = '' - endif - - let opts = go#job#Options(l:opts) - - if has_key(result, 'stdin_content') - let l:tmpname = tempname() - call writefile(split(result.stdin_content, "\n"), l:tmpname, "b") - let l:opts.in_io = "file" - let l:opts.in_name = l:tmpname - endif - - call go#job#Start(result.cmd, opts) - - if a:args.needs_scope && go#config#EchoCommandInfo() && !has_key(a:args, 'disable_progress') - call go#util#EchoProgress("analysing with scope " . result.scope . - \ " (see ':help go-guru-scope' if this doesn't work)...") - endif -endfunc - -function! s:complete(job, exit_status, messages) dict abort - let output = join(a:messages, "\n") - call self.parse(a:exit_status, output, self.mode) -endfunction - -" run_guru runs the given guru argument -function! s:run_guru(args) abort - if go#util#has_job() - let res = s:async_guru(a:args) - else - let res = s:sync_guru(a:args) - endif - - return res -endfunction - -" Show 'implements' relation for selected package -function! go#guru#Implements(selected) abort - let args = { - \ 'mode': 'implements', - \ 'format': 'plain', - \ 'selected': a:selected, - \ 'needs_scope': 1, - \ } - - call s:run_guru(args) -endfunction - -" Shows the set of possible objects to which a pointer may point. -function! go#guru#PointsTo(selected) abort - let l:args = { - \ 'mode': 'pointsto', - \ 'format': 'plain', - \ 'selected': a:selected, - \ 'needs_scope': 1, - \ } - - call s:run_guru(l:args) -endfunction - -" Report the possible constants, global variables, and concrete types that may -" appear in a value of type error -function! go#guru#Whicherrs(selected) abort - let args = { - \ 'mode': 'whicherrs', - \ 'format': 'plain', - \ 'selected': a:selected, - \ 'needs_scope': 1, - \ } - - - " TODO(arslan): handle empty case for both sync/async - " if empty(out.out) - " call go#util#EchoSuccess("no error variables found. Try to change the scope with :GoGuruScope") - " return - " endif - call s:run_guru(args) -endfunction - -" Describe selected syntax: definition, methods, etc -function! go#guru#Describe(selected) abort - let args = { - \ 'mode': 'describe', - \ 'format': 'plain', - \ 'selected': a:selected, - \ 'needs_scope': 1, - \ } - - call s:run_guru(args) -endfunction - -function! go#guru#DescribeInfo(showstatus) abort - - " check if the version of Vim being tested supports json_decode() - if !exists("*json_decode") - call go#util#EchoError("GoDescribeInfo requires 'json_decode'. Update your Vim/Neovim version.") - return - endif - - let args = { - \ 'mode': 'describe', - \ 'format': 'json', - \ 'selected': -1, - \ 'needs_scope': 0, - \ 'custom_parse': function('s:info'), - \ 'disable_progress': a:showstatus == 0, - \ } - - call s:run_guru(args) -endfunction - -function! s:info(exit_val, output, mode) - if a:exit_val != 0 - return - endif - - if a:output[0] !=# '{' - return - endif - - if empty(a:output) || type(a:output) != type("") - return - endif - - let result = json_decode(a:output) - if type(result) != type({}) - call go#util#EchoError(printf("malformed output from guru: %s", a:output)) - return - endif - - if !has_key(result, 'detail') - " if there is no detail check if there is a description and print it - if has_key(result, "desc") - call go#util#EchoInfo(result["desc"]) - return - endif - - call go#util#EchoError("detail key is missing. Please open a bug report on vim-go repo.") - return - endif - - let detail = result['detail'] - let info = "" - - " guru gives different information based on the detail mode. Let try to - " extract the most useful information - - if detail == "value" - if !has_key(result, 'value') - call go#util#EchoError("value key is missing. Please open a bug report on vim-go repo.") - return - endif - - let val = result["value"] - if !has_key(val, 'type') - call go#util#EchoError("type key is missing (value.type). Please open a bug report on vim-go repo.") - return - endif - - let info = val["type"] - elseif detail == "type" - if !has_key(result, 'type') - call go#util#EchoError("type key is missing. Please open a bug report on vim-go repo.") - return - endif - - let type = result["type"] - if !has_key(type, 'type') - call go#util#EchoError("type key is missing (type.type). Please open a bug report on vim-go repo.") - return - endif - - let info = type["type"] - elseif detail == "package" - if !has_key(result, 'package') - call go#util#EchoError("package key is missing. Please open a bug report on vim-go repo.") - return - endif - - let package = result["package"] - if !has_key(package, 'path') - call go#util#EchoError("path key is missing (package.path). Please open a bug report on vim-go repo.") - return - endif - - let info = printf("package %s", package["path"]) - elseif detail == "unknown" - let info = result["desc"] - else - call go#util#EchoError(printf("unknown detail mode found '%s'. Please open a bug report on vim-go repo", detail)) - return - endif - - call go#util#ShowInfo(info) -endfunction - -" Show possible targets of selected function call -function! go#guru#Callees(selected) abort - let args = { - \ 'mode': 'callees', - \ 'format': 'plain', - \ 'selected': a:selected, - \ 'needs_scope': 1, - \ } - - call s:run_guru(args) -endfunction - -" Show path from callgraph root to selected function -function! go#guru#Callstack(selected) abort - let args = { - \ 'mode': 'callstack', - \ 'format': 'plain', - \ 'selected': a:selected, - \ 'needs_scope': 1, - \ } - - call s:run_guru(args) -endfunction - -" Show free variables of selection -function! go#guru#Freevars(selected) abort - " Freevars requires a selection - if a:selected == -1 - call go#util#EchoError("GoFreevars requires a selection (range) of code") - return - endif - - let args = { - \ 'mode': 'freevars', - \ 'format': 'plain', - \ 'selected': 1, - \ 'needs_scope': 0, - \ } - - call s:run_guru(args) -endfunction - -" Show send/receive corresponding to selected channel op -function! go#guru#ChannelPeers(selected) abort - let args = { - \ 'mode': 'peers', - \ 'format': 'plain', - \ 'selected': a:selected, - \ 'needs_scope': 1, - \ } - - call s:run_guru(args) -endfunction - -" Show all refs to entity denoted by selected identifier -function! go#guru#Referrers(selected) abort - let args = { - \ 'mode': 'referrers', - \ 'format': 'plain', - \ 'selected': a:selected, - \ 'needs_scope': 0, - \ } - - call s:run_guru(args) -endfunction - -"""""""""""""""""""""""""""""""""""""""" -"" HELPER FUNCTIONS -"""""""""""""""""""""""""""""""""""""""" - -" This uses Vim's errorformat to parse the output from Guru's 'plain output -" and put it into location list. I believe using errorformat is much more -" easier to use. If we need more power we can always switch back to parse it -" via regex. Match two possible styles of errorformats: -" -" 'file:line.col-line2.col2: message' -" 'file:line:col: message' -" -" We discard line2 and col2 for the first errorformat, because it's not -" useful and location only has the ability to show one line and column -" number -function! s:parse_guru_output(exit_val, output, title) abort - if a:exit_val - call go#util#EchoError(a:output) - return - endif - - let errformat = "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m" - let l:listtype = go#list#Type("_guru") - call go#list#ParseFormat(l:listtype, errformat, a:output, a:title, 0) - - let errors = go#list#Get(l:listtype) - call go#list#Window(l:listtype, len(errors)) -endfunction - -function! go#guru#Scope(...) abort - if a:0 - let scope = a:000 - if a:0 == 1 && a:1 == '""' - let scope = [] - endif - - call go#config#SetGuruScope(scope) - if empty(scope) - call go#util#EchoSuccess("guru scope is cleared") - else - call go#util#EchoSuccess("guru scope changed to: ". join(a:000, ",")) - endif - - return - endif - - let scope = go#config#GuruScope() - if empty(scope) - call go#util#EchoError("guru scope is not set") - else - call go#util#EchoSuccess("current guru scope: ". join(scope, ",")) - endif -endfunction - -" restore Vi compatibility settings -let &cpo = s:cpo_save -unlet s:cpo_save - -" vim: sw=2 ts=2 et diff --git a/autoload/go/guru_test.vim b/autoload/go/guru_test.vim deleted file mode 100644 index 63b41a6c3f..0000000000 --- a/autoload/go/guru_test.vim +++ /dev/null @@ -1,19 +0,0 @@ -" don't spam the user when Vim is started in Vi compatibility mode -let s:cpo_save = &cpo -set cpo&vim - -function Test_GuruScope_Set() abort - silent call go#guru#Scope("example.com/foo/bar") - let actual = go#config#GuruScope() - call assert_equal(["example.com/foo/bar"], actual) - - silent call go#guru#Scope('""') - silent let actual = go#config#GuruScope() - call assert_equal([], actual, "setting scope to empty string should clear") -endfunction - -" restore Vi compatibility settings -let &cpo = s:cpo_save -unlet s:cpo_save - -" vim: sw=2 ts=2 et diff --git a/autoload/go/referrers.vim b/autoload/go/referrers.vim index bf52652e8b..755bae8ae9 100644 --- a/autoload/go/referrers.vim +++ b/autoload/go/referrers.vim @@ -4,10 +4,7 @@ set cpo&vim function! go#referrers#Referrers(selected) abort let l:mode = go#config#ReferrersMode() - if l:mode == 'guru' - call go#guru#Referrers(a:selected) - return - elseif l:mode == 'gopls' + if l:mode == 'gopls' if !go#config#GoplsEnabled() call go#util#EchoError("go_referrers_mode is 'gopls', but gopls is disabled") return diff --git a/autoload/go/tool.vim b/autoload/go/tool.vim index d3dd5dee3b..c7a47fc9f2 100644 --- a/autoload/go/tool.vim +++ b/autoload/go/tool.vim @@ -82,9 +82,7 @@ endfunction function! go#tool#Info(showstatus) abort let l:mode = go#config#InfoMode() - if l:mode == 'guru' - call go#guru#DescribeInfo(a:showstatus) - elseif l:mode == 'gopls' + if l:mode == 'gopls' if !go#config#GoplsEnabled() call go#util#EchoError("go_info_mode is 'gopls', but gopls is disabled") return diff --git a/doc/vim-go.txt b/doc/vim-go.txt index f29672563e..900467fbaa 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -56,10 +56,8 @@ experience. quickfix or location list. * Lint your code with |:GoLint|, run your code through |:GoVet| to catch static errors, or make sure errors are checked with |:GoErrCheck|. - * Advanced source analysis tools utilizing `guru`, such as |:GoImplements|, - |:GoCallees|, and |:GoReferrers|. - * Automatic `GOPATH` detection which works with `gb` and `godep`. Change or - display `GOPATH` with |:GoPath|. + * Advanced source analysis tools utilizing ``gopls`, such as + * |:GoImplements| and |:GoReferrers|. * Integrated and improved snippets, supporting `ultisnips`, `neosnippet`, and `vim-minisnip`. * Share your current code to `go.dev/play` with |:GoPlay|. @@ -376,10 +374,7 @@ CTRL-t :GoInfo Show type information about the identifier under the cursor. For example putting it above a function call is going to show the full function - signature. By default it uses `gopls` to get the type informations. To - change the underlying tool from `gopls` to another tool, see - |'g:go_info_mode'|. - + signature. By default it uses `gopls` to get the type informations. *:GoInstall* :GoInstall[!] [options] @@ -546,89 +541,6 @@ CTRL-t If [!] is not given the first error is jumped to. - *:GoGuruScope* -:GoGuruScope [pattern] ... - - Changes the custom |'g:go_guru_scope'| setting and overrides it with the - given package patterns. The custom scope is cleared (unset) if `""` is - given as the only path. If no arguments is given it prints the current - custom scope. Example patterns are: -> - golang.org/x/tools/cmd/guru # a single package - golang.org/x/tools/... # all packages beneath dir - ... # the entire workspace. -< - Example usage, the following sets the scope to a `github.com/fatih/color` - and to all packages under `golang.org/x/tools/`: -> - :GoGuruScope github.com/fatih/color golang.org/x/tools/... -< - The following sets it to the entire workspace: -> - :GoGuruScope ... -< - Under the hood, the patterns are all joined to a comma-separated list and - passed to `guru`'s `-scope` flag. - - Also see |go-guru-scope|. - - *:GoCallees* -:GoCallees - - Show "callees" relation for a selected package. A list of possible call - targets for the type under the cursor (or selected package) is shown in a - location list. - - *:GoCallers* -:GoCallers - - Show "callers" relation for a selected function. A list of possible - callers for the selected function under the cursor is shown in a location - list. - - *:GoDescribe* -:GoDescribe - - Shows various properties of the selected syntax: its syntactic kind, its - type (for an expression), its value (for a constant expression), its size, - alignment, method set and interfaces (for a type), its declaration (for an - identifier), etc. Almost any piece of syntax may be described, and the - guru will try to print all the useful information it can. - - *:GoCallstack* -:GoCallstack - - Shows "callstack" relation for the selected function. An arbitrary path - from the root of the callgraph to the selected function is shown in a - location list. This may be useful to understand how the function is - reached in a given program. - - *:GoFreevars* -:GoFreevars - - Enumerates the free variables of the selection. "Free variables" is a - technical term meaning the set of variables that are referenced but not - defined within the selection, or loosely speaking, its inputs. - - This information is useful when considering whether to refactor the - selection into a function of its own, as the free variables would be the - necessary parameters of that function. It's also useful when you want to - understand what the inputs are to a complex block of code even if you - don’t plan to change it. - - *:GoChannelPeers* -:GoChannelPeers - - Shows the set of possible sends/receives on the channel operand of the - selected send or receive operation; the selection must be a `<-` token. - - For example, visually select a channel operand in the form of: -> - done <- true -< - And call |:GoChannelPeers| on it. It will show where it was allocated, and - the sending and receiving endings. - *:GoReferrers* :GoReferrers @@ -687,9 +599,9 @@ CTRL-t :GoBuildTags [tags] Changes the build tags for various commands. If you have any file that - uses a custom build tag, such as `// +build integration` , this command + uses a custom build tag, such as `// +build integration`, this command can be used to pass it to all tools that accepts tags, such as gopls, - guru, gorename, etc. + gorename, etc. The build tags is cleared (unset) if `""` is given. If no arguments are given it prints the current build tags. @@ -722,17 +634,6 @@ CTRL-t augroup END < - *:GoPointsTo* -:GoPointsTo - - Show all variables to which the pointer under the cursor may point to. - - *:GoWhicherrs* -:GoWhicherrs - - Show the list of possible constants, global variables, and concrete types - for the error type under the cursor in a location list. - *:GoDecls* :GoDecls [file] @@ -1347,15 +1248,6 @@ updated. By default it's disabled. The delay can be configured with the let g:go_auto_type_info = 0 < - *'g:go_info_mode'* - -Use this option to define the command to be used for |:GoInfo|. By default -`gopls` is used, because it is the fastest and is known to be highly accurate. -One might also use `guru` for its accuracy. -Valid options are `gopls` and `guru`. -> - let g:go_info_mode = 'gopls' -< *'g:go_auto_sameids'* Use this option to highlight all uses of the identifier under the cursor @@ -1520,9 +1412,7 @@ Use this option to use the popup-window for |K| and |:GoDoc|, rather than the *'g:go_def_mode'* Use this option to define the command to be used for |:GoDef|. By default -`gopls` is used, because it is the fastest. One might also use `guru` for its -accuracy or `godef` for its performance. Valid options are `godef`, `gopls`, -and `guru`. +`gopls` is used, because it is the fastest. Valid options are `godef` and `gopls`. > let g:go_def_mode = 'gopls' < @@ -1533,22 +1423,6 @@ default `fillstruct` is used. Valid values are `fillstruct` and `gopls`. By default it is `fillstruct`. > let g:go_fillstruct_mode = 'fillstruct' -< - *'g:go_referrers_mode'* - -Use this option to define the command to be used for |:GoReferrers|. By -default `gopls` is used, because it is the fastest and works with Go modules. -Valid options are `gopls` and `guru`. By default it's `gopls`. -> - let g:go_referrers_mode = 'gopls' -< - *'g:go_implements_mode'* - -Use this option to define the command to be used for |:GoImplements|. -The Implements feature in gopls is still new and being worked upon. -Valid options are `gopls` and `guru`. By default it's `gopls`. -> - let g:go_implements_mode = 'gopls' < *'g:go_def_mapping_enabled'* @@ -1607,20 +1481,6 @@ Use this option to disable updating dependencies with |:GoInstallBinaries|. By default this is enabled. > let g:go_get_update = 1 -< - *'g:go_guru_scope'* - -Use this option to define the scope of the analysis to be passed for guru -related commands, such as |:GoImplements|, |:GoChannelPeers|, etc. You can -change it on-the-fly with |:GoGuruScope|. The input should be a a list of -package pattern. An example input might be: -`["github.com/fatih/color","github.com/fatih/structs"]` - -Also see |go-guru-scope|. - -By default it's not set, so the relevant commands' defaults are being used. -> - let g:go_guru_scope = [] < *'g:go_build_tags'* @@ -2665,10 +2525,10 @@ Completion and other functions that use `gopls` don't work~ Vim-go is heavily reliant on `gopls` for completion and other functionality. Many of the features that use `gopls` (e.g. completion, jumping to definitions, showing identifier information, et al.) can be configured to -delegate to other tools. e.g. completion via 'omnifunc', |'g:go_info_mode'| -and |'g:go_def_mode'| can be set to use other tools for now (though some of -the alternatives to `gopls` are effectively at their end of life and support -for them from within vim-go may be removed soon). +delegate to other tools. e.g. completion via 'omnifunc' and |'g:go_def_mode'| +can be set to use other tools for now (though some of the alternatives to +`gopls` are effectively at their end of life and support for them from within +vim-go may be removed soon). I want to disable `gopls`~ @@ -2728,36 +2588,6 @@ After opening vim, run `:echo $PATH`, the output must be your current `$PATH` plus `$GOPATH/bin` (the location where |:GoInstallBinaries| installed the binaries). - *go-guru-scope* -What is the guru scope and how do I set it?~ - -Many vim-go commands use the `guru` commandline tool to get information. Some -`guru` commands require an expensive analysis of the source code. To still get -a reasonable amount of performance `guru` limits this analysis to a selected -list of packages. This is known as the "guru scope". - -The default is to use the package the current buffer belongs to, but this may -not always be correct. For example for the file `github.com/user/pkg/a/a.go` -the scope will be set to `github.com/user/pkg/a`, but you probably want -`github.com/user/pkg` - -Guessing what package(s) you do want is not easy so you may need to set this -manually, usually from an |autocommand|: -> - autocmd BufRead /home/martin/go/src/github.com/user/pkg/*.go - \ :GoGuruScope github.com/user/pkg -< - -If you have a lot of packages with the same prefix (`github.com/user`) you can -use a single autocommand: -> - autocmd BufRead /home/martin/go/src/*.go - \ let s:tmp = matchlist(expand('%:p'), - \ '/home/martin/go/src/\(github.com/user/[^/]\+\)') - \| if len(s:tmp) > 1 | exe 'silent :GoGuruScope ' . s:tmp[1] | endif - \| unlet s:tmp -< -Also see |:GoGuruScope| and |'g:go_guru_scope'|. Vim becomes slow while editing Go files~ @@ -2770,8 +2600,7 @@ the problem should be restricted to a short period when the first buffer in a package is first loaded. If you see unexpected characters rendered in the current window, the problem -is most likely due to |'g:go_auto_sameids'| or |'g:go_auto_type_info'|. First, -try using another mode for |'g:go_info_mode'|. If that doesn't work, try +is most likely due to |'g:go_auto_sameids'| or |'g:go_auto_type_info'|. Try disabling |'g:go_auto_sameids'| and |'g:go_auto_type_info'|. To a lesser extent, this can be caused by `g:go_highlight_*` options. If Vim diff --git a/ftplugin/go/commands.vim b/ftplugin/go/commands.vim index b354fad2fc..79d917317b 100644 --- a/ftplugin/go/commands.vim +++ b/ftplugin/go/commands.vim @@ -1,19 +1,6 @@ " -- gorename command! -nargs=? -complete=customlist,go#rename#Complete GoRename call go#rename#Rename(0, ) -" -- guru -" do not configure commands that _require_ guru when not in GOPATH mode. -"if go#package#InGOPATH() - command! -nargs=* -complete=customlist,go#package#Complete GoGuruScope call go#guru#Scope() - command! -range=% GoPointsTo call go#guru#PointsTo() - command! -range=% GoWhicherrs call go#guru#Whicherrs() - command! -range=% GoCallees call go#guru#Callees() - command! -range=% GoDescribe call go#guru#Describe() - command! -range=% GoCallstack call go#guru#Callstack() - command! -range=% GoFreevars call go#guru#Freevars() - command! -range=% GoChannelPeers call go#guru#ChannelPeers() -"endif - command! -range=% GoImplements call go#implements#Implements() command! -range=% GoReferrers call go#referrers#Referrers() command! -range=0 GoSameIds call go#sameids#SameIds(1) diff --git a/ftplugin/go/mappings.vim b/ftplugin/go/mappings.vim index 49cf05da0a..a210e8d89e 100644 --- a/ftplugin/go/mappings.vim +++ b/ftplugin/go/mappings.vim @@ -38,18 +38,8 @@ nnoremap (go-imports) :call go#fmt#Format(1) nnoremap (go-fmt) :call go#fmt#Format(0) nnoremap (go-implements) :call go#implements#Implements(-1) -nnoremap (go-callees) :call go#guru#Callees(-1) -nnoremap (go-callers) :call go#calls#Callers() -nnoremap (go-describe) :call go#guru#Describe(-1) -nnoremap (go-callstack) :call go#guru#Callstack(-1) -xnoremap (go-freevars) :call go#guru#Freevars(0) -" go-channelpeers is deprecated, but remains for backward compatibility -nnoremap (go-channelpeers) :call go#guru#ChannelPeers(-1) -nnoremap (go-channel-peers) :call go#guru#ChannelPeers(-1) nnoremap (go-referrers) :call go#referrers#Referrers(-1) nnoremap (go-sameids) :call go#sameids#SameIds(1) -nnoremap (go-pointsto) :call go#guru#PointsTo(-1) -nnoremap (go-whicherrs) :call go#guru#Whicherrs(-1) nnoremap (go-sameids-toggle) :call go#sameids#ToggleSameIds() nnoremap (go-rename) :call go#rename#Rename(!g:go_jump_to_error) diff --git a/plugin/go.vim b/plugin/go.vim index 5e8d1b4615..b8992437e5 100644 --- a/plugin/go.vim +++ b/plugin/go.vim @@ -53,7 +53,6 @@ let s:packages = { \ 'gomodifytags': ['github.com/fatih/gomodifytags@latest'], \ 'gorename': ['golang.org/x/tools/cmd/gorename@master'], \ 'gotags': ['github.com/jstemmer/gotags@master'], - \ 'guru': ['golang.org/x/tools/cmd/guru@v0.19.0'], \ 'impl': ['github.com/josharian/impl@main'], \ 'keyify': ['honnef.co/go/tools/cmd/keyify@master'], \ 'motion': ['github.com/fatih/motion@latest'],