Skip to content

[FEAT]: Focus currently edited file after opening #1926

@alteriks

Description

@alteriks

Is your feature request related to a problem? Please describe.
I've recently been using Neogit more and more in favor of LazyGit. Most of the time I'm editing files on [WIP] branch with lots of changes which won't make to other branches or aren't commited yet.
I'm launching Neogit with this keymap:

{ "<leader>gg", '<cmd>Neogit<CR>',      desc = "Neogit" },

But after launching Neogit I'm lost for a while and have to think for couple of seconds name of the file I was editing and I'd like to commit.
I've came up with this crude solution:

			{
				"<leader>gn",
				function()
					local file = vim.fn.expand("%:t") -- just the filename
					require("neogit").open({ cwd = vim.fn.expand("%:p:h") })
					vim.defer_fn(function()
						vim.fn.search(file, "w")
					end, 200)
				end,
				desc = "Neogit (focus current file)"
			}

Describe the solution you'd like
I'd like to propose additional Neogit subcommand like :Neogit focus name doesn't matter really. But I think it would streamline working with Neogit.

Thanks a lot for your work and your passion. Neogit is growing on me every day!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions