nvimdev / dashboard-nvim

vim dashboard
MIT License
2.21k stars 179 forks source link

Use as new tab page? #369

Closed ThePolishHussar closed 1 year ago

ThePolishHussar commented 1 year ago

Is there a way to use this as a new tab page

in other words, if i run :tabnew the dashboard will show up unless a file is specified

glepnir commented 1 year ago

something like

vim.api.nvim_create_autocmd('TabEnter', {
    command ='Dashboard'
})
ThePolishHussar commented 1 year ago

something like

vim.api.nvim_create_autocmd('TabEnter', {
    command ='Dashboard'
})

Doesn't work - causes many errors

Error executing vim.schedule lua callback: ...packer/start/dashboard-nvim/lua/dashboard/theme/doom.lua:112: Cursor pos
ition outside buffer
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        ...packer/start/dashboard-nvim/lua/dashboard/theme/doom.lua:112: in function 'generate_center'
        ...packer/start/dashboard-nvim/lua/dashboard/theme/doom.lua:178: in function <...packer/start/dashboard-nvim/l
ua/dashboard/theme/doom.lua:176>
        .../pack/packer/start/dashboard-nvim/lua/dashboard/init.lua:214: in function 'load_theme'
        .../pack/packer/start/dashboard-nvim/lua/dashboard/init.lua:270: in function 'callback'
        .../pack/packer/start/dashboard-nvim/lua/dashboard/init.lua:192: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

TabEnter is also a bad event to use as it will run whenver i enter a tab, empty or not old or new. So I tried TabNewEntered. This works fine if :tabnew is given no args, but if a file is opened using tabnew, id like it to not launch dashboard.

In other words i need a way to make this

vim.api.nvim_create_autocmd('TabNewEntered', { command = 'Dashboard'})

only run if the new tab is blank