From 178a328cd65bd36a2242f57265c7d4d9371036ef Mon Sep 17 00:00:00 2001 From: asep komarudin Date: Wed, 15 Feb 2023 20:00:17 +0700 Subject: [PATCH] update config dashboard --- .gitignore | 1 - lua/custom/dashboard.lua | 26 ++++++++++++++ lua/custom/dashboard_example.lua | 16 --------- lua/plugins/ui.lua | 7 +--- lua/user/alpha.lua | 62 ++++++-------------------------- lua/user/dashboard.lua | 57 +++++++++++++++++++++++++++++ lua/user/startify.lua | 14 +++++++- 7 files changed, 108 insertions(+), 75 deletions(-) create mode 100644 lua/custom/dashboard.lua delete mode 100644 lua/custom/dashboard_example.lua create mode 100644 lua/user/dashboard.lua diff --git a/.gitignore b/.gitignore index 7b2e9cc..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -lua/custom/dashboard.lua diff --git a/lua/custom/dashboard.lua b/lua/custom/dashboard.lua new file mode 100644 index 0000000..e317010 --- /dev/null +++ b/lua/custom/dashboard.lua @@ -0,0 +1,26 @@ +local M = {} + +-- Untuk Ubah Dashboard +-- 1. Buka remark dash board dibawah +-- 2. Ubah dashboard sesuai keinginan dan kebutuhan + +-- M.dashboard1 = { +-- [[ _ __ __ ]], +-- [[ ___ ___ (____ / /__ _______ ___/ ___ ]], +-- [[ / _ / _ \ / / _ \/ '_/ / __/ _ / _ / -_) ]], +-- [[ / .__\_____/ /\___/_/\_\ \__/\___\_,_/\__/ ]], +-- [[ /_/ |___/ ]], +-- } + +-- M.dashboard2 = { +-- [[ __ ]], +-- [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], +-- [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], +-- [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], +-- [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], +-- [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], +-- } + +M.model = 1 -- isi dengan 1 atau 2 untuk model dashboard + +return M diff --git a/lua/custom/dashboard_example.lua b/lua/custom/dashboard_example.lua deleted file mode 100644 index b9a60eb..0000000 --- a/lua/custom/dashboard_example.lua +++ /dev/null @@ -1,16 +0,0 @@ -local M = {} - --- Untuk Ubah Dashboard --- 1. Rename File ini dari dashboard_exsample.lua menjadi dashboard.lua --- 2. Ubah dashboard sesuai keinginan dan kebutuhan - -M.dashboard = { - [[ __ ]], - [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], - [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], - [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], - [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], - [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], -} - -return M diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 9923c4b..ffee114 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -80,12 +80,7 @@ return { -- event = "BufWinEnter", event = "VimEnter", config = function() - local is_dashboard = false - if is_dashboard then - require("user.alpha") - else - require("user.startify") - end + require("user.alpha") end, }, -- line info bootom diff --git a/lua/user/alpha.lua b/lua/user/alpha.lua index 6d48b02..dd97e93 100644 --- a/lua/user/alpha.lua +++ b/lua/user/alpha.lua @@ -1,57 +1,17 @@ -local status_ok, alpha = pcall(require, "alpha") -if not status_ok then - return -end - -local board = { - [[ _ _ _ ]], - [[ (_) | | | | ]], - [[ _ __ ___ _ ___ | | __ ___ ___ __| | ___ ]], - [[| '_ \ / _ \| |/ _ \| |/ / / __/ _ \ / _` |/ _ \]], - [[| |_) | (_) | | (_) | < | (_| (_) | (_| | __/]], - [[| .__/ \___/| |\___/|_|\_\ \___\___/ \__,_|\___|]], - [[| | _/ | ]], - [[|_| |__/ ]], -} - local data_exists, custom_dasboard = pcall(require, "custom.dashboard") if data_exists then if type(custom_dasboard) == "table" then - local data_board = custom_dasboard.dashboard - if data_board ~= nil then - board = data_board + local model = custom_dasboard.model + if model ~= nil then + if model == 1 then + require("user.startify") + else + require("user.dashboard") + end + else + require("user.startify") end end +else + require("user.startify") end - -local dashboard = require("alpha.themes.dashboard") -dashboard.section.header.val = board -dashboard.section.buttons.val = { - dashboard.button("f", " Find file", ":Telescope find_files "), - dashboard.button("e", " New file", ":ene startinsert "), - dashboard.button("p", " Find project", ":Telescope projects "), - dashboard.button("r", " Recently used files", ":Telescope oldfiles "), - dashboard.button("t", " Find text", ":Telescope live_grep "), - dashboard.button("c", " Configuration", ":e $MYVIMRC "), - dashboard.button("z", "鈴 Lazy", ":Lazy"), - dashboard.button("q", " Quit Neovim", ":qa"), -} - -local function footer() - -- NOTE: requires the fortune-mod package to work - -- local handle = io.popen("fortune") - -- local fortune = handle:read("*a") - -- handle:close() - -- return fortune - return "Pojok Code" -end - -dashboard.section.footer.val = footer() - -dashboard.section.footer.opts.hl = "Type" -dashboard.section.header.opts.hl = "Include" -dashboard.section.buttons.opts.hl = "Keyword" - -dashboard.opts.opts.noautocmd = true --- vim.cmd([[autocmd User AlphaReady echo 'ready']]) -alpha.setup(dashboard.opts) diff --git a/lua/user/dashboard.lua b/lua/user/dashboard.lua new file mode 100644 index 0000000..48249eb --- /dev/null +++ b/lua/user/dashboard.lua @@ -0,0 +1,57 @@ +local status_ok, alpha = pcall(require, "alpha") +if not status_ok then + return +end + +local board = { + [[ _ _ _ ]], + [[ (_) | | | | ]], + [[ _ __ ___ _ ___ | | __ ___ ___ __| | ___ ]], + [[| '_ \ / _ \| |/ _ \| |/ / / __/ _ \ / _` |/ _ \]], + [[| |_) | (_) | | (_) | < | (_| (_) | (_| | __/]], + [[| .__/ \___/| |\___/|_|\_\ \___\___/ \__,_|\___|]], + [[| | _/ | ]], + [[|_| |__/ ]], +} + +local data_exists, custom_dasboard = pcall(require, "custom.dashboard") +if data_exists then + if type(custom_dasboard) == "table" then + local data_board = custom_dasboard.dashboard2 + if data_board ~= nil then + board = data_board + end + end +end + +local dashboard = require("alpha.themes.dashboard") +dashboard.section.header.val = board +dashboard.section.buttons.val = { + dashboard.button("f", " Find file", ":Telescope find_files "), + dashboard.button("e", " New file", ":ene startinsert "), + dashboard.button("p", " Find project", ":Telescope projects "), + dashboard.button("r", " Recently used files", ":Telescope oldfiles "), + dashboard.button("t", " Find text", ":Telescope live_grep "), + dashboard.button("c", " Configuration", ":e $MYVIMRC "), + dashboard.button("z", "鈴 Lazy", ":Lazy"), + dashboard.button("q", " Quit Neovim", ":qa"), +} + +local function footer() + -- NOTE: requires the fortune-mod package to work + -- local handle = io.popen("fortune") + -- local fortune = handle:read("*a") + -- handle:close() + -- return fortune + return "Pojok Code" +end + +dashboard.section.footer.val = footer() + +dashboard.section.footer.opts.hl = "Type" +dashboard.section.header.opts.hl = "Include" +dashboard.section.buttons.opts.hl = "Keyword" + +dashboard.opts.opts.noautocmd = true +-- vim.cmd([[autocmd User AlphaReady echo 'ready']]) +alpha.setup(dashboard.opts) diff --git a/lua/user/startify.lua b/lua/user/startify.lua index 1f96342..3885ffa 100644 --- a/lua/user/startify.lua +++ b/lua/user/startify.lua @@ -1,12 +1,24 @@ local alpha = require("alpha") local startify = require("alpha.themes.startify") -startify.section.header.val = { +local dash_model = {} +dash_model = { [[ _ __ __ ]], [[ ___ ___ (____ / /__ _______ ___/ ___ ]], [[ / _ / _ \ / / _ \/ '_/ / __/ _ / _ / -_) ]], [[ / .__\_____/ /\___/_/\_\ \__/\___\_,_/\__/ ]], [[ /_/ |___/ ]], } + +local data_exists, custom_dasboard = pcall(require, "custom.dashboard") +if data_exists then + if type(custom_dasboard) == "table" then + local board = custom_dasboard.dashboard1 + if board ~= nil then + dash_model = board + end + end +end +startify.section.header.val = dash_model startify.section.top_buttons.val = { startify.button("f", " Find file", ":Telescope find_files "), startify.button("e", " New file", ":ene startinsert "),