Skip to content

Display statuslines consistently #1937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions autoload/go/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ function! go#complete#GetInfo() abort
return s:sync_info(0)
endfunction

function! go#complete#Info() abort
function! go#complete#Info(showstatus) abort
if go#util#has_job(1) || has('nvim')
return s:async_info(1)
return s:async_info(1, a:showstatus)
else
return s:sync_info(1)
endif
endfunction

function! s:async_info(echo)
function! s:async_info(echo, showstatus)
let state = {'echo': a:echo}

function! s:complete(job, exit_status, messages) abort dict
Expand Down Expand Up @@ -113,6 +113,10 @@ function! s:async_info(echo)
\ 'for': '_',
\ }

if a:showstatus
let opts.statustype = 'gocode'
endif

let opts = go#job#Options(l:opts)

let cmd = s:gocodeCommand('autocomplete',
Expand Down
15 changes: 12 additions & 3 deletions autoload/go/guru.vim
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function! s:async_guru(args) abort
let state.complete = function('s:complete', [], state)

let opts = {
\ 'statustype': printf("%s", a:args.mode),
\ 'statustype': get(a:args, 'statustype', a:args.mode),
\ 'for': '_',
\ 'errorformat': "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m",
\ 'complete': state.complete,
Expand Down Expand Up @@ -219,7 +219,7 @@ function! go#guru#Describe(selected) abort
call s:run_guru(args)
endfunction

function! go#guru#DescribeInfo() abort
function! go#guru#DescribeInfo(showstatus) abort
" json_encode() and friends are introduced with this patch (7.4.1304)
" vim: https://groups.google.com/d/msg/vim_dev/vLupTNhQhZ8/cDGIk0JEDgAJ
" nvim: https://github.com/neovim/neovim/pull/4131
Expand Down Expand Up @@ -315,13 +315,18 @@ function! go#guru#DescribeInfo() abort

let args = {
\ 'mode': 'describe',
\ 'statustype': '',
\ 'format': 'json',
\ 'selected': -1,
\ 'needs_scope': 0,
\ 'custom_parse': function('s:info'),
\ 'disable_progress': 1,
\ }

if a:showstatus
let args.statustype = args.mode
endif

call s:run_guru(args)
endfunction

Expand Down Expand Up @@ -403,7 +408,7 @@ function! go#guru#Referrers(selected) abort
call s:run_guru(args)
endfunction

function! go#guru#SameIds() abort
function! go#guru#SameIds(showstatus) abort
" we use matchaddpos() which was introduce with 7.4.330, be sure we have
" it: http://ftp.vim.org/vim/patches/7.4/7.4.330
if !exists("*matchaddpos")
Expand All @@ -421,11 +426,15 @@ function! go#guru#SameIds() abort

let args = {
\ 'mode': 'what',
\ 'statustype': '',
\ 'format': 'json',
\ 'selected': -1,
\ 'needs_scope': 0,
\ 'custom_parse': function('s:same_ids_highlight'),
\ }
if a:showstatus
let args.statustype = args.mode
endif

call s:run_guru(args)
endfunction
Expand Down
6 changes: 3 additions & 3 deletions autoload/go/tool.vim
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ function! go#tool#Imports() abort
return imports
endfunction

function! go#tool#Info() abort
function! go#tool#Info(showstatus) abort
let l:mode = go#config#InfoMode()
if l:mode == 'gocode'
call go#complete#Info()
call go#complete#Info(a:showstatus)
elseif l:mode == 'guru'
call go#guru#DescribeInfo()
call go#guru#DescribeInfo(a:showstatus)
else
call go#util#EchoError('go_info_mode value: '. l:mode .' is not valid. Valid values are: [gocode, guru]')
endif
Expand Down
4 changes: 2 additions & 2 deletions ftplugin/go/commands.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ command! -range=% GoFreevars call go#guru#Freevars(<count>)
command! -range=% GoChannelPeers call go#guru#ChannelPeers(<count>)
command! -range=% GoReferrers call go#guru#Referrers(<count>)

command! -range=0 GoSameIds call go#guru#SameIds()
command! -range=0 GoSameIds call go#guru#SameIds(1)
command! -range=0 GoSameIdsClear call go#guru#ClearSameIds()
command! -range=0 GoSameIdsToggle call go#guru#ToggleSameIds()
command! -range=0 GoSameIdsAutoToggle call go#guru#AutoToogleSameIds()
Expand All @@ -29,7 +29,7 @@ command! -nargs=0 -range GoModFmt call go#mod#Format()
" -- tool
command! -nargs=* -complete=customlist,go#tool#ValidFiles GoFiles echo go#tool#Files(<f-args>)
command! -nargs=0 GoDeps echo go#tool#Deps()
command! -nargs=0 GoInfo call go#tool#Info()
command! -nargs=0 GoInfo call go#tool#Info(1)
command! -nargs=0 GoAutoTypeInfoToggle call go#complete#ToggleAutoTypeInfo()

" -- cmd
Expand Down
4 changes: 2 additions & 2 deletions plugin/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ endfunction
function! s:auto_type_info()
" GoInfo automatic update
if get(g:, "go_auto_type_info", 0)
call go#tool#Info()
call go#tool#Info(0)
endif
endfunction

function! s:auto_sameids()
" GoSameId automatic update
if get(g:, "go_auto_sameids", 0)
call go#guru#SameIds()
call go#guru#SameIds(0)
endif
endfunction

Expand Down