Compare commits

...

2 Commits

Author SHA1 Message Date
hyzen
fbf75ac3ed Remove: dead code 2026-06-27 20:48:34 +05:30
hyzen
e713e93426 Update: alpha opens in every new tab 2026-06-27 20:41:58 +05:30
4 changed files with 45 additions and 25 deletions

View File

@@ -2,6 +2,33 @@
_G.alpha_tab_ascii = {}
-- Temporarily unlist other buffers so alpha.start(true) isn't skipped
-- when other tabs have real files open, then restore them after
local function force_alpha_start()
local alpha_loaded, alpha = pcall(require, 'alpha')
if not alpha_loaded then
return
end
local curbuf = vim.api.nvim_get_current_buf()
local restore = {}
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
if buf ~= curbuf and vim.api.nvim_buf_is_valid(buf) and vim.api.nvim_buf_get_option(buf, 'buflisted') then
table.insert(restore, buf)
vim.api.nvim_buf_set_option(buf, 'buflisted', false)
end
end
alpha.start(true)
for _, buf in ipairs(restore) do
if vim.api.nvim_buf_is_valid(buf) then
vim.api.nvim_buf_set_option(buf, 'buflisted', true)
end
end
end
_G.force_alpha_start = force_alpha_start
local last_tab_count = #vim.api.nvim_list_tabpages()
-- Save ASCII art
@@ -46,7 +73,7 @@ vim.api.nvim_create_autocmd('TabEnter', {
local dashboard_loaded, dashboard = pcall(require, 'alpha.themes.dashboard')
if not dashboard_loaded then
vim.cmd 'enew'
alpha.start(true)
force_alpha_start()
return
end
@@ -57,19 +84,27 @@ vim.api.nvim_create_autocmd('TabEnter', {
end
vim.cmd 'enew'
alpha.start(true)
force_alpha_start()
end)
end
end,
})
-- Clean
-- <afile> here is the tab's position number, not its handle, so we
-- can't use it to key into alpha_tab_ascii directly. Prune any cached
-- handle that's no longer a live tabpage instead.
vim.api.nvim_create_autocmd('TabClosed', {
pattern = '*',
callback = function()
local closed_tab = tonumber(vim.fn.expand '<afile>')
if closed_tab then
_G.alpha_tab_ascii[closed_tab] = nil
local live_tabs = {}
for _, tab in ipairs(vim.api.nvim_list_tabpages()) do
live_tabs[tab] = true
end
for cached_tab, _ in pairs(_G.alpha_tab_ascii) do
if not live_tabs[cached_tab] then
_G.alpha_tab_ascii[cached_tab] = nil
end
end
end,
})

View File

@@ -117,7 +117,7 @@ vim.keymap.set('n', '<leader>th', '<Cmd>vsplit | wincmd l | terminal<CR>i', { no
vim.keymap.set('n', '<Leader>e', function()
vim.cmd 'tabnew' -- create a new tab
vim.cmd 'enew' -- create a new empty buffer in it
require('alpha').start(true) -- open Alpha dashboard in this new tab
_G.force_alpha_start() -- opens Alpha
end, { noremap = true, silent = true, desc = 'Create a new tab' })
-- [[ Horizontal split with new empty buffer below ]]

View File

@@ -126,7 +126,6 @@ return {
end
-- Reuse empty buffer in current tab
local wins = vim.api.nvim_tabpage_list_wins(0)
local empty_buf = nil
for _, win in ipairs(wins) do
if vim.api.nvim_win_is_valid(win) then
local buf = vim.api.nvim_win_get_buf(win)
@@ -165,11 +164,8 @@ return {
end
end
end
if empty_buf then
vim.cmd('edit ' .. vim.fn.fnameescape(path))
else
vim.cmd('tabnew ' .. vim.fn.fnameescape(path))
end
-- No reusable window found, open in a new tab
vim.cmd('tabnew ' .. vim.fn.fnameescape(path))
-- Always close Neo-tree window if open
for _, win in ipairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_is_valid(win) then

View File

@@ -311,19 +311,8 @@ return {
require('telescope.builtin').git_files {
attach_mappings = function(_, map)
map('n', 'q', actions.close)
local actions = require 'telescope.actions'
local action_state = require 'telescope.actions.state'
local function open_smart(prompt_bufnr)
local entry = action_state.get_selected_entry()
if not entry then
return
end
pcall(actions.close, prompt_bufnr)
smart_open(prompt_bufnr)
end
map('i', '<CR>', open_smart)
map('n', '<CR>', open_smart)
map('i', '<CR>', smart_open)
map('n', '<CR>', smart_open)
return true
end,
}