Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to disable or override a mapping #31

Open
HartBlanc opened this issue Nov 27, 2022 · 0 comments
Open

Make it possible to disable or override a mapping #31

HartBlanc opened this issue Nov 27, 2022 · 0 comments

Comments

@HartBlanc
Copy link

HartBlanc commented Nov 27, 2022

I tried to override the vertical split mapping so that it would open the file in a vertical split right away rather than waiting for the user to manually close vifm.

I achieved this with some hacky config:

local function mappings()
	-- make ctrl-v close the file manager and open the file in a split pane. The default behaviour is to only
	-- open the split pane once the flie manager has been closed manually by the user.
	vim.api.nvim_buf_set_keymap(
		0,
		"t",
		"<c-v>",
		'<C-\\><C-n>:lua require("fm-nvim").setMethod("vsplit | edit")<CR>il<cr>',
		{ silent = true }
	)
end

fm_nvim.setup({
	on_open = {
		mappings,
	},
	mappings = {
		-- something that I'm unlikely to press so that it is effectively disabled (these mappings are set after on_open
		-- so it would override the <c-v> defined in mappings if we didn't set it)
		vert_split = "sirerofpuwyq-;ufwyq-;pufyqw-;pufyqw-;",
	},
})

This works, but it's a bit messy. Providing an empty string to, or omitting, the vert_spilt mappings map entry causes it to error or default to <c-v> and because the default mappings are set up after on_open it would override my override.

Adding an override was my use case, but it would also be nice to disable mappings that users have no intention to use as they may conflict with other mappings, and generally create unnecessary noise.

@HartBlanc HartBlanc reopened this Nov 27, 2022
@HartBlanc HartBlanc changed the title d Make it possible to disable or override a mapping Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant