From 1f2d65ecf836c8767db319814e7abe9f44554191 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 31 Oct 2024 12:03:37 +0100 Subject: [PATCH] Breaking!: Use `gitcommit` and `gitrebase` filetypes instead of custom NeogitCommitMessage -> gitcommit NeogitBranchDescription -> gitcommit NeogitMergeMessage -> gitcommit NeogitTagMessage -> gitcommit NeogitRebaseTodo -> gitrebase --- lua/neogit/buffers/editor/init.lua | 25 +++++------------------ lua/neogit/buffers/rebase_editor/init.lua | 17 ++------------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/lua/neogit/buffers/editor/init.lua b/lua/neogit/buffers/editor/init.lua index dbfff356e..4d1b631ea 100644 --- a/lua/neogit/buffers/editor/init.lua +++ b/lua/neogit/buffers/editor/init.lua @@ -13,10 +13,10 @@ local pad = util.pad_right local M = {} local filetypes = { - ["COMMIT_EDITMSG"] = "NeogitCommitMessage", - ["MERGE_MSG"] = "NeogitMergeMessage", - ["TAG_EDITMSG"] = "NeogitTagMessage", - ["EDIT_DESCRIPTION"] = "NeogitBranchDescription", + ["COMMIT_EDITMSG"] = "gitcommit", + ["MERGE_MSG"] = "gitcommit", + ["TAG_EDITMSG"] = "gitcommit", + ["EDIT_DESCRIPTION"] = "gitcommit", } ---@class EditorBuffer @@ -96,10 +96,8 @@ function M:open(kind) end end, }, - on_detach = function(buffer) + on_detach = function() logger.debug("[EDITOR] Cleaning Up") - pcall(vim.treesitter.stop, buffer.handle) - if self.on_unload then logger.debug("[EDITOR] Running on_unload callback") self.on_unload(aborted and 1 or 0) @@ -171,19 +169,6 @@ function M:open(kind) vim.cmd(":startinsert") end - -- Source runtime ftplugin - vim.cmd.source("$VIMRUNTIME/ftplugin/gitcommit.vim") - - -- Apply syntax highlighting - local ok, _ = pcall(vim.treesitter.language.inspect, "gitcommit") - if ok then - logger.debug("[EDITOR] Loading treesitter for gitcommit") - vim.treesitter.start(buffer.handle, "gitcommit") - else - logger.debug("[EDITOR] Loading syntax for gitcommit") - vim.cmd.source("$VIMRUNTIME/syntax/gitcommit.vim") - end - if git.branch.current() then vim.fn.matchadd("NeogitBranch", git.branch.current(), 100) end diff --git a/lua/neogit/buffers/rebase_editor/init.lua b/lua/neogit/buffers/rebase_editor/init.lua index 671a4b93b..c4bc9b393 100644 --- a/lua/neogit/buffers/rebase_editor/init.lua +++ b/lua/neogit/buffers/rebase_editor/init.lua @@ -72,7 +72,7 @@ function M:open(kind) self.buffer = Buffer.create { name = self.filename, load = true, - filetype = "NeogitRebaseTodo", + filetype = "gitrebase", buftype = "", status_column = not config.values.disable_signs and "" or nil, kind = kind, @@ -80,9 +80,7 @@ function M:open(kind) disable_line_numbers = config.values.disable_line_numbers, disable_relative_line_numbers = config.values.disable_relative_line_numbers, readonly = false, - on_detach = function(buffer) - pcall(vim.treesitter.stop, buffer.handle) - + on_detach = function() if self.on_unload then self.on_unload(aborted and 1 or 0) end @@ -130,17 +128,6 @@ function M:open(kind) buffer:set_lines(-1, -1, false, help_lines) buffer:write() buffer:move_cursor(1) - - -- Source runtime ftplugin - vim.cmd.source("$VIMRUNTIME/ftplugin/gitrebase.vim") - - -- Apply syntax highlighting - local ok, _ = pcall(vim.treesitter.language.inspect, "git_rebase") - if ok then - vim.treesitter.start(buffer.handle, "git_rebase") - else - vim.cmd.source("$VIMRUNTIME/syntax/gitrebase.vim") - end end, mappings = { i = {