Skip to content

Commit 29d46f6

Browse files
authored
Merge pull request #189 from mvanderkamp/autoclose_option
2 parents 5b17916 + 7d977a2 commit 29d46f6

File tree

2 files changed

+49
-26
lines changed

2 files changed

+49
-26
lines changed

doc/vimux.txt

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ vimux from automatically sending a return after the command.
9494
VimuxSendText~
9595

9696
Send raw text to the runner pane. This command will not open a new pane if one
97-
does not already exist. You will need to use VimuxOpenRunner to do this. This
97+
does not already exist. You will need to use |VimuxOpenRunner| to do this. This
9898
command can be used to interact with REPLs or other interactive terminal
9999
programs that are not shells.
100100

@@ -104,7 +104,7 @@ programs that are not shells.
104104
VimuxSendKeys~
105105

106106
Send keys to the runner pane. This command will not open a new pane if one
107-
does not already exist. You will need to use VimuxOpenRunner to do this. You
107+
does not already exist. You will need to use |VimuxOpenRunner| to do this. You
108108
can use this command to send keys such as "Enter" or "C-c" to the runner pane.
109109

110110
------------------------------------------------------------------------------
@@ -113,7 +113,7 @@ VimuxOpenRunner~
113113

114114
This will either open a new pane or use the nearest pane and set it as the
115115
vimux runner pane for the other vimux commands. You can control if this command
116-
uses the nearest pane or always creates a new one with g:VimuxUseNearest
116+
uses the nearest pane or always creates a new one with g:|VimuxUseNearest|
117117

118118
------------------------------------------------------------------------------
119119
*VimuxPromptCommand*
@@ -295,9 +295,9 @@ change the behavior of Vimux in just the current buffer.
295295
4.1 g:VimuxHeight~
296296

297297
The percent of the screen the split pane Vimux will spawn should take up.
298-
298+
>
299299
let g:VimuxHeight = "40"
300-
300+
<
301301
Default: "20"
302302

303303
------------------------------------------------------------------------------
@@ -307,9 +307,9 @@ Default: "20"
307307
The default orientation of the split tmux pane. This tells tmux to make the
308308
pane either vertically or horizontally, which is backward from how Vim handles
309309
creating splits.
310-
310+
>
311311
let g:VimuxOrientation = "h"
312-
312+
<
313313
Options:
314314
"v": vertical
315315
"h": horizontal
@@ -318,13 +318,13 @@ Default: "v"
318318

319319
------------------------------------------------------------------------------
320320
*VimuxConfiguration_use_nearest*
321-
4.3 g:VimuxUseNearest
321+
4.3 g:VimuxUseNearest~
322322

323323
Use existing pane or window (not used by vim) if found instead of running
324324
split-window.
325-
325+
>
326326
let g:VimuxUseNearest = 1
327-
327+
<
328328
Default: 1
329329

330330
------------------------------------------------------------------------------
@@ -333,9 +333,9 @@ Default: 1
333333

334334
The keys sent to the runner pane before running a command. By default it sends
335335
`q` to make sure the pane is not in scroll-mode and `C-u` to clear the line.
336-
336+
>
337337
let g:VimuxResetSequence = ""
338-
338+
<
339339
Default: "q C-u"
340340

341341
------------------------------------------------------------------------------
@@ -345,9 +345,9 @@ Default: "q C-u"
345345
The string presented in the vim command line when Vimux is invoked. Be sure
346346
to put a space at the end of the string to allow for distinction between
347347
the prompt and your input.
348-
348+
>
349349
let g:VimuxPromptString = ""
350-
350+
<
351351
Default: "Command? "
352352

353353
------------------------------------------------------------------------------
@@ -356,9 +356,9 @@ Default: "Command? "
356356

357357
The type of view object Vimux should use for the runner. For reference, a
358358
tmux session is a group of windows, and a window is a layout of panes.
359-
359+
>
360360
let g:VimuxRunnerType = "window"
361-
361+
<
362362
Options:
363363
"pane": for panes
364364
"window": for windows
@@ -367,14 +367,16 @@ Default: "pane"
367367

