You are not logged in.
Pages: 1
Neovim / Vim-Plug / Sudo / Arch
I'm running on Arch and new to Vim. I've tried multiple times to get plugins to work with neovim. Today I've once again curl'ed the autoload file from the git repo. Edited the config file with a test plugin. Ran the :PlugStatus :PlugInstall but the plugin error "NERDTree: fatal: could not create work". It appeared to be halfway working and at least the plugin was found, so I run sudo nvim and now the :PlugStatus and :PlugInstall aren't even available. I ran :checkhealth and appears to default to the root config file. As most of you know Arch pretty much requires sudo to edit basic files. I'm at a loss on what to do. I need some outside prospective.
Thanks for the help
Last edited by Rabid3east (2022-07-02 11:34:53)
Offline
Vim (and probably neovim, the two are far from the same) read their configs from your user's home folder, usually $HOME/.vimrc. Using sudo means you're now the user root with the home folder /root/ and /root/.vimrc.
I advice against installing plugins for the root user for security reasons. You can write to files that belong to root from your user's vim without running "sudo vim".
I'm on my phone. Google "vim write with sudo".
Offline
I’ve read multiple times about sudo -E nvim $file but is that best practice?
Offline
I've Set the EDITOR environment variable to nvim instead of vi
And then it's sudoedit $file
Everything is working as far as editing the config file with sudo but when I run :PlugInstall I still get the same error. Maybe this is more of a neovim issue at this point then arch
I've got the sudoedit working fine, but that didn't appear to fix the vim-plug error "fatal: could not create work tree dir permission denied " when entering in :PlugInstall
Solved: Ended up giving permissions to the plugged folder and things started to work. Thanks for the help.
Last edited by Rabid3east (2022-07-02 11:31:06)
Offline
We have two different issues here:
1. Editing root owned files with vim: I'm talking about opening a file as in vim as a normal user and then using some ":w !sudo..." write method to use sudo to just write the file.
2. You need help installing vim plugins in nvim. What are you doing and how? You haven't specified what plugin load method you're attempting. Is this some neovim thing where you don't need an external plugin to manage plugins?
The NERDTree github page explicitly states, that you are to pick your favourite plugin manager:
Use your favorite plugin manager to install this plugin. tpope/vim-pathogen, VundleVim/Vundle.vim, junegunn/vim-plug, and Shougo/dein.vim are some of the more popular ones. A lengthy discussion of these and other managers can be found on vi.stackexchange.com. Basic instructions are provided below, but please be sure to read, understand, and follow all the safety rules that come with your power tools plugin manager.
If you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: Vim screencast #75: Plugin managers.
Pathogen
Pathogen is more of a runtime path manager than a plugin manager. You must clone the plugins' repositories yourself to a specific location, and Pathogen makes sure they are available in Vim.
Vundle
Vim-Plug
Dein
Vim 8+ packages
If you want to use the builtin package manager, try :help packages in (neo)vim.
EDIT: What's this autoload you've curled you're talking about, anyway?
Last edited by Awebb (2022-07-02 11:28:40)
Offline
Thanks for chiming in again Awebb. Ended up solving the issue after figuring out how to solve the sudoedit mess. Was able to read the error message that it gave and searched deeper to discover that the plugged folder needed permissions. The curled file was for vim-plug the plugin manager. You were indeed correct that it was two different issues and at the time I didn't realize how to untangle the mess. Thanks for your help.
Offline
We have two different issues here:
1. Editing root owned files with vim: I'm talking about opening a file as in vim as a normal user and then using some ":w !sudo..." write method to use sudo to just write the file.
I've tried using the :w !sudo in neovim and it's not working. Sudoedit $file appears to be my only option right now but it won't write to the file until I :wq if i just :w it doesn't go into effect until completely exiting.
Offline
sudoedit creates a temporary copy of the file; you edit the copy, and then when you quit the editor, it moves the temporary copy into place. When you do `:w` it saves to the temporary file, but doesn't move it into place until you quit.
Anyway
:%!sudo tee %works for me with neovim, though it's not a very elegant solution.
Last edited by frabjous (2022-07-03 04:32:51)
Offline
Awebb wrote:We have two different issues here:
1. Editing root owned files with vim: I'm talking about opening a file as in vim as a normal user and then using some ":w !sudo..." write method to use sudo to just write the file.
I've tried using the :w !sudo in neovim and it's not working. Sudoedit $file appears to be my only option right now but it won't write to the file until I :wq if i just :w it doesn't go into effect until completely exiting.
Those three dots were there for a reason. I didn't want to ruin your learning curve by just coughing it up :-)
Offline
Hah okay. Regardless learning a lot of programming and want to get good with nvim as its so useful and customizable.
I think i’ll figure this out and make a nmap key to quickly save so i dont have to memorize the exact save phrase.
Offline
sudoedit creates a temporary copy of the file; you edit the copy, and then when you quit the editor, it moves the temporary copy into place. When you do `:w` it saves to the temporary file, but doesn't move it into place until you quit.
Anyway
:%!sudo tee %works for me with neovim, though it's not a very elegant solution.
You gave me an idea to make it nmap so i have a quick shortcut to save with this command or one similar. Aweb made a point i should read the doc about the :!sudo command hah
Offline
Pages: 1