Neovim in Root profile

Hi everybody,

I’m installing Nixos since a few weeks and i like the philosophy :slightly_smiling_face:.
My question is about neovim : no problem to configure it with home-manager.

However, after many searches, I can’t manage to configure neovim when I use it in root profile (for example : set number and relativenumber).
An idea ?

NB : I tried in configuration.nix that, but without success :

Hi everybody,

I’m installing Nixos since a few weeks and i like the philosophy :slightly_smiling_face:.
My question is about neovim : no problem to configure it with home-manager.

However, after many searches, I can’t manage to configure neovim when I use it in root profile (for example : set number and relativenumber).
An idea ?

NB : I tried in configuration.nix that, but without success :

programs.neovim = { 
  enable = true;
  defaultEditor = true;
  configure = {
    customRC = ''
      set number relativenumber    
      #colorscheme blue         
      #colorscheme tokyo-night  
    '';

NixOS and Neovim – a great match!

It looks like your customRC is vimScript, not Lua. Are you able to tell what file was created from your customRC?

Also curious what error you are getting when you start neovim. Thanks!

Hi,
Thanks a lot for your quick answer.
For my customRC, I was inspired by the nixos documentation here.

Concerning your 2nd question, I’ve not error when I use neovim in root : my settings (set number or relativenumber) don’t appear ; no error. it’s boring :frowning:

1 Like

maybe this is not your answer but have a look at this

you can use

sudo -E nvim file.txt # this also works if you jump to another file and try to edit that

or

sudoedit file.txt

for the second one you need to set

environment.variables.EDITOR = "nvim";
1 Like

Yes ! That’s it !
it’s a roundabout way, but it works.
Thanks a lot :slight_smile:

2 Likes

Glad to hear it! Sounds like you could mark @nix-newbie’s answer as the solution, yes?

yes ! thank you for helping a beginner :slight_smile: in NixOs