aboutsummaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/after/ftplugin/fugitive.lua
blob: 2d0fef66e47e8a909c72234de5ecf3b00d6e4e3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
--- Personal lua config files for NeoVim.
--  Last Changed: 2023-02-17
--  Author: Federico Igne <git@federicoigne.com>
--  License: This file is placed in the public domain.

local map = vim.keymap

local function tag()
    local old = vim.fn.split(vim.fn.system('git describe --tags --abbrev=0'),'\n',1)[1]
    local new = vim.fn.input('tag: ' .. old .. ' -> ')
    if new:len() == 0 then
        print("Empty tag not allowed.")
    else
        local msg = { "release(" .. new .. "): <++>", "" }
        local log = vim.fn.systemlist('git log --reverse --oneline ' .. old .. '..HEAD')
        for _,l in ipairs(log) do
            table.insert(msg,l)
        end
        vim.cmd.Git('tag -a "' .. new .. '"')
        vim.api.nvim_buf_set_lines(0, 0, -1, false, msg)
    end
end

vim.keymap.set('n', 'ct', tag, { buffer = true })