mhinz / neovim-remote

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

Edit as current user #103

Closed benwr closed 5 years ago

benwr commented 5 years ago

This might turn out to be impossible, but it would be really useful for me / simplify my workflow.

As of today I'm trying to use neovim as my terminal multiplexer, and so I need to do things as root inside of terminal buffers. This can get annoying when I need to edit a file (like a configuration file) as root. I can use nvr, but then neovim complains at me that I'm editing a read-only file, and then I can't save it. So right now it seems like my best option is to nest neovim sessions.

I haven't thought much about how this might be done (ideally, done safely and correctly), but I figured I'd register the request anyway.

KillTheMule commented 5 years ago

I suggest you look into using sudoedit with EDITOR=nvr -l or something similar.

benwr commented 5 years ago

I guess that works if you're careful to close the buffer and use --remote-wait; unfortunately sudoedit doesn't copy the file contents on write, only on editor exit, so I think I'm likely to go through several rounds of :w, followed by "why didn't my changes work?"

benwr commented 5 years ago

If this is something that the project maintainer(s) would be open to, there's a decent chance I'd want to submit a PR with this functionality; if so I'd appreciate any guidance (e.g. what the flag should be called, or how it should work).

mhinz commented 5 years ago

I'm not using nvr like that (I still rely heavily on tmux), but if it really can't be solved with a standalone tool, I'm open for a PR.

benwr commented 5 years ago

I'm currently working on a standalone tool as a proof-of-concept; if I get it to work I'll probably try to submit the functionality as a PR here (a fair bit of functionality is shared between my tool and nvr)

mhinz commented 5 years ago

I'm closing this as it's unlikely to be solved by someone else in the future.

Thanks for coming up with this anyway, @benwr!