mhinz / neovim-remote

:ok_hand: Support for --remote and friends.
MIT License
1.76k stars 82 forks source link

Prevent opening files in terminal buffers #129

Closed tuxflo closed 4 years ago

tuxflo commented 4 years ago

Hi! At first thanks for nvr it helped me a lot to get our of nested neovim sessions... My current workflow for a react app looks like that:

The tool Create React App which is used for the React project is able to open up the editor directly from a browser tab if an error occurs. With setting the environment variable REACT_EDITOR="nvr -l" this works as expected: if the term split was focused it switches the window (-l flag) and opens the file. But if the term split is not focused (which is more often the case) it openes the file in the term split.

So basically the question is: is there a way to tell nvr it shouldn't open files inside terminal buffers?

mhinz commented 4 years ago

At first thanks for nvr it helped me a lot to get our of nested neovim sessions...

Thanks. :)

Okay, the issue is that -l (which really is just a shortcut for -cc 'wincmd p'), is used unconditionally here. Try this instead:

export REACT_EDITOR="nvr -cc 'if &buftype ==# \"terminal\" | wincmd p | endif'"
mhinz commented 4 years ago

It's working interactively from the shell, so it should work for REACT_EDITOR as well. Closing. :)

tuxflo commented 4 years ago

Sorry for the late reply! Yes, the workaround works, but one has to add the parameters to the lauchEditor.js file of the Create React App react-dev-utils. Thanks again for nvr and helping :+1:

tuxflo commented 4 years ago

Just in case somebody ends up here while searching for a solution when developing a Create React App, I submitted a PR to the CRA repo to add nvr to the list of editors.