neogit-config.lua (1678B)
1 local gitsigns = require 'gitsigns' 2 3 gitsigns.setup { 4 -- current_line_blame = true, 5 -- current_line_blame_opts = { 6 -- delay = 1000, 7 -- }, 8 -- sign_priority = 1, 9 on_attach = function(bufnr) 10 vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-S>', ':Gitsigns stage_hunk<CR>', { silent = true }) 11 vim.api.nvim_buf_set_keymap(bufnr, 'v', '<C-S>', ':Gitsigns stage_hunk<CR>', { silent = true }) 12 vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gbl', ':Gitsigns blame_line<CR>', { silent = true }) 13 end 14 } 15 16 do -- Terminal mode configuration 17 local cfg_template = [[ 18 git: 19 paging: 20 colorArg: always 21 pager: delta --dark --paging=never 22 promptToReturnFromSubprocess: false 23 os: 24 editCommand: 'nvim' 25 editCommandTemplate: '{{editor}} --server "%s" --remote {{filename}}' 26 openCommand: 'nvim --server "%s" --remote {{filename}}' 27 ]] 28 local lg_config_path = "/tmp/nvim.lg.config" 29 30 local cfg = io.open(lg_config_path, "w") 31 if cfg then 32 cfg:write(string.format(cfg_template, vim.v.servername, vim.v.servername)) 33 else 34 error("Could not open config file") 35 end 36 local function open_lz() 37 vim.cmd.tabnew() 38 vim.opt_local.number = false 39 vim.opt_local.relativenumber = false 40 vim.opt_local.signcolumn = "no" 41 42 vim.cmd.terminal { "lazygit", "--use-config-file", lg_config_path } 43 44 vim.api.nvim_create_autocmd("TermClose", { 45 buffer = vim.api.nvim_get_current_buf(), 46 callback = function(opts) 47 if vim.v.event.status == 0 then 48 vim.api.nvim_buf_delete(opts.buf, { force = true }) 49 gitsigns.refresh() 50 end 51 end 52 }) 53 54 vim.cmd.startinsert() 55 end 56 57 vim.keymap.set('n', '<Leader>g', open_lz) 58 end