From cd4ef7cc7aaa551cad8256811e60d7102e2f3771 Mon Sep 17 00:00:00 2001 From: Alisue Date: Tue, 2 Aug 2022 09:20:42 +0900 Subject: [PATCH 1/3] :shower: Remove unused variables --- denops/gin/feat/edit/command.ts | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) 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); From f055071cad3b31b035aeb04a5f1d7fd037766604 Mon Sep 17 00:00:00 2001 From: Alisue Date: Tue, 2 Aug 2022 09:14:52 +0900 Subject: [PATCH 2/3] :+1: Add `gin-diff` filetype --- denops/gin/feat/diff/command.ts | 47 ++++++++------------------------- ftplugin/gin-diff.vim | 11 ++++++++ syntax/gin-diff.vim | 6 +++++ 3 files changed, 28 insertions(+), 36 deletions(-) create mode 100644 ftplugin/gin-diff.vim create mode 100644 syntax/gin-diff.vim 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/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' From dc6afadfd7e758ddf1c034d095a1748c6e4ef406 Mon Sep 17 00:00:00 2001 From: Alisue Date: Tue, 2 Aug 2022 14:40:20 +0900 Subject: [PATCH 3/3] :bug: Fix `GinPatch` --- denops/gin/feat/patch/command.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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,