Last active
August 21, 2020 16:51
-
-
Save nelstrom/ced14300f689bf5ffafac592d3aa9373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
augroup startup | |
autocmd! | |
autocmd VimEnter * call PreventNestedNeovim() | |
augroup END | |
function! PreventNestedNeovim() | |
if !empty($NVIM_LISTEN_ADDRESS) && $NVIM_LISTEN_ADDRESS !=# v:servername | |
let g:r=sockconnect('pipe', $NVIM_LISTEN_ADDRESS, {'rpc':v:true}) | |
let g:f=fnameescape(expand('%:p')) | |
noautocmd bwipe | |
if empty(g:f) | |
call rpcrequest(g:r, "nvim_command", "enew ") | |
else | |
call rpcrequest(g:r, "nvim_command", "edit ".g:f) | |
endif | |
qall | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment