use jj.nvim instead of custom jank
Some checks failed
build / build (nvim-min) (push) Failing after 37m5s

This commit is contained in:
iofq 2026-01-18 02:20:54 -06:00
parent 3c5c3a6745
commit 7a86861f09
7 changed files with 57 additions and 100 deletions

17
flake.lock generated
View file

@ -178,6 +178,22 @@
"type": "github"
}
},
"jj-nvim": {
"flake": false,
"locked": {
"lastModified": 1768169857,
"narHash": "sha256-8POSGuNYdAR2peyzN92vWR87GqWf+Y6I1arOwNxwd6U=",
"owner": "NicolasGB",
"repo": "jj.nvim",
"rev": "d13a5c9aec08318323f19fcdc1a1d2c469e00739",
"type": "github"
},
"original": {
"owner": "NicolasGB",
"repo": "jj.nvim",
"type": "github"
}
},
"luvit-meta": {
"flake": false,
"locked": {
@ -296,6 +312,7 @@
"dart": "dart",
"flake-utils": "flake-utils_2",
"gen-luarc": "gen-luarc",
"jj-nvim": "jj-nvim",
"neovim-nightly-overlay": "neovim-nightly-overlay",
"nixpkgs": "nixpkgs_2"
}

View file

@ -15,6 +15,10 @@
dart = {
url = "github:iofq/dart.nvim";
};
jj-nvim = {
url = "github:NicolasGB/jj.nvim";
flake = false;
};
};
outputs =
inputs@{

View file

@ -4,12 +4,20 @@ final: prev:
let
mkNeovim = prev.callPackage ./mkNeovim.nix { pkgs = final; };
dart-nvim = inputs.dart.packages.x86_64-linux.default;
mkPlugin =
src: pname:
prev.vimUtils.buildVimPlugin {
inherit pname src;
version = src.lastModifiedDate;
};
jj-nvim = mkPlugin inputs.jj-nvim "jj-nvim";
plugins = with prev.vimPlugins; [
blink-cmp
blink-ripgrep-nvim
conform-nvim
dart-nvim
jj-nvim
mini-nvim
nvim-autopairs
nvim-lint

View file

@ -0,0 +1,17 @@
local M = {}
M.is_jj_diffedit_open = function()
local qf = vim.fn.getqflist()
local entry = qf[1]
if not entry or not entry.user_data or not entry.user_data.diff then
return 0
else
return 1
end
end
M.diffedit = function()
vim.fn.jobstart('jj diffedit --tool diffview-new')
end
return M

View file

@ -1,90 +0,0 @@
local M = {}
function M.status()
local function get_files()
local status_raw = vim.fn.system('jj diff --no-pager --quiet --summary')
local files = {}
for status in status_raw:gmatch('[^\r\n]+') do
local state, file = string.match(status, '^(%a)%s(.+)$')
if state and file then
local hl = ''
if state == 'A' then
hl = 'SnacksPickerGitStatusAdded'
elseif state == 'M' then
hl = 'SnacksPickerGitStatusModified'
elseif state == 'D' then
hl = 'SnacksPickerGitStatusDeleted'
elseif state == 'R' then
hl = 'SnacksPickerGitStatusRenamed'
file = string.match(file, '{.-=>%s*(.-)}')
end
local diff = vim.fn.system('jj diff ' .. file .. ' --no-pager --stat --git')
table.insert(files, {
file = file,
filename_hl = hl,
diff = diff,
})
end
end
return files
end
Snacks.picker.pick {
source = 'jj_status',
items = get_files(),
format = 'file',
title = 'jj status',
preview = function(ctx)
if ctx.item.file then
Snacks.picker.preview.diff(ctx)
else
ctx.preview:reset()
ctx.preview:set_title('No preview')
end
end,
}
end
function M.file_history(filename)
local function preview(ctx)
if ctx.item.rev then
Snacks.picker.preview.cmd(
{ 'jj', 'log', '--ignore-working-copy', '--git', '-r', ctx.item.rev, '-p', filename },
ctx
)
else
ctx.preview:reset()
return 'No preview available.'
end
end
local function get_history(f)
local status_raw = vim.fn.system(
'jj log --ignore-working-copy --no-graph'
.. ' --template \'if(root, format_root_commit(self), label(if(current_working_copy, "working_copy"), concat(separate(" ", self.change_id().shortest(8), self.bookmarks()), " | ", if(empty, label("empty", "(empty)")), if(description, description.first_line(), label(if(empty, "empty"), description_placeholder),),) ++ "\n",),)\''
.. ' -- '
.. f
)
local lines = {}
for line in status_raw:gmatch('[^\r\n]+') do
local rev = string.match(line, '(%w+)%s.*')
table.insert(lines, {
text = line,
rev = rev,
})
end
return lines
end
Snacks.picker.pick {
format = 'text',
title = 'jj file history for ' .. filename,
items = get_history(filename),
preview = preview,
}
end
return M

View file

@ -9,17 +9,12 @@ vim.schedule(function()
ai.setup {
n_lines = 300,
custom_textobjects = {
i = require('mini.extra').gen_ai_spec.indent(),
a = ai.gen_spec.treesitter { a = '@parameter.outer', i = '@parameter.inner' },
f = ai.gen_spec.treesitter { a = '@function.outer', i = '@function.inner' },
},
}
require('mini.git').setup()
map('n', '<leader>gb', '<Cmd>Git blame -- %<CR>')
map('n', '<leader>go', function()
return MiniGit.show_at_cursor()
end)
local jump = require('mini.jump2d')
jump.setup {
mappings = {

View file

@ -55,16 +55,22 @@ map('n', '<leader>fj', Snacks.picker.jumps)
map('n', '<leader>f.', Snacks.picker.resume)
map('n', '<leader>fb', Snacks.picker.buffers)
map('n', '<leader>fq', Snacks.picker.qflist)
map('n', '<leader>jf', require('iofq.snacks_jj').status)
map('n', '<leader>jh', function()
require('iofq.snacks_jj').file_history(vim.api.nvim_buf_get_name(0))
end)
vim.schedule(function()
require('nvim-treesitter').setup()
require('nvim-treesitter-textobjects').setup()
require('nvim-autopairs').setup()
require('jj').setup {}
map('n', '<leader>gb', require('jj.annotate').file)
map('n', '<leader>jf', require('jj.picker').status)
map('n', '<leader>jj', require('jj.cmd').log)
map('n', '<leader>jh', require('jj.picker').file_history)
map('n', '<leader>je', require('iofq.jj').diffedit)
map('n', '<leader>jd', function()
require('jj.diff').open_vdiff { rev = 'trunk()' }
end)
require('quicker').setup()
map('n', '<leader>qf', function()
require('quicker').toggle { max_height = 20 }