NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
3.71k stars 221 forks source link

Inline status diff highlighting (and overall config) #1264

Open petobens opened 3 months ago

petobens commented 3 months ago

Hi! I'm playing with the inline status diff and have a few questions:

  1. Is possible to add custom highlights? For instance in the image below I would like to change the light blue highlight of the hunk, how the green add line is highlighted and so on image

  2. I want to be able to move between hunks with both [h and [c (since I never remember which one to press) however when add the following mapping config:

        status = {
            ['='] = 'Toggle',
            ['[h'] = 'GoToPreviousHunkHeader',
            [']h'] = 'GoToNextHunkHeader',
            ['[c'] = 'GoToPreviousHunkHeader',
            [']c'] = 'GoToNextHunkHeader',
        },

    I get:

    E5108: Error executing lua: ...hare/nvim/lazy/neogit/lua/neogit/buffers/status/init.lua:421: table index is nil
    stack traceback:
        ...hare/nvim/lazy/neogit/lua/neogit/buffers/status/init.lua:421: in function 'open'
        /home/pedro/.local/share/nvim/lazy/neogit/lua/neogit.lua:115: in function 'open_status_buffer'
        /home/pedro/.local/share/nvim/lazy/neogit/lua/neogit.lua:187: in function 'open'
        ...e/pedro/.config/nvim/lua/plugin-config/neogit_config.lua:68: in function <...e/pedro/.config/nvim/lua/plugin-config/neogit_config.lua:66>

    If I remove the last two mappings the error goes away but then [c and ]c are not mapped.

  3. If as in the gif I press = on a modified file to toggle the diffs and then move inside a hunk and press = again then only the hunk get folded. To fold the whole file I therefore need to move to the filename and press = there. Is it possible to simply autoggle hunks (i.e closing and opening alltogether rather in a 2 step process?). I guess this is similar to https://github.com/NeogitOrg/neogit/issues/651#issuecomment-1681235969

Peek 2024-04-27 17-13

  1. I don't quite understand how the diff (diffview) integration works from within the status buffer. I press d and then d again on a modified file (or d and s on a staged file) diffview always opens a window with diffview://null as per the following GIF: Peek 2024-04-27 17-25

  2. Bonus: I guess 1. also applies to NeogitCommitView where highlight groups also seem not configurable? image

CKolkey commented 3 months ago
  1. All the highlight groups are here: https://github.com/NeogitOrg/neogit/blob/nightly/lua/neogit/lib/hl.lua - you can just define the colors you want somewhere in your config (before loading neogit) and we won't overload that.
  2. That's not going to work 😓 The table gets inverted (keys become values) for easy lookup, so if two key have the same value, I think that's going to create a collision. Someday I'd like to have a mapping API as nice as telescope, but for now... here's what we've got.
  3. No, toggle works on whatever the smallest local scope is. If you're on a hunk, you'll toggle the hunk. That's not something I'm interested in messing with 🤷🏼
  4. dd is a fast way of doing "do what I mean" - it'll diff whatever you have selected. It seems to be working fine for me.. If you can make a simple reproduction I'll try to figure out why it's not working for you.
  5. HL groups are all configurable, just make sure whatever you define is loaded before neogit.
petobens commented 3 months ago
  1. Thanks! I'll take a look to that file. Any idea why running :Inspect doesn't report the highlight groups? Peek 2024-04-27 20-01
  2. Thanks for the explanation
  3. Roger that
  4. I'll cook a minimal working example and report back.
  5. I guess it's the same as 1.. for some reason :Inspect is not reporting the hl groups.
petobens commented 3 months ago

That's not going to work 😓 The table gets inverted (keys become values) for easy lookup, so if two key have the same value, I think that's going to create a collision. Someday I'd like to have a mapping API as nice as telescope, but for now... here's what we've got.

Coming but to this I did notice today that in my config I have:

    mappings = {
        status = {
            ['X'] = 'Discard',
          ....
          }
}

and both x and X work to trigger a discard event. So the [c and [h doesn't work because both are user defined? Whereas X is user defined and x is from neogit default config?