Skip to content

NeogitLogView has problem with open commit link in browser mapping #1914

@stryukovsky

Description

@stryukovsky

Description

Hello guys, many thanks for your plugin, its awesome. In lua/neogit/buffers/log_view/init.lua line 132 there is defined mapping of pressing "o" in normal mode. This mapping is lacking overriding option. I want to override it because my other mapping with "o" in normal mode clashes with it.

Speaking exactly, log_view popup takes GoToFile mapping from status popup and then some Lua magic happens and either my overriden GoToFile mapping is applied or open commit in browser is executed.

This clashing appears to be kinda strange: sometimes opens commit link in my browser, sometimes commit details are opened in neogit.

I think lua sometimes takes first value in the table of mappings, and sometimes the second value with the same key of "o"

I think the best and easiest way to fix that is to allow override mapping of opening commit link in browser

Neovim version

NVIM v0.11.6
Build type: RelWithDebInfo
LuaJIT 2.1.1767980792

Operating system and version

Fedora 43

Steps to reproduce

  1. go to some git repository
  2. nvim -nu minimal.lua
  3. open neogit log popup :Neogit log
  4. pick current by pressing l in normal mode
  5. press "o" in normal mode when selected some commit

NOTE: this is kinda sporadical problem, retry 3-5 times to reproduce, i think the reason is how lua resolves table with several values with the same key

Expected behavior

There shall be way to override mapping of open commit link in browser

Actual behavior

Opens either commit link in new browser tab or open commit in neovim

Minimal config

-- THIS IS MY minimal.lua content

-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
	local lazyrepo = "https://github.com/folke/lazy.nvim.git"
	local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
	if vim.v.shell_error ~= 0 then
		vim.api.nvim_echo({
			{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
			{ out, "WarningMsg" },
			{ "\nPress any key to exit..." },
		}, true, {})
		vim.fn.getchar()
		os.exit(1)
	end
end
vim.opt.rtp:prepend(lazypath)

-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Setup lazy.nvim
require("lazy").setup({
	spec = {
		{
			"NeogitOrg/neogit",
			dependencies = {
				"nvim-lua/plenary.nvim", -- required

				-- Only one of these is needed.
				"nvim-telescope/telescope.nvim", -- optional
			},
		},
	},
})

local neogit = require("neogit")

neogit.setup({
	log_view = {
		kind = "split",
	},
	mappings = {
		status = {
			["o"] = "GoToFile",
		},
	},
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions