Skip to content

Commit

Permalink
Provide a descriptive quickfix/location list title.
Browse files Browse the repository at this point in the history
Currently, the w:quickfix_title is being automatically set to the actual
Vim command that populates quickfix/location list. For example, running
any Guru command it will be displayed as ':    lgetexpr a:items' which
is not really informative.
  • Loading branch information
Kent Sibilev committed Aug 27, 2016
1 parent c63c798 commit 717f612
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 23 deletions.
4 changes: 2 additions & 2 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function! go#cmd#Run(bang, ...)
let items = go#list#Get(l:listtype)
let errors = go#tool#FilterValids(items)

call go#list#Populate(l:listtype, errors)
call go#list#Populate(l:listtype, errors, &makeprg)
call go#list#Window(l:listtype, len(errors))
if !empty(errors) && !a:bang
call go#list#JumpToFirst(l:listtype)
Expand Down Expand Up @@ -251,7 +251,7 @@ function! go#cmd#Test(bang, compile, ...)
let errors = go#tool#ParseErrors(split(out, '\n'))
let errors = go#tool#FilterValids(errors)

call go#list#Populate(l:listtype, errors)
call go#list#Populate(l:listtype, errors, command)
call go#list#Window(l:listtype, len(errors))
if !empty(errors) && !a:bang
call go#list#JumpToFirst(l:listtype)
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function! go#fmt#Format(withGoimport)
% | " Couldn't detect gofmt error format, output errors
endif
if !empty(errors)
call go#list#Populate(l:listtype, errors)
call go#list#Populate(l:listtype, errors, 'Format')
echohl Error | echomsg "Gofmt returned error" | echohl None
endif

Expand Down
22 changes: 11 additions & 11 deletions autoload/go/guru.vim
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ endfunc
" 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.
func! s:loclistSecond(output)
func! s:loclistSecond(output, title)
" backup users errorformat, will be restored once we are finished
let old_errorformat = &errorformat

Expand All @@ -128,7 +128,7 @@ func! s:loclistSecond(output)
" useful and location only has the ability to show one line and column
" number
let errformat = "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m"
call go#list#ParseFormat("locationlist", errformat, split(a:output, "\n"))
call go#list#ParseFormat("locationlist", errformat, split(a:output, "\n"), a:title)

let errors = go#list#Get("locationlist")
call go#list#Window("locationlist", len(errors))
Expand Down Expand Up @@ -189,7 +189,7 @@ function! go#guru#Whicherrs(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'Whicherrs')
endfunction

" Show 'implements' relation for selected package
Expand All @@ -200,7 +200,7 @@ function! go#guru#Implements(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'Implements')
endfunction

" Describe selected syntax: definition, methods, etc
Expand All @@ -211,7 +211,7 @@ function! go#guru#Describe(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'Describe')
endfunction

" Show possible targets of selected function call
Expand All @@ -222,7 +222,7 @@ function! go#guru#Callees(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'Callees')
endfunction

" Show possible callers of selected function
Expand All @@ -233,7 +233,7 @@ function! go#guru#Callers(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'Callers')
endfunction

" Show path from callgraph root to selected function
Expand All @@ -244,7 +244,7 @@ function! go#guru#Callstack(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'Callback')
endfunction

" Show free variables of selection
Expand All @@ -261,7 +261,7 @@ function! go#guru#Freevars(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'Freevars')
endfunction

" Show send/receive corresponding to selected channel op
Expand All @@ -272,7 +272,7 @@ function! go#guru#ChannelPeers(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'ChannelPeers')
endfunction

" Show all refs to entity denoted by selected identifier
Expand All @@ -283,7 +283,7 @@ function! go#guru#Referrers(selected)
return
endif

call s:loclistSecond(out.out)
call s:loclistSecond(out.out, 'Referrers')
endfunction

function! go#guru#What(selected)
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/jobcontrol.vim
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function! s:on_exit(job_id, exit_status)
" if we are still in the same windows show the list
if self.winnr == winnr()
let l:listtype = "locationlist"
call go#list#Populate(l:listtype, errors)
call go#list#Populate(l:listtype, errors, self.desc)
call go#list#Window(l:listtype, len(errors))
if !empty(errors) && !self.bang
call go#list#JumpToFirst(l:listtype)
Expand Down
8 changes: 4 additions & 4 deletions autoload/go/lint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function! go#lint#Gometa(autosave, ...) abort
let errformat = "%f:%l:%c:%t%*[^:]:\ %m,%f:%l::%t%*[^:]:\ %m"

" Parse and populate our location list
call go#list#ParseFormat(l:listtype, errformat, split(out, "\n"))
call go#list#ParseFormat(l:listtype, errformat, split(out, "\n"), 'GoMetaLinter')

let errors = go#list#Get(l:listtype)
call go#list#Window(l:listtype, len(errors))
Expand Down Expand Up @@ -129,7 +129,7 @@ function! go#lint#Vet(bang, ...)
let l:listtype = "quickfix"
if go#util#ShellError() != 0
let errors = go#tool#ParseErrors(split(out, '\n'))
call go#list#Populate(l:listtype, errors)
call go#list#Populate(l:listtype, errors, 'Vet')
call go#list#Window(l:listtype, len(errors))
if !empty(errors) && !a:bang
call go#list#JumpToFirst(l:listtype)
Expand Down Expand Up @@ -171,7 +171,7 @@ function! go#lint#Errcheck(...) abort
let errformat = "%f:%l:%c:\ %m, %f:%l:%c\ %#%m"

" Parse and populate our location list
call go#list#ParseFormat(l:listtype, errformat, split(out, "\n"))
call go#list#ParseFormat(l:listtype, errformat, split(out, "\n"), 'Errcheck')

let errors = go#list#Get(l:listtype)

Expand All @@ -182,7 +182,7 @@ function! go#lint#Errcheck(...) abort
endif

if !empty(errors)
call go#list#Populate(l:listtype, errors)
call go#list#Populate(l:listtype, errors, 'Errcheck')
call go#list#Window(l:listtype, len(errors))
if !empty(errors)
call go#list#JumpToFirst(l:listtype)
Expand Down
8 changes: 6 additions & 2 deletions autoload/go/list.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ function! go#list#Get(listtype)
endfunction

" Populate populate the location list with the given items
function! go#list#Populate(listtype, items)
function! go#list#Populate(listtype, items, title)
let l:listtype = go#list#Type(a:listtype)
if l:listtype == "locationlist"
call setloclist(0, a:items, 'r')
call setloclist(0, [], 'a', {'title': a:title})
else
call setqflist(a:items, 'r')
call setqflist([], 'a', {'title': a:title})
endif
endfunction

Expand All @@ -65,7 +67,7 @@ endfunction

" Parse parses the given items based on the specified errorformat nad
" populates the location list.
function! go#list#ParseFormat(listtype, errformat, items)
function! go#list#ParseFormat(listtype, errformat, items, title)
let l:listtype = go#list#Type(a:listtype)
" backup users errorformat, will be restored once we are finished
let old_errorformat = &errorformat
Expand All @@ -74,8 +76,10 @@ function! go#list#ParseFormat(listtype, errformat, items)
let &errorformat = a:errformat
if l:listtype == "locationlist"
lgetexpr a:items
call setloclist(0, [], 'a', {'title': a:title})
else
cgetexpr a:items
call setqflist([], 'a', {'title': a:title})
endif

"restore back
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/rename.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function! go#rename#Rename(bang, ...)
let l:listtype = "quickfix"
if go#util#ShellError() != 0
let errors = go#tool#ParseErrors(split(out, '\n'))
call go#list#Populate(l:listtype, errors)
call go#list#Populate(l:listtype, errors, 'Rename')
call go#list#Window(l:listtype, len(errors))
if !empty(errors) && !a:bang
call go#list#JumpToFirst(l:listtype)
Expand Down
3 changes: 2 additions & 1 deletion autoload/go/term.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function! go#term#newmode(bang, cmd, mode)
let $GOPATH = old_gopath

let job.id = id
let job.cmd = a:cmd
startinsert

" resize new term if needed.
Expand Down Expand Up @@ -115,7 +116,7 @@ function! s:on_exit(job_id, exit_status)
" close terminal we don't need it anymore
close

call go#list#Populate(l:listtype, errors)
call go#list#Populate(l:listtype, errors, job.cmd)
call go#list#Window(l:listtype, len(errors))
if !self.bang
call go#list#JumpToFirst(l:listtype)
Expand Down

0 comments on commit 717f612

Please sign in to comment.