Files
neovim-config/lua/plugins/util.lua
T
rootiest b622454835 ️ perf(lazy-load): delegate plugins to their cmd/keymaps
Increase performance: Allow plugins to only load with their commands and keymaps whenever possible
2024-08-04 06:57:07 -04:00

286 lines
6.6 KiB
Lua

-- -----------------------------------------------------------------------------
-- -------------------------------- UTILITIES ----------------------------------
-- -----------------------------------------------------------------------------
-- Function to convert RGB to hexadecimal
local function rgb_to_hex(rgb)
return string.format("#%02x%02x%02x", rgb[1], rgb[2], rgb[3])
end
local function get_fg_color(hlgroup)
local hl = vim.api.nvim_get_hl(0, { name = hlgroup, link = false })
local fg = hl.fg
if fg then
return rgb_to_hex({
bit.rshift(bit.band(fg, 0xFF0000), 16),
bit.rshift(bit.band(fg, 0x00FF00), 8),
bit.band(fg, 0x0000FF),
})
end
return nil
end
return {
{ -- Chezmoi
import = "lazyvim.plugins.extras.util.chezmoi",
},
{ -- Dotfiles plugins
import = "lazyvim.plugins.extras.util.dot",
},
{ -- Git UI
import = "lazyvim.plugins.extras.util.gitui",
},
{ -- Octo plugin
import = "lazyvim.plugins.extras.util.octo",
},
{ -- Wakatime
"wakatime/vim-wakatime",
cond = vim.g.usewakatime,
},
{ -- Link following
"chrishrb/gx.nvim",
lazy = true,
cmd = { "Browse" },
keys = {
{ -- Open URL/Link
"gx",
"<cmd>Browse<cr>",
mode = { "n", "x" },
desc = "Open URL/Link",
},
},
init = function()
vim.g.netrw_nogx = 1
end,
dependencies = { "nvim-lua/plenary.nvim" },
config = true,
},
{ -- Auto-save
"Pocco81/auto-save.nvim",
event = "BufEnter",
},
{ -- Ripgrep substitute
"chrisgrieser/nvim-rip-substitute",
event = "InsertEnter",
cmd = "RipSubstitute",
keys = {
{ -- Rip Substitute
"<leader>fs",
function()
require("rip-substitute").sub()
end,
mode = { "n", "x" },
desc = "Rip Substitute",
},
},
},
{ -- Gist Tools
"Rawnly/gist.nvim",
lazy = true,
cmd = {
"GistCreate",
"GistCreateFromFile",
"GistsList",
},
keys = {
{ -- Create Gist
"<leader>gnc",
"<cmd>GistCreate<cr>",
desc = "Create Gist",
mode = { "n", "x" },
},
{ -- Find Gists
"<leader>gnf",
"<cmd>GistList<cr>",
desc = "Find Gists",
},
},
config = true,
},
{ -- Unception
"samjwill/nvim-unception",
init = function()
vim.g.unception_block_while_host_edits = true
end,
},
{ -- 🍎 Icon Picker
"ziontee113/icon-picker.nvim",
lazy = true,
config = function()
require("icon-picker").setup({ disable_legacy_commands = true })
end,
keys = {
{ -- Pick Icon
"<leader>Ii",
"<cmd>IconPickerNormal<cr>",
desc = "Pick Icon",
},
{ -- Yank Icon
"<leader>Iy",
"<cmd>IconPickerYank<cr>",
desc = "Yank Icon",
},
{ -- Insert Icon in insert mode
"<C-i>",
"<cmd>IconPickerInsert<cr>",
desc = "Insert Icon",
mode = "i",
},
},
},
{ -- LazyGit
"kdheepak/lazygit.nvim",
event = "VeryLazy",
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
keys = {
{
"<leader>lg",
"<cmd>LazyGit<cr>",
desc = "LazyGit",
},
},
dependencies = {
"nvim-lua/plenary.nvim",
},
},
{ -- Codesnap
"mistricky/codesnap.nvim",
lazy = true,
build = "make",
opts = {
save_path = "~/Pictures/Screenshots/",
has_breadcrumbs = true,
show_workspace = true,
bg_theme = "default",
watermark = "Rootiest Snippets",
code_font_family = "Iosevka NF",
code_font_size = 12,
},
cmd = {
"CodeSnap",
"CodeSnapSave",
"CodeSnapHighlight",
"CodeSnapASCII",
},
keys = {
{ -- Save selected code snapshot into clipboard
"<leader>cy",
"<cmd>CodeSnap<cr>",
desc = "Save selected code snapshot into clipboard",
mode = "x",
},
{ -- Save selected code snapshot in ~/Pictures
"<leader>cs",
"<cmd>CodeSnapSave<cr>",
desc = "Save selected code snapshot in ~/Pictures",
mode = "x",
},
{ -- Highlight and snapshot selected code into clipboard
"<leader>ch",
"<cmd>CodeSnapHighlight<cr>",
desc = "Highlight and snapshot selected code into clipboard",
mode = "x",
},
{ -- Save ASCII code snapshot into clipboard
"<leader>ci",
"<cmd>CodeSnapASCII<cr>",
desc = "Save ASCII code snapshot into clipboard",
mode = "x",
},
},
},
{ -- Kulala
"mistweaverco/kulala.nvim",
event = "InsertEnter",
config = function()
require("kulala").setup()
end,
},
{ -- Thanks/github-stars
"jsongerber/thanks.nvim",
lazy = true,
cmd = {
"ThanksAll",
"ThanksGithubAuth",
"ThanksGithubLogout",
"ThanksClearCache",
},
opts = {
star_on_install = false,
},
},
{ -- Hardtime
"m4xshen/hardtime.nvim",
dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" },
opts = function()
return { enabled = vim.g.usehardtime }
end,
},
{ -- GitLinker
"linrongbin16/gitlinker.nvim",
lazy = true,
cmd = "GitLink",
opts = {},
keys = {
{
"<leader>gy",
"<cmd>GitLink<cr>",
mode = { "n", "v" },
desc = "Yank git link",
},
{
"<leader>gY",
"<cmd>GitLink!<cr>",
mode = { "n", "v" },
desc = "Open git link",
},
},
},
{ -- CapsWord
"dmtrKovalenko/caps-word.nvim",
lazy = true,
opts = {},
keys = {
{
"<C-s>",
function()
require("caps-word").toggle()
end,
desc = "Toggle CapsWord",
mode = { "i", "n" },
},
},
},
{ -- Music Controls
"AntonVanAssche/music-controls.nvim",
dependencies = { "rcarriga/nvim-notify" },
opts = {
default_player = "YoutubeMusic",
},
},
{ -- Git Blame
"f-person/git-blame.nvim",
event = "VeryLazy",
opts = function()
-- Get the current lualine configuration
local config = require("lualine").get_config()
local git_blame = require("gitblame")
-- Add Git-blame to lualine_c section
table.insert(config.sections.lualine_c, {
git_blame.get_current_blame_text,
cond = git_blame.is_blame_text_available,
color = { fg = get_fg_color("GitSignsCurrentLineBlame") },
})
-- Apply the new configuration
require("lualine").setup(config)
end,
},
}