From d6e8fb17c00759ffe79072ee22c04755de2c74a9 Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Fri, 13 Feb 2015 22:52:31 -0500 Subject: [PATCH] complete the cylce of new syntax checking --- .vim/syntax_checkers/go/golintc.vim | 42 +++++++++++++++++++++++++++++++ .vim/syntax_checkers/go/gonyet.vim | 49 +++++++++++++++++++++++++++++++++++++ .vimrc | 24 +++++++++++++++--- 3 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 .vim/syntax_checkers/go/golintc.vim create mode 100644 .vim/syntax_checkers/go/gonyet.vim diff --git a/.vim/syntax_checkers/go/golintc.vim b/.vim/syntax_checkers/go/golintc.vim new file mode 100644 index 0000000..58e6102 --- /dev/null +++ b/.vim/syntax_checkers/go/golintc.vim @@ -0,0 +1,42 @@ +"============================================================================ +"File: golintc.vim +"Description: Check go syntax using 'golintc' +"Maintainer: Hiroshi Ioka +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists("g:loaded_syntastic_go_golintc_checker") + finish +endif +let g:loaded_syntastic_go_golintc_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_go_golintc_GetLocList() dict + let makeprg = self.makeprgBuild({}) + + let errorformat = + \ '%f:%l:%c: %m,' . + \ '%-G%.%#' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'defaults': {'type': 'w'}, + \ 'subtype': 'Style' }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'go', + \ 'name': 'golintc'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/.vim/syntax_checkers/go/gonyet.vim b/.vim/syntax_checkers/go/gonyet.vim new file mode 100644 index 0000000..8561190 --- /dev/null +++ b/.vim/syntax_checkers/go/gonyet.vim @@ -0,0 +1,49 @@ +"============================================================================ +"File: gonyet.vim +"Description: Perform static analysis of Go code with the go-nyet tool +"Maintainer: Barak Michener +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists("g:loaded_syntastic_go_gonyet_checker") + finish +endif +let g:loaded_syntastic_go_gonyet_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_go_gonyet_IsAvailable() dict + return executable('go-nyet') +endfunction + +function! SyntaxCheckers_go_gonyet_GetLocList() dict + let makeprg = 'go-nyet ' . expand('%:p:h') . '/' + let errorformat = '%f:%l:%c:%m' + + " The go compiler needs to either be run with an import path as an + " argument or directly from the package directory. Since figuring out + " the proper import path is fickle, just cwd to the package. + + let errors = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'cwd': expand('%:p:h'), + \ 'defaults': {'type': 'w'} }) + + return errors +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'go', + \ 'name': 'gonyet'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sts=4 sw=4: diff --git a/.vimrc b/.vimrc index a642f2e..a9d5345 100644 --- a/.vimrc +++ b/.vimrc @@ -173,7 +173,11 @@ let g:EclimCompletionMethod = 'omnifunc' " * Syntastic let g:syntastic_python_flake8_args='--ignore=E111' -let g:syntastic_go_checkers=['go', 'govet', 'golintc'] +let g:syntastic_go_checkers=['go', 'govet', 'gonyet', 'golintc'] +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_auto_loc_list = 2 +let g:syntastic_loc_list_height = 10 +let g:syntastic_aggregate_errors = 1 " E111 = Spaces should be multiples of 4. I use 2. " * Configure browser for haskell_doc.vim @@ -360,6 +364,18 @@ function! QFixToggle(forced) endif endfunction +" Toggle LocationList +command -bang -nargs=? LFix call LFixToggle(0) +function! LFixToggle(forced) + if exists("g:lfix_win") && a:forced == 0 + unlet! g:lfix_win + lclose + else + execute "lopen " . 10 + let g:lfix_win = "t" + endif +endfunction + " Make the Quickfix window respond well to commands (for instance, q to close, " Enter to select, etc). In tandem with the above. augroup QFixToggle @@ -511,13 +527,13 @@ inoremap jj " Leader key functions " See quickfix. -nnoremap ff :QFix +nnoremap ff :LFix " See quickfix. nnoremap ss :SyntasticSetLoclist " Next quickfix. -nnoremap fn :cnext +nnoremap fn :lnext " Prev quickfix. -nnoremap fp :cprev +nnoremap fp :lprev " Ack (grep) for the word under the cursor. nnoremap aw :exe 'Ack ' . expand('') " Ack prompt.