Fix: alpha intro-screen not being treated as normal no-name buffer in telescope+neotree.

This commit is contained in:
psychhim
2025-10-14 15:34:01 +05:30
parent 9796478476
commit 7d9edc3468
3 changed files with 26 additions and 4 deletions

View File

@@ -5,12 +5,18 @@ return {
local alpha = require 'alpha'
local dashboard = require 'alpha.themes.dashboard'
-- Load ASCII splash
local splash = require 'ascii_splash'
dashboard.section.header.val = splash
-- Get Neovim starting directory
local start_dir = vim.fn.getcwd()
-- Setup buttons
dashboard.section.buttons.val = {
dashboard.button('e', ' New File', ':ene <BAR> startinsert <CR>'),
dashboard.button('q', ' Quit', ':qa<CR>'),
dashboard.button('i', ' New File', ':ene <BAR> startinsert <CR>'),
dashboard.button('<leader>n', ' Open Neo-tree', ':cd ' .. start_dir .. ' | Neotree toggle float<CR>'),
dashboard.button('<leader>q', ' Quit', ':qa<CR>'),
}
alpha.setup(dashboard.opts)

View File

@@ -20,6 +20,12 @@ return {
return vim.fn.fnamemodify(path, ':p')
end
-- Helper function to detect Alpha dashboard buffer
local function is_alpha_buffer(buf)
local ft = vim.api.nvim_buf_get_option(buf, 'filetype')
return ft == 'alpha'
end
-- Handling deleted file or folder buffers, marking them as removed
local function delete_file_mark_removed(state)
local node = state.tree:get_node()
@@ -128,7 +134,8 @@ return {
local bufname = vim.api.nvim_buf_get_name(buf)
local buftype = vim.api.nvim_buf_get_option(buf, 'buftype')
local modified = vim.api.nvim_buf_get_option(buf, 'modified')
if bufname == '' and buftype == '' and not modified then
-- PATCH: Treat Alpha dashboard as empty
if (bufname == '' and buftype == '' and not modified) or is_alpha_buffer(buf) then
empty_buf = buf
vim.api.nvim_set_current_win(win)
break

View File

@@ -55,6 +55,13 @@ return {
-- smart_open function for Telescope to check if the current tab has an empty "No Name" buffer. If it has, it replaces the empty buffer and open a file in the same tab
local actions = require 'telescope.actions'
local action_state = require 'telescope.actions.state'
-- Helper function to detect Alpha dashboard buffer
local function is_alpha_buffer(buf)
local ft = vim.api.nvim_buf_get_option(buf, 'filetype')
return ft == 'alpha'
end
local function smart_open(prompt_bufnr)
local entry = action_state.get_selected_entry()
if not entry then
@@ -86,7 +93,9 @@ return {
local name = vim.api.nvim_buf_get_name(buf)
local buftype = vim.api.nvim_buf_get_option(buf, 'buftype')
local modified = vim.api.nvim_buf_get_option(buf, 'modified')
if name == '' and buftype == '' and not modified then
-- PATCH: also treat Alpha dashboard buffer as empty
if (name == '' and buftype == '' and not modified) or is_alpha_buffer(buf) then
vim.api.nvim_set_current_win(win)
vim.cmd('edit ' .. vim.fn.fnameescape(path))
return