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

Doesn't work with neovim from snap #82

Open
appomsk opened this issue Jan 27, 2023 · 5 comments
Open

Doesn't work with neovim from snap #82

appomsk opened this issue Jan 27, 2023 · 5 comments
Labels
waiting waiting for a reply or more info

Comments

@appomsk
Copy link

appomsk commented Jan 27, 2023

Kubuntu 22.04.1:

$ which -a nvim
/snap/bin/nvim

$ echo hi | ~/.local/bin/nvimpager
error: unknown flag `R'

$ (exec -a nvimpager nvim -R)  
error: unknown flag `R' 

$ (exec -a nvimpager nvim)   
The snap command lets you install, configure, refresh and remove snaps.
  ...

$ snap -R
error: unknown flag `R' 
@lucc
Copy link
Owner

lucc commented Jan 27, 2023

The actual nvim binary has a -R option: https://neovim.io/doc/user/starting.html#-R

I do not have snap (and the ubuntu docker container does not have systemd so I can not try it there) so you will have to figure out what snap does to the binary of neovim and why it does not pass on the switch.

Maybe start with

/snap/bin/nvim --help
/snap/bin/nvim -R some-file

@lucc lucc added the waiting waiting for a reply or more info label Jan 27, 2023
@appomsk
Copy link
Author

appomsk commented Jan 27, 2023

Yes, of course, nvim has -R switch. But snap somehow intercepts this option when nvim is invoked through exec.

I really don't want to go in snap guts. It is simpler for me to download the appimage or the deb package. So it is just for your information. You may close this issue if you see fit.

@lucc
Copy link
Owner

lucc commented Jan 27, 2023

I spun up a VM with Ubuntu and found:

  • /snap/bin/nvim -R works
  • /snap/bin/nvim is a symlink to /usr/bin/snap
  • exec nvim -R works
  • exec -a nvim snap also starts nvim
  • exec -a anything-else nvim fails

I conclude that snap uses symlinks and the "original name" that we can set with "exec -a" to figure out which application to start.

I have to think about it, if I want to drop the -a nvimpager part.

lucc added a commit that referenced this issue Jan 27, 2023
Tools like snap rely on the name of the executable to determine which
program to run.  Using "exec -a nvimpager /snap/bin/nvim" breaks this
expectation.

Fixes #82.
@lucc
Copy link
Owner

lucc commented Jan 27, 2023

@appomsk can you try the commit 9da7585? If you have several nvim verions installed you can select the snap version with

export NVIMPAGER_NVIM=/snap/bin/nvim 

@appomsk
Copy link
Author

appomsk commented Jan 28, 2023

Well, there is another problem. I removed all nvim directories with rm -rf:

~/.config/nvim
~/.local/share/nvim
~/.local/state/nvim
~/.cache/nvim

Install nvimpager:

$ make PREFIX=$HOME/.local install
mkdir -p /home/and/.local/bin /home/and/.local/share/nvimpager/runtime/lua \
  /home/and/.local/share/zsh/site-functions
install nvimpager.configured /home/and/.local/bin/nvimpager
install -m 644 lua/nvimpager.lua /home/and/.local/share/nvimpager/runtime/lua
install -m 644 _nvimpager /home/and/.local/share/zsh/site-functions
mkdir -p /home/and/.local/share/man/man1
install -m 644 nvimpager.1 /home/and/.local/share/man/man1

Then changed ~/.local/bin/nvimpager with the new one with your patch (just pasted and copied from gui). And then tried with nvim-8.2 from snap and with nvim-9.0dev appimage but:

$ export NVIMPAGER_NVIM=/snap/bin/nvim; echo hi | nvimpager

Error detected while processing pre-vimrc command line:
E5108: Error executing lua [string ":lua"]:1: module 'nvimpager' not found:
        no field package.preload['nvimpager']
        no file './nvimpager.lua'
        no file '/__w/neovim/neovim/.deps/usr/share/luajit-2.1.0-beta3/nvimpager.lua'
        no file '/usr/local/share/lua/5.1/nvimpager.lua'
        no file '/usr/local/share/lua/5.1/nvimpager/init.lua'
        no file '/__w/neovim/neovim/.deps/usr/share/lua/5.1/nvimpager.lua'
        no file '/__w/neovim/neovim/.deps/usr/share/lua/5.1/nvimpager/init.lua'
        no file './nvimpager.so'
        no file '/usr/local/lib/lua/5.1/nvimpager.so'
        no file '/__w/neovim/neovim/.deps/usr/lib/lua/5.1/nvimpager.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk
E5108: Error executing lua [string ":lua"]:1: attempt to index global 'nvimpager' (a nil value)
stack traceback:
        [string ":lua"]:1: in main chunk
Error detected while processing command line:
E5108: Error executing lua [string ":lua"]:1: attempt to index global 'nvimpager' (a nil value)
stack traceback:
        [string ":lua"]:1: in main chunk

I also moved away .vimrc and .vim from $HOME but the result was the same.

Well, then I installed nvimpager into /usr/local/bin with sudo and then it worked. But when I tried export NVINPAGER_NVIM=... it stopped working again (with the same message about no lua package "nvimpager"). And then I felt bad from my stupidity and I deleted everything - and neovim and nvimpager and decided to continue to use old good vim and less)). Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting waiting for a reply or more info
Projects
None yet
Development

No branches or pull requests

2 participants