Skip to content

Instantly share code, notes, and snippets.

@majamin
Created October 12, 2022 21:41
Show Gist options
  • Save majamin/374717acfb1d190c79177269d139b005 to your computer and use it in GitHub Desktop.
Save majamin/374717acfb1d190c79177269d139b005 to your computer and use it in GitHub Desktop.
Alpha fallback on last buffer close
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
local is_bootstrap = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
is_bootstrap = true
vim.fn.execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
vim.cmd [[packadd packer.nvim]]
end
require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use 'https://github.com/famiu/bufdelete.nvim'
use {
'goolord/alpha-nvim',
requires = { 'kyazdani42/nvim-web-devicons' },
config = function ()
require'alpha'.setup(require'alpha.themes.startify'.config)
end
}
if is_bootstrap then
require('packer').sync()
end
end)
vim.api.nvim_create_augroup("alpha_on_empty", { clear = true })
vim.api.nvim_create_autocmd("User", {
pattern = "BDeletePost*",
group = "alpha_on_empty",
callback = function(event)
local fallback_name = vim.api.nvim_buf_get_name(event.buf)
local fallback_ft = vim.api.nvim_buf_get_option(event.buf, "filetype")
local fallback_on_empty = fallback_name == "" and fallback_ft == ""
if fallback_on_empty then
vim.cmd("Alpha")
end
end,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment