From 64715b251f2262977dbb5d137fd26f75ca6bf44a Mon Sep 17 00:00:00 2001 From: rootiest Date: Tue, 9 Jul 2024 09:26:46 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A4=20LazyGit=20and=20Gists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implement LazyGit and integrate with UI - Implement Gists: - Create Gist from file or selection - Find existing gists and open them for editing --- lua/config/keybinds.lua | 24 ++++++++- lua/plugins/dashboard.lua | 109 +++++++++++++++++++------------------- lua/plugins/gists.lua | 17 ++++++ lua/plugins/lazygit.lua | 19 +++++++ 4 files changed, 114 insertions(+), 55 deletions(-) create mode 100644 lua/plugins/gists.lua create mode 100644 lua/plugins/lazygit.lua diff --git a/lua/config/keybinds.lua b/lua/config/keybinds.lua index b5ee625..462c815 100644 --- a/lua/config/keybinds.lua +++ b/lua/config/keybinds.lua @@ -1,6 +1,28 @@ -- ----------------------------------------------------------------------------- -- -------------------------------- KEYBINDS ----------------------------------- -- ----------------------------------------------------------------------------- + +-- Leader Maps +local wk = require("which-key") +wk.register({ + [""] = { + l = { + name = "󰒲 Lazy", + v = { "Lazy", "󰒲 LazyVim" }, + x = { "LazyExtras", " LazyExtras" }, + }, + g = { + name = " Git", + S = { "LazyGit", " LazyGit" }, + n = { + name = " Gists", + c = { "GistCreate", " Create Gist" }, + f = { "GistList", "󰮗 Find Gists" }, + }, + }, + }, +}) + -- Make :Q close all of the buffers vim.api.nvim_create_user_command("Q", function() vim.cmd.bdelete() @@ -43,4 +65,4 @@ function _G.set_terminal_keymaps() vim.keymap.set("t", "", [[wincmd k]], opts) vim.keymap.set("t", "", [[wincmd l]], opts) vim.keymap.set("t", "", [[]], opts) -end \ No newline at end of file +end diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index 26956d1..67d9ec4 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -1,11 +1,10 @@ - return { - "nvimdev/dashboard-nvim", - lazy = false, - opts = function() - -- if line length is greater than 80, use fancy mode - if vim.fn.winwidth(0) >= 100 then - LOGO = [[ + "nvimdev/dashboard-nvim", + lazy = false, + opts = function() + -- if line length is greater than 80, use fancy mode + if vim.fn.winwidth(0) >= 100 then + LOGO = [[ ██████╗ ██████╗ ██████╗ ████████╗██╗███████╗███████╗████████╗ ███╗ ██╗██╗ ██╗██╗███╗ ███╗ ██╔══██╗██╔═══██╗██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝╚══██╔══╝ ████╗ ██║██║ ██║██║████╗ ████║ ██████╔╝██║ ██║██║ ██║ ██║ ██║█████╗ ███████╗ ██║ ██╔██╗ ██║██║ ██║██║██╔████╔██║ @@ -13,8 +12,8 @@ return { ██║ ██║╚██████╔╝╚██████╔╝ ██║ ██║███████╗███████║ ██║ ██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ]] - elseif vim.fn.winwidth(0) >= 80 then - LOGO = [[ + elseif vim.fn.winwidth(0) >= 80 then + LOGO = [[ ███████████ █████ ███ █████ ░░███░░░░░███ ░░███ ░░░ ░░███ ░███ ░███ ██████ ██████ ███████ ████ ██████ █████ ███████ @@ -33,27 +32,28 @@ return { ░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░ ░░░ ░░░░░ ]] - else - LOGO = [[ + else + LOGO = [[ ░█▀▄░█▀█░█▀█░▀█▀░▀█▀░█▀▀░█▀▀░▀█▀░░░█▀█░█░█░▀█▀░█▄█ ░█▀▄░█░█░█░█░░█░░░█░░█▀▀░▀▀█░░█░░░░█░█░▀▄▀░░█░░█░█ ░▀░▀░▀▀▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀▀▀░░▀░░░░▀░▀░░▀░░▀▀▀░▀░▀ ]] - end - LOGO = string.rep("\n", 8) .. LOGO .. "\n\n" - local opts = { - theme = "doom", - hide = { - statusline = false, - }, - config = { - header = vim.split(LOGO, "\n"), + end + LOGO = string.rep("\n", 8) .. LOGO .. "\n\n" + local opts = { + theme = "doom", + hide = { + statusline = false, + }, + config = { + header = vim.split(LOGO, "\n"), -- stylua: ignore center = { { action = 'lua LazyVim.pick()()', desc = " Find File", icon = " ", key = "f" }, { action = "ene | startinsert", desc = " New File", icon = " ", key = "n" }, { action = 'lua LazyVim.pick("oldfiles")()', desc = " Recent Files", icon = " ", key = "r" }, { action = 'lua LazyVim.pick("live_grep")()', desc = " Find Text", icon = " ", key = "g" }, + { action = "LazyGit", desc = " LazyGit", icon = " ", key = "G" }, { action = 'lua LazyVim.pick.config_files()()', desc = " Config", icon = " ", key = "c" }, { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, { action = 'RemoteStart', desc = " Remote Session", icon = "󰢹 ", key = "v" }, @@ -61,37 +61,38 @@ return { { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, { action = function() vim.api.nvim_input("qa") end, desc = " Quit", icon = " ", key = "q" }, }, - footer = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return { - "⚡ Neovim loaded " - .. stats.loaded - .. "/" - .. stats.count - .. " plugins in " - .. ms - .. "ms", - } - end, - }, - } - for _, button in ipairs(opts.config.center) do - button.desc = button.desc .. string.rep(" ", 43 - #button.desc) - button.key_format = " %s" - end - -- open dashboard after closing lazy - if vim.o.filetype == "lazy" then - vim.api.nvim_create_autocmd("WinClosed", { - pattern = tostring(vim.api.nvim_get_current_win()), - once = true, - callback = function() - vim.schedule(function() - vim.api.nvim_exec_autocmds("UIEnter", { group = "dashboard" }) - end) - end, - }) - end - return opts - end, -} \ No newline at end of file + footer = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { + "⚡ Neovim loaded " + .. stats.loaded + .. "/" + .. stats.count + .. " plugins in " + .. ms + .. "ms", + } + end, + }, + } + for _, button in ipairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 43 - #button.desc) + button.key_format = " %s" + end + -- open dashboard after closing lazy + if vim.o.filetype == "lazy" then + vim.api.nvim_create_autocmd("WinClosed", { + pattern = tostring(vim.api.nvim_get_current_win()), + once = true, + callback = function() + vim.schedule(function() + vim.api.nvim_exec_autocmds("UIEnter", { group = "dashboard" }) + end) + end, + }) + end + return opts + end, +} + diff --git a/lua/plugins/gists.lua b/lua/plugins/gists.lua new file mode 100644 index 0000000..fc2d04f --- /dev/null +++ b/lua/plugins/gists.lua @@ -0,0 +1,17 @@ +return { + { + "Rawnly/gist.nvim", + cmd = { "GistCreate", "GistCreateFromFile", "GistsList" }, + config = true, + }, + -- `GistsList` opens the selected gif in a terminal buffer, + -- nvim-unception uses neovim remote rpc functionality to open the gist in an actual buffer + -- and prevents neovim buffer inception + { + "samjwill/nvim-unception", + lazy = false, + init = function() + vim.g.unception_block_while_host_edits = true + end, + }, +} diff --git a/lua/plugins/lazygit.lua b/lua/plugins/lazygit.lua new file mode 100644 index 0000000..058b4bb --- /dev/null +++ b/lua/plugins/lazygit.lua @@ -0,0 +1,19 @@ +return { + "kdheepak/lazygit.nvim", + cmd = { + "LazyGit", + "LazyGitConfig", + "LazyGitCurrentFile", + "LazyGitFilter", + "LazyGitFilterCurrentFile", + }, + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { "lg", "LazyGit", desc = " LazyGit" }, + }, +}