Closed uetcis closed 1 year ago
I can reproduce this but there is no place in the code where we touch gcr
.
Strangely it works for me if I set gcr=
via --cmd
but not via -c
.
A temporary workaround for you could be PAGER='nvimpager -- --cmd "set gcr="'
but that would force you in pager mode I think.
We have to investigate this further, but I don't have any more time today. If you find something please report back.
The same problem occurs when I used noice.nvim. There could be come connections
I created a small init file, gcr.vim
containing just se gcr=
. Then I can test this with
export MANPAGER='./nvimpager -- -u gcr.vim'
alacritty -o cursor.style=Beam -e man man
I found that this patch fixes the initial cursor for me:
diff --git a/lua/nvimpager.lua b/lua/nvimpager.lua
index eb89a4e..10e7e7f 100644
--- a/lua/nvimpager.lua
+++ b/lua/nvimpager.lua
@@ -764,7 +764,7 @@ function nvimpager.stage1()
os.remove(tmp)
end})
end
- doc = detect_parent_process()
+ --doc = detect_parent_process()
if doc == 'git' then
-- We disable modelines for this buffer as they could disturb the git
-- highlighting in diffs.
This seems to be the culpit
diff --git a/lua/nvimpager.lua b/lua/nvimpager.lua
index eb89a4e..bb3da6f 100644
--- a/lua/nvimpager.lua
+++ b/lua/nvimpager.lua
@@ -331,7 +331,7 @@ end
local function detect_parent_process()
local ppid = os.getenv('PARENT')
if not ppid then return nil end
- local proc = nvim.nvim_get_proc(tonumber(ppid))
+-- local proc = nvim.nvim_get_proc(tonumber(ppid))
if proc == nil then return 'none' end
local command = proc.name
if command == 'man' then
I can reproduce this with plain neovim:
nvim --clean -u gcr.vim README.md --cmd "echo nvim_get_proc($$)" # changes shape
nvim --clean -u gcr.vim README.md -c "echo nvim_get_proc($$)" # keeps shape (honors gcr)
In nvimpager we run nvim_get_proc() in detect_parent_process() which is run in stage1() which is run from --cmd.
Sadly the neovim docs say
-c {command} {command} will be executed after the first file has been read (and after autocommands and modelines for that file have been processed). "command" is interpreted as an Ex command.
But we are using the output from nvim_get_proc to detect the parent process of nvimpager and if it is git we disable modelines https://github.com/lucc/nvimpager/blob/838e4aa1417981743d95578f4c9625d8fddcba6f/lua/nvimpager.lua#L767-L773 but this has to happen in stage1 == --cmd
@weitcis as I can reproduce this with plain neovim and do not want to change this architecture I explained above, I think you have to take this bug report upstream.
I have thought about this again, and maybe we can fix this in nvimpager after all. Can you do some experiments with
diff --git a/lua/nvimpager.lua b/lua/nvimpager.lua
index eb89a4e..1ba0c7d 100644
--- a/lua/nvimpager.lua
+++ b/lua/nvimpager.lua
@@ -331,7 +331,10 @@ end
local function detect_parent_process()
local ppid = os.getenv('PARENT')
if not ppid then return nil end
+ local old_gcr = vim.o.gcr
+ vim.o.gcr = ''
local proc = nvim.nvim_get_proc(tonumber(ppid))
+ vim.o.gcr = old_gcr
if proc == nil then return 'none' end
local command = proc.name
if command == 'man' then
Also check what happens if we use other gcr values in the init file.
I think it is still valueable to report this upstream as it is a neovim issue.
It came to me when I did these experiments with plain neovim that if gcr=
is set before running nvim_get_proc it works:
alacritty -o cursor.style=Beam -e nvim --clean -u NONE --cmd 'se gcr=' -c "echo nvim_get_proc(1)" # good
alacritty -o cursor.style=Beam -e nvim --clean -u NONE --cmd 'se gcr=' --cmd "echo nvim_get_proc(1)" # good
alacritty -o cursor.style=Beam -e nvim --clean -u gcr.vim -c "echo nvim_get_proc(1)" # good
alacritty -o cursor.style=Beam -e nvim --clean -u gcr.vim --cmd "echo nvim_get_proc(1)" # bad
@lucc I got the same results with NVIM v0.8.3. I will try to report this to upstream once I have time.
I opened the upsteam bug report: https://github.com/neovim/neovim/issues/23122
In my init.lua, I added
vim.o.guicursor = ''
. In nvim, this would prevent nvim from changing the cursor of my terminal. However, the same config does not prevent nvimpager from doing that.