nvimdev / dashboard-nvim

vim dashboard
MIT License
2.19k stars 177 forks source link

How to show ascii in header ? #435

Closed LelouchFR closed 3 months ago

LelouchFR commented 3 months ago

Describe the bug I've been struggling to show this ascii which comes from the wiki, I tried pretty much everything I could think of, I would like to get some help on how to show ascii's and some boilerplate code (using lua) to get me out of this problem

To Reproduce

require('dashboard').setup({
    theme = 'doom',
    config = {
        header = {
            \'        [48;5;0m                                              [38;2;167;201;171m',
            \'       [38;2;31;107;152m███████████           [38;2;57;108;63m█████[38;2;167;201;171m      ██',
            \'      [38;2;34;115;163m███████████             [38;2;61;116;68m█████ ',
            \'      [38;2;36;122;174m███████[48;5;0m██[38;2;20;69;110m[38;2;122;187;225m███████ ███[38;2;65;124;72m████████ [38;2;152;192;157m███   ███████',
            \'     [38;2;38;130;184m█████████[38;2;132;191;226m███████[48;5;0m ████[38;2;69;132;76m████████ [38;2;160;196;164m█████ ██████████████',
            \'    [38;2;40;138;195m█████████[38;2;142;196;228m█████[48;5;0m[38;2;20;69;110m██[38;2;142;196;228m██████[38;2;73;140;81m███████ [38;2;167;201;171m█████ █████ ████ █████',
            \'  [38;2;43;145;206m███████████[38;2;151;200;229m█████████████████[38;2;77;147;86m██████ [38;2;175;205;179m█████ █████ ████ █████',
            \' [38;2;45;153;217m██████  ███ [38;2;160;204;231m█████████████████ [38;2;81;155;90m████ [38;2;183;209;186m█████ █████ ████ ██████',
            \' [38;2;20;69;110m██████   ██  ███████████████   [38;2;46;78;42m██ █████████████████',
            \'[48;2;20;20;40m [38;2;11;39;63m██████   ██  ███████████████   [38;2;25;42;23m██ █████████████████ [48;5;0m',
          },
          -- basic config from the demo
    },
})

error: Erreur détectée en traitant :source (no file) :
E5107: Error loading lua [string ":source (no file)"]:95: unexpected symbol near '['

It would be cool if there was a clear tutorial about how to show it up, I've seen talk about preview, but no idea how and where to find it.

Expected behavior The same doom config as in the demo

Jas-SinghFSU commented 3 months ago

You should be able to remove the \ behind each string in the header table and that should fix it. Mine for example is

                        header = {
                            "     ██  █████  ███████ ██   ██ ██ ██████  ",
                            "     ██ ██   ██ ██      ██  ██  ██ ██   ██ ",
                            "     ██ ███████ ███████ █████   ██ ██████  ",
                            "██   ██ ██   ██      ██ ██  ██  ██ ██   ██ ",
                            " █████  ██   ██ ███████ ██   ██ ██ ██   ██ ",
                            "                                           ",
                            "                                           "
                        },
LelouchFR commented 3 months ago

That's not the problem. How to add colors to it, like in the preview ? Or even how to make a command like cat ascii.txt | lolcat and add that into the header ?

AustinCGause commented 3 months ago

If you or anyone else can figure out how to get colors in the header, please do share, as I have also been looking for a while to see if I can figure it out, to no avail of course.

speelbarrow commented 3 months ago

If you or anyone else can figure out how to get colors in the header, please do share, as I have also been looking for a while to see if I can figure it out, to no avail of course.

https://github.com/speelbarrow/dotfiles/blob/295744e344da0c96d8c6fe5d0e021fd8eecd6534/.config/nvim/lua/config/dashboard.lua#L9

You have to put it in an external file, so that it can be run through a command that will process the colours. Here I'm using lolcrab, but lolcat is another command-line tool that will produce similar effects. You have to configure all this in the call to dashboard.setup (example shown in the link).

AustinCGause commented 3 months ago

Is it only possible in the doom theme?

speelbarrow commented 3 months ago

Is it only possible in the doom theme?

Only one way to find out 😜 (I have no idea, try it with the other theme and see if works)

AustinCGause commented 3 months ago

Fair enough, I'll give it a shot and post the answer here.

hexcowboy commented 3 months ago

using LazyVim:

~/.config/nvim/lua/plugins/dashboard.lua

return {
  "nvimdev/dashboard-nvim",
  opts = function(_, opts)
    local preview = opts.preview or {}
    preview.command = "lolcrab"
    preview.file_path = "~/.config/nvim/lua/plugins/dashboard.txt"
    preview.file_width = 69
    preview.file_height = 10
    opts.preview = preview
  end,
}

~/.config/nvim/lua/plugins/dashboard.txt

                                             
      ███████████           █████      ██
     ███████████             █████ 
     ████████████████ ███████████ ███   ███████
    ████████████████ ████████████ █████ ██████████████
   ██████████████████████████████ █████ █████ ████ █████
 ██████████████████████████████████ █████ █████ ████ █████
██████  ███ █████████████████ ████ █████ █████ ████ ██████
██████   ██  ███████████████   ██ █████████████████
██████   ██  ███████████████   ██ █████████████████

note: install lolcrab with cargo: cargo install lolcrab