Skip to content

Commit 55467c6

Browse files
committed
Merge pull request #689 from nhooyr/nvim-docs
Neovim integration details in vim-go.txt and README.md
2 parents a03b2a0 + d73ef08 commit 55467c6

File tree

2 files changed

+129
-16
lines changed

2 files changed

+129
-16
lines changed

README.md

+29-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ disabled/enabled easily.
4444
* Custom vim text objects such as `a function` or `inner function`
4545
* All commands support collecting and displaying errors in Vim's location
4646
list.
47+
* A async launcher for the go command is implemented for neovim, fully async
48+
building and testing.
49+
* Check the status of any async jobs in the statusline with `go#jobcontrol#Statusline()`
50+
* Integrated with the neovim terminal, launch `:GoRun` and other go commands
51+
in their own new terminal.
4752

4853
## Install
4954

@@ -207,17 +212,38 @@ let g:go_bin_path = "/home/fatih/.mypath" "or give absolute path
207212

208213
### Location list navigation
209214

210-
All commands support collecting and displaying errors in Vim's location
211-
list.
215+
All commands support collecting and displaying errors in Vim's location list.
212216

213-
Quickly navigate through these location lists with `:lne` for next error and `:lp`
217+
Quickly navigate through these location lists with `:lne` for next error and `:lp`
214218
for previous. You can also bind these to keys, for example:
215219

216220
```vim
217221
map <C-n> :lne<CR>
218222
map <C-m> :lp<CR>
219223
```
220224

225+
### Using with Neovim
226+
227+
Run `:GoRun` in a new tab, horizontal split or vertical split terminal
228+
229+
```vim
230+
au FileType go nmap <leader>rt <Plug>(go-run-tab)
231+
au FileType go nmap <Leader>rs <Plug>(go-run-split)
232+
au FileType go nmap <Leader>rv <Plug>(go-run-vertical)
233+
```
234+
235+
By default new terminals are opened in a vertical split. To change it
236+
237+
```vim
238+
let g:go_term_mode = "split" "or set to tab
239+
```
240+
241+
By default the testing commands run asynchronously in the background and display results
242+
with `go#jobcontrol#Statusline()`. To make them run in a new terminal
243+
244+
```vim
245+
let g:go_term_enabled = 1
246+
```
221247

222248
### Using with Syntastic
223249
Sometimes when using both `vim-go` and `syntastic` Vim will start lagging while saving and opening

doc/vim-go.txt

+100-13
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
===============================================================================
1515
CONTENTS *go-contents*
1616

17-
1. Intro........................................|go-intro|
18-
2. Install......................................|go-install|
19-
3. Commands.....................................|go-commands|
20-
4. Mappings.....................................|go-mappings|
21-
5. Text Objects.................................|go-text-objects|
22-
6. Settings.....................................|go-settings|
23-
7. Troubleshooting..............................|go-troubleshooting|
24-
8. Credits......................................|go-credits|
17+
1. Intro........................................|go-intro|
18+
2. Install......................................|go-install|
19+
3. Commands.....................................|go-commands|
20+
4. Mappings.....................................|go-mappings|
21+
5. Text Objects.................................|go-text-objects|
22+
6. Functions....................................|go-functions|
23+
7. Settings.....................................|go-settings|
24+
8. Troubleshooting..............................|go-troubleshooting|
25+
9. Credits......................................|go-credits|
2526

2627
===============================================================================
2728
INTRO *go-intro*
@@ -65,7 +66,12 @@ easily.
6566
* Tagbar support to show tags of the source code in a sidebar with `gotags`
6667
* Custom vim text objects such as `a function` or `inner function`
6768
* All commands support collecting and displaying errors in Vim's location
68-
list.
69+
list
70+
* A async launcher for the go command is implemented for neovim, fully async
71+
building and testing.
72+
* Check the status of any async jobs in the statusline with |go#jobcontrol#Statusline()|
73+
* Integrated with the neovim terminal, launch `:GoRun` and other go commands
74+
in their own new terminal.
6975

7076
===============================================================================
7177
INSTALL *go-install*
@@ -223,18 +229,25 @@ COMMANDS *go-commands*
223229

224230
If [!] is not given the first error is jumped to.
225231

232+
If using neovim then `:GoRun` will run in a new terminal according to
233+
|g:go_term_mode|.
234+
226235
*:GoBuild*
227236
:GoBuild[!] [expand]
228237

229-
Build your package with `go build`. It automatically builds only the files
230-
that depends on the current file. GoBuild doesn't produce a result file.
238+
Build your package with `go build`. Errors are populated inside the
239+
location list. It automatically builds only the files that depends on the
240+
current file. `:GoBuild` doesn't produce a result file.
231241
Use 'make' to create a result file.
232242

233243
You may optionally pass any valid go build flags/options. For a full list
234244
please see `go help build`. Options are expanded with 'expand'.
235245

236246
If [!] is not given the first error is jumped to.
237247

248+
If using neovim then this command is fully async, it does not block the
249+
UI.
250+
238251
*:GoGenerate*
239252
:GoGenerate[!] [expand]
240253

