diff --git a/lua/config/options.lua b/lua/config/options.lua index 7598305..c4253d7 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -12,7 +12,13 @@ vim.g.loaded_perl_provider = 0 vim.g.lazyvim_python_lsp = "basedpyright" -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Git-Blame ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -vim.g.gitblame_display_virtual_text = 0 -- Disable virtual text +-- vim.g.gitblame_display_virtual_text = 0 -- Disable virtual text +-- vim.g.gitblame_date_format = "%r" +-- vim.g.gitblame_message_when_not_committed = "Not yet committed!" +-- vim.g.gitblame_message_template = " <>" + +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +vim.g.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1 -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ROOTIEST ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- stylua: ignore start diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..c149cbe --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,205 @@ +-- ╭─────────────────────────────────────────────────────────╮ +-- │ Git Plugins │ +-- ╰─────────────────────────────────────────────────────────╯ + +return { + { -- Git UI + import = "lazyvim.plugins.extras.util.gitui", + }, + { -- Octo plugin + import = "lazyvim.plugins.extras.util.octo", + }, + { -- Gist Tools + "Rawnly/gist.nvim", + lazy = true, + cmd = { + "GistCreate", + "GistCreateFromFile", + "GistsList", + }, + keys = { + { -- Create Gist + "gnc", + "GistCreate", + desc = "Create Gist", + mode = { "n", "x" }, + }, + { -- Find Gists + "gnf", + "GistList", + desc = "Find Gists", + }, + }, + config = true, + }, + { -- LazyGit + "kdheepak/lazygit.nvim", + lazy = true, + cmd = { + "LazyGit", + "LazyGitConfig", + "LazyGitCurrentFile", + "LazyGitFilter", + "LazyGitFilterCurrentFile", + }, + keys = { + { -- LazyGit + "lg", + "LazyGit", + desc = "LazyGit", + }, + }, + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim", + }, + config = function() + require("telescope").load_extension("lazygit") + end, + }, + { -- Thanks/github-stars + "jsongerber/thanks.nvim", + lazy = true, + cmd = { + "ThanksAll", + "ThanksGithubAuth", + "ThanksGithubLogout", + "ThanksClearCache", + }, + opts = { + star_on_install = false, + }, + }, + { -- GitLinker + "linrongbin16/gitlinker.nvim", + lazy = true, + cmd = "GitLink", + opts = {}, + keys = { + { -- Yank git link + "gy", + "GitLink", + mode = { "n", "v" }, + desc = "Yank git link", + }, + { -- Open git link + "gY", + "GitLink!", + mode = { "n", "v" }, + desc = "Open git link", + }, + }, + }, + { -- 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") + local rootilities = require("utils.rootiest") + -- Define the width limit for displaying the Git blame component + local width_limit = 180 -- Adjust this value as needed + -- Add Git-blame to lualine_c section + table.insert(config.sections.lualine_c, { + git_blame.get_current_blame_text, + cond = function() -- Only show the component if the text is available + return git_blame.is_blame_text_available() + and rootilities.is_window_wide_enough(width_limit) + end, + color = { fg = rootilities.get_fg_color("GitSignsCurrentLineBlame") }, + }) + -- Apply the lualine configuration + require("lualine").setup(config) + -- Define git-blame options + local git_ops = { + display_virtual_text = 0, -- Disable virtual text + date_format = "%r", -- Relative date format + message_when_not_committed = " Fly, you fools!", + message_template = "", + } + -- Return the git-blame options + return git_ops + end, + }, + { -- Git Graph + "isakbm/gitgraph.nvim", + opts = { + symbols = { + merge_commit = "", + commit = "", + merge_commit_end = "", + commit_end = "", + + -- Advanced symbols + GVER = "", + GHOR = "", + GCLD = "", + GCRD = "╭", + GCLU = "", + GCRU = "", + GLRU = "", + GLRD = "", + GLUD = "", + GRUD = "", + GFORKU = "", + GFORKD = "", + GRUDCD = "", + GRUDCU = "", + GLUDCD = "", + GLUDCU = "", + GLRDCL = "", + GLRDCR = "", + GLRUCL = "", + GLRUCR = "", + }, + format = { + timestamp = "%H:%M:%S %d-%m-%Y", + fields = { "hash", "timestamp", "author", "branch_name", "tag" }, + }, + hooks = { + on_select_commit = function(commit) + print("selected commit:", commit.hash) + end, + on_select_range_commit = function(from, to) + print("selected range:", from.hash, to.hash) + end, + }, + }, + keys = { + { -- gitgraph_toggle + "gm", + function() + require("utils.git").gitgraph_toggle() + end, + desc = "GitGraph - Toggle", + }, + }, + }, + { -- FuGit + "SuperBo/fugit2.nvim", + opts = { + width = 100, + }, + dependencies = { + "MunifTanjim/nui.nvim", + "nvim-lua/plenary.nvim", + { + "chrisgrieser/nvim-tinygit", -- optional: for Github PR view + dependencies = { "stevearc/dressing.nvim" }, + }, + }, + cmd = { + "Fugit2", + "Fugit2Diff", + "Fugit2Graph", + }, + keys = { + { -- Open Fugit + "F", + mode = "n", + "Fugit2", + }, + }, + }, +} diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index 04b34d6..5e4a520 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -2,8 +2,6 @@ -- │ Utilities │ -- ╰─────────────────────────────────────────────────────────╯ -local rootilities = require("utils.rootilities") - return { { -- Chezmoi import = "lazyvim.plugins.extras.util.chezmoi", @@ -11,12 +9,6 @@ return { { -- 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, @@ -64,29 +56,6 @@ return { }, }, }, - { -- Gist Tools - "Rawnly/gist.nvim", - lazy = true, - cmd = { - "GistCreate", - "GistCreateFromFile", - "GistsList", - }, - keys = { - { -- Create Gist - "gnc", - "GistCreate", - desc = "Create Gist", - mode = { "n", "x" }, - }, - { -- Find Gists - "gnf", - "GistList", - desc = "Find Gists", - }, - }, - config = true, - }, { -- Unception "samjwill/nvim-unception", init = function() @@ -118,31 +87,6 @@ return { }, }, }, - { -- LazyGit - "kdheepak/lazygit.nvim", - event = "VeryLazy", - cmd = { - "LazyGit", - "LazyGitConfig", - "LazyGitCurrentFile", - "LazyGitFilter", - "LazyGitFilterCurrentFile", - }, - keys = { - { -- LazyGit - "lg", - "LazyGit", - desc = "LazyGit", - }, - }, - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim", - }, - config = function() - require("telescope").load_extension("lazygit") - end, - }, { -- Codesnap "mistricky/codesnap.nvim", lazy = true, @@ -196,19 +140,6 @@ return { 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" }, @@ -216,26 +147,6 @@ return { return { enabled = vim.g.usehardtime } end, }, - { -- GitLinker - "linrongbin16/gitlinker.nvim", - lazy = true, - cmd = "GitLink", - opts = {}, - keys = { - { - "gy", - "GitLink", - mode = { "n", "v" }, - desc = "Yank git link", - }, - { - "gY", - "GitLink!", - mode = { "n", "v" }, - desc = "Open git link", - }, - }, - }, { -- CapsWord "dmtrKovalenko/caps-word.nvim", lazy = true, @@ -258,30 +169,6 @@ return { 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") - -- Define the width limit for displaying the Git blame component - local width_limit = 180 -- Adjust this value as needed - - -- Add Git-blame to lualine_c section - table.insert(config.sections.lualine_c, { - git_blame.get_current_blame_text, - cond = function() - return git_blame.is_blame_text_available() - and rootilities.is_window_wide_enough(width_limit) - end, - color = { fg = rootilities.get_fg_color("GitSignsCurrentLineBlame") }, - }) - - -- Apply the new configuration - require("lualine").setup(config) - end, - }, { -- Qalc "Apeiros-46B/qalc.nvim", cmd = { @@ -307,4 +194,15 @@ return { }, config = true, }, + { -- Encourage + "r-cha/encourage.nvim", + config = true, + }, + { -- Helpview + "OXY2DEV/helpview.nvim", + ft = "help", + dependencies = { + "nvim-treesitter/nvim-treesitter", + }, + }, } diff --git a/lua/utils/git.lua b/lua/utils/git.lua new file mode 100644 index 0000000..5d016a4 --- /dev/null +++ b/lua/utils/git.lua @@ -0,0 +1,30 @@ +local M = {} + +function M.gitgraph_draw() + -- open gitgraph in a seperate tab + if vim.bo.filetype == "gitgraph" then + return + end + vim.cmd("tab split") + require("gitgraph").draw({}, { all = true, max_count = 5000 }) +end + +function M.gitgraph_close() + --- close the tab page if it is a gitgraph page + if vim.bo.filetype == "gitgraph" then + vim.cmd("tabclose") + else + return + end +end + +function M.gitgraph_toggle() + -- toggle gitgraph + if vim.bo.filetype == "gitgraph" then + M.gitgraph_close() + else + M.gitgraph_draw() + end +end + +return M