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

Dynamic numbers #97

Open
sarmong opened this issue Apr 1, 2022 · 3 comments
Open

Dynamic numbers #97

sarmong opened this issue Apr 1, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@sarmong
Copy link

sarmong commented Apr 1, 2022

I want to change a layout of elements in my config, so I did the following:

local alpha = require("alpha")
local startify_config = require("alpha.themes.startify")

local config = {
  layout = {
    { type = "padding", val = 1 },
    startify_config.section.header,
    { type = "padding", val = 2 },
    startify_config.section.top_buttons,
    startify_config.section.mru_cwd,
    startify_config.section.mru,
    { type = "padding", val = 1 },
    startify_config.section.bottom_buttons,
    startify_config.section.footer,
  },
  opts = {
    margin = 3,
    redraw_on_resize = false,
    setup = function()
      vim.cmd([[
            autocmd alpha_temp DirChanged * lua require('alpha').redraw()
            ]])
    end,
  },
}

alpha.setup(config)

I swapped mru_cwd and mru, because usually the files relevant for the current directory are more important. (Maybe it could be the default?)

However, the numbers didn't change, so I get 10, 1, 2, 3...

  1. Is there an easy way to do this on my side not to rewriting half the config?
  2. If not, how can I do this the hard way?
  3. Can dynamic numbering be added to the plugin?
  4. Maybe ordering mru_cwd before mru would make sense for a lot of people, so it could be made a default?

PS. Thanks for a nice plugin!

@goolord
Copy link
Owner

goolord commented Apr 1, 2022

alpha's ui is just data, so you can just mutate the mru_cwd table to a copy of what exists in the code, but with the numbers starting on the right index

    mru_cwd = {
        type = "group",
        val = {
            { type = "padding", val = 1 },
            { type = "text", val = mru_title, opts = { hl = "SpecialComment", shrink_margin = false } },
            { type = "padding", val = 1 },
            {
                type = "group",
                val = function()
                    local x = mru(0, vim.fn.getcwd()) -- the first argument is the beginning index
                    return {x}
                end,
                opts = { shrink_margin = false },
            },
        },
    },

but, this is a little too involved, so i think i'm going to try to make the buttons independent of the order of the mru sections

@goolord
Copy link
Owner

goolord commented Apr 1, 2022

ok, it should behave the way you expect as of c4a3b23

@goolord goolord closed this as completed Apr 1, 2022
@goolord
Copy link
Owner

goolord commented Apr 2, 2022

nvm, this caused some nasty bug. i'll investigate later 534a86b

@goolord goolord reopened this Apr 2, 2022
@goolord goolord added the enhancement New feature or request label Feb 14, 2023
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

2 participants