@@ -279,6 +292,10 @@ COMMANDS *go-commands*
279292

280293
If [!] is not given the first error is jumped to.
281294

295+
If using neovim `:GoTest` will run in a new terminal or run asynchronously
296+
in the background according to |g:go_term_enabled|. You can set the mode of
297+
the new terminal with |g:go_term_mode|.
298+
282299
*:GoTestFunc*
283300
:GoTestFunc[!] [expand]
284301

@@ -291,6 +308,10 @@ COMMANDS *go-commands*
291308

292309
If [!] is not given the first error is jumped to.
293310

311+
If using neovim `:GoTestFunc` will run in a new terminal or run asynchronously
312+
in the background according to |g:go_term_enabled|. You can set the mode of
313+
the new terminal with |g:go_term_mode|.
314+
294315
*:GoTestCompile*
295316
:GoTestCompile[!] [expand]
296317

@@ -302,6 +323,10 @@ COMMANDS *go-commands*
302323

303324
If [!] is not given the first error is jumped to.
304325

326+
If using neovim `:GoTestCompile` will run in a new terminal or run asynchronously
327+
in the background according to |g:go_term_enabled|. You can set the mode of
328+
the new terminal with |g:go_term_mode|.
329+
305330
*:GoCoverage*
306331
:GoCoverage[!] [options]
307332

@@ -446,8 +471,8 @@ COMMANDS *go-commands*
446471
:GoOracleTags [tags]
447472

448473
Changes the custom |g:go_oracle_tags| setting and overrides it with the
449-
given build tags. This command cooperate with GoReferrers command when
450-
there exist mulitiple build tags in your project,then you can set one
474+
given build tags. This command cooperate with GoReferrers command when
475+
there exist mulitiple build tags in your project, then you can set one
451476
of the build tags for GoReferrers to find more accurate.
452477
The custom build tags is cleared (unset) if `""` is given. If no arguments
453478
is given it prints the current custom build tags.
@@ -477,6 +502,21 @@ documentation in the |go-commands| section. Available <Plug> keys are:
477502

478503
Calls `go run` for the current file
479504

505+
*(go-run-tab)*
506+
507+
Calls `go run` for the current file in a new terminal tab
508+
This option is neovim only.
509+
510+
*(go-run-split)*
511+
512+
Calls `go run` for the current file in a new terminal horizontal split
513+
This option is neovim only.
514+
515+
*(go-run-vertical)*
516+
517+
Calls `go run` for the current file in a new terminal vertical split
518+
This option is neovim only.
519+
480520

481521
*(go-build)*
482522

@@ -628,6 +668,22 @@ if "inside a function", select contents of a function,
628668

629669

630670

671+
===============================================================================
672+
FUNCTIONS *go-functions*
673+
674+
*go#jobcontrol#Statusline()*
675+
676+
Shows the status of a job running asynchronously. Can be used to plug into the
677+
statusline. It works to show the status per package instead of per
678+
file. Assume you have three files open, all belonging to the same package,
679+
if the package build (`:GoBuild`) is successful, all statusline's will be empty
680+
(means SUCCESS), if you it fails all file's statusline will show FAILED.
681+
682+
*go#complete#GetInfo()*
683+
684+
Returns the description of the identifer under the cursor. Can be used to plug
685+
into the statusline. This function is also used for |g:go_auto_type_info|.
686+
631687
===============================================================================
632688
SETTINGS *go-settings*
633689

@@ -929,6 +985,37 @@ Use this option to auto |:AsmFmt| on save. By default it's enabled. >
929985
930986
let g:go_asmfmt_autosave = 1
931987
<
988+
*g:go_term_mode*
989+
990+
This option is neovim only. Use it to change the default terminal mode of
991+
go commands that run in a new terminal. The default is vsplit.
992+
Current options are vsplit, split or tab.
993+
>
994+
let g:go_term_mode = "vsplit"
995+
<
996+
*g:go_term_height*
997+
*g:go_term_width*
998+
999+
These options are neovim only. Use them to control the height and width of
1000+
a terminal split. By default these are not set meaning that the height and
1001+
width are set automatically by neovim. The height only applies with a
1002+
horizontal split and width only applies to a vertical split.
1003+
1004+
For example here is how to set each to 30.
1005+
>
1006+
let g:go_term_height = 30
1007+
let g:go_term_width = 30
1008+
<
1009+
*g:go_term_enabled*
1010+
1011+
This option is neovim only. Use it to change the behavior of the test
1012+
commands. If set to 1 it opens the test commands inside a new terminal
1013+
according to |g:go_term_mode|, otherwise it will run them in the background
1014+
just like `:GoBuild` and then display the status with |go#jobcontrol#Statusline()|.
1015+
By default it is disabled.
1016+
>
1017+
let g:go_term_enabled = 0
1018+
<
9321019

9331020
===============================================================================
9341021
TROUBLESHOOTING *go-troubleshooting*

0 commit comments

Comments
 (0)