goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.82k stars 109 forks source link

How to autostart this plugin ? #118

Closed Twiggeh closed 1 year ago

Twiggeh commented 2 years ago

It doesn't appear to autostart by itself so I added a vim.cmd("Alpha") which makes it start on nvim launching, but then it generates this weird empty file that makes the editor close image But if I remove the vim cmd and call :Alpha after nvim launches, then this file doesn't appear image

 local status_ok, alpha = pcall(require, "alpha")
if not status_ok then
    return
end
local dashboard = require("alpha.themes.dashboard")
dashboard.section.header.val = {
    [[                               __                ]],
    [[  ___     ___    ___   __  __ /\_\    ___ ___    ]],
    [[ / _ `\  / __`\ / __`\/\ \/\ \\/\ \  / __` __`\  ]],
    [[/\ \/\ \/\  __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
    [[\ \_\ \_\ \____\ \____/\ \___/  \ \_\ \_\ \_\ \_\]],
    [[ \/_/\/_/\/____/\/___/  \/__/    \/_/\/_/\/_/\/_/]],
}
dashboard.section.buttons.val = {
    dashboard.button("<C-P>", "  Find file", ":Telescope find_files <CR>"),
    dashboard.button("e", "  New file", ":ene <BAR> startinsert <CR>"),
    dashboard.button("p", "  Find project", ":Telescope projects <CR>"),
    dashboard.button("r", "  Recently used files", ":Telescope oldfiles <CR>"),
    dashboard.button("<CS-F>", "  Find text", ":Telescope live_grep <CR>"),
    dashboard.button("c", "  Configuration", ":e ~/.config/nvim/init.lua <CR>"),
    dashboard.button("q", "  Quit Neovim", ":qa<CR>"),
}

local function footer()
    return "hello there ... "
end

dashboard.section.footer.val = footer()

dashboard.section.footer.opts.hl = "Type"
dashboard.section.header.opts.hl = "Include"
dashboard.section.buttons.opts.hl = "Keyword"

dashboard.opts.opts.noautocmd = true
vim.cmd([[autocmd User AlphaReady echo 'ready']])
alpha.setup(dashboard.opts)

-- vim.cmd("Alpha")
goolord commented 2 years ago

what other plugins do you have installed? can you run let @+ = ('au VimEnter') and paste the output here

Twiggeh commented 2 years ago

what other plugins do you have installed? can you run let @+ = ('au VimEnter') and paste the output here I am sorry am new to nvim, I put it into the cmdprompt and nothing was printed in neither the terminal or the editor itself.

With only alpha enabled that file shows always up. When adding bufferline makes that one open file go from [Scratch] to [No Name].

Since I didn't manage to run the command correctly here you go with the plugin list:

    -- My plugins here
    use "wbthomason/packer.nvim" -- Have packer manage itself
    use "nvim-lua/popup.nvim" -- An implementation of the Popup API from vim in Neovim
    use "nvim-lua/plenary.nvim" -- Useful lua functions used in lots of plugins
    use "windwp/nvim-autopairs" -- Autopairs, integrates with both cmp and treesitter
    use "numToStr/Comment.nvim" -- Easily comment stuff
    use "kyazdani42/nvim-web-devicons"
    use "kyazdani42/nvim-tree.lua"
    use "akinsho/bufferline.nvim"
    use "moll/vim-bbye"
    use "nvim-lualine/lualine.nvim"
    use "akinsho/toggleterm.nvim"
    use "ahmedkhalf/project.nvim"
    use "lewis6991/impatient.nvim"
    use "lukas-reineke/indent-blankline.nvim"
    use "goolord/alpha-nvim"
    use "antoinemadec/FixCursorHold.nvim" -- This is needed to fix lsp doc highlight
    use "folke/which-key.nvim"

    -- Colorschemes
    -- use "lunarvim/colorschemes" -- A bunch of colorschemes you can try out
    use "lunarvim/darkplus.nvim"

    -- cmp plugins
    use "hrsh7th/nvim-cmp" -- The completion plugin
    use "hrsh7th/cmp-buffer" -- buffer completions
    use "hrsh7th/cmp-path" -- path completions
    use "hrsh7th/cmp-cmdline" -- cmdline completions
    use "saadparwaiz1/cmp_luasnip" -- snippet completions
    use "hrsh7th/cmp-nvim-lsp"

    -- snippets
    use "L3MON4D3/LuaSnip" --snippet engine
    use "rafamadriz/friendly-snippets" -- a bunch of snippets to use

    -- LSP
    use "neovim/nvim-lspconfig" -- enable LSP
    use "williamboman/nvim-lsp-installer" -- simple to use language server installer
    use "tamago324/nlsp-settings.nvim" -- language server settings defined in json for
    use "jose-elias-alvarez/null-ls.nvim" -- for formatters and linters

    -- Telescope
    use "nvim-telescope/telescope.nvim"
    --  use "nvim-telescope/telescope-media-files.nvim"

    -- Treesitter
    use {
        "nvim-treesitter/nvim-treesitter",
        run = ":TSUpdate",
    }
    use "p00f/nvim-ts-rainbow"
    use "JoosepAlviste/nvim-ts-context-commentstring"
    use "lewis6991/spellsitter.nvim"

    -- Git
    use "lewis6991/gitsigns.nvim"

    -- Theme
    use({
        "catppuccin/nvim",
        as = "catppuccin"
    })

    -- Smooth Scrolling
    use 'declancm/cinnamon.nvim'

    -- Debugging
    use 'mfussenegger/nvim-dap'
    use "rcarriga/nvim-dap-ui"
    use "theHamsta/nvim-dap-virtual-text"
    use 'nvim-telescope/telescope-dap.nvim'
    use 'kndndrj/nvim-dap-projector'
goolord commented 2 years ago

if you run that command in vim it will put the output of au VimEnter into your clipboard. otherwise you could just run au VimEnter and screenshot it

Twiggeh commented 2 years ago

image

if you run that command in vim it will put the output of au VimEnter into your clipboard. otherwise you could just run au VimEnter and screenshot it

Thanks! Am really new to nvim sorry

Twiggeh commented 2 years ago

My full config: https://github.com/Twiggeh/nvim-cfg

erlonbie commented 2 years ago

My full config: https://github.com/Twiggeh/nvim-cfg

Have you managed to solve this? I'm facing the same issue. (I'm very new to nvim too)

goolord commented 2 years ago

i can see a few problems with your config @Twiggeh https://github.com/Twiggeh/nvim-cfg/blob/master/lua/user/alpha.lua#L43 this line definitely shouldn't be there for starters. also, it may help to load your config like this

    use {
        "goolord/alpha-nvim",
        requires = { 'kyazdani42/nvim-web-devicons' },
        config = function () [your config here] end
    }

since packer doesn't guarantee the plugin will be loaded before then otherwise

goolord commented 2 years ago

https://github.com/goolord/nvim/blob/main/lua/plugins/init.lua#L94-L98 https://github.com/goolord/nvim/blob/main/lua/plugins/alpha.lua

here's my personal config for reference

noahxzhu commented 2 years ago

The same issue is on my side, don't know how to solve it. 😭

goolord commented 2 years ago

what happens if you clone alpha-nvim and run the debug config from the alpha-nvim directory https://github.com/goolord/alpha-nvim/blob/main/debug/DEBUG.md

noahxzhu commented 2 years ago

Run 'nvim --clean -u debug/min-alpha-dashboard.lua'

CleanShot 2022-08-29 at 08 17 12@2x

Other two options '--noplugin', '-u' work fine.

goolord commented 2 years ago

what happens if you move your alpha config loading to the packer setup field like mentioned above

noahxzhu commented 2 years ago

Nothing happened. All the configurations were loaded without any errors. I need to execute Alpha to start it.

goolord commented 2 years ago

what's the output of nvim --version

goolord commented 2 years ago

it would be really helpful if i could see your config, also. this feature works for 99% of this plugin's userbase and the debug configs work for you, so this must be a user config error

noahxzhu commented 2 years ago
CleanShot 2022-08-30 at 11 37 42@2x

This is my alpha config https://github.com/virezox/nvim/blob/main/lua/plugins/alpha.lua, Here is my packer config https://github.com/virezox/nvim/blob/main/lua/plugins/packer.lua#L56,

https://github.com/virezox/nvim/blob/main/lua/plugins/init.lua#L3 I require it in this place, if I don't require it, there's no "Alpha" command, so I require it. I also tested when deleting the require, not succeed.

goolord commented 2 years ago

i cloned your config and it autostarted on my machine lol

https://user-images.githubusercontent.com/24906808/187344280-716743b8-2baf-4df4-b192-46a476651075.mov

goolord commented 2 years ago

would you happen to have nvim aliased (check which nvim)

goolord commented 2 years ago

i'm on HEAD neovim (0.8), it may also be that

noahxzhu commented 2 years ago
CleanShot 2022-08-30 at 21 51 59@2x

I'm a mac user. I upgraded my neovim to 0.8, but it still doesn't work. I'm not sure if some dependencies are missing using homebrew to install. Both M1 and Intel don't work on my side.

noahxzhu commented 2 years ago

The reason is that I use neovim to open a folder, lol. I should start neovim directly. 😄