Skip to content

Commit

Permalink
Breaking!: Use gitcommit and gitrebase filetypes instead of custom
Browse files Browse the repository at this point in the history
NeogitCommitMessage -> gitcommit
NeogitBranchDescription -> gitcommit
NeogitMergeMessage -> gitcommit
NeogitTagMessage  -> gitcommit
NeogitRebaseTodo -> gitrebase
  • Loading branch information
CKolkey committed Oct 31, 2024
1 parent 001f43f commit 1f2d65e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 35 deletions.
25 changes: 5 additions & 20 deletions lua/neogit/buffers/editor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
17 changes: 2 additions & 15 deletions lua/neogit/buffers/rebase_editor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,15 @@ 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,
modifiable = true,
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
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 1f2d65e

Please sign in to comment.