goolord / alpha-nvim

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

Create bookmarks to files and keep the icons. #14

Closed rafamadriz closed 3 years ago

rafamadriz commented 3 years ago

Right now I have something like this to have bookmarks to files:

    startify.section.bottom_buttons.val = {
        startify.button(
            "c",
            "~/.config/nvim/lua/config.lua",
            ":e ~/.config/nvim/lua/config.lua<CR>"
        ),
        startify.button("i", "~/.config/nvim/init.lua", ":e ~/.config/nvim/init.lua<CR>"),
        startify.button(
            "P",
            "~/.config/nvim/lua/modules/plugins/init.lua",
            ":e ~/.config/nvim/lua/modules/plugins/init.lua<CR>"
        ),

But, as you can see, it doesn't show up with icons.

Screenshot_20210909_212356

This is just a nitpick and I'm happy with it not showing icons for those files, but I was wondering if it was possible to make it so I can create bookmarks to files and have it with icons.

Also, not related to this issue but how can I change and add titles ? I've looking through the docs and playing around with a few options but can't figure it out.

For example, I'd like to add "Bookmarks" above those files. and I'd like to change the MRU from this image: Screenshot_20210909_213101

To something else.

goolord commented 3 years ago

ok, icon and file_button are now exported https://github.com/goolord/alpha-nvim/commit/fb47b78d89e31c15344f66550f13c42a729f4100. you should be able to write your bookmarks like

startify.file_button( "~/.config/nvim/lua/config.lua", "c" ),

and get the icon + highlighting

goolord commented 3 years ago

Also, not related to this issue but how can I change and add titles ? I've looking through the docs and playing around with a few options but can't figure it out.

For example, I'd like to add "Bookmarks" above those files. and I'd like to change the MRU from this image:

this level of granularity in configuration is frankly annoying to support.. after a certain point it becomes easier to just define your own opts. the startify module should export everything you would need to make your own layout using startify widgets.

goolord commented 3 years ago

this isn't a "hard no", I just don't know where I need to draw the line in the sand with respect to these themes that are meant to mimic the look and feel of other greeter plugins

rafamadriz commented 3 years ago

ok, icon and file_button are now exported fb47b78. you should be able to write your bookmarks like

startify.file_button( "c", "~/.config/nvim/lua/config.lua" ),

and get the icon + highlighting

The order is inverted, it needs to be:

startify.file_button("~/.config/nvim/lua/config.lua" , "c"),

Otherwise it gives an error.

this level of granularity in configuration is frankly annoying to support.. after a certain point it becomes easier to just define your own opts. the startify module should export everything you would need to make your own layout using startify widgets.

That's a fair point.

goolord commented 3 years ago

my mistake. i'll think on this, there might be a solution that doesn't suck too bad

goolord commented 3 years ago

somehow i missed that with sections you can already pretty easily rearrange the layout with minimal effort.

example moving the header to the bottom:

    startify.opts.layout = {
        {type = "padding", val = 2},
        startify.section.top_buttons,
        startify.section.mru,
        startify.section.mru_cwd,
        {type = "padding", val = 1},
        startify.section.bottom_buttons,
        {type = "padding", val = 1},
        startify.section.header,
        startify.section.footer,
    }

:)

evantancy commented 2 years ago

hi is it possible to still add this to our own configs? like if i have the line local startify = require("alpha.themes.startify") just use startify.opts.layout = {...} to reorder the layout?

goolord commented 2 years ago

yes

erikw commented 1 year ago

For those coming here in the future and looking for a complete config example of adding bookmarks to the startify theme, it could look like this (with Packer) adding 3 bookmarks:

use({
    "goolord/alpha-nvim",
    requires = { "nvim-tree/nvim-web-devicons" },
    config = function()
        local startify = require("alpha.themes.startify")

        startify.section.bottom_buttons.val = {
            startify.button("q", "Quit", "<cmd>q <CR>"), -- preserve the quit button
            startify.file_button(vim.fn.stdpath("config") .. "/init.lua", "v"),
            startify.file_button(vim.fn.stdpath("config") .. "/lua/plugins.lua", "p"),
            startify.file_button("~/some/file", "f"),
        }

        require("alpha").setup(startify.config)
    end,
})

Another way to preserve the q button could be to append to this table instead of redefining it:

        table.insert(startify.section.bottom_buttons.val, startify.file_button(~/some/file", "f"))