mirror of
https://github.com/hyzendust/KickestEnd.nvim.git
synced 2026-02-15 09:21:12 +01:00
Added custom function for tabline not to display the 'X'/Close symbol on top right corner. Additionally, given it some Kanagawa theme compatible native tabline look.
This commit is contained in:
66
init.lua
66
init.lua
@@ -812,5 +812,71 @@ require('luasnip.loaders.from_vscode').lazy_load()
|
||||
-- Theme
|
||||
require('kanagawa').setup { transparent = true }
|
||||
vim.cmd [[colorscheme kanagawa]]
|
||||
|
||||
-- Custom native-looking tabline that matches Kanagawa theme
|
||||
vim.o.showtabline = 1
|
||||
_G.tab_offset = 1
|
||||
local max_visible_tabs = 8 -- maximum number of tabs visible at once
|
||||
|
||||
function _G.Tabline()
|
||||
local current_tab = vim.fn.tabpagenr()
|
||||
local tab_count = vim.fn.tabpagenr '$'
|
||||
local win_width = vim.o.columns
|
||||
local tab_width = math.floor(win_width / max_visible_tabs) -- FIXED width
|
||||
|
||||
local tabs = {}
|
||||
for i = 1, tab_count do
|
||||
local buflist = vim.fn.tabpagebuflist(i)
|
||||
local winnr = vim.fn.tabpagewinnr(i)
|
||||
local bufname = vim.fn.bufname(buflist[winnr])
|
||||
if bufname == '' then
|
||||
bufname = '[No Name]'
|
||||
end
|
||||
local modified = vim.fn.getbufvar(buflist[winnr], '&mod') == 1 and ' ●' or ''
|
||||
local label = i .. ': ' .. vim.fn.fnamemodify(bufname, ':t') .. modified
|
||||
|
||||
-- truncate/pad to fixed tab_width
|
||||
if #label > tab_width - 2 then
|
||||
label = label:sub(1, tab_width - 3) .. '…'
|
||||
end
|
||||
label = label .. string.rep(' ', tab_width - #label)
|
||||
|
||||
tabs[i] = (i == current_tab and '%#TabLineSel#' or '%#TabLine#') .. label
|
||||
end
|
||||
|
||||
-- scrolling logic to keep active tab visible
|
||||
local start_index = _G.tab_offset
|
||||
if current_tab < start_index then
|
||||
start_index = current_tab
|
||||
elseif current_tab >= start_index + max_visible_tabs then
|
||||
start_index = current_tab - max_visible_tabs + 1
|
||||
end
|
||||
_G.tab_offset = start_index
|
||||
|
||||
-- select visible tabs
|
||||
local visible_tabs = {}
|
||||
for i = start_index, math.min(start_index + max_visible_tabs - 1, tab_count) do
|
||||
table.insert(visible_tabs, tabs[i])
|
||||
end
|
||||
|
||||
-- scrolling arrows
|
||||
local left_arrow = start_index > 1 and '< ' or ' '
|
||||
local right_arrow = start_index + max_visible_tabs - 1 < tab_count and ' >' or ' '
|
||||
|
||||
return '%#TabLine#' .. left_arrow .. table.concat(visible_tabs, '') .. right_arrow .. '%#TabLineFill#'
|
||||
end
|
||||
|
||||
vim.o.tabline = '%!v:lua.Tabline()'
|
||||
|
||||
-- adjust offset if tabs are closed
|
||||
vim.api.nvim_create_autocmd({ 'TabClosed' }, {
|
||||
callback = function()
|
||||
local tab_count = vim.fn.tabpagenr '$'
|
||||
if _G.tab_offset > tab_count then
|
||||
_G.tab_offset = math.max(tab_count - max_visible_tabs + 1, 1)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||
-- vim: ts=2 sts=2 sw=2 et
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "107c2458cdc780c4ed2c2b5e1b7800cd019010bd" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "a13a12861d29fe07b3e5660136baa5cd40751612" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" },
|
||||
|
||||
Reference in New Issue
Block a user