Browse Source

Add keybind to show commit from current line

master
Tovi Jaeschke-Rogers 12 months ago
parent
commit
a66ee40f2e
2 changed files with 24 additions and 8 deletions
  1. +8
    -8
      .config/nvim/lua/tovi/plugins/formatting.lua
  2. +16
    -0
      .config/nvim/lua/tovi/plugins/fugitive.lua

+ 8
- 8
.config/nvim/lua/tovi/plugins/formatting.lua View File

@ -19,14 +19,14 @@ return {
shell = { "shfmt", "shellcheck" },
python = { "isort", "black" },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500,
},
format_after_save = {
lsp_fallback = true,
},
-- format_on_save = {
-- lsp_fallback = true,
-- async = false,
-- timeout_ms = 500,
-- },
-- format_after_save = {
-- lsp_fallback = true,
-- },
log_level = vim.log.levels.WARN,
notify_on_error = false,
})


+ 16
- 0
.config/nvim/lua/tovi/plugins/fugitive.lua View File

@ -9,5 +9,21 @@ return {
vim.api.nvim_set_keymap("n", "<leader>gl", ":GBrowse<CR>", { noremap = true })
vim.cmd([[ let g:fugitive_gitlab_domains = {"ssh://code.codium.com.au": "https://code.codium.com.au"} ]])
local function gitBlame(lines)
local current_file = vim.fn.expand('%:p')
local range = lines[1] .. "," .. lines[2]
local cmd = string.format("git -C %s blame -L %s %s | awk '{print $1}'", vim.fn.shellescape(vim.fn.fnamemodify(current_file, ':h')), range, vim.fn.fnamemodify(current_file, ':t'))
local handle = io.popen(cmd)
local result = handle:read("*a")
handle:close()
return result
end
vim.keymap.set('n', '<leader>gc', function ()
vim.cmd(string.format('Git show %s', gitBlame({vim.fn.line('.'), vim.fn.line('.')})))
end)
end,
}

Loading…
Cancel
Save