Last active
May 1, 2022 23:18
-
-
Save RaafatTurki/b29ac80ae4e6ce8e4ef93a69d945e8fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- vim.g.last_tab_page_handler = nil | |
-- LastTabPageHandler = nil | |
function TabSwitch(handler) | |
local curr_handler = vim.api.nvim_get_current_tabpage() | |
local next_handler = handler | |
-- if (handler == curr_handler) then | |
-- next_handler = LastTabPageHandler | |
-- LastTabPageHandler = curr_handler | |
-- end | |
if (next_handler ~= nil) then | |
vim.api.nvim_set_current_tabpage(next_handler) | |
end | |
end | |
function TabCreate(n) | |
vim.cmd [[tabnew]] | |
end | |
function TabChicanery(n) | |
local tab_page_handlers = vim.api.nvim_list_tabpages() | |
if (n > #tab_page_handlers) then | |
if (n == #tab_page_handlers+1) then | |
TabCreate(n) | |
end | |
else | |
TabSwitch(tab_page_handlers[n]) | |
end | |
end | |
for n = 1, 9 do | |
vim.keymap.set('n', '<A-'..n..'>', function() TabChicanery(n) end) | |
end | |
vim.keymap.set('n', '<A-l>', '<CMD>tabnext<CR>') | |
vim.keymap.set('n', '<A-h>', '<CMD>tabprevious<CR>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment