Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3dc3fa0d
Commit
3dc3fa0d
authored
Sep 22, 2011
by
Paul Sbarra
Committed by
David Symonds
Sep 22, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vim: Send GoFmt errors to a location list
R=golang-dev, dsymonds CC=golang-dev
https://golang.org/cl/5043046
parent
76d82dbc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
fmt.vim
misc/vim/ftplugin/go/fmt.vim
+18
-4
No files found.
misc/vim/ftplugin/go/fmt.vim
View file @
3dc3fa0d
...
...
@@ -17,12 +17,26 @@ command! -buffer Fmt call s:GoFormat()
function
!
s:GoFormat
()
let
view
=
winsaveview
()
%
!
gofmt
silent
%
!
gofmt
if
v
:
shell_error
%
|
" output errors returned by gofmt
" TODO(dchest): perhaps, errors should go to quickfix
let
errors
=
[]
for
line
in
getline
(
1
,
line
(
'$'
))
let
tokens
=
matchlist
(
line
,
'^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)'
)
if
!
empty
(
tokens
)
call
add
(
errors
,
{
"filename"
:
@%
,
\
"lnum"
:
tokens
[
2
],
\
"col"
:
tokens
[
3
],
\
"text"
:
tokens
[
4
]})
endif
endfor
if
empty
(
errors
)
%
|
" Couldn'
t
detect gofmt error format
,
output errors
endif
undo
echohl Error
|
echomsg
"Gofmt returned error"
|
echohl None
if
!
empty
(
errors
)
call
setloclist
(
0
,
errors
,
'r'
)
endif
echohl Error
|
echomsg
"Gofmt returned error"
|
echohl None
endif
call
winrestview
(
view
)
endfunction
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment