This commit is contained in:
parent
472d9b0b05
commit
8694c7d81f
3 changed files with 70 additions and 137 deletions
|
|
@ -21,50 +21,4 @@
|
|||
nix-hash --type sha256 --to-base64 (nix-prefetch-url $argv)
|
||||
'';
|
||||
};
|
||||
fish_jj_prompt = {
|
||||
body = ''
|
||||
if not command -sq jj
|
||||
return 1
|
||||
end
|
||||
if not command -sq timeout
|
||||
return 1
|
||||
end
|
||||
if set -q FISH_JJ
|
||||
return 0
|
||||
end
|
||||
if not jj workspace root --ignore-working-copy &>/dev/null
|
||||
return 1
|
||||
end
|
||||
|
||||
# Generate prompt
|
||||
set -l info "$(
|
||||
timeout 5 jj log --ignore-working-copy --no-graph --color=always --revisions=@ --template "
|
||||
separate(
|
||||
' ',
|
||||
self.change_id().shortest(),
|
||||
bookmarks.join(', '),
|
||||
if(conflict, label('conflict', '×')),
|
||||
if(empty, label('empty', '(empty)')),
|
||||
if(divergent, label('divergent', '(divergent)')),
|
||||
if(hidden, label('hidden', '(hidden)')),
|
||||
)
|
||||
"
|
||||
)"
|
||||
or return 1
|
||||
|
||||
if test -n $info
|
||||
printf ' (jj: %s)' $info
|
||||
else
|
||||
return 1
|
||||
end
|
||||
'';
|
||||
};
|
||||
fish_vcs_prompt = {
|
||||
body = ''
|
||||
fish_jj_prompt $argv
|
||||
or fish_git_prompt $argv
|
||||
or fish_hg_prompt $argv
|
||||
or fish_fossil_prompt $argv
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
default-command = [ "log" ];
|
||||
conflict-marker-style = "git";
|
||||
merge-editor = "vimdiff";
|
||||
diff-editor = "diffview";
|
||||
diff-editor = "difftool";
|
||||
diff-instructions = false;
|
||||
diff-formatter = ":git";
|
||||
movement = {
|
||||
|
|
@ -65,81 +65,43 @@
|
|||
merge-tools.vimdiff = {
|
||||
program = "nvim";
|
||||
};
|
||||
merge-tools.diffview = {
|
||||
program = "sh";
|
||||
edit-args = [
|
||||
"-c"
|
||||
''
|
||||
set -eu
|
||||
rm -f "$right/JJ-INSTRUCTIONS"
|
||||
git -C "$left" init -q
|
||||
git -C "$left" add -A
|
||||
git -C "$left" commit -q -m baseline --allow-empty
|
||||
mv "$left/.git" "$right"
|
||||
git -C "$right" add --intent-to-add -A
|
||||
(cd "$right"; nix run /home/e/dev/nvim.nix/ -- -c "lua require('difftool').open('$left', '$right', {ignore = { '.git', '.jj' }})")
|
||||
git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
|
||||
git -C "$right" commit -q -m split
|
||||
git -C "$right" restore . # undo changes in modified files
|
||||
git -C "$right" reset . # undo --intent-to-add
|
||||
git -C "$right" clean -q -df # remove untracked files
|
||||
''
|
||||
];
|
||||
diff-args = [
|
||||
"-c"
|
||||
''
|
||||
set -eu
|
||||
rm -f "$right/JJ-INSTRUCTIONS"
|
||||
git -C "$left" init -q
|
||||
git -C "$left" add -A
|
||||
git -C "$left" commit -q -m baseline --allow-empty
|
||||
mv "$left/.git" "$right"
|
||||
git -C "$right" add --intent-to-add -A
|
||||
(cd "$right"; nvim -c "lua vim.g.snacks_indent=false" -c "lua require('lazy').load({plugins = {'diffview.nvim'}})" -c DiffviewOpen)
|
||||
git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
|
||||
git -C "$right" commit -q -m split
|
||||
git -C "$right" restore . # undo changes in modified files
|
||||
git -C "$right" reset . # undo --intent-to-add
|
||||
git -C "$right" clean -q -df # remove untracked files
|
||||
''
|
||||
];
|
||||
};
|
||||
merge-tools.diffview-new = {
|
||||
program = "sh";
|
||||
edit-args = [
|
||||
"-c"
|
||||
''
|
||||
set -eux
|
||||
nix run /home/e/dev/nvim.nix -- \
|
||||
--server $NVIM \
|
||||
--remote-send "<cmd>lua require('difftool').open('$left', '$right', {ignore = { '.git', '.jj' }})<cr>"
|
||||
until nix run /home/e/dev/nvim.nix -- \
|
||||
--headless \
|
||||
--server "$NVIM" \
|
||||
--remote-expr "v:lua.require'iofq.jj'.is_jj_diffedit_open()" 2>/dev/null | grep 0; do
|
||||
sleep 1
|
||||
done
|
||||
''
|
||||
];
|
||||
diff-args = [
|
||||
"-c"
|
||||
''
|
||||
set -eu
|
||||
rm -f "$right/JJ-INSTRUCTIONS"
|
||||
git -C "$left" init -q
|
||||
git -C "$left" add -A
|
||||
git -C "$left" commit -q -m baseline --allow-empty
|
||||
mv "$left/.git" "$right"
|
||||
git -C "$right" add --intent-to-add -A
|
||||
(cd "$right"; nvim -c "lua vim.g.snacks_indent=false" -c "lua require('lazy').load({plugins = {'diffview.nvim'}})" -c DiffviewOpen)
|
||||
git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
|
||||
git -C "$right" commit -q -m split
|
||||
git -C "$right" restore . # undo changes in modified files
|
||||
git -C "$right" reset . # undo --intent-to-add
|
||||
git -C "$right" clean -q -df # remove untracked files
|
||||
''
|
||||
];
|
||||
};
|
||||
merge-tools.difftool =
|
||||
let
|
||||
cmd = [
|
||||
"-c"
|
||||
''
|
||||
ARGS="lua require('difftool').open('$left', '$right', {ignore = { '.git', '.jj' }})"
|
||||
git -C "$left" init -q
|
||||
git -C "$left" add -A
|
||||
git -C "$left" commit -q -m baseline --allow-empty
|
||||
mv "$left/.git" "$right"
|
||||
git -C "$right" add --intent-to-add -A
|
||||
if [ -z "$NVIM" ]; then
|
||||
vim -c "$ARGS"
|
||||
else
|
||||
vim \
|
||||
--server $NVIM \
|
||||
--remote-send "<cmd>$ARGS<cr>"
|
||||
until vim \
|
||||
--headless \
|
||||
--server "$NVIM" \
|
||||
--remote-expr "v:lua.require'iofq.jj'.is_jj_diffedit_open()" 2>/dev/null | grep 0; do
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
|
||||
git -C "$right" commit -q -m split
|
||||
git -C "$right" restore . # undo changes in modified files
|
||||
git -C "$right" reset . # undo --intent-to-add
|
||||
git -C "$right" clean -q -df # remove untracked files
|
||||
''
|
||||
];
|
||||
in
|
||||
{
|
||||
program = "sh";
|
||||
edit-args = cmd;
|
||||
diff-args = cmd;
|
||||
};
|
||||
snapshot = {
|
||||
max-new-file-size = "10MiB";
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue