Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to change NVIM_APPNAME #2334

Open
mairs8 opened this issue Sep 28, 2024 · 6 comments
Open

Add feature to change NVIM_APPNAME #2334

mairs8 opened this issue Sep 28, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@mairs8
Copy link

mairs8 commented Sep 28, 2024

Description

https://neovim.io/doc/user/starting.html#_nvim_appname

is it possible to change the neovim config directory in nixvim? Usually neovim installs to `.config/nvim' but i don't want to overwrite existing config and instead install to '.config/nixvim'. is this possible? it would be similar to using the $NVIM_APPNAME environment variable in neovim api.

if nixvim does not care about .config directory, there should at least be the ability to install nixvim with different NVIM_APPNAME so that you can use it alongside existing neovim configs.

Minimal, Reproducible Example

see pseudo code below to how i envision changing nvim_appname in nixvim.

programs.nixvim = {
    nvim-appname = "nvim-nixvim"
}
@mairs8 mairs8 added the bug Something isn't working label Sep 28, 2024
@MattSturgeon
Copy link
Member

This could be added. Similar to allowing the exe name to be changed, it could be a useful customization.

Currently it's possible to use a "wrapped" config instead of ~/.config/nvim by setting wrapRc = true and impureRtp = false.

wrapRc will call nvim with -u, telling it to use the init.lua directly from the nix store.

Disabling impureRtp will cause ~/.config.nvim to be removed from the runtimepath.

@mairs8
Copy link
Author

mairs8 commented Sep 28, 2024

hmmm i am still quite new to neovim and although it's great to see there is a workaround this seems quite complicated which goes against the ethos of nixvim. Is it possible to include such an update as i mention in the psuedo code? i believe this will be a great feature as it will allow people to do parallel installs of nixvim and increase the takeup rate (possibly could be added to readme or install instructions)

@MattSturgeon
Copy link
Member

this seems quite complicated which goes against the ethos of nixvim.

Firstly, I don't think the following is especially complex:

programs.nixvim = {
  wrapRc = true;
  impureRtp = false;
}

Secondly, the ethos of nixvim isn't necessarily that everything should be simple. Rather our primary goal is to allow configuring neovim via the nix module system, as transparently as possible, with as little magic happening behind the scenes as possible.

is it possible to include such an update as i mention in the psuedo code?

As I said before: This could be added. Similar to allowing the exe name to be changed, it could be a useful customization.

i believe this will be a great feature as it will allow people to do parallel installs of nixvim

Just having NVIM_APPNAME support (or using a wrapped init via -u) is not enough to allow parallel nixvim installs.

The issue is that nixvim doesn't just install neovim config, it actually installs a nvim exe onto the PATH. Having multiple nixvim installs at the same time would therefore cause conflicts.

Therefore to achive multiple nixvim installs we need to do some additional refactoring, e.g:

  • allow disabling exe installation and only generate an init file
  • allow renaming the exe to avoid name conflicts

@mairs8
Copy link
Author

mairs8 commented Sep 28, 2024

on related topic, i have installed nixvim but i would like to use it in parallel with my previous config i.e. i have two configs, one which uses programs.neovim.enable and the other that uses makeNixvimWithModule.

How can i run both on same machine in different terminal sessions? apologies if it is provided somewhere in your previous answer, there is alot going on under the hood which a novice like myself can't infer.

@MattSturgeon
Copy link
Member

makeNixvimWithModule will use wrapRc internally to tell the nvim it installs to use the init file it builds. So you don't have to worry about init file conflicts.

If you use the nixvim build using makeNixvimWithModule via nix run or nix shell then yes, you can have access to it in a specific shell while still using your "globally installed" neovim elsewhere.

@Deliganli
Copy link

Deliganli commented Oct 11, 2024

I couldn't seem to make it work. Started developing as a standalone flake. Than tried to port to my NixOS setup as an overlay.

    # overlay
    deliganli.novim = let
      system = "x86_64-linux";
      nixvim' = inputs.nixvim.legacyPackages.${system};
      nvim = nixvim'.makeNixvimWithModule {
        pkgs = prev;
        module = import ./novim;
      };
    in nvim;

    # ./novim/default.nix
    {
      # imports
      wrapRc = true;
      impureRtp = false;
    }

    # home config
    # contains my regular neovim setup
    home.file.".config/nvim".source = mkOutOfStoreSymlink "./nvim";

    # shell alias
    "novim" = pkgs.lib.getExe pkgs.deliganli.novim;

~/.config/nvim has the config from home-manager setup. But both novim and the nvim command is using the settings from nixvim

edit: I retried after killing zsh and tmux processes, seems to work with config above. Not sure what was the issue

edit 2: it may be related to whether it is added as home-manager package or system package

  # this makes `nvim` command to work with my old config
  environment.systemPackages = with pkgs; [
    deliganli.novim
  ]

  # this makes `nvim` command to run with nixvim config
  home.packages = with pkgs; [
    deliganli.novim
  ]

Thanks everyone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants