1
0
Fork 0
chezmoi/dot_config/nvim/lua/configs/packages/fterm.lua

68 lines
1.8 KiB
Lua

local M = {
'numToStr/FTerm.nvim',
keys = {
{ '<Space>gg', '<Plug>Lazygit', desc = 'Lazygit' },
{ '<Space>gh', '<Plug>GitHistory', desc = 'Git history' },
{ '<Space>gB', '<Plug>GitBlame', desc = 'Git Blame' },
{ '<Space>gC', '<Plug>GitLabCIView', desc = 'Show gitlab pipeline' },
},
lazy = true,
}
function M.config()
local fterm = require('FTerm')
local lazygit = fterm:new({
-- ft = 'fterm_lazygit', -- You can also override the default filetype, if you want
cmd = 'lazygit',
dimensions = {
height = 0.9,
width = 0.9,
},
})
local git_history = function()
local file = vim.api.nvim_buf_get_name(0)
local cmd = 'git log -p --ext-diff ' .. file
fterm.scratch({
-- ft = 'git_history', -- You can also override the default filetype, if you want
cmd = cmd,
dimensions = {
height = 0.9,
width = 0.9,
},
})
end
local git_blame = function()
local file = vim.api.nvim_buf_get_name(0)
local cmd = 'git blame ' .. file
fterm.scratch({
-- ft = 'git_history', -- You can also override the default filetype, if you want
cmd = cmd,
dimensions = {
height = 0.9,
width = 0.9,
},
})
end
local gitlab_ci = function()
local file = vim.api.nvim_buf_get_name(0)
local cmd = 'glab ci view'
fterm.scratch({
cmd = cmd,
dimensions = {
height = 0.9,
width = 0.9,
},
})
end
vim.keymap.set('n', '<Plug>Lazygit', function() lazygit:toggle() end, { desc = 'Toggle lazygit' })
vim.keymap.set('n', '<Plug>GitHistory', git_history, { desc = 'Show git history' })
vim.keymap.set('n', '<Plug>GitBlame', git_blame, { desc = 'Show git blame' })
vim.keymap.set('n', '<Plug>GitLabCIView', gitlab_ci, { desc = 'Show gitlab pipeline' })
end
return M