Created
October 12, 2022 21:41
-
-
Save majamin/374717acfb1d190c79177269d139b005 to your computer and use it in GitHub Desktop.
Alpha fallback on last buffer close
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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