Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix GinPatch #53

Merged
merged 3 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'