mirror of
https://github.com/hyzendust/KickestEnd.nvim.git
synced 2026-02-15 06:21:13 +01:00
Fix: alpha in normal mode. New tab keybind to fix all tab/buffer problems.
This commit is contained in:
3
init.lua
3
init.lua
@@ -343,9 +343,6 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
|||||||
pattern = '*',
|
pattern = '*',
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Auto-apply settings to all normal buffers
|
|
||||||
require('settings_autoload_after_alpha').setup()
|
|
||||||
|
|
||||||
-- Theme
|
-- Theme
|
||||||
require('kanagawa').setup { transparent = true }
|
require('kanagawa').setup { transparent = true }
|
||||||
vim.cmd [[colorscheme kanagawa]]
|
vim.cmd [[colorscheme kanagawa]]
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ end, { desc = 'Discard changes in current window & quit' })
|
|||||||
|
|
||||||
-- [[ Close Neovim ]]
|
-- [[ Close Neovim ]]
|
||||||
-- Function to close Neovim, discarding all unsaved changes if confirmed
|
-- Function to close Neovim, discarding all unsaved changes if confirmed
|
||||||
_G.close_nvim_with_prompt = function()
|
local function close_nvim_with_prompt()
|
||||||
-- Get list of all listed buffers
|
-- Get list of all listed buffers
|
||||||
local buffers = vim.fn.getbufinfo { buflisted = 1 }
|
local buffers = vim.fn.getbufinfo { buflisted = 1 }
|
||||||
-- Check for unsaved buffers
|
-- Check for unsaved buffers
|
||||||
@@ -332,10 +332,10 @@ _G.close_nvim_with_prompt = function()
|
|||||||
vim.cmd 'qa!'
|
vim.cmd 'qa!'
|
||||||
else
|
else
|
||||||
-- Cancel quitting
|
-- Cancel quitting
|
||||||
print '\nCancelled closing Neovim.'
|
print 'Cancelled closing Neovim.'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vim.keymap.set('n', '<leader>qa', _G.close_nvim_with_prompt, { noremap = true, silent = true, desc = 'Quit Neovim' })
|
vim.keymap.set('n', '<leader>qa', close_nvim_with_prompt, { noremap = true, silent = true, desc = 'Quit Neovim' })
|
||||||
|
|
||||||
-- [[ Switch below/right split windows ]]
|
-- [[ Switch below/right split windows ]]
|
||||||
vim.keymap.set('n', '<leader><Tab>', '<C-W><C-W>')
|
vim.keymap.set('n', '<leader><Tab>', '<C-W><C-W>')
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ return {
|
|||||||
local splash = require 'ascii_splash'
|
local splash = require 'ascii_splash'
|
||||||
dashboard.section.header.val = splash
|
dashboard.section.header.val = splash
|
||||||
|
|
||||||
-- Get Neovim starting directory
|
|
||||||
local start_dir = vim.fn.getcwd()
|
|
||||||
|
|
||||||
-- Setup buttons
|
-- Setup buttons
|
||||||
dashboard.section.buttons.val = {
|
dashboard.section.buttons.val = {
|
||||||
-- New file
|
-- New file
|
||||||
@@ -21,55 +18,24 @@ return {
|
|||||||
vim.cmd 'enew'
|
vim.cmd 'enew'
|
||||||
vim.cmd 'startinsert'
|
vim.cmd 'startinsert'
|
||||||
end),
|
end),
|
||||||
-- Open Neo-tree in starting directory
|
-- Create new empty buffer in a new tab
|
||||||
dashboard.button('<leader>n', ' Open Neo-tree', '<Cmd>cd ' .. vim.fn.fnameescape(start_dir) .. ' | Neotree toggle float<CR>'),
|
dashboard.button('<leader>e', ' New Tab', function()
|
||||||
-- Close Alpha window
|
local alpha_buf = vim.api.nvim_get_current_buf()
|
||||||
dashboard.button('<leader>q', ' Close this window', function()
|
-- Close Alpha buffer
|
||||||
local current_buf = vim.api.nvim_get_current_buf()
|
vim.api.nvim_buf_delete(alpha_buf, { force = true })
|
||||||
-- Count listed buffers
|
-- Create new tab and empty buffer
|
||||||
local listed_count = 0
|
vim.cmd 'tabnew'
|
||||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
vim.cmd 'enew'
|
||||||
if vim.api.nvim_buf_get_option(buf, 'buflisted') then
|
end),
|
||||||
listed_count = listed_count + 1
|
-- Open Neo-tree in current directory
|
||||||
end
|
dashboard.button('<leader>n', ' Open Neo-tree', '<Cmd>Neotree toggle float<CR>'),
|
||||||
end
|
-- Close Neovim
|
||||||
-- If only 1 listed buffer left, force quit Neovim
|
dashboard.button('<leader>q', ' Exit', function()
|
||||||
if listed_count == 1 then
|
|
||||||
vim.cmd 'qa!'
|
vim.cmd 'qa!'
|
||||||
else
|
|
||||||
-- Delete current buffer
|
|
||||||
if vim.api.nvim_buf_is_valid(current_buf) then
|
|
||||||
vim.api.nvim_buf_delete(current_buf, { force = true })
|
|
||||||
end
|
|
||||||
-- Delete one listed, unmodified, no-name buffer
|
|
||||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
|
||||||
if vim.api.nvim_buf_is_valid(buf) then
|
|
||||||
local listed = vim.api.nvim_buf_get_option(buf, 'buflisted')
|
|
||||||
local modified = vim.api.nvim_buf_get_option(buf, 'modified')
|
|
||||||
local name = vim.api.nvim_buf_get_name(buf)
|
|
||||||
-- target buffers that are listed, have no modifications, and no name
|
|
||||||
if listed and not modified and name == '' then
|
|
||||||
vim.api.nvim_buf_delete(buf, { force = true })
|
|
||||||
break -- delete only one buffer
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end),
|
end),
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Ensure Alpha buffer is a scratch buffer so closing it doesn’t leave [No Name]
|
-- Setup Alpha dashboard
|
||||||
local opts = dashboard.opts
|
alpha.setup(dashboard.opts)
|
||||||
opts.hide = true -- hide it from buffer list
|
|
||||||
alpha.setup(opts)
|
|
||||||
|
|
||||||
-- Open Alpha in a dedicated scratch buffer if no file is loaded
|
|
||||||
if vim.fn.bufnr '$' == 1 and vim.fn.bufname(0) == '' then
|
|
||||||
vim.cmd 'enew' -- create a proper empty buffer
|
|
||||||
vim.cmd 'Alpha' -- open Alpha in that buffer
|
|
||||||
vim.bo.buflisted = false -- mark it unlisted so it doesn’t pollute buffer pickers
|
|
||||||
vim.bo.buftype = 'nofile' -- make it a scratch buffer
|
|
||||||
-- vim.bo.bufhidden = 'wipe' -- critical: buffer is automatically deleted when hidden
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ return {
|
|||||||
if prompt_bufnr and vim.api.nvim_buf_is_valid(prompt_bufnr) then
|
if prompt_bufnr and vim.api.nvim_buf_is_valid(prompt_bufnr) then
|
||||||
pcall(actions.close, prompt_bufnr)
|
pcall(actions.close, prompt_bufnr)
|
||||||
end
|
end
|
||||||
-- 1. If file is already open → jump to it
|
-- If file is already open → jump to it
|
||||||
local tabpages = vim.api.nvim_list_tabpages()
|
local tabpages = vim.api.nvim_list_tabpages()
|
||||||
for _, tab in ipairs(tabpages) do
|
for _, tab in ipairs(tabpages) do
|
||||||
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(tab)) do
|
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(tab)) do
|
||||||
@@ -86,7 +86,7 @@ return {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- 2. If current tab has an empty "No Name" buffer → reuse it
|
-- If current tab has an empty "No Name" buffer → reuse it
|
||||||
local wins = vim.api.nvim_tabpage_list_wins(0)
|
local wins = vim.api.nvim_tabpage_list_wins(0)
|
||||||
for _, win in ipairs(wins) do
|
for _, win in ipairs(wins) do
|
||||||
local buf = vim.api.nvim_win_get_buf(win)
|
local buf = vim.api.nvim_win_get_buf(win)
|
||||||
@@ -106,7 +106,7 @@ return {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- 3. Otherwise → open in a new tab
|
-- Otherwise → open in a new tab
|
||||||
vim.cmd('tabnew ' .. vim.fn.fnameescape(path))
|
vim.cmd('tabnew ' .. vim.fn.fnameescape(path))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
-- Auto-apply all preferred settings to every normal buffer
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
function M.setup()
|
|
||||||
vim.api.nvim_create_autocmd({ 'BufWinEnter', 'WinEnter', 'BufEnter' }, {
|
|
||||||
callback = function()
|
|
||||||
local ft = vim.bo.filetype
|
|
||||||
local bt = vim.bo.buftype
|
|
||||||
|
|
||||||
-- Skip floating or special buffers
|
|
||||||
if ft == 'neo-tree' or ft == 'TelescopePrompt' or bt == 'terminal' or bt == 'nofile' then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Window-local options
|
|
||||||
vim.wo.number = true
|
|
||||||
vim.wo.relativenumber = true
|
|
||||||
vim.wo.signcolumn = 'yes'
|
|
||||||
vim.wo.scrolloff = 8
|
|
||||||
|
|
||||||
-- Global options
|
|
||||||
vim.o.hlsearch = false
|
|
||||||
vim.o.mouse = '' -- disable mouse
|
|
||||||
vim.o.breakindent = true
|
|
||||||
vim.o.undofile = true
|
|
||||||
vim.o.ignorecase = true
|
|
||||||
vim.o.smartcase = true
|
|
||||||
vim.o.updatetime = 250
|
|
||||||
vim.o.timeoutlen = 300
|
|
||||||
vim.o.completeopt = 'menuone,noselect'
|
|
||||||
vim.o.termguicolors = true
|
|
||||||
vim.o.showtabline = 1
|
|
||||||
|
|
||||||
-- Tabs and indentation
|
|
||||||
vim.o.expandtab = false
|
|
||||||
vim.o.shiftwidth = 4
|
|
||||||
vim.o.softtabstop = 0
|
|
||||||
vim.o.tabstop = 4
|
|
||||||
vim.o.smartindent = true
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
Reference in New Issue
Block a user