NeogitOrg/neogit

Option to open status with the current file selected

開放

#1,173 建立於 2024年2月12日

 (0 則留言) (1 個反應) (0 位負責人)Lua (335 個分叉)batch import
enhancementgood first issue

倉庫指標

星標
 (5,351 顆星)
PR 合併指標
 (平均合併 18小時 52分鐘) (30 天內合併 1 個 PR)

描述

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.

貢獻者指南