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

[Bug]: Pressing Esc moves bufferline tabs to the left #968

Open
1 task done
neilsimp1 opened this issue Oct 7, 2024 · 1 comment
Open
1 task done

[Bug]: Pressing Esc moves bufferline tabs to the left #968

neilsimp1 opened this issue Oct 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@neilsimp1
Copy link

neilsimp1 commented Oct 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

If I press Escape while in Normal mode, the current tab in bufferline moves one to the left.

What did you expect to happen?

Expected behaviour: If already in normal mode, I expect nothing to happen.

Config

{
	"akinsho/bufferline.nvim",
	version = "*",
	dependencies = "nvim-tree/nvim-web-devicons",
	config = function()
		local get_file_explorer_text = function(default)
			local text = default
			local branch = vim.fn.system("git branch --show-current 2> /dev/null | tr -d '\n'")
			if branch ~= nil and branch ~= "" then
				text = vim.fn.substitute(vim.fn.getcwd(), "^.*/", "", "") .. " / " .. branch
			end
			return text
		end
		require("bufferline").setup({
			options = {
				diagnostics = "nvim_lsp",
				right_mouse_command = nil,
				offsets = {
					{
						filetype = "neo-tree",
						text = get_file_explorer_text,
						text_align = "center",
						separator = false,
						highlight = "BufferLineFill",
					},
					{ filetype = "dapui_breakpoints" },
					{ filetype = "dapui_scopes" },
					{ filetype = "dapui_stacks" },
					{ filetype = "dapui_watches" },
					{ filetype = "dbui" },
					{
						filetype = "DiffviewFiles",
						text = get_file_explorer_text,
						text_align = "center",
						separator = false,
						highlight = "BufferLineFill",
					},
				},
				separator_style = "slant",
			},
		})
		-- Re-order to previous/next
		KeyMap("n", "<C-[>", "<Cmd>BufferLineMovePrev<CR>")
		KeyMap("n", "<C-]>", "<Cmd>BufferLineMoveNext<CR>")
		-- Goto buffer in position...
		KeyMap("n", "<C-1>", "<Cmd>BufferLineGoToBuffer 1<CR>")
		KeyMap("n", "<C-2>", "<Cmd>BufferLineGoToBuffer 2<CR>")
		KeyMap("n", "<C-3>", "<Cmd>BufferLineGoToBuffer 3<CR>")
		KeyMap("n", "<C-4>", "<Cmd>BufferLineGoToBuffer 4<CR>")
		KeyMap("n", "<C-5>", "<Cmd>BufferLineGoToBuffer 5<CR>")
		KeyMap("n", "<C-6>", "<Cmd>BufferLineGoToBuffer 6<CR>")
		KeyMap("n", "<C-7>", "<Cmd>BufferLineGoToBuffer 7<CR>")
		KeyMap("n", "<C-8>", "<Cmd>BufferLineGoToBuffer 8<CR>")
		KeyMap("n", "<C-9>", "<Cmd>BufferLineGoToBuffer 9<CR>")
		KeyMap("n", "<C-0>", "<Cmd>BufferLineGoToBuffer 10<CR>")
		KeyMap("n", "<C-`>", "<Cmd>BufferLineGoToBuffer -1<CR>")
		-- Pin/unpin buffer
		KeyMap("n", "<C-p>", "<Cmd>BufferLineTogglePin<CR>")
		-- Close buffers
		KeyMap("n", "<C-w>", "<Cmd>Bdelete<CR>", "Close tab", true)
		KeyMap("n", "<C-S-w>", "<Cmd>BufferLineCloseOthers<CR>", "Close other tabs", true)
		KeyMap("n", "<C-S-[>", "<Cmd>BufferLineCloseLeft<CR>", "Close tabs to the left", true)
		KeyMap("n", "<C-S-]>", "<Cmd>BufferLineCloseRight<CR>", "Close tabs to the right", true)
	end,
}

Additional Information

...

commit

No response

@neilsimp1 neilsimp1 added the bug Something isn't working label Oct 7, 2024
@hexcowboy
Copy link

I'm also noticing this with the same keybindings as you

vim.api.nvim_set_keymap('n', '<C-[>', '<cmd>BufferLineCyclePrev<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-]>', '<cmd>BufferLineCycleNext<cr>', { noremap = true, silent = true })

and weirdly when I map <esc> to nothing, the keybind <C-[> stops working

vim.api.nvim_set_keymap('n', '<esc>', '', { noremap = true, silent = true })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants