Skip to content

Commit

Permalink
Provide a descriptive quickfix/location list title. (#1004)
Browse files Browse the repository at this point in the history
quickfix: provide a descriptive quickfix/location list title.

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
datanoise authored and fatih committed Nov 25, 2016
1 parent 96a07bd commit 01ec25c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 17 deletions.
4 changes: 2 additions & 2 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function! go#cmd#Run(bang, ...) abort
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 @@ -285,7 +285,7 @@ function! go#cmd#Test(bang, compile, ...) abort
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) abort
% | " 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
8 changes: 4 additions & 4 deletions autoload/go/guru.vim
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function! s:sync_guru(args) abort
if has_key(a:args, 'custom_parse')
call a:args.custom_parse(go#util#ShellError(), out)
else
call s:parse_guru_output(go#util#ShellError(), out)
call s:parse_guru_output(go#util#ShellError(), out, a:args.mode)
endif

return out
Expand Down Expand Up @@ -193,7 +193,7 @@ function! s:async_guru(args) abort
if has_key(a:args, 'custom_parse')
call a:args.custom_parse(l:info.exitval, out)
else
call s:parse_guru_output(l:info.exitval, out)
call s:parse_guru_output(l:info.exitval, out, a:args.mode)
endif
endfunction

Expand Down Expand Up @@ -584,15 +584,15 @@ endfunction
" 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) abort
function! s:parse_guru_output(exit_val, output, title) abort
if a:exit_val
call go#util#EchoError(a:output)
return
endif

let old_errorformat = &errorformat
let errformat = "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m"
call go#list#ParseFormat("locationlist", errformat, a:output)
call go#list#ParseFormat("locationlist", errformat, a:output, a:title)
let &errorformat = old_errorformat

let errors = go#list#Get("locationlist")
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/job.vim
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function go#job#Spawn(args)
endif

if self.winnr == winnr()
call go#list#Populate(a:listtype, errors)
call go#list#Populate(a:listtype, errors, join(self.args))
call go#list#Window(a:listtype, len(errors))
if !empty(errors) && !self.bang
call go#list#JumpToFirst(a:listtype)
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/jobcontrol.vim
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function! s:on_exit(job_id, exit_status) abort

" if we are still in the same windows show the list
if self.winnr == winnr()
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
14 changes: 10 additions & 4 deletions autoload/go/lint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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 @@ -134,7 +134,7 @@ function! go#lint#Vet(bang, ...) abort
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 @@ -176,7 +176,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 @@ -187,7 +187,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 Expand Up @@ -269,6 +269,12 @@ function s:lint_job(args)
let errors = go#list#Get(l:listtype)
if empty(errors)
call go#list#Window(l:listtype, len(errors))
else
if l:listtype == 'quickfix'
call setqflist([], 'a', {'title': 'Lint'})
else
call setloclist(0, [], 'a', {'title': 'Lint'})
endif
endif

if get(g:, 'go_echo_command_info', 1)
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) abort
endfunction

" Populate populate the location list with the given items
function! go#list#Populate(listtype, items) abort
function! go#list#Populate(listtype, items, title) abort
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) abort
function! go#list#ParseFormat(listtype, errformat, items, title) abort
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) abort
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 @@ -118,7 +118,7 @@ function s:parse_errors(exit_val, bang, out)
if a:exit_val != 0
call go#util#EchoError("FAILED")
let errors = go#tool#ParseErrors(a:out)
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) abort
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) abort
" 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 01ec25c

Please sign in to comment.