mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-05 02:36:07 +00:00
refactor: restructure the whole plugin following a better separation of concers
This commit is contained in:
+31
-3
@@ -1,6 +1,8 @@
|
||||
local M = {}
|
||||
local cmd = require("jj.cmd")
|
||||
local picker = require("jj.picker")
|
||||
local editor = require("jj.ui.editor")
|
||||
local diff = require("jj.diff")
|
||||
local utils = require("jj.utils")
|
||||
|
||||
--- Jujutsu plugin configuration
|
||||
@@ -11,14 +13,14 @@ M.config = {
|
||||
picker = {
|
||||
snacks = {},
|
||||
},
|
||||
--- @type jj.utils.highlights Highlight configuration for describe buffer
|
||||
--- @type jj.ui.editor.highlights Highlight configuration for describe buffer
|
||||
highlights = {
|
||||
added = { fg = "#3fb950", ctermfg = "Green" },
|
||||
modified = { fg = "#56d4dd", ctermfg = "Cyan" },
|
||||
deleted = { fg = "#f85149", ctermfg = "Red" },
|
||||
renamed = { fg = "#d29922", ctermfg = "Yellow" },
|
||||
},
|
||||
--- @type string Editor mode for describe command: "buffer" (Git-style editor) or "input" (simple input prompt)
|
||||
--- @type "buffer"|"input" Editor mode for describe command: "buffer" (Git-style editor) or "input" (simple input prompt)
|
||||
describe_editor = "buffer",
|
||||
}
|
||||
|
||||
@@ -27,8 +29,10 @@ M.config = {
|
||||
function M.setup(opts)
|
||||
M.config = vim.tbl_deep_extend("force", M.config, opts or {})
|
||||
|
||||
-- Setup for sub-modules
|
||||
picker.setup(opts and opts.picker or {})
|
||||
utils.setup({ highlights = M.config.highlights })
|
||||
editor.setup({ highlights = M.config.highlights })
|
||||
utils.setup(opts) -- Keep for future-proofing, even if it's a no-op now
|
||||
|
||||
-- Pass describe_editor config to cmd module
|
||||
if opts and opts.describe_editor then
|
||||
@@ -36,6 +40,30 @@ function M.setup(opts)
|
||||
end
|
||||
|
||||
cmd.register_command()
|
||||
|
||||
-- Expose public API functions on the top-level module
|
||||
M.status = cmd.status
|
||||
M.describe = cmd.describe
|
||||
M.log = cmd.log
|
||||
M.new = cmd.new
|
||||
M.edit = cmd.edit
|
||||
M.squash = cmd.squash
|
||||
M.rebase = cmd.rebase
|
||||
M.undo = cmd.undo
|
||||
M.redo = cmd.redo
|
||||
M.bookmark_create = cmd.bookmark_create
|
||||
M.bookmark_delete = cmd.bookmark_delete
|
||||
M.j = cmd.j
|
||||
|
||||
M.picker = {
|
||||
status = picker.status,
|
||||
file_history = picker.file_history,
|
||||
}
|
||||
|
||||
M.diff = {
|
||||
vsplit = diff.open_vdiff,
|
||||
hsplit = diff.open_hdiff,
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user