From 786b28fba535cd0a658fcd372db133296506e9c0 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sat, 24 Feb 2024 21:08:01 +0100 Subject: [PATCH] vim: Apply `gitcommit` options to `NeogitCommitMessage` buffers --- config/nvim/after/ftplugin/gitcommit.lua | 4 +--- config/nvim/lua/fschauen/autocmd.lua | 9 +++++++++ config/nvim/lua/fschauen/util/options.lua | 7 +++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/config/nvim/after/ftplugin/gitcommit.lua b/config/nvim/after/ftplugin/gitcommit.lua index 6ff2460..e8bcc2b 100644 --- a/config/nvim/after/ftplugin/gitcommit.lua +++ b/config/nvim/after/ftplugin/gitcommit.lua @@ -1,4 +1,2 @@ -vim.bo.textwidth = 72 -vim.opt.formatoptions:append('t') -- wrap text on 'textwidth' -vim.opt.spell = true -- turn on spell checking +require("fschauen.util.options").set_gitcommit_buffer_options() diff --git a/config/nvim/lua/fschauen/autocmd.lua b/config/nvim/lua/fschauen/autocmd.lua index 621521d..c24ef12 100644 --- a/config/nvim/lua/fschauen/autocmd.lua +++ b/config/nvim/lua/fschauen/autocmd.lua @@ -29,6 +29,15 @@ M.setup = function() vim.opt.cursorlineopt = "both" end, }) + + vim.api.nvim_create_autocmd("FileType", { + desc = "Replicate gitcommit filetype options for Neogit commit.", + group = group, + pattern = "NeogitCommitMessage", + callback = function(_) + require("fschauen.util.options").set_gitcommit_buffer_options() + end, + }) end return M diff --git a/config/nvim/lua/fschauen/util/options.lua b/config/nvim/lua/fschauen/util/options.lua index 2f117a8..1685ad8 100644 --- a/config/nvim/lua/fschauen/util/options.lua +++ b/config/nvim/lua/fschauen/util/options.lua @@ -25,4 +25,11 @@ M.toggle_spell = function() vim.cmd([[set spell?]]) end +M.set_gitcommit_buffer_options = function() + print('here we are!') + vim.bo.textwidth = 72 + vim.opt.formatoptions:append('t') -- wrap text on 'textwidth' + vim.opt.spell = true -- turn on spell checking +end + return M