From 2bdfb291aea22dee8898658df97ee83fc8694b95 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 9 May 2025 21:53:53 +0200 Subject: [PATCH] nvim: Add jj source to neotree --- nvim/.config/nvim/lazy-lock.json | 1 + nvim/.config/nvim/lua/plugins/git.lua | 24 ++++++------ nvim/.config/nvim/lua/plugins/pickers.lua | 47 +++++++++++++++++++++-- 3 files changed, 58 insertions(+), 14 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 263c56a..dbe4963 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -42,6 +42,7 @@ "mdeval.nvim": { "branch": "master", "commit": "0e1b248db174a9659a9ab16eb8c90ff3aec55264" }, "mini.nvim": { "branch": "main", "commit": "0420076298c4457f200c2de468f65d080597a347" }, "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, + "neo-tree-jj.nvim": { "branch": "main", "commit": "c6534930c6f79893e12eafbb722ee23e6a83e80e" }, "neo-tree.nvim": { "branch": "main", "commit": "1ef260eb4f54515fe121a2267b477efb054d108a" }, "neogen": { "branch": "main", "commit": "b2e78708876f4da507839726816010a68e33fec8" }, "neotest": { "branch": "master", "commit": "d66cf4e05a116957f0d3a7755a24291c7d1e1f72" }, diff --git a/nvim/.config/nvim/lua/plugins/git.lua b/nvim/.config/nvim/lua/plugins/git.lua index bf443ca..d466133 100644 --- a/nvim/.config/nvim/lua/plugins/git.lua +++ b/nvim/.config/nvim/lua/plugins/git.lua @@ -1,15 +1,4 @@ return { - { - "julienvincent/hunk.nvim", - dependencies = { - "MunifTanjim/nui.nvim", - { "nvim-tree/nvim-web-devicons", optional = true }, - }, - cmd = { "DiffEditor" }, - config = function() - require("hunk").setup() - end, - }, { "akinsho/git-conflict.nvim", event = { "InsertEnter", "CursorHold", "VeryLazy" }, @@ -106,4 +95,17 @@ return { }) end, }, + + -- jj diffing + { + "julienvincent/hunk.nvim", + dependencies = { + "MunifTanjim/nui.nvim", + { "nvim-tree/nvim-web-devicons", optional = true }, + }, + cmd = { "DiffEditor" }, + config = function() + require("hunk").setup() + end, + }, } diff --git a/nvim/.config/nvim/lua/plugins/pickers.lua b/nvim/.config/nvim/lua/plugins/pickers.lua index 3682999..120ac26 100644 --- a/nvim/.config/nvim/lua/plugins/pickers.lua +++ b/nvim/.config/nvim/lua/plugins/pickers.lua @@ -38,13 +38,54 @@ return { -- file/item pickers and managers }) end, cmd = "Neotree", - opts = { - source_selector = { winbar = true }, - }, + opts = function(_, opts) + opts.sources = { "filesystem", "git_status", "buffers" } + opts.source_selector = { + winbar = true, + sources = { + { source = "filesystem" }, + { source = "git_status" }, + }, + } + opts.close_if_last_window = true + opts.enable_cursor_hijack = true + end, keys = { { "se", "Neotree toggle left", desc = "filetree", silent = true }, }, }, + { -- substituting git tree listing with jj listing if in jj repo + dependencies = { "Cretezy/neo-tree-jj.nvim" }, + "nvim-neo-tree/neo-tree.nvim", + optional = true, + opts = function(_, opts) + opts.sources = opts.sources or {} + opts.source_selector = opts.source_selector or {} + -- Add jj source as available + table.insert(opts.sources, "jj") + -- If there is a git tab in neo-tree replace it when in jj repo + if require("neo-tree.sources.jj.utils").get_repository_root() then + -- Remove git tab + if opts.source_selector.sources then + for i, source in ipairs(opts.source_selector.sources) do + if source.source == "git_status" then + table.remove(opts.source_selector.sources, i) + break + end + end + else + opts.source_selector.sources = {} + end + + -- Add jj tab + table.insert(opts.source_selector.sources, { + display_name = "󰊢 JJ", + source = "jj", + }) + end + end, + }, + { "MagicDuck/grug-far.nvim", opts = {}, cmd = "GrugFar" }, { "ibhagwan/fzf-lua",