diff --git a/denops/gin/feat/diff/command.ts b/denops/gin/feat/diff/command.ts index 3a875a82..b7a2981a 100644 --- a/denops/gin/feat/diff/command.ts +++ b/denops/gin/feat/diff/command.ts @@ -110,23 +110,16 @@ export async function exec( } export async function read(denops: Denops): Promise { - const [env, verbose, bufnr, bname, cmdarg, disableDefaultMappings] = - await batch.gather( - denops, - async (denops) => { - await fn.environ(denops); - await option.verbose.get(denops); - await fn.bufnr(denops, "%"); - await fn.bufname(denops, "%"); - await vars.v.get(denops, "cmdarg"); - await vars.g.get( - denops, - "gin_diff_disable_default_mappings", - false, - ); - }, - ) as [Record, number, number, string, string, unknown]; - unknownutil.assertBoolean(disableDefaultMappings); + const [env, verbose, bufnr, bname, cmdarg] = await batch.gather( + denops, + async (denops) => { + await fn.environ(denops); + await option.verbose.get(denops); + await fn.bufnr(denops, "%"); + await fn.bufname(denops, "%"); + await vars.v.get(denops, "cmdarg"); + }, + ) as [Record, number, number, string, string, unknown]; const [opts, _] = parseOpts(cmdarg.split(" ")); validateOpts(opts, builtinOpts); const { expr, params, fragment } = bufname.parse(bname); @@ -167,7 +160,7 @@ export async function read(denops: Denops): Promise { } await buffer.ensure(denops, bufnr, async () => { await batch.batch(denops, async (denops) => { - await option.filetype.setLocal(denops, "diff"); + await option.filetype.setLocal(denops, "gin-diff"); await option.bufhidden.setLocal(denops, "unload"); await option.buftype.setLocal(denops, "nofile"); await option.swapfile.setLocal(denops, false); @@ -190,24 +183,6 @@ export async function read(denops: Denops): Promise { noremap: true, }, ); - if (!disableDefaultMappings) { - await mapping.map( - denops, - "g", - "(gin-diffjump-old)zv", - { - buffer: true, - }, - ); - await mapping.map( - denops, - "", - "(gin-diffjump-new)zv", - { - buffer: true, - }, - ); - } }); }); await buffer.assign(denops, bufnr, stdout, { diff --git a/denops/gin/feat/edit/command.ts b/denops/gin/feat/edit/command.ts index a7ae2a9b..4cb3a83c 100644 --- a/denops/gin/feat/edit/command.ts +++ b/denops/gin/feat/edit/command.ts @@ -109,23 +109,16 @@ export async function exec( } export async function read(denops: Denops): Promise { - const [env, verbose, bufnr, bname, cmdarg, disableDefaultMappings] = - await batch.gather( - denops, - async (denops) => { - await fn.environ(denops); - await option.verbose.get(denops); - await fn.bufnr(denops, "%"); - await fn.bufname(denops, "%"); - await vars.v.get(denops, "cmdarg"); - await vars.g.get( - denops, - "gin_diff_disable_default_mappings", - false, - ); - }, - ) as [Record, number, number, string, string, unknown]; - unknownutil.assertBoolean(disableDefaultMappings); + const [env, verbose, bufnr, bname, cmdarg] = await batch.gather( + denops, + async (denops) => { + await fn.environ(denops); + await option.verbose.get(denops); + await fn.bufnr(denops, "%"); + await fn.bufname(denops, "%"); + await vars.v.get(denops, "cmdarg"); + }, + ) as [Record, number, number, string, string, unknown]; const [opts, _] = parseOpts(cmdarg.split(" ")); validateOpts(opts, builtinOpts); const { expr, params, fragment } = bufname.parse(bname); diff --git a/denops/gin/feat/patch/command.ts b/denops/gin/feat/patch/command.ts index 66c6da3b..a012058a 100644 --- a/denops/gin/feat/patch/command.ts +++ b/denops/gin/feat/patch/command.ts @@ -76,10 +76,9 @@ export async function exec( !!verbose, ); - const infoIndex = await editExec(denops, filename, undefined, { - "cached": "", - }, { + const infoIndex = await editExec(denops, filename, undefined, {}, { worktree, + cached: true, opener: options.opener, cmdarg: options.cmdarg, mods: options.mods, diff --git a/ftplugin/gin-diff.vim b/ftplugin/gin-diff.vim new file mode 100644 index 00000000..9ad4b6db --- /dev/null +++ b/ftplugin/gin-diff.vim @@ -0,0 +1,11 @@ +if exists('b:did_ftplugin') + finish +endif +runtime ftplugin/diff.vim + +if !get(g:, 'gin_diff_disable_default_mappings') + nmap g (gin-diffjump-old)zv + nmap (gin-diffjump-new)zv +endif + +let b:did_ftplugin = 1 diff --git a/syntax/gin-diff.vim b/syntax/gin-diff.vim new file mode 100644 index 00000000..d3082f43 --- /dev/null +++ b/syntax/gin-diff.vim @@ -0,0 +1,6 @@ +if exists('b:current_syntax') + finish +endif +runtime syntax/diff.vim + +let b:current_syntax = 'gin-diff'