Re: Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Victorias(dot)Linux(at)gmail(dot)com, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue
Date: 2018-03-16 17:58:10
Message-ID: 423630eb-637d-8158-3325-ee036910b2c6@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/16/2018 10:47 AM, Victoria wrote:
> Hello; I am using PostgreSQL v.10.2 as a root user (sudo -u postgres -i) on my local Arch Linux installation.
>
> I want to use Neovim (nvim v.0.2.2) as my external editor (\e) in psql; the current default is the Arch Linux default system editor, vi.
>
> If I add this to my ~/.psqlrc (/home/victoria/.psqlrc)
>
> \setenv EDITOR "/usr/bin/nano"
>
> then I can use nano, no problem.
>
> However, if I replace that with
>
> \setenv EDITOR "/usr/bin/nvim"
>
> and chown this postgres directory (to get around a .local/ permissions error that arises)
>
> sudo chown -R postgres:victoria /var/lib/postgres
>
> when I type \e in psql I can edit in nvim.
>
> The issue I have is that as I am in a postgres environment, my user (victoria) ~/.vimrc file (I link my nvim.init file to it) is not being loaded, so I don't have access to my Vim/NeoVim settings.

I guess the question is why sudo -u postgres -i? You can access the
server via psql from your home directory. If you want to work as
postgres user the simplest solution would be to add the .vimrc file to
the postgres user directory.

>
> I tried the nvim -u "<path-to-vimrc>" type statements in my ~/.psqlrc, but that throws an error about not a valid path (again, likely due to the Pg root environment?).
>
> Suggestions? Thank you.
>
> ==============================================================================
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-03-16 18:03:53 Re: ora2pg and invalid command \N
Previous Message Victoria 2018-03-16 17:47:46 Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue