more custom commit actions

This commit is contained in:
Dmitry O 2024-03-28 00:03:35 +01:00
parent 9ccd1bcd3c
commit 1284b048a5
No known key found for this signature in database
GPG Key ID: F3F70C3C74A4BDA6
2 changed files with 34 additions and 10 deletions

View File

@ -546,7 +546,7 @@ require('lazy').setup({
local servers = { local servers = {
-- clangd = {}, -- clangd = {},
-- gopls = {}, -- gopls = {},
-- pyright = {}, pyright = {},
pylsp = { pylsp = {
settings = { settings = {
pylsp = { pylsp = {

View File

@ -2,6 +2,24 @@
-- I promise not to create any merge conflicts in this directory :) -- I promise not to create any merge conflicts in this directory :)
-- --
-- See the kickstart.nvim README for more information -- See the kickstart.nvim README for more information
local function do_custom_commit(prefix)
local ok, _ = pcall(vim.cmd, 'G commit -a')
if ok then
local branch = vim.fn.system "git branch --show-current | tr -d '\n'"
local ticket = branch:match '([A-Z]+%-%d+)'
vim.cmd 'startinsert'
if not ticket then
vim.api.nvim_put({ string.format('%s: ', prefix) }, 'c', true, true)
return
end
if prefix == '' then
vim.api.nvim_put({ string.format('%s: ', ticket) }, 'c', true, true)
return
end
vim.api.nvim_put({ string.format('%s(%s): ', prefix, ticket) }, 'c', true, true)
end
end
return { return {
{ {
'christoomey/vim-tmux-navigator', 'christoomey/vim-tmux-navigator',
@ -140,17 +158,23 @@ return {
config = function() config = function()
vim.keymap.set('n', '<leader>gb', '<Cmd>Telescope git_branches<CR>', { desc = '[G]it [B]ranches' }) vim.keymap.set('n', '<leader>gb', '<Cmd>Telescope git_branches<CR>', { desc = '[G]it [B]ranches' })
vim.keymap.set('n', '<leader>gs', '<Cmd>Git<CR>', { desc = '[G]it [S]tatus' }) vim.keymap.set('n', '<leader>gs', '<Cmd>Git<CR>', { desc = '[G]it [S]tatus' })
vim.keymap.set('n', '<leader>gc', function() vim.keymap.set('n', '<leader>gcf', function()
local ok, _ = pcall(vim.cmd, 'G commit -a') do_custom_commit 'feat'
if ok then end, { desc = '[G]it [C]ommit [F]eat' })
local branch = vim.fn.system "git branch --show-current | tr -d '\n'" vim.keymap.set('n', '<leader>gcc', function()
local ticket = branch:match '([A-Z]+%-%d+)' do_custom_commit 'chore'
vim.cmd 'startinsert' end, { desc = '[G]it [C]ommit [C]hore' })
vim.api.nvim_put({ string.format('feat(%s): ', ticket) }, 'c', true, true) vim.keymap.set('n', '<leader>gcr', function()
end do_custom_commit 'refactor'
end, { desc = '[G]it [C]ommit' }) end, { desc = '[G]it [C]ommit [R]efactor' })
vim.keymap.set('n', '<leader>gce', function()
do_custom_commit ''
end, { desc = '[G]it [C]ommit [E]mpty' })
vim.keymap.set('n', '<leader>gp', '<Cmd>Git push<CR>', { desc = '[G]it [P]ush' }) vim.keymap.set('n', '<leader>gp', '<Cmd>Git push<CR>', { desc = '[G]it [P]ush' })
vim.keymap.set('n', '<leader>gf', '<Cmd>Git pull<CR>', { desc = '[G]it [F]pull' }) vim.keymap.set('n', '<leader>gf', '<Cmd>Git pull<CR>', { desc = '[G]it [F]pull' })
vim.keymap.set('n', '<leader>gd', '<Cmd>Git diff<CR>', { desc = '[G]it [D]iff' })
vim.keymap.set('n', '<leader>gl', '<Cmd>Git log<CR>', { desc = '[G]it [L]og' })
end, end,
}, },
{ {