nvimdev / dashboard-nvim

vim dashboard
MIT License
2.19k stars 177 forks source link

Open Dashboard when nvim has path arg #431

Closed FromWau closed 3 months ago

FromWau commented 4 months ago

Hi, I would like the ability to run nvim ~/.config/nvim and nvim opens up the dashboard and sets the cwd to the given path.

Is your feature request related to a problem? Please describe. I have to manually open dashboard when I run nvim with a path arg

Describe the solution you'd like nvim ~/.config/nvim will open dashboard and sets the cwd to ~/.config/nvim

Describe alternatives you've considered I tried to start dashboard via a custom init:

return {
    "nvimdev/dashboard-nvim",
    event = "VimEnter",
    opts = opts,
    dependencies = { "nvim-tree/nvim-web-devicons" },
    init = function()
        if vim.fn.argc(-1) == 1 then
            local stat = vim.loop.fs_stat(vim.fn.argv(0))
            if stat and stat.type == "directory" then
                require("dashboard"):instance()
            end
        end
    end,
}

But this makes the interaction with other plugins dirty (lualine shows up, lazy.stats are not correct, ...)

Additional context nvim: v0.9.5 pm: lazy v10.16.0 dashboard: commit 413442b

FromWau commented 3 months ago

I ended up just using a fish function, maybe someone else will find this useful:

function nvim -d "Open nvim and handle arg path"
    set -l dir (pwd)
    if count $argv -eq "2" >/dev/null && test -d $argv[1]
        cd $argv[1]
        command nvim
        cd $dir
    else
        command nvim $argv
    end
end

Closing Issue.