NeogitOrg/neogit

Option to open status with the current file selected

Aberta

#1.173 aberto em 12 de fev. de 2024

 (0 comentário) (1 reação) (0 responsável)Lua (335 forks)batch import
enhancementgood first issue

Métricas do repositório

Stars
 (5.351 estrelas)
Métricas de merge de PR
 (Mesclagem média 18h 52m) (1 fundiu PR em 30d)

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.

Guia do colaborador