Compare commits

..

3 commits

Author SHA1 Message Date
f6e4e39f2f jj file hist 2025-10-22 02:08:39 -05:00
ce017fd37c fix os.execute return
Some checks failed
build / build (nvim-min) (push) Has been cancelled
2025-10-15 19:53:57 -05:00
35b0e05965 fix local flake path 2025-10-15 19:41:31 -05:00
6 changed files with 81 additions and 36 deletions

69
flake.lock generated
View file

@ -6,14 +6,17 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1760318820, "lastModified": 1760745932,
"narHash": "sha256-3ETm+AZ/UEU0OYFSYviMSv/Ov4BN1cEsBH6KNGuTYS4=", "narHash": "sha256-Z9idyP9kiKxC10VL0vHnxcBwrkpNtBrC+Zxl9mQbCj8=",
"path": "/home/e/dev/dart.nvim", "owner": "iofq",
"type": "path" "repo": "dart.nvim",
"rev": "26b476f2113143329637a27d4e52ce9772bcae5b",
"type": "github"
}, },
"original": { "original": {
"path": "/home/e/dev/dart.nvim", "owner": "iofq",
"type": "path" "repo": "dart.nvim",
"type": "github"
} }
}, },
"flake-compat": { "flake-compat": {
@ -90,11 +93,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1759362264, "lastModified": 1760813311,
"narHash": "sha256-wfG0S7pltlYyZTM+qqlhJ7GMw2fTF4mLKCIVhLii/4M=", "narHash": "sha256-lbHQ7FXGzt6/IygWvJ1lCq+Txcut3xYYd6VIpF1ojkg=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "758cf7296bee11f1706a574c77d072b8a7baa881", "rev": "4e627ac2e1b8f1de7f5090064242de9a259dbbc8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -195,11 +198,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1759523803, "lastModified": 1760663237,
"narHash": "sha256-PTod9NG+i3XbbnBKMl/e5uHDBYpwIWivQ3gOWSEuIEM=", "narHash": "sha256-BflA6U4AM1bzuRMR8QqzPXqh8sWVCNDzOdsxXEguJIc=",
"owner": "cachix", "owner": "cachix",
"repo": "git-hooks.nix", "repo": "git-hooks.nix",
"rev": "cfc9f7bb163ad8542029d303e599c0f7eee09835", "rev": "ca5b894d3e3e151ffc1db040b6ce4dcc75d31c37",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -306,11 +309,11 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1760313895, "lastModified": 1760832323,
"narHash": "sha256-39JFRb006AOsIcOq+03H3y6YcGyaphk1CW5DRi14cOE=", "narHash": "sha256-THAk4qzBOsp03bDBYK9Ek3mQEvl2g8Fea0QhpCoEzfs=",
"owner": "nix-community", "owner": "nix-community",
"repo": "neovim-nightly-overlay", "repo": "neovim-nightly-overlay",
"rev": "7ff73a295b0065bde2f8b43b31558136ca77bd98", "rev": "3c9432813e5528a13075f5493da6ff9ef249ad1d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -322,11 +325,11 @@
"neovim-src": { "neovim-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1760312166, "lastModified": 1760810839,
"narHash": "sha256-RnB+oJcP37YT9pjr1osUQtJc+1qcVyaaeSbiSyXwm1Y=", "narHash": "sha256-VYkZdjjMOYsugoSydDDWE/1l79swm4zc4NJl1Z0brjA=",
"owner": "neovim", "owner": "neovim",
"repo": "neovim", "repo": "neovim",
"rev": "72b0bfa1fb7e897e5126aabae718a5480f466b9e", "rev": "be73c35943f85e7835c3a0fc89bddaeba944db29",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -380,11 +383,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1760326837, "lastModified": 1760913523,
"narHash": "sha256-z+C6KRPRjwqEsTEAwUavapBWcbR7YOlQP91O+W5L1ek=", "narHash": "sha256-Il5+67iRA3xp0cIErILj4VwEJ2ICrDrvTAHEmBsZJKQ=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "cfe6b045750c3aa5127817bc3f44f2909b1ee175", "rev": "6a3b08503e9cab108f9f0ec27065c5854655662a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -396,11 +399,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1760038930, "lastModified": 1760524057,
"narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=", "narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3", "rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -413,11 +416,11 @@
"nvim-treesitter": { "nvim-treesitter": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1760260935, "lastModified": 1760866486,
"narHash": "sha256-To/syCZPs7vKA0WkuBz7ZxCGT/wzj705QfxZng6Nsjo=", "narHash": "sha256-ZeNCXy6+I18N+Nu2sKnEk2otVEb8V3tKhL8Jq95wS5k=",
"owner": "nvim-treesitter", "owner": "nvim-treesitter",
"repo": "nvim-treesitter", "repo": "nvim-treesitter",
"rev": "0606c7a9dcaa5c5beee0b0f09043e9fdd1ba0a68", "rev": "71bf1665f804d46f7e4b24ad7ffc11f6ea5b271a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -434,11 +437,11 @@
"nvim-treesitter-textobjects": "nvim-treesitter-textobjects" "nvim-treesitter-textobjects": "nvim-treesitter-textobjects"
}, },
"locked": { "locked": {
"lastModified": 1760324917, "lastModified": 1760906917,
"narHash": "sha256-ZlVGaUbxHf4DNR4GWhF1mvlMhP8IBbwF0g8WO1SL+Yw=", "narHash": "sha256-WJScDX0q/+PCRpvBSlJfV01kwvu9WCk5YDpzW2Zswj8=",
"owner": "iofq", "owner": "iofq",
"repo": "nvim-treesitter-main", "repo": "nvim-treesitter-main",
"rev": "da2262419eb66cfa426aa62ccf1fc8fdea33b4a0", "rev": "420c14c0523d65c6c7ce943e8f2fb896eff950e3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -512,11 +515,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1760120816, "lastModified": 1760802554,
"narHash": "sha256-gq9rdocpmRZCwLS5vsHozwB6b5nrOBDNc2kkEaTXHfg=", "narHash": "sha256-5YkOYOCF8/XNw89/ABKFB0c/P78U2EVuKRDGTql6+kA=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "761ae7aff00907b607125b2f57338b74177697ed", "rev": "296ebf0c3668ebceb3b0bfee55298f112b4b5754",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -13,7 +13,7 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
dart = { dart = {
url = "path:/home/e/dev/dart.nvim"; url = "github:iofq/dart.nvim";
}; };
nvim-treesitter-main = { nvim-treesitter-main = {
url = "github:iofq/nvim-treesitter-main"; url = "github:iofq/nvim-treesitter-main";

1
new Normal file
View file

@ -0,0 +1 @@
print('kjsnadf')

View file

@ -49,4 +49,42 @@ function M.status()
} }
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 return M

View file

@ -35,13 +35,13 @@ vim.api.nvim_create_autocmd('FileType', {
group = vim.api.nvim_create_augroup('difftool', { clear = true }), group = vim.api.nvim_create_augroup('difftool', { clear = true }),
callback = function(event) callback = function(event)
local function exec(fmt, str) local function exec(fmt, str)
os.execute(string.format(fmt, str)) return os.execute(string.format(fmt, str))
end end
local function refresh() local function refresh()
local qf = vim.fn.getqflist() local qf = vim.fn.getqflist()
local entry = qf[1] local entry = qf[1]
if not entry or not entry.user_data.diff then if not entry or not entry.user_data or not entry.user_data.diff then
return nil return nil
end end

View file

@ -56,6 +56,9 @@ map('n', '<leader>f.', Snacks.picker.resume)
map('n', '<leader>fb', Snacks.picker.buffers) map('n', '<leader>fb', Snacks.picker.buffers)
map('n', '<leader>fq', Snacks.picker.qflist) map('n', '<leader>fq', Snacks.picker.qflist)
map('n', '<leader>jf', require('iofq.snacks_jj').status) 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() vim.schedule(function()
require('nvim-treesitter').setup() require('nvim-treesitter').setup()