40 lines
1.4 KiB
Lua
40 lines
1.4 KiB
Lua
-- Tab display settings
|
|
vim.opt.showtabline = 1 -- Always show tabline (0=never, 1=when multiple tabs, 2=always)
|
|
vim.opt.tabline = '' -- Use default tabline (empty string uses built-in)
|
|
|
|
-- Transparent tabline appearance
|
|
vim.cmd([[
|
|
hi TabLineFill guibg=NONE ctermfg=242 ctermbg=NONE
|
|
]])
|
|
|
|
-- Alternative navigation (more intuitive)
|
|
vim.keymap.set('n', '<leader>tn', ':tabnew<CR>', { desc = 'New tab' })
|
|
|
|
-- Tab moving
|
|
vim.keymap.set('n', '<leader>tm', ':tabmove<CR>', { desc = 'Move tab' })
|
|
vim.keymap.set('n', '<leader>t>', ':tabmove +1<CR>', { desc = 'Move tab right' })
|
|
vim.keymap.set('n', '<leader>t<', ':tabmove -1<CR>', { desc = 'Move tab left' })
|
|
|
|
-- Function to open file in new tab
|
|
local function open_file_in_tab()
|
|
vim.ui.input({ prompt = 'File to open in new tab: ', completion = 'file' }, function(input)
|
|
if input and input ~= '' then
|
|
vim.cmd('tabnew ' .. input)
|
|
end
|
|
end)
|
|
end
|
|
|
|
-- Enhanced keybindings
|
|
vim.keymap.set('n', '<leader>tO', open_file_in_tab, { desc = 'Open file in new tab' })
|
|
|
|
-- Function to close buffer but keep tab if it's the only buffer in tab
|
|
local function smart_close_buffer()
|
|
local buffers_in_tab = #vim.fn.tabpagebuflist()
|
|
if buffers_in_tab > 1 then
|
|
vim.cmd('bdelete')
|
|
else
|
|
-- If it's the only buffer in tab, close the tab
|
|
vim.cmd('tabclose')
|
|
end
|
|
end
|
|
vim.keymap.set('n', '<leader>x', smart_close_buffer, { desc = 'Smart close buffer/tab' })
|