max397574 / startup.nvim

A highly configurable neovim startup screen
GNU General Public License v2.0
443 stars 35 forks source link

Changing colours of sections #43

Closed anurag3301 closed 9 months ago

anurag3301 commented 1 year ago

Hey I recently switched from nvim-dashbaord to startup.nvim, I took the copy of lua/startup/themes/dashboard.lua and I want to change the colours of the sections.

I want the top unicode image in white color and the key binds in the middle in blue. I tried doing some things but didnt work, can you help me with this.

image

My current config

require("startup").setup({
    header = {
        type = "text",
        oldfiles_directory = false,
        align = "center",
        fold_section = false,
        title = "Header",
        margin = 5,
        content = {
                '                                                              ',
                '                                                              ',
                '                                                              ',
                '                                                              ',
                '    ⢀⣀⣤⣤⣤⠤⢤⣤⣤⣤⣤⣄⣀⡀           ⢀⣠⣤⣄⡀            ⣀⣀⣀⣤⣤⣤⣤⣤⣤⣤⣤⣀⡀   ',
                ' ⢀⣤⠚⠩⠁⡄ ⠠⣤⠒⠒⣂ ⢈⣨⣭⣿⠛⠶⣦⣤⣄⡀   ⢠⣾⡟⠉⠉⠝⠿⠇    ⢀⣠⡤⠔⠒⣻⠟⠋⠩⠉⢁⣀⡀  ⣶  ⠙⡛⠷  ',
                ' ⠸⢟⡠⠒⢊⡤  ⠋⣠ ⠈⣉⣉⣉⣉⣀⣛⣿⡒⠭⡿⢿⣷⣤⣤⣀⣽⣇⣴⠆⣴⡃⢀⣠⣤⠴⣚⣫⡥ ⠒⠛⠁⣀⣉⣉⣙⢏⡉  ⢀⣼⣤⣜⠳⡦⠂  ',
                '   ⠐⠚⠫⣤⠖⢣⣤⡕ ⠉⣩⣤⠔ ⠂⣋⣭⣥⣤⠴⠛⣛⠈⢩⣿⠿⠛⢉  ⡐⠞⠫⢍⠙⣓⠢⠴⣥⣍⣙⠛⢓⡢⢤⣬⠉⠅ ⣤⡜⢛⠻⠛⠉⠁   ',
                '      ⠘⢔⢎⣡⡔⠂⣠⡿⠁⠒⢛⡻⢛⣩⠅  ⠉  ⠚⣯⣄⢠⣿⢀⣾⠇ ⠓ ⠁⠂⠈⠍⠐⠈⡉⣿⠛⣛⠛⠉⣤⣰⣿⣿⡟⠛⠁      ',
                '        ⠙⠛⠐⠚⠋ ⠒⣲⡿⠇⣋        ⢺⡏⠈⣀ ⠉⠈        ⠙⢿⠟⢰⣖⡢ ⠂⠒⠚⠉         ',
                '             ⣴⠛⠅⢀⣾⠟⢃       ⢹⠃⠠⠁⠈⠩         ⢠⣿ ⣀⢹⣿⡷             ',
                '             ⢿⣤⢚⣫⠅         ⢸⠇ ⢚ ⢀         ⣸⡇ ⠉⣿⣿⠇             ',
                '             ⠈⠛⢻⣥⡚⠔⣠⢣⣄⡀    ⢸⡇ ⢘ ⠈ ⠠⠈    ⣀⣰⡿⣧⣄⠾⠋⠁              ',
                '                ⠈⠑⠁        ⠘⣿⡀⣈⣀    ⠈  ⠈⠙⠁                    ',
                '                            ⠘⣷⠁                               ',
                '                             ⠙⣤                               ',
                '                              ⠛⠂                              ',
                '                                                              '
        },
        highlight = "Statement",
        default_color = "#FFFFFF",
        oldfiles_amount = 0,
    },
    -- name which will be displayed and command
    body = {
        type = "mapping",
        oldfiles_directory = false,
        align = "center",
        fold_section = false,
        title = "Basic Commands",
        margin = 5,
        content = {
            { " Find File", "Telescope find_files", "<leader>ff" },
            { " Find Word", "Telescope live_grep", "<leader>lg" },
            { " Recent Files", "Telescope oldfiles", "<leader>of" },
            { " File Browser", "Telescope file_browser", "<leader>fb" },
            { " Colorschemes", "Telescope colorscheme", "<leader>cs" },
            { " New File", "lua require'startup'.new_file()", "<leader>nf" },
        },
        highlight = "String",
        default_color = "",
        oldfiles_amount = 0,
    },
    footer = {
        type = "text",
        oldfiles_directory = false,
        align = "center",
        fold_section = false,
        title = "Footer",
        margin = 5,
        content = { "startup.nvim" },
        highlight = "Number",
        default_color = "",
        oldfiles_amount = 0,
    },

    options = {
        mapping_keys = true,
        cursor_column = 0.5,
        empty_lines_between_mappings = true,
        disable_statuslines = true,
        paddings = { 1, 3, 3, 0 },
    },

    mappings = {
        execute_command = "<CR>",
        open_file = "o",
        open_file_split = "<c-o>",
        open_section = "<TAB>",
        open_help = "?",
    },
    colors = {
        background = "#1f2227",
        folded_section = "#56b6c2",
    },
    parts = { "header", "body", "footer" },
})
napuzu commented 1 year ago

You can change the default_color if you didn't specify the highlight. highlight = "", default_color = "#FFFFFF"

anurag3301 commented 9 months ago

Thanks but highlight = "" didnt work, Screenshot from 2024-01-19 11-44-01

I had to enter a random string like highlight = "Header", I dont know about the internal details, you can tell me why.

Ethiraric commented 1 month ago

Hi, May be a long time, but I ran into your specific issue. highlight refers to the nvim highlight group that will be used to display your section. By using :hi, you can see what groups are available, and :hi <groupname> would tell you what it corresponds to. On my config, :hi String returns String xxx guifg=#c3e88d, meaning it uses a color as close to #c3e88d as possible.

I wanted to have my section in a bold blue color so I ended up with something like:

vim.api.nvim_set_hl(0, 'MySectionColorGroup', { fg = "#4493f8", bold = true })

local settings = {
  header = {
    type = "text",
    oldfiles_directory = false,
    align = "center",
    fold_section = false,
    title = "Header",
    margin = 5,
    content = "whatever",
    highlight = "MySectionColorGroup", -- <== Right here, the highlightgroup we just created.
    default_color = "",
    oldfiles_amount = 0,
  },
  -- ...

I think it just so happened on your config that Header was a background-less white text (which you can check using :hi Header).