Skip to content

Instantly share code, notes, and snippets.

@nelstrom
Last active August 21, 2020 16:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelstrom/ced14300f689bf5ffafac592d3aa9373 to your computer and use it in GitHub Desktop.
Save nelstrom/ced14300f689bf5ffafac592d3aa9373 to your computer and use it in GitHub Desktop.
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