NeogitOrg/neogit

Option to open status with the current file selected

Ouverte

#1 173 ouverte le 12 févr. 2024

 (0 commentaire) (1 réaction) (0 personne assignée)Lua (335 forks)batch import
enhancementgood first issue

Métriques du dépôt

Stars
 (5 351 étoiles)
Métriques de merge PR
 (Merge moyen 18h 52m) (1 PR mergée en 30 j)

Description

Is your feature request related to a problem? Please describe. About 100 times a day, I open NeoGit status, then search for the current file I was on, so I can see it's unstaged changes. I have tried other diff tools (like Diffview.nvim), but Neogit is by far my favourite. E.g below you can see wc-cal-month/shadow.css is open. Say I was on that file and then ran neogit.open({ file = true}) then this new feature would open the status with that file open: image

Describe the solution you'd like Add an option to neogit.open to handle opening the current file. neogit.open({ file = true}) to jump to the current file if it is in the status. Optionally one could also test if file is a string and if so search for it, e.g. { file = '/foo/bar/baz.py'} to open some other file .

Describe alternatives you've considered

Not nearly as awesome as NeoGit:

local function viewGitDiffCurrentFile()
    local filePath = vim.fn.expand('%')
    vim.cmd('vsplit | terminal git diff ' .. filePath)
end

vim.keymap.set('n', '<leader>I', viewGitDiffCurrentFile, { noremap = true, silent = true })

Additional context I tried going through the source code, but could not find the entry point to where the open function is defined. If you like the idea.... and can give me a starting point or some advice, I could try tackle the issue, unless it's a super fast feature to implement for you, then by all means go for it.

Guide contributeur