diff --git a/init.lua b/init.lua index 5f8b4aeb..97e8f6c2 100644 --- a/init.lua +++ b/init.lua @@ -546,7 +546,7 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = {}, pylsp = { settings = { pylsp = { diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 63079339..ac868802 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,6 +2,24 @@ -- I promise not to create any merge conflicts in this directory :) -- -- 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 { { 'christoomey/vim-tmux-navigator', @@ -140,17 +158,23 @@ return { config = function() vim.keymap.set('n', 'gb', 'Telescope git_branches', { desc = '[G]it [B]ranches' }) vim.keymap.set('n', 'gs', 'Git', { desc = '[G]it [S]tatus' }) - vim.keymap.set('n', 'gc', function() - 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' - vim.api.nvim_put({ string.format('feat(%s): ', ticket) }, 'c', true, true) - end - end, { desc = '[G]it [C]ommit' }) + vim.keymap.set('n', 'gcf', function() + do_custom_commit 'feat' + end, { desc = '[G]it [C]ommit [F]eat' }) + vim.keymap.set('n', 'gcc', function() + do_custom_commit 'chore' + end, { desc = '[G]it [C]ommit [C]hore' }) + vim.keymap.set('n', 'gcr', function() + do_custom_commit 'refactor' + end, { desc = '[G]it [C]ommit [R]efactor' }) + vim.keymap.set('n', 'gce', function() + do_custom_commit '' + end, { desc = '[G]it [C]ommit [E]mpty' }) + vim.keymap.set('n', 'gp', 'Git push', { desc = '[G]it [P]ush' }) vim.keymap.set('n', 'gf', 'Git pull', { desc = '[G]it [F]pull' }) + vim.keymap.set('n', 'gd', 'Git diff', { desc = '[G]it [D]iff' }) + vim.keymap.set('n', 'gl', 'Git log', { desc = '[G]it [L]og' }) end, }, {