.config/nvim/plugin/tig.lua

Wed, 28 Aug 2024 04:44:05 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Wed, 28 Aug 2024 04:44:05 -0500
changeset 1178
8993dc4128de
parent 1160
28e64ed03c25
permissions
-rw-r--r--

add assign types gopls hint too

local api = vim.api
local fn = vim.fn

local function tig(ctx)
  local cmd = ctx.fargs
  local orig_number = vim.wo.number

  local buf = api.nvim_create_buf(false, true)
  vim.bo[buf].bufhidden = "delete"

  api.nvim_set_current_buf(buf)
  vim.wo.number = false

  table.insert(cmd, 1, "tig")
  fn.termopen(cmd, {
    on_exit = function()
      vim.wo.number = orig_number
      vim.cmd.buffer("#")
    end,
  })
end

api.nvim_create_user_command("Tig", tig, { nargs = "*", complete = "file" })

api.nvim_create_user_command("TigBlame", function()
  tig({ fargs = { "blame", "+" .. fn.line("."), "--", fn.expand("%") } })
end, {})

api.nvim_create_user_command("TigLog", function()
  tig({ fargs = { "log", "-p", "--", fn.expand("%") } })
end, {})

mercurial