f-person / git-blame.nvim

Git Blame plugin for Neovim written in Lua
GNU General Public License v3.0
839 stars 41 forks source link

Getting "Not Committed Yet" in every line. #117

Open avilesj opened 6 months ago

avilesj commented 6 months ago

Hi. I am using LazyVim and I am extending it with this plugin. I have not added any special config.

Here is the config.

return {
  {
    "f-person/git-blame.nvim",
    opts = {
      enabled = true,
    },
  },
}
f-person commented 6 months ago

Hey! A couple of questions:

  1. Are you running nvim from the root of your repo?
  2. Any errors in the log? (:messages)
  3. I wonder if LazyVim has anything to do with this; could you try running it without LazyVim on your system?
avilesj commented 6 months ago

Hi!

  1. Yes. I also tried running it outside and cd-ing into it with projects.
  2. No errors in the log sadly.
  3. I removed LazyVim, installed vim-plug and this plugin with it. Still have the same result.

Thank you for the swift response!

filipkrayem commented 6 months ago

I am running into the same issue, however it only happens on large projects to me (NX monorepo with 130k LOC.)

Smaller projects work fine.

Noodle-Bug commented 5 months ago

Can confirm, happening to me as well on a larger repo. Happens regardless of whether or not I open nvim at the root of the repo.

f-person commented 5 months ago

@Noodle-Bug would that repo happen to be open-source? :)

Noodle-Bug commented 5 months ago

@Noodle-Bug would that repo happen to be open-source? :)

...no? Is that an issue?

avilesj commented 5 months ago

Does not work on this public repo I own https://github.com/avilesj/configs

It didn't work there when it was private either.

filipkrayem commented 4 months ago

I figured it out! I've been having this issue for so long and now I finally figured it out by accident when I was trying to copy the file URL.

The issue lies in .nvmrc file being in the repo. I'm using fnm, not sure if this happens with nvm as well, but fnm prints 'Using Node 18.16.1' (or whatever your specified node version is) when .nvmrc is present and that messes up the script.

The plugin works as it's supposed to when you delete the .nvmrc file. However, for obvious reasons, that is not the ideal solution.

I remember having problems or seeing this "Using node x" in more places using nvim. It also prints the line when you open a new shell (i'm using fish, but it probably happens with others as well I would guess). So I guess nvim internally opens a new shell for the commands?

Output of GitBlameCopyFileURL with .nvmrc Using Node v18.16.1/blob/Using Node v18.16.1/ts/Repos/folder/folder/project/src/metrics.ts#L13

Output of GitBlameCopyFileURL without .nvmrc

https://ssh.dev.azure.com/v3/org/project/repo-name/blob/d66a1294736bcf60cebe9455f92efdfab1cd2e82/src/metrics.ts#L17

The URL doesn't really work either since it's completely incorrect when it comes to Azure, it should look something like this:

https://dev.azure.com/org/project/_git/repo-name?path=/src/metrics.ts

But that's besides the point.

@f-person what do you think?

f-person commented 4 months ago

Thanks @filipkrayem! This is very weird, but it makes sense that an issue like this would be caused by the output being tampered with. I wonder if @avilesj & @Noodle-Bug could confirm your observations and share whether they also had nvmrc (or things)?

avilesj commented 4 months ago

Hi. Thanks again for keeping up with this.

I make no use of nvmrc. I do use Volta but the specs are within package.json

One thing tho, I have the same issue in my Terraform repository too and there is 0 Node code inside, fwiw.

filipkrayem commented 4 months ago

does anything print to your console when you open up a new terminal? The actual problem most likely isn't a .nvmrc file or fnm, but the fact that it prints something to the console

Try running the command :GitBlameCopyFileURL, that should reveal the problem imo. If the URL looks valid, we may have a different issue that results in the same behavior, I guess "Not commited yet" is a fallback message so multiple issues could be causing it.

f-person commented 4 months ago

The actual problem most likely isn't a .nvmrc file or fnm, but the fact that it prints something to the console

exactly!

Try running the command :GitBlameCopyFileURL

yes please! it would be very nice if you could also share it in case it looked weird! please replace any sensitive details with a placeholder, though! :)

bossley9 commented 4 months ago

I figured it out! I've been having this issue for so long and now I finally figured it out by accident when I was trying to copy the file URL.

The issue lies in .nvmrc file being in the repo. I'm using fnm, not sure if this happens with nvm as well, but fnm prints 'Using Node 18.16.1' (or whatever your specified node version is) when .nvmrc is present and that messes up the script.

The plugin works as it's supposed to when you delete the .nvmrc file. However, for obvious reasons, that is not the ideal solution.

@filipkrayem do you have anything into your fish shell init script or repo that runs nvm before or after every command? I use nvm regularly in other nodejs repos and don't run into any issues. The only way that nvm will provide an output is if you invoke it (via nvm use or nvm install). In this case it looks like nvm use is being run. I've tried to reproduce but can't find a way to do so. Do you know if this command is running automatically through a shell init script or git hook?

filipkrayem commented 4 months ago

In my conf.d/fnm.fish I have this script:

# fnm
set PATH "~/.config/.fnm" $PATH
fnm env --use-on-cd --log-level error | source

Basically what it does it runs fnm use if a .nvmrc file is specified and prints the Using version to the console.

By adding --log-level error flag I have fixed the issue, since fnm prints the version log as level info.

bossley9 commented 4 months ago

I've tried a bit but can't manage to reproduce the issue even if I output to my shell after every command. I also looked into testing the url generation for azure but I don't think I can create a repo without paying :sweat_smile: