summaryrefslogtreecommitdiffstats
path: root/.config/nvim/after/ftplugin/gitcommit.lua
blob: c30f6c538dc4fe9fc54d068233d536050ee21d26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
vim.opt_local.colorcolumn = "+1" -- Highlight one column after 'textwidth'
vim.opt_local.tabstop = 2 -- CommonMark expects two spaces for indentation
vim.opt_local.shiftwidth = 0
vim.opt_local.softtabstop = -1
vim.opt_local.expandtab = true -- Change tabs to spaces
vim.opt_local.spelllang = "en_us"
vim.opt_local.complete = {
	"w", -- other windows
	".", -- current buffer
}

vim.api.nvim_create_autocmd("BufWinEnter", {
	desc = "Set up gitcommit buffer",
	group = vim.g.dotfiles.augroup,
	buffer = 0,
	callback = function()
		local gitcommit_window = vim.api.nvim_get_current_win()
		-- Open cached diff window
		vim.cmd.DiffGitCached()
		vim.cmd.wincmd("L")
		-- Enable English spell check in the original window
		-- If `'spell'` is set before `:DiffGitCached` it propagates to the cached diff window (that we don't want)
		vim.api.nvim_set_option_value("spell", true, { win = gitcommit_window })
		-- The current window is the diff window
		vim.o.filetype = "diff"
		vim.o.foldenable = false
	end,
})