Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create bookmarks to files and keep the icons. #14

Closed
rafamadriz opened this issue Sep 10, 2021 · 9 comments
Closed

Create bookmarks to files and keep the icons. #14

rafamadriz opened this issue Sep 10, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@rafamadriz
Copy link

rafamadriz commented Sep 10, 2021

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
Copy link
Owner

goolord commented Sep 10, 2021

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

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

and get the icon + highlighting

@goolord
Copy link
Owner

goolord commented Sep 10, 2021

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
Copy link
Owner

goolord commented Sep 10, 2021

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

@goolord goolord added the enhancement New feature or request label Sep 10, 2021
@rafamadriz
Copy link
Author

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
Copy link
Owner

goolord commented Sep 10, 2021

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

@goolord
Copy link
Owner

goolord commented Sep 26, 2021

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,
    }

:)

@goolord goolord closed this as completed Sep 26, 2021
@evantancy
Copy link

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
Copy link
Owner

goolord commented Mar 19, 2022

yes

@erikw
Copy link

erikw commented Mar 28, 2023

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"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants