From a4e6a3d5f72f5c2bd3ed7e0d4bc363eb7b562889 Mon Sep 17 00:00:00 2001 From: Charles Crete Date: Fri, 10 May 2024 14:55:31 -0400 Subject: [PATCH] pack(jj): Add lazyjj --- lua/astrocommunity/pack/jj/README.md | 1 + lua/astrocommunity/pack/jj/init.lua | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lua/astrocommunity/pack/jj/README.md b/lua/astrocommunity/pack/jj/README.md index 29d8e31ec..eddcbb22d 100644 --- a/lua/astrocommunity/pack/jj/README.md +++ b/lua/astrocommunity/pack/jj/README.md @@ -10,3 +10,4 @@ This plugin pack does the following: - `jd` for files with changes, like `jj diff` - `jc` for files with conflicts, like `jj resolve --list` - Adds syntax highlighting for `.jjdescription` files (for use with `jj describe`) with [vim-jjdescription](https://github.com/avm99963/vim-jjdescription) +- Adds a [lazyjj](https://github.com/Cretezy/lazyjj) (TUI for jj) terminal with `jl` when `lazyjj` is in `$PATH` diff --git a/lua/astrocommunity/pack/jj/init.lua b/lua/astrocommunity/pack/jj/init.lua index 238bcf54b..e60e594ec 100644 --- a/lua/astrocommunity/pack/jj/init.lua +++ b/lua/astrocommunity/pack/jj/init.lua @@ -58,4 +58,23 @@ return { }, }, { "avm99963/vim-jjdescription", lazy = false }, + { + "AstroNvim/astrocore", + ---@param opts AstroCoreOpts + opts = function(_, opts) + local maps = assert(opts.mappings) + + if vim.fn.executable "lazyjj" == 1 then + maps.n["jl"] = { + function() + local astro = require "astrocore" + local worktree = astro.file_worktree() + local flags = worktree and ("--path '%s'"):format(worktree.toplevel, worktree.gitdir) or "" + astro.toggle_term_cmd("lazyjj " .. flags) + end, + desc = "lazyjj", + } + end + end, + }, }