preservim / vimux

easily interact with tmux from vim
MIT License
2.19k stars 158 forks source link

[question] is there a way to specifiy new pane's orientation from functions args? #205

Closed alexzanderr closed 2 years ago

alexzanderr commented 2 years ago

i know that there is a:

let g:VimuxOrientation = "h"
" or 
let g:VimuxOrientation = "v"

but is there a way to specifiy orientation as argument to the function VimuxRunCommand ?

because i want to map:

" this should open a new vertical pane
nnoremap <silent> <C-A-n> <C-o>:wa!<CR><C-o>:call VimuxRunCommand("python3 " . getcwd() . "/" . expand('%:f'), orientation?)<CR>

" this should opena new horizontal pane
inoremap <silent> <C-A-m> <C-o>:wa!<CR><C-o>:call VimuxRunCommand("python3 " . getcwd() . "/" . expand('%:f'), orientation?)<CR>

as you can see i put orientation just as filling.

any ideas? thanks.

alerque commented 2 years ago

I don't think so, but can't you just prefix the command you run with a let that sets up the variable the way you want it for the following command?

alexzanderr commented 2 years ago

hmm. interesting idea

alexzanderr commented 2 years ago

another question (related): i saw that vimux always vertically split to the right side, is there a way to specify that i want to split the new pane to left?

or this is about tmux; tmux by default vertically splits to right?

alexzanderr commented 2 years ago

well i found the command that split to left:

tmux split-window -hb "zsh"

but how to i specify that to vimux?

alerque commented 2 years ago

You should be able to use g:VimuxOpenExtraArgs to add things to the split-window command that Vimux runs. Also consider if you want that much manual control over your panes you can manage them yourself and use g:VimuxUseNearest and/or g::VimuxRunnerName or similar to just use the splits you have manually setup.

alexzanderr commented 2 years ago

well i found the command that split to left:

tmux split-window -hb "zsh"

but how to i specify that to vimux?

to achieve this you must go to /plugged/vimux/plugin/vimux.vim and edit line 101:

- call VimuxTmux('split-window  '.s:vimuxPaneOptions().' '.extraArguments)
+ call VimuxTmux('split-window -b '.s:vimuxPaneOptions().' '.extraArguments)

-b means that tmux will split new created pane to left

alexzanderr commented 2 years ago

g:VimuxOpenExtraArgs

so if I set g:VimuxOpenExtraArgs = "-b" i will achieve split to left?

alexzanderr commented 2 years ago

g:VimuxOpenExtraArgs

so if I set g:VimuxOpenExtraArgs = "-b" i will achieve split to left?

okey. its working, very nice. this is very useful, so that i dont need to hard edit the plugin's code.

alexzanderr commented 2 years ago

I don't think so, but can't you just prefix the command you run with a let that sets up the variable the way you want it for the following command?

it works. thanks.

here the code that i used:

function! s:code_runner_orientation_below()
    if &modified == 1
        w!
    endif 
    if &filetype == "python"
        let g:VimuxOrientation = "v"
        let g:VimuxOpenExtraArgs = ""

        call VimuxRunCommand("python3 " . getcwd() . "/" . expand('%:f'))

        let g:VimuxOrientation = "h"
        let g:VimuxOpenExtraArgs = "-b"

    endif
endfunction

nnoremap <silent> <C-A-b> :call <SID>code_runner_orientation_below()<CR>
inoremap <silent> <C-A-b> <C-o>:call <SID>code_runner_orientation_below()<CR>