💤 LazyGit and Gists
- Implement LazyGit and integrate with UI - Implement Gists: - Create Gist from file or selection - Find existing gists and open them for editing
This commit is contained in:
@@ -1,6 +1,28 @@
|
|||||||
-- -----------------------------------------------------------------------------
|
-- -----------------------------------------------------------------------------
|
||||||
-- -------------------------------- KEYBINDS -----------------------------------
|
-- -------------------------------- KEYBINDS -----------------------------------
|
||||||
-- -----------------------------------------------------------------------------
|
-- -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- Leader Maps
|
||||||
|
local wk = require("which-key")
|
||||||
|
wk.register({
|
||||||
|
["<leader>"] = {
|
||||||
|
l = {
|
||||||
|
name = " Lazy",
|
||||||
|
v = { "<cmd>Lazy<cr>", " LazyVim" },
|
||||||
|
x = { "<cmd>LazyExtras<cr>", " LazyExtras" },
|
||||||
|
},
|
||||||
|
g = {
|
||||||
|
name = " Git",
|
||||||
|
S = { "<cmd>LazyGit<cr>", " LazyGit" },
|
||||||
|
n = {
|
||||||
|
name = " Gists",
|
||||||
|
c = { "<cmd>GistCreate<cr>", " Create Gist" },
|
||||||
|
f = { "<cmd>GistList<cr>", " Find Gists" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
-- Make :Q close all of the buffers
|
-- Make :Q close all of the buffers
|
||||||
vim.api.nvim_create_user_command("Q", function()
|
vim.api.nvim_create_user_command("Q", function()
|
||||||
vim.cmd.bdelete()
|
vim.cmd.bdelete()
|
||||||
|
|||||||
+54
-53
@@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"nvimdev/dashboard-nvim",
|
"nvimdev/dashboard-nvim",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
opts = function()
|
opts = function()
|
||||||
-- if line length is greater than 80, use fancy mode
|
-- if line length is greater than 80, use fancy mode
|
||||||
if vim.fn.winwidth(0) >= 100 then
|
if vim.fn.winwidth(0) >= 100 then
|
||||||
LOGO = [[
|
LOGO = [[
|
||||||
██████╗ ██████╗ ██████╗ ████████╗██╗███████╗███████╗████████╗ ███╗ ██╗██╗ ██╗██╗███╗ ███╗
|
██████╗ ██████╗ ██████╗ ████████╗██╗███████╗███████╗████████╗ ███╗ ██╗██╗ ██╗██╗███╗ ███╗
|
||||||
██╔══██╗██╔═══██╗██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝╚══██╔══╝ ████╗ ██║██║ ██║██║████╗ ████║
|
██╔══██╗██╔═══██╗██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝╚══██╔══╝ ████╗ ██║██║ ██║██║████╗ ████║
|
||||||
██████╔╝██║ ██║██║ ██║ ██║ ██║█████╗ ███████╗ ██║ ██╔██╗ ██║██║ ██║██║██╔████╔██║
|
██████╔╝██║ ██║██║ ██║ ██║ ██║█████╗ ███████╗ ██║ ██╔██╗ ██║██║ ██║██║██╔████╔██║
|
||||||
@@ -13,8 +12,8 @@ return {
|
|||||||
██║ ██║╚██████╔╝╚██████╔╝ ██║ ██║███████╗███████║ ██║ ██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
██║ ██║╚██████╔╝╚██████╔╝ ██║ ██║███████╗███████║ ██║ ██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||||
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||||
]]
|
]]
|
||||||
elseif vim.fn.winwidth(0) >= 80 then
|
elseif vim.fn.winwidth(0) >= 80 then
|
||||||
LOGO = [[
|
LOGO = [[
|
||||||
███████████ █████ ███ █████
|
███████████ █████ ███ █████
|
||||||
░░███░░░░░███ ░░███ ░░░ ░░███
|
░░███░░░░░███ ░░███ ░░░ ░░███
|
||||||
░███ ░███ ██████ ██████ ███████ ████ ██████ █████ ███████
|
░███ ░███ ██████ ██████ ███████ ████ ██████ █████ ███████
|
||||||
@@ -33,27 +32,28 @@ return {
|
|||||||
░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░ ░░░ ░░░░░
|
░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░ ░░░ ░░░░░
|
||||||
|
|
||||||
]]
|
]]
|
||||||
else
|
else
|
||||||
LOGO = [[
|
LOGO = [[
|
||||||
░█▀▄░█▀█░█▀█░▀█▀░▀█▀░█▀▀░█▀▀░▀█▀░░░█▀█░█░█░▀█▀░█▄█
|
░█▀▄░█▀█░█▀█░▀█▀░▀█▀░█▀▀░█▀▀░▀█▀░░░█▀█░█░█░▀█▀░█▄█
|
||||||
░█▀▄░█░█░█░█░░█░░░█░░█▀▀░▀▀█░░█░░░░█░█░▀▄▀░░█░░█░█
|
░█▀▄░█░█░█░█░░█░░░█░░█▀▀░▀▀█░░█░░░░█░█░▀▄▀░░█░░█░█
|
||||||
░▀░▀░▀▀▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀▀▀░░▀░░░░▀░▀░░▀░░▀▀▀░▀░▀
|
░▀░▀░▀▀▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀▀▀░░▀░░░░▀░▀░░▀░░▀▀▀░▀░▀
|
||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
LOGO = string.rep("\n", 8) .. LOGO .. "\n\n"
|
LOGO = string.rep("\n", 8) .. LOGO .. "\n\n"
|
||||||
local opts = {
|
local opts = {
|
||||||
theme = "doom",
|
theme = "doom",
|
||||||
hide = {
|
hide = {
|
||||||
statusline = false,
|
statusline = false,
|
||||||
},
|
},
|
||||||
config = {
|
config = {
|
||||||
header = vim.split(LOGO, "\n"),
|
header = vim.split(LOGO, "\n"),
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
center = {
|
center = {
|
||||||
{ action = 'lua LazyVim.pick()()', desc = " Find File", icon = " ", key = "f" },
|
{ action = 'lua LazyVim.pick()()', desc = " Find File", icon = " ", key = "f" },
|
||||||
{ action = "ene | startinsert", desc = " New File", icon = " ", key = "n" },
|
{ action = "ene | startinsert", desc = " New File", icon = " ", key = "n" },
|
||||||
{ action = 'lua LazyVim.pick("oldfiles")()', desc = " Recent Files", icon = " ", key = "r" },
|
{ action = 'lua LazyVim.pick("oldfiles")()', desc = " Recent Files", icon = " ", key = "r" },
|
||||||
{ action = 'lua LazyVim.pick("live_grep")()', desc = " Find Text", icon = " ", key = "g" },
|
{ 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 LazyVim.pick.config_files()()', desc = " Config", icon = " ", key = "c" },
|
||||||
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" },
|
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" },
|
||||||
{ action = 'RemoteStart', desc = " Remote Session", icon = " ", key = "v" },
|
{ action = 'RemoteStart', desc = " Remote Session", icon = " ", key = "v" },
|
||||||
@@ -61,37 +61,38 @@ return {
|
|||||||
{ action = "Lazy", desc = " Lazy", icon = " ", key = "l" },
|
{ action = "Lazy", desc = " Lazy", icon = " ", key = "l" },
|
||||||
{ action = function() vim.api.nvim_input("<cmd>qa<cr>") end, desc = " Quit", icon = " ", key = "q" },
|
{ action = function() vim.api.nvim_input("<cmd>qa<cr>") end, desc = " Quit", icon = " ", key = "q" },
|
||||||
},
|
},
|
||||||
footer = function()
|
footer = function()
|
||||||
local stats = require("lazy").stats()
|
local stats = require("lazy").stats()
|
||||||
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
|
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
|
||||||
return {
|
return {
|
||||||
"⚡ Neovim loaded "
|
"⚡ Neovim loaded "
|
||||||
.. stats.loaded
|
.. stats.loaded
|
||||||
.. "/"
|
.. "/"
|
||||||
.. stats.count
|
.. stats.count
|
||||||
.. " plugins in "
|
.. " plugins in "
|
||||||
.. ms
|
.. ms
|
||||||
.. "ms",
|
.. "ms",
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, button in ipairs(opts.config.center) do
|
for _, button in ipairs(opts.config.center) do
|
||||||
button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
|
button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
|
||||||
button.key_format = " %s"
|
button.key_format = " %s"
|
||||||
end
|
end
|
||||||
-- open dashboard after closing lazy
|
-- open dashboard after closing lazy
|
||||||
if vim.o.filetype == "lazy" then
|
if vim.o.filetype == "lazy" then
|
||||||
vim.api.nvim_create_autocmd("WinClosed", {
|
vim.api.nvim_create_autocmd("WinClosed", {
|
||||||
pattern = tostring(vim.api.nvim_get_current_win()),
|
pattern = tostring(vim.api.nvim_get_current_win()),
|
||||||
once = true,
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
vim.api.nvim_exec_autocmds("UIEnter", { group = "dashboard" })
|
vim.api.nvim_exec_autocmds("UIEnter", { group = "dashboard" })
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
return opts
|
return opts
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -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 = {
|
||||||
|
{ "<leader>lg", "<cmd>LazyGit<cr>", desc = " LazyGit" },
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user