11import type { Denops } from "jsr:@denops/std@^7.0.0" ;
22import { unnullish } from "jsr:@lambdalisue/unnullish@^1.0.0" ;
3- import { assert , is } from "jsr:@core/unknownutil@^4.0.0" ;
3+ import { assert , ensure , is } from "jsr:@core/unknownutil@^4.0.0" ;
44import * as helper from "jsr:@denops/std@^7.0.0/helper" ;
55import * as buffer from "jsr:@denops/std@^7.0.0/buffer" ;
6+ import * as fn from "jsr:@denops/std@^7.0.0/function" ;
7+ import { parse as parseBufname } from "jsr:@denops/std@^7.0.0/bufname" ;
68import {
79 builtinOpts ,
810 formatOpts ,
@@ -14,6 +16,7 @@ import { normCmdArgs, parseSilent } from "../../util/cmd.ts";
1416import { exec } from "./command.ts" ;
1517import { edit } from "./edit.ts" ;
1618import { read } from "./read.ts" ;
19+ import { main as mainDiffJump } from "../../feat/diffjump/main.ts" ;
1720
1821export function main ( denops : Denops ) : void {
1922 denops . dispatcher = {
@@ -47,6 +50,38 @@ export function main(denops: Denops): void {
4750 ) ;
4851 } ,
4952 } ;
53+ mainDiffJump ( denops , "buffer" , {
54+ commitishMap : {
55+ old : async ( { bufnr } ) => {
56+ const bufname = await fn . bufname ( denops , bufnr ) ;
57+ const { params } = parseBufname ( bufname ) ;
58+ const jumpCommitish = params ?. diffjump ;
59+ if ( jumpCommitish === undefined ) {
60+ return "HEAD^" ;
61+ }
62+ const commitish = ensure (
63+ jumpCommitish || "HEAD" ,
64+ is . String ,
65+ { message : "jump must be string" } ,
66+ ) ;
67+ return `${ commitish } ^` ;
68+ } ,
69+ new : async ( { bufnr } ) => {
70+ const bufname = await fn . bufname ( denops , bufnr ) ;
71+ const { params } = parseBufname ( bufname ) ;
72+ const jumpCommitish = params ?. diffjump ;
73+ if ( jumpCommitish === undefined ) {
74+ return "HEAD" ;
75+ }
76+ const commitish = ensure (
77+ jumpCommitish || "HEAD" ,
78+ is . String ,
79+ { message : "jump must be string" } ,
80+ ) ;
81+ return commitish ;
82+ } ,
83+ } ,
84+ } ) ;
5085}
5186
5287async function command (
@@ -62,6 +97,9 @@ async function command(
6297 "monochrome" ,
6398 "opener" ,
6499 "emojify" ,
100+ "diffjump" ,
101+ "difffold" ,
102+ "filetype" ,
65103 ...builtinOpts ,
66104 ] ) ;
67105 return exec ( denops , residue , {
@@ -70,6 +108,9 @@ async function command(
70108 monochrome : unnullish ( opts . monochrome , ( ) => true ) ,
71109 opener : opts . opener ,
72110 emojify : unnullish ( opts . emojify , ( ) => true ) ,
111+ diffjump : opts . diffjump ,
112+ difffold : unnullish ( opts . difffold , ( ) => true ) ,
113+ filetype : opts . filetype ,
73114 cmdarg : formatOpts ( opts , builtinOpts ) . join ( " " ) ,
74115 mods,
75116 bang : bang === "!" ,
0 commit comments