Closed echaya closed 2 months ago
Good idea to turn on logging, find the command that gitgutter was running, and try to run it directly in your shell. With this kind of problem, fixing it in the shell will tell us what the code needs to do differently.
Having said that, E344 and E472 are vim/nvim errors so it doesn't look like you ran it in the shell. Perhaps you could try this in your shell (and let me know which shell that is)?
cd /d "d:/Dropbox/neovim/config"
And inside nvim, what does :echo &shell
produce?
Thanks for your prompt reply!
When I said I try to run "cd /d "d:/Dropbox/neovim/config" && C:/Program Files/Git/bin/git.exe ls-files -v --error-unmatch --full-name -z -- .vimrc" on command line, I actually mean cmdline
within nvim
echo &shell
returns me cmd.exe
cd /d "d:/Dropbox/neovim/config"
works fine in CMD. or shall i run it in bash
?
Now I run cd /d "d:/Dropbox/neovim/config" && c:/Program Files/Git/bin/git.exe ls-files -v --error-unmatch --full-name -z -- .vimrc
in CMD, I got 'c:/program' is not recognized as an internal or external command, operable program or batch file
.
Interesting that &shell
is cmd.exe
and cd /d d:/Dropbox/neovim/config"
works fine in CMD – but fails inside nvim. I'll have to think about that.
The 'c:/program' is not recognized...
is separate. I don't know how to specify the absolute path to Git on Windows. If you use plain git
instead, does it work? I.e. cd /d "d:/Dropbox/neovim/config" && git ls-files -v --error-unmatch --full-name -z -- .vimrc
Seems to me the error is caused by the space between "Program" and "Files". On my home pc, I can try changing the install dir later and try but on my corp PC, it is not changable.
(By the way I'm planning to update gitgutter to use -C <dir>
to avoid having to cd. But it would be good to get you up and running in the meantime.)
Interesting that
&shell
iscmd.exe
andcd /d d:/Dropbox/neovim/config"
works fine in CMD – but fails inside nvim. I'll have to think about that.The
'c:/program' is not recognized...
is separate. I don't know how to specify the absolute path to Git on Windows. If you use plaingit
instead, does it work? I.e.cd /d "d:/Dropbox/neovim/config" && git ls-files -v --error-unmatch --full-name -z -- .vimrc
It returns me H .vimrc
so it seems it is working fine (?).
OK, so don't set let g:gitgutter_git_executable = ...
in your config.
I think it is working now - Thanks much!!!
Just curious, I feel the editor is bit "stuttering" => so I have turned they Async on, it stops working immediately.
I saw you asks another windows user to turn async off - may I check why?
When vim/nvim had only just introduced jobs, it was useful to turn off async to find out whether the problem at hand was caused by buggy async code or the core diffing stuff. These days there's no benefit to turning async off; in fact doing so will make your editor feel slower.
When you stay it stops working immediately, can you be more specific?
Also, what is your updatetime
? You can find out with :echo &updatetime
. Vim/nvim's default is 4000 (milliseconds) which is far too slow; you want something like 100.
When vim/nvim had only just introduced jobs, it was useful to turn off async to find out whether the problem at hand was caused by buggy async code or the core diffing stuff. These days there's no benefit to turning async off; in fact doing so will make your editor feel slower.
When you stay it stops working immediately, can you be more specific?
Also, what is your
updatetime
? You can find out with:echo &updatetime
. Vim/nvim's default is 4000 (milliseconds) which is far too slow; you want something like 100.
my updatetime
has been set to 100;
When set let g:gitgutter_async=1
in .vimrc
then source $MYVIMRC
:
signcolumn
stops updating.nvim
and reopen =>shows "no hunks in file"check the async command produced in the log [async] cd /d "d:/Dropbox/neovim/config" && git ls-files -v --error-unmatch --full-name -z -- vim_config.vimrc
which works fine in the cmd
.
Please could you post more of the log? The command you pasted above is just the first one it runs, to find out whether a file is tracked by git. The diff stuff will be further down the log.
Also I just noticed that you are telling gitgutter that grep isn't available by setting a script variable (s:
) instead of a global (g:
). It needs to be a global.
Please could you post more of the log? The command you pasted above is just the first one it runs, to find out whether a file is tracked by git. The diff stuff will be further down the log.
Also I just noticed that you are telling gitgutter that grep isn't available by setting a script variable (
s:
) instead of a global (g:
). It needs to be a global.
I may have paste it from somewhere have update it to g:
for grep. Below is the log just gen:
========== start log session 13.07.2024 13:25:55 ==========
0.002292 function startify#open_buffers[6]..
0.162554 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
1.198566 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
1.864175 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
2.093610 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
2.249814 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
2.406145 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
2.604755 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
4.115714 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
8.076096 BufEnter Autocommands for "*"..function
8.107685 nvim_exec2()..BufEnter Autocommands for "*"..function
8.258966 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
8.955768 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
9.879474 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
10.191138 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
10.989487 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
11.127895 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
11.373412 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
11.632597 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
12.401863 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
12.727002 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
13.317027 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
13.919332 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
14.071309 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
14.193420 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
15.621553 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
16.879140 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
18.114964 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
18.813974 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
19.133967 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
19.475529 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
20.444032 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
20.597150 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
20.844639 CursorHold Autocommands for "*"..function gitgutter#process_buffer[14]..
25.416507 BufEnter Autocommands for "*"..function
Thank you. And what does :echo b:gitgutter
give?
By the way, I just pushed a change which avoids the cd /d
step. Perhaps you could update your gitgutter, reproduce the problem, and tell me what :echo b:gitgutter
shows.
By the way, I just pushed a change which avoids the
cd /d
step. Perhaps you could update your gitgutter, reproduce the problem, and tell me what:echo b:gitgutter
shows.
{'path': -2, 'enable': 1, 'mapped': 1}
Thanks!
A path of -2 means either that gitgutter thinks the file is not tracked by git or that the git ls-files
command error'ed for some other reason.
Given that signs appear when you turn off async, the problem must be running the git ls-files
asynchronously – which is weird because that stuff hasn't caused any problems for years, as far as I know.
If you've updated gitgutter, the command should look like:
git -C "d:/Dropbox/neovim/config" ls-files -v --error-unmatch --full-name -z -- vim_config.vimrc
Please could you confirm that? And whether :echo has("win32")
prints 1
?
I confess I'm not really sure what the problem is. I'll keep thinking...
Thanks!
A path of -2 means either that gitgutter thinks the file is not tracked by git or that the
git ls-files
command error'ed for some other reason.Given that signs appear when you turn off async, the problem must be running the
git ls-files
asynchronously – which is weird because that stuff hasn't caused any problems for years, as far as I know.If you've updated gitgutter, the command should look like:
git -C "d:/Dropbox/neovim/config" ls-files -v --error-unmatch --full-name -z -- vim_config.vimrc
Please could you confirm that? And whether
:echo has("win32")
prints1
?I confess I'm not really sure what the problem is. I'll keep thinking...
Thanks!
re :echo has("win32")
prints 1
=> yes
and confirm now the command looks like git -C "d:/Dropbox/neovim/config" ls-files -v --error-unmatch --full-name -z -- repl_config.lua
Separately, I have managed to get gitsign-nvim
works out of box. But since I have been using both vim and nvim depending on secnairo / enviroment, I'll also keep exploring :)
not much progress - I have updated my git to the latest versions the same issue persists.
Ok, to summarise:
let g:gitgutter_async = 0
, the diff signs appear.let g:gitgutter_async = 0
, the diff signs don't appear and b:gitgutter.path
is -2
.git -C "d:/Dropbox/neovim/config" ls-files -v --error-unmatch --full-name -z -- repl_config.lua
in your shell produces H repl_config.lua
.:!git -C "d:/Dropbox/neovim/config" ls-files -v --error-unmatch --full-name -z -- repl_config.lua
in Neovim produces H repl_config.lua
.Is that all correct?
All correct. Except now I run :echo b:gitgutter
=> 'path':'vim_config.vimrc'. It was in a different out format (only 3 keys) with path = -2.
Ok, to summarise:
- You're using Neovim on Windows.
- When you edit a file tracked by git, with
let g:gitgutter_async = 0
, the diff signs appear.- When you edit a file tracked by git, without
let g:gitgutter_async = 0
, the diff signs don't appear andb:gitgutter.path
is-2
.- Running
git -C "d:/Dropbox/neovim/config" ls-files -v --error-unmatch --full-name -z -- repl_config.lua
in your shell producesH repl_config.lua
.- Running
:!git -C "d:/Dropbox/neovim/config" ls-files -v --error-unmatch --full-name -z -- repl_config.lua
in Neovim producesH repl_config.lua
.Is that all correct?
The path format doesn't matter. b:gitgutter
is a dictionary and path
is one of its keys.
Anyway, if it says vim_config.vimrc
instead of -2
, that's progress. It means gitgutter has established that the file is tracked by git and can move on to diffing it.
But you're still not seeing diff signs? What does the log say now?
The path format doesn't matter.
b:gitgutter
is a dictionary andpath
is one of its keys.Anyway, if it says
vim_config.vimrc
instead of-2
, that's progress. It means gitgutter has established that the file is tracked by git and can move on to diffing it.But you're still not seeing diff signs? What does the log say now?
Okay. It is still -2
when doing async, returns the file_name
in sync mode.
Please make this change, which hopefully will tell us what the problem is:
diff --git i/autoload/gitgutter/async.vim w/autoload/gitgutter/async.vim
index 8b9f130..114ca90 100644
--- i/autoload/gitgutter/async.vim
+++ w/autoload/gitgutter/async.vim
@@ -63,9 +63,14 @@ function! s:on_stdout_nvim(_job_id, data, _event) dict abort
endif
endfunction
+let s:lines = ['']
function! s:on_stderr_nvim(_job_id, data, _event) dict abort
if a:data != [''] " With Neovim there is always [''] reported on stderr.
+ let s:lines[-1] .= a:data[0]
+ call extend(s:lines, a:data[1:])
call self.handler.err(self.buffer)
+ else
+ echom s:lines[0]
endif
endfunction
You can see the error message with :messages
.
Please make this change, which hopefully will tell us what the problem is:
diff --git i/autoload/gitgutter/async.vim w/autoload/gitgutter/async.vim index 8b9f130..114ca90 100644 --- i/autoload/gitgutter/async.vim +++ w/autoload/gitgutter/async.vim @@ -63,9 +63,14 @@ function! s:on_stdout_nvim(_job_id, data, _event) dict abort endif endfunction +let s:lines = [''] function! s:on_stderr_nvim(_job_id, data, _event) dict abort if a:data != [''] " With Neovim there is always [''] reported on stderr. + let s:lines[-1] .= a:data[0] + call extend(s:lines, a:data[1:]) call self.handler.err(self.buffer) + else + echom s:lines[0] endif endfunction
You can see the error message with
:messages
.
I think we are getting there. Finally there is some error msg, actually an array of "The syntax of the command is incorrect. ^M
"
^M
is a bad
The ^M is irrelevant: it's just a stray line ending from the first line of the error message.
The syntax of the command is incorrect.
This is coming from cmd.exe
but I don't know why.
This is a total guess:
diff --git i/autoload/gitgutter/async.vim w/autoload/gitgutter/async.vim
index 8b9f130..c9d782e 100644
--- i/autoload/gitgutter/async.vim
+++ w/autoload/gitgutter/async.vim
@@ -46,7 +46,7 @@ function! s:build_command(cmd)
endif
if has('win32')
- return has('nvim') ? ['cmd.exe', '/c', a:cmd] : 'cmd.exe /c '.a:cmd
+ return has('nvim') ? a:cmd : 'cmd.exe /c '.a:cmd
endif
throw 'unknown os'
@@ -63,9 +63,14 @@ function! s:on_stdout_nvim(_job_id, data, _event) dict abort
endif
endfunction
+let s:lines = ['']
function! s:on_stderr_nvim(_job_id, data, _event) dict abort
if a:data != [''] " With Neovim there is always [''] reported on stderr.
+ let s:lines[-1] .= a:data[0]
+ call extend(s:lines, a:data[1:])
call self.handler.err(self.buffer)
+ else
+ echom s:lines[0]
endif
endfunction
If that doesn't work, you could try:
- return has('nvim') ? ['cmd.exe', '/c', a:cmd] : 'cmd.exe /c '.a:cmd
+ return has('nvim') ? [a:cmd] : 'cmd.exe /c '.a:cmd
return has('nvim') ? a:cmd : 'cmd.exe /c '.a:cmd
This line works! Really appreciate your help all along. Confirm the plug-in works on my vim and vim.
Feel free to close or lmk if you want me to test anything. Thanks again!
I re-entered this post as it was accidentally deleted :p]
Phew! Thanks for your help debugging this.
Hi there - hope you are well! I am switching from vscode to nvim now. And would appreciate any help!
This is my current gitgutter config:
When I do
[-c] =>
no hunk in file, also there is no sign in the singcolumn which is set to
auto`. When ckecking the log file I see:When try to execute
cd /d "d:/Dropbox/neovim/config" && C:/Program Files/Git/bin/git.exe ls-files -v --error-unmatch --full-name -z -- .vimrc
from the comand line, it producesE344: Can't find directory "/d" in cdpath E472: Command failed
I thought I was on the right track and found a similar issue #174 and also tried set GIT_DISCOVERY_ACROSS_FILESYSTEM=1 on
cmd
bebefore running nvim. Got the same issue.other things i have tried:
git init
in the repo folder => same log msgpowershell
=> same log msgC:/Program Files/Git/
folder => same log msgThanks a lot in advance!