Skip to content

Commit f6296a8

Browse files
author
Younes Moustaghfir
committed
chore: add additional plugins
1 parent b95f53f commit f6296a8

File tree

1 file changed

+76
-6
lines changed

1 file changed

+76
-6
lines changed

init.lua

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,56 @@ require('lazy').setup({
253253
topdelete = { text = '' },
254254
changedelete = { text = '~' },
255255
},
256+
on_attach = function(bufnr)
257+
local gitsigns = require 'gitsigns'
258+
259+
local function map(mode, l, r, opts)
260+
opts = opts or {}
261+
opts.buffer = bufnr
262+
vim.keymap.set(mode, l, r, opts)
263+
end
264+
265+
-- Navigation
266+
map('n', ']c', function()
267+
if vim.wo.diff then
268+
vim.cmd.normal { ']c', bang = true }
269+
else
270+
gitsigns.nav_hunk 'next'
271+
end
272+
end, { desc = 'Jump to next git [c]hange' })
273+
274+
map('n', '[c', function()
275+
if vim.wo.diff then
276+
vim.cmd.normal { '[c', bang = true }
277+
else
278+
gitsigns.nav_hunk 'prev'
279+
end
280+
end, { desc = 'Jump to previous git [c]hange' })
281+
282+
-- Actions
283+
-- visual mode
284+
map('v', '<leader>hs', function()
285+
gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
286+
end, { desc = 'git [s]tage hunk' })
287+
map('v', '<leader>hr', function()
288+
gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
289+
end, { desc = 'git [r]eset hunk' })
290+
-- normal mode
291+
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' })
292+
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' })
293+
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' })
294+
map('n', '<leader>hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' })
295+
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' })
296+
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' })
297+
map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' })
298+
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' })
299+
map('n', '<leader>hD', function()
300+
gitsigns.diffthis '@'
301+
end, { desc = 'git [D]iff against last commit' })
302+
-- Toggles
303+
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
304+
map('n', '<leader>tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' })
305+
end,
256306
},
257307
},
258308

@@ -570,7 +620,7 @@ require('lazy').setup({
570620
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
571621
local servers = {
572622
-- clangd = {},
573-
-- gopls = {},
623+
gopls = {},
574624
-- pyright = {},
575625
rust_analyzer = {},
576626
ruff = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
@@ -613,6 +663,7 @@ require('lazy').setup({
613663
'stylua', -- Used to format Lua code
614664
'ruff',
615665
'rust_analyzer',
666+
-- 'go',
616667
})
617668
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
618669

@@ -863,6 +914,25 @@ require('lazy').setup({
863914
name = 'catppuccin',
864915
priority = 1000,
865916
},
917+
{
918+
'kdheepak/lazygit.nvim',
919+
cmd = {
920+
'LazyGit',
921+
'LazyGitConfig',
922+
'LazyGitCurrentFile',
923+
'LazyGitFilter',
924+
'LazyGitFilterCurrentFile',
925+
},
926+
-- optional for floating window border decoration
927+
dependencies = {
928+
'nvim-lua/plenary.nvim',
929+
},
930+
-- setting the keybinding for LazyGit with 'keys' is recommended in
931+
-- order to load the plugin when the command is run for the first time
932+
keys = {
933+
{ '<leader>lg', '<cmd>LazyGit<cr>', desc = 'LazyGit' },
934+
},
935+
},
866936
config = function(_, opts)
867937
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
868938

@@ -887,11 +957,11 @@ require('lazy').setup({
887957
-- Here are some example plugins that I've included in the Kickstart repository.
888958
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
889959
--
890-
-- require 'kickstart.plugins.debug',
891-
-- require 'kickstart.plugins.indent_line',
892-
-- require 'kickstart.plugins.lint',
893-
-- require 'kickstart.plugins.autopairs',
894-
-- require 'kickstart.plugins.neo-tree',
960+
require 'kickstart.plugins.debug',
961+
require 'kickstart.plugins.indent_line',
962+
require 'kickstart.plugins.lint',
963+
require 'kickstart.plugins.autopairs',
964+
require 'kickstart.plugins.neo-tree',
895965
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
896966

897967
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`

0 commit comments

Comments
 (0)