Skip to content

Commit

Permalink
Merge pull request #53 from lambdalisue/ref
Browse files Browse the repository at this point in the history
🐛 Fix `GinPatch`
  • Loading branch information
lambdalisue authored Aug 2, 2022
2 parents 6bfc537 + dc6afad commit 28d9ee4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 56 deletions.
47 changes: 11 additions & 36 deletions denops/gin/feat/diff/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,16 @@ export async function exec(
}

export async function read(denops: Denops): Promise<void> {
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<string, string>, 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<string, string>, number, number, string, string, unknown];
const [opts, _] = parseOpts(cmdarg.split(" "));
validateOpts(opts, builtinOpts);
const { expr, params, fragment } = bufname.parse(bname);
Expand Down Expand Up @@ -167,7 +160,7 @@ export async function read(denops: Denops): Promise<void> {
}
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);
Expand All @@ -190,24 +183,6 @@ export async function read(denops: Denops): Promise<void> {
noremap: true,
},
);
if (!disableDefaultMappings) {
await mapping.map(
denops,
"g<CR>",
"<Plug>(gin-diffjump-old)zv",
{
buffer: true,
},
);
await mapping.map(
denops,
"<CR>",
"<Plug>(gin-diffjump-new)zv",
{
buffer: true,
},
);
}
});
});
await buffer.assign(denops, bufnr, stdout, {
Expand Down
27 changes: 10 additions & 17 deletions denops/gin/feat/edit/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,16 @@ export async function exec(
}

export async function read(denops: Denops): Promise<void> {
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<string, string>, 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<string, string>, number, number, string, string, unknown];
const [opts, _] = parseOpts(cmdarg.split(" "));
validateOpts(opts, builtinOpts);
const { expr, params, fragment } = bufname.parse(bname);
Expand Down
5 changes: 2 additions & 3 deletions denops/gin/feat/patch/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions ftplugin/gin-diff.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if exists('b:did_ftplugin')
finish
endif
runtime ftplugin/diff.vim

if !get(g:, 'gin_diff_disable_default_mappings')
nmap <buffer> g<CR> <Plug>(gin-diffjump-old)zv
nmap <buffer> <CR> <Plug>(gin-diffjump-new)zv
endif

let b:did_ftplugin = 1
6 changes: 6 additions & 0 deletions syntax/gin-diff.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if exists('b:current_syntax')
finish
endif
runtime syntax/diff.vim

let b:current_syntax = 'gin-diff'

0 comments on commit 28d9ee4

Please sign in to comment.