Thomas 1 year ago
parent
commit
fb94db24ea
4 changed files with 76 additions and 13 deletions
  1. 1 0
      lazy-lock.json
  2. 1 1
      lua/config/lazy.lua
  3. 6 0
      lua/config/mappings.lua
  4. 68 12
      lua/plugins/git.lua

+ 1 - 0
lazy-lock.json

@@ -5,6 +5,7 @@
   "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
   "edgy.nvim": { "branch": "main", "commit": "9ea7b22048f08a1a0d49a4a789e36c2fe1b8579f" },
   "fzf-lua": { "branch": "main", "commit": "3d214f8db4a4119723ab5148b7a333aab3fa9063" },
+  "gitsigns.nvim": { "branch": "main", "commit": "e9c4187c3774a46df2d086a66cf3a7e6bea4c432" },
   "image.nvim": { "branch": "master", "commit": "61c76515cfc3cdac8123ece9e9761b20c3dc1315" },
   "lazy.nvim": { "branch": "main", "commit": "b02c9eae6a250f98908c146d1dc1a891f5019f0a" },
   "lualine.nvim": { "branch": "master", "commit": "6a40b530539d2209f7dc0492f3681c8c126647ad" },

+ 1 - 1
lua/config/lazy.lua

@@ -29,7 +29,7 @@ require("lazy").setup({
   },
   -- Configure any other settings here. See the documentation for more details.
   -- colorscheme that will be used when installing plugins.
-  install = { colorscheme = { "habamax" } },
+  install = { --[[ colorscheme = { "habamax" } ]] },
   -- automatically check for plugin updates
   checker = { enabled = true },
 })

+ 6 - 0
lua/config/mappings.lua

@@ -1,5 +1,7 @@
 local wk = require("which-key")
 local builtin = require("telescope.builtin")
+local gitsigns = require('gitsigns')
+
 -- local tree = require "nvim-tree.api"
 
 function FormatBuffer(command)
@@ -111,6 +113,10 @@ wk.add({
     { "K", function() vim.lsp.buf.hover() end, desc = "LSP toggle" },
     { "<leader>ca", function() vim.lsp.buf.code_action() end, desc = "LSP code action" },
     { "<leader>cd", function() vim.diagnostic.setqflist() end, desc = "LSP code diagnostic" },
+
+    -- Gitsigns
+    { "<leader>nc", function() gitsigns.nav_hunk('next') end, desc = "Next change" },
+    { "<leader>pc", function() gitsigns.nav_hunk('prev') end, desc = "Previous change" },
 	},
 	{
 		mode = "v",

+ 68 - 12
lua/plugins/git.lua

@@ -1,16 +1,72 @@
 return {
-	"NeogitOrg/neogit",
-	dependencies = {
-		"nvim-lua/plenary.nvim", -- required
-		"sindrets/diffview.nvim", -- optional - Diff integration
+	{
+		"NeogitOrg/neogit",
+		dependencies = {
+			"nvim-lua/plenary.nvim", -- required
+			"sindrets/diffview.nvim", -- optional - Diff integration
 
-		-- Only one of these is needed, not both.
-		"nvim-telescope/telescope.nvim", -- optional
-		"ibhagwan/fzf-lua", -- optional
+			-- Only one of these is needed, not both.
+			"nvim-telescope/telescope.nvim", -- optional
+			"ibhagwan/fzf-lua", -- optional
+		},
+		config = function()
+			-- init.lua
+			local neogit = require("neogit")
+			neogit.setup({})
+		end,
+	},
+	{
+		"lewis6991/gitsigns.nvim",
+		config = function()
+			require("gitsigns").setup({
+				signs = {
+					add = { text = "┃" },
+					change = { text = "┃" },
+					delete = { text = "_" },
+					topdelete = { text = "‾" },
+					changedelete = { text = "~" },
+					untracked = { text = "┆" },
+				},
+				signs_staged = {
+					add = { text = "┃" },
+					change = { text = "┃" },
+					delete = { text = "_" },
+					topdelete = { text = "‾" },
+					changedelete = { text = "~" },
+					untracked = { text = "┆" },
+				},
+				signs_staged_enable = true,
+				signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
+				numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
+				linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
+				word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
+				watch_gitdir = {
+					follow_files = true,
+				},
+				auto_attach = true,
+				attach_to_untracked = false,
+				current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
+				current_line_blame_opts = {
+					virt_text = true,
+					virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
+					delay = 1000,
+					ignore_whitespace = false,
+					virt_text_priority = 100,
+				},
+				current_line_blame_formatter = "<author>, <author_time:%R> - <summary>",
+				sign_priority = 6,
+				update_debounce = 100,
+				status_formatter = nil, -- Use default
+				max_file_length = 40000, -- Disable if file is longer than this (in lines)
+				preview_config = {
+					-- Options passed to nvim_open_win
+					border = "single",
+					style = "minimal",
+					relative = "cursor",
+					row = 0,
+					col = 1,
+				},
+			})
+		end,
 	},
-	config = function()
-    -- init.lua
-    local neogit = require('neogit')
-    neogit.setup {}
-  end,
 }