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

When wrapping with Nix to set arguments, always uses cat mode #89

Closed
spikespaz opened this issue Aug 17, 2023 · 7 comments
Closed

When wrapping with Nix to set arguments, always uses cat mode #89

spikespaz opened this issue Aug 17, 2023 · 7 comments
Labels

Comments

@spikespaz
Copy link

I have the following Nix derivation, which will replace the nvimpager command with a wrapper script:

nvimpager' = pkgs.nvimpager.overrideAttrs (self: super: {
  nativeBuildInputs = super.nativeBuildInputs or [ ] ++ [ pkgs.makeWrapper ];
  postInstall = super.postInstall or "" + ''
    wrapProgram $out/bin/nvimpager \
      --add-flags '-p -c "lua nvimpager.maps = false; lua nvimpager.git_colors = true"'
  '';
});

This is the content of the script:

#! /nix/store/ir0j7zqlw9dc49grmwplppc7gh0s40yf-bash-5.2-p15/bin/bash -e
exec -a "$0" "/nix/store/gms73z8zvfps98rdkcf2r5xs1pbay0lc-nvimpager-0.12.0/bin/.nvimpager-wrapped"  -p -c "lua nvimpager.maps = false; lua nvimpager.git_colors = true" "$@"

When I use the pager for anything from STDIN, it always just prints out the content (syntax highlighted) to my terminal.

@lucc
Copy link
Owner

lucc commented Aug 17, 2023

In your script you have the options -p -c which are both parsed by nvimpager. Nvim options can only be given after -- or after a file argument.

@spikespaz
Copy link
Author

If they're parsed by nvimpager why do they need to be after --?

@spikespaz
Copy link
Author

Oh I see, I need to end the arguments parsed by nvimpager with --.

@spikespaz
Copy link
Author

Nope, that doesn't work.

#! /nix/store/ir0j7zqlw9dc49grmwplppc7gh0s40yf-bash-5.2-p15/bin/bash -e
exec -a "$0" "/nix/store/14qsc1x1i7wwqr6kn2vdxk4wy100dwgi-nvimpager-0.12.0/bin/.nvimpager-wrapped"  -p -c "lua nvimpager.maps = false; lua nvimpager.git_colors = true" -- "$@"

@lucc
Copy link
Owner

lucc commented Aug 17, 2023

You need nvimpager -p -- -c "lua nvimpager.maps ..." because you want to use the -c option of nvim but are actually using the -c option of nvimpager (with a file nameof "lua nvimpager.maps = ..." which probably does not exist).

@spikespaz spikespaz changed the title Whe wrapping with Nix to set arguments, always uses cat mode When wrapping with Nix to set arguments, always uses cat mode Aug 18, 2023
@spikespaz
Copy link
Author

Alright, I've got that. Now what is the correct way to set multiple attributes with Lua?

Error detected while processing command line:
E5107: Error loading lua [string ":lua"]:1: '=' expected near 'nvimpager'

@lucc
Copy link
Owner

lucc commented Aug 18, 2023

You are mixing vim script and lua. You need lua nvimpager.maps = false; nvimpager.git_colors = true

@lucc lucc closed this as completed Aug 18, 2023
@lucc lucc added the invalid label Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants