Skip to content

Commit b6e2b14

Browse files
committed
doc: add setting to change the behavior of mappings
1 parent b6f9c77 commit b6e2b14

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

doc/vim-go.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,18 @@ By default it's disabled >
578578
579579
let g:go_auto_type_info = 0
580580
<
581+
582+
*'g:go_jump_to_error'*
583+
584+
Use this option to enable/disable passing the bang attribute to the mappings
585+
|(go-build)|, |(go-run)|, etc.. When enabled it will jump to the first error
586+
automatically (means it will NOT pass the bang attribute to the appropriate
587+
command, i.e: (go-run) -> :GoRun ). Note, that calling this doesn't have any
588+
affect on calling the commands manually. This setting is only useful for
589+
changing the behaviour of our custom static mappings. By default it's enabled.
590+
>
591+
let g:go_jump_to_error = 1
592+
<
581593
*'g:go_fmt_autosave'*
582594

583595
Use this option to auto |:GoFmt| on save. By default it's enabled >

ftplugin/go/commands.vim

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,26 @@ if exists("g:go_loaded_commands")
33
endif
44
let g:go_loaded_commands = 1
55

6+
" go_jump_to_error defines whether we should pass the bang attribute to the
7+
" command or not. This is only used for mappings, because the user can't pass
8+
" the bang attribute to the plug mappings below. So instead of hardcoding it
9+
" as 0 (no '!' attribute) or 1 (with '!' attribute) we pass the user setting,
10+
" which by default is enabled. For commands the user has the ability to pass
11+
" the '!', such as :GoBuild or :GoBuild!
12+
if !exists("g:go_jump_to_error")
13+
let g:go_jump_to_error = 1
14+
endif
15+
616

717
" Some handy plug mappings
8-
nnoremap <silent> <Plug>(go-run) :<C-u>call go#cmd#Run(0,expand('%'))<CR>
9-
nnoremap <silent> <Plug>(go-build) :<C-u>call go#cmd#Build(0,'')<CR>
10-
nnoremap <silent> <Plug>(go-install) :<C-u>call go#cmd#Install(0)<CR>
11-
nnoremap <silent> <Plug>(go-test) :<C-u>call go#cmd#Test(0, 0, '')<CR>
12-
nnoremap <silent> <Plug>(go-test-func) :<C-u>call go#cmd#TestFunc(0, '')<CR>
13-
nnoremap <silent> <Plug>(go-test-compile) :<C-u>call go#cmd#Test(0, 1, '')<CR>
14-
nnoremap <silent> <Plug>(go-coverage) :<C-u>call go#cmd#Coverage(0, '')<CR>
15-
nnoremap <silent> <Plug>(go-vet) :<C-u>call go#cmd#Vet(0)<CR>
18+
nnoremap <silent> <Plug>(go-run) :<C-u>call go#cmd#Run(!g:go_jump_to_error,expand('%'))<CR>
19+
nnoremap <silent> <Plug>(go-build) :<C-u>call go#cmd#Build(!g:go_jump_to_error,'')<CR>
20+
nnoremap <silent> <Plug>(go-install) :<C-u>call go#cmd#Install(!g:go_jump_to_error)<CR>
21+
nnoremap <silent> <Plug>(go-test) :<C-u>call go#cmd#Test(!g:go_jump_to_error, 0, '')<CR>
22+
nnoremap <silent> <Plug>(go-test-func) :<C-u>call go#cmd#TestFunc(!g:go_jump_to_error, '')<CR>
23+
nnoremap <silent> <Plug>(go-test-compile) :<C-u>call go#cmd#Test(!g:go_jump_to_error, 1, '')<CR>
24+
nnoremap <silent> <Plug>(go-coverage) :<C-u>call go#cmd#Coverage(!g:go_jump_to_error, '')<CR>
25+
nnoremap <silent> <Plug>(go-vet) :<C-u>call go#cmd#Vet(!g:go_jump_to_error)<CR>
1626
1727
nnoremap <silent> <Plug>(go-files) :<C-u>call go#tool#Files()<CR>
1828
nnoremap <silent> <Plug>(go-deps) :<C-u>call go#tool#Deps()<CR>

0 commit comments

Comments
 (0)