Skip to content
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

Show multiline errors #1456

Merged
merged 3 commits into from
Sep 18, 2017
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
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ IMPROVEMENTS:
easier to use [[GH-1386]](https://github.com/fatih/vim-go/pull/1386)
* `:GoDef` sets the path of new buffers as relative to the current directory
when appropriate, instead of always using the full path [[GH-1277]](https://github.com/fatih/vim-go/pull/1277).
* Syntax highlighting for variable declarations (disabled by default) [[GH-1426]](https://github.com/fatih/vim-go/pull/1426).
* Syntax highlighting for variable declarations and assignments (disabled by default)
[[GH-1426]](https://github.com/fatih/vim-go/pull/1426) and
[[GH-1458]](https://github.com/fatih/vim-go/pull/1458).

* Add support for `:GoDecls[Dir]` in [unite.vim](https://github.com/Shougo/unite.vim) [[GH-1391]](https://github.com/fatih/vim-go/pull/1391).
* Support relative imports for `:GoImpl` [[GH-1322]](https://github.com/fatih/vim-go/pull/1322).
* A new `g:go_list_type_commands` setting is added to individually set the list type for each command [[GH-1415]](https://github.com/fatih/vim-go/pull/1415). As en example:

let g:go_list_type_commands = {"GoBuild": "quickfix", "GoTest": "locationlist"}

* Variable assignments are highlighted when `g:go_highlight_variable_assignments` is enabled [[GH-1458]](https://github.com/fatih/vim-go/pull/1458)
* Show unexpected errors better by expanding newlines and tabs
[[GH-1456]](https://github.com/fatih/vim-go/pull/1456).

BUG FIXES:

Expand Down
3 changes: 1 addition & 2 deletions autoload/go/job.vim
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ function go#job#Spawn(args)

if !len(errors)
" failed to parse errors, output the original content
call go#util#EchoError(join(self.messages, " "))
call go#util#EchoError(self.dir)
call go#util#EchoError(self.messages + [self.dir])
return
endif

Expand Down
2 changes: 1 addition & 1 deletion autoload/go/rename.vim
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function s:parse_errors(exit_val, bang, out)
call go#list#JumpToFirst(l:listtype)
elseif empty(errors)
" failed to parse errors, output the original content
call go#util#EchoError(join(a:out, ""))
call go#util#EchoError(a:out)
endif

return
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/test.vim
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function! s:show_errors(args, exit_val, messages) abort

if !len(errors)
" failed to parse errors, output the original content
call go#util#EchoError(join(a:messages, " "))
call go#util#EchoError(a:messages)
call go#util#EchoError(a:args.dir)
return
endif
Expand Down
36 changes: 23 additions & 13 deletions autoload/go/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -261,29 +261,39 @@ function! go#util#camelcase(word) abort
endif
endfunction

" TODO(arslan): I couldn't parameterize the highlight types. Check if we can
" simplify the following functions
" Echo a message to the screen and highlight it with the group in a:hi.
"
" NOTE(arslan): echon doesn't work well with redraw, thus echo doesn't print
" even though we order it. However echom seems to be work fine.
function! go#util#EchoSuccess(msg)
redraw | echohl Function | echom "vim-go: " . a:msg | echohl None
" The message can be a list or string; every line with be :echomsg'd separately.
function! s:echo(msg, hi)
let l:msg = a:msg
if type(l:msg) != v:t_list
let l:msg = split(l:msg, "\n")
endif

" Tabs display as ^I or <09>, so manually expand them.
let l:msg = map(l:msg, 'substitute(v:val, "\t", " ", "")')

exe 'echohl ' . a:hi
for line in l:msg
echom "vim-go: " . line
endfor
echohl None
endfunction

function! go#util#EchoSuccess(msg)
call s:echo(a:msg, 'Function')
endfunction
function! go#util#EchoError(msg)
redraw | echohl ErrorMsg | echom "vim-go: " . a:msg | echohl None
call s:echo(a:msg, 'ErrorMsg')
endfunction

function! go#util#EchoWarning(msg)
redraw | echohl WarningMsg | echom "vim-go: " . a:msg | echohl None
call s:echo(a:msg, 'WarningMsg')
endfunction

function! go#util#EchoProgress(msg)
redraw | echohl Identifier | echom "vim-go: " . a:msg | echohl None
call s:echo(a:msg, 'Identifier')
endfunction

function! go#util#EchoInfo(msg)
redraw | echohl Debug | echom "vim-go: " . a:msg | echohl None
call s:echo(a:msg, 'Debug')
endfunction

function! go#util#GetLines()
Expand Down