368368
------------------------------------------------------------------------------
369369
*VimuxRunnerName*
370-
4.7 g:VimuxRunnerName
370+
4.7 g:VimuxRunnerName~
371371

372372
Setting the name for the runner. Works for panes and windows. This makes the
373373
VimuxRunner reusable between sessions. Caveat is, all your instances (in the
374-
same session/window) use the same window.
374+
same session/window) use the same window.
375375

376+
Caution: It is probably best not to mix this with |VimuxCloseOnExit|.
377+
>
376378
let g:VimuxRunnerName = "vimuxout"
377-
379+
<
378380
Default: ""
379381

380382
------------------------------------------------------------------------------
@@ -383,9 +385,9 @@ Default: ""
383385

384386
The command that Vimux runs when it calls out to tmux. It may be useful to
385387
redefine this if you're using something like tmate.
386-
388+
>
387389
let g:VimuxTmuxCommand = "tmate"
388-
390+
<
389391
Default: "tmux"
390392

391393
------------------------------------------------------------------------------
@@ -395,13 +397,13 @@ Default: "tmux"
395397
Allows addtional arguments to be passed to the tmux command that opens the
396398
runner. Make sure that the arguments specified are valid depending on whether
397399
you're using panes or windows, and your version of tmux.
398-
400+
>
399401
let g:VimuxOpenExtraArgs = "-c #{pane_current_path}"
400-
401-
Default: "tmux"
402+
<
403+
Default: ""
402404

403405
------------------------------------------------------------------------------
404-
VimuxExpandCommand
406+
*VimuxExpandCommand*
405407
4.10 g:VimuxExpandCommand~
406408

407409
Should the command given at the prompt via VimuxPromptCommand be expanded
@@ -411,9 +413,22 @@ Unfortunately expand() only expands % (etc.) if the string starts with that
411413
character. So the command is split at spaces and then rejoined after
412414
expansion. With this simple approach things like "%:h/test.xml" are not
413415
possible.
414-
416+
>
415417
let g:VimuxExpandCommand = 1
418+
<
419+
Default: 0
416420

421+
------------------------------------------------------------------------------
422+
*VimuxCloseOnExit*
423+
4.11 g:VimuxCloseOnExit~
424+
425+
Set this option to `1` or `v:true` to tell vimux to close the runner when you quit
426+
vim.
427+
428+
Caution: It is probably best not to mix this with |VimuxRunnerName|.
429+
>
430+
let g:VimuxCloseOnExit = 1
431+
<
417432
Default: 0
418433

419434
==============================================================================

plugin/vimux.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane')
1515
let g:VimuxTmuxCommand = get(g:, 'VimuxTmuxCommand', 'tmux')
1616
let g:VimuxUseNearest = get(g:, 'VimuxUseNearest', v:true)
1717
let g:VimuxExpandCommand = get(g:, 'VimuxExpandCommand', v:false)
18+
let g:VimuxCloseOnExit = get(g:, 'VimuxCloseOnExit', v:false)
1819

1920
function! VimuxOption(name) abort
2021
return get(b:, a:name, get(g:, a:name))
@@ -39,6 +40,13 @@ command -bar VimuxClearTerminalScreen :call VimuxClearTerminalScreen()
3940
command -bar VimuxClearRunnerHistory :call VimuxClearRunnerHistory()
4041
command -bar VimuxTogglePane :call VimuxTogglePane()
4142

43+
if VimuxOption('VimuxCloseOnExit')
44+
augroup VimuxAutocloseCommands
45+
au!
46+
autocmd VimLeave * call VimuxCloseRunner()
47+
augroup END
48+
endif
49+
4250
function! VimuxRunCommandInDir(command, useFile)
4351
let l:file = ''
4452
if a:useFile ==# 1

0 commit comments

Comments
 (0)