Skip to content

Commit 28d9ee4

Browse files
authored
Merge pull request #53 from lambdalisue/ref
🐛 Fix `GinPatch`
2 parents 6bfc537 + dc6afad commit 28d9ee4

File tree

5 files changed

+40
-56
lines changed

5 files changed

+40
-56
lines changed

denops/gin/feat/diff/command.ts

+11-36
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,16 @@ export async function exec(
110110
}
111111

112112
export async function read(denops: Denops): Promise<void> {
113-
const [env, verbose, bufnr, bname, cmdarg, disableDefaultMappings] =
114-
await batch.gather(
115-
denops,
116-
async (denops) => {
117-
await fn.environ(denops);
118-
await option.verbose.get(denops);
119-
await fn.bufnr(denops, "%");
120-
await fn.bufname(denops, "%");
121-
await vars.v.get(denops, "cmdarg");
122-
await vars.g.get(
123-
denops,
124-
"gin_diff_disable_default_mappings",
125-
false,
126-
);
127-
},
128-
) as [Record<string, string>, number, number, string, string, unknown];
129-
unknownutil.assertBoolean(disableDefaultMappings);
113+
const [env, verbose, bufnr, bname, cmdarg] = await batch.gather(
114+
denops,
115+
async (denops) => {
116+
await fn.environ(denops);
117+
await option.verbose.get(denops);
118+
await fn.bufnr(denops, "%");
119+
await fn.bufname(denops, "%");
120+
await vars.v.get(denops, "cmdarg");
121+
},
122+
) as [Record<string, string>, number, number, string, string, unknown];
130123
const [opts, _] = parseOpts(cmdarg.split(" "));
131124
validateOpts(opts, builtinOpts);
132125
const { expr, params, fragment } = bufname.parse(bname);
@@ -167,7 +160,7 @@ export async function read(denops: Denops): Promise<void> {
167160
}
168161
await buffer.ensure(denops, bufnr, async () => {
169162
await batch.batch(denops, async (denops) => {
170-
await option.filetype.setLocal(denops, "diff");
163+
await option.filetype.setLocal(denops, "gin-diff");
171164
await option.bufhidden.setLocal(denops, "unload");
172165
await option.buftype.setLocal(denops, "nofile");
173166
await option.swapfile.setLocal(denops, false);
@@ -190,24 +183,6 @@ export async function read(denops: Denops): Promise<void> {
190183
noremap: true,
191184
},
192185
);
193-
if (!disableDefaultMappings) {
194-
await mapping.map(
195-
denops,
196-
"g<CR>",
197-
"<Plug>(gin-diffjump-old)zv",
198-
{
199-
buffer: true,
200-
},
201-
);
202-
await mapping.map(
203-
denops,
204-
"<CR>",
205-
"<Plug>(gin-diffjump-new)zv",
206-
{
207-
buffer: true,
208-
},
209-
);
210-
}
211186
});
212187
});
213188
await buffer.assign(denops, bufnr, stdout, {

denops/gin/feat/edit/command.ts

+10-17
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,16 @@ export async function exec(
109109
}
110110

111111
export async function read(denops: Denops): Promise<void> {
112-
const [env, verbose, bufnr, bname, cmdarg, disableDefaultMappings] =
113-
await batch.gather(
114-
denops,
115-
async (denops) => {
116-
await fn.environ(denops);
117-
await option.verbose.get(denops);
118-
await fn.bufnr(denops, "%");
119-
await fn.bufname(denops, "%");
120-
await vars.v.get(denops, "cmdarg");
121-
await vars.g.get(
122-
denops,
123-
"gin_diff_disable_default_mappings",
124-
false,
125-
);
126-
},
127-
) as [Record<string, string>, number, number, string, string, unknown];
128-
unknownutil.assertBoolean(disableDefaultMappings);
112+
const [env, verbose, bufnr, bname, cmdarg] = await batch.gather(
113+
denops,
114+
async (denops) => {
115+
await fn.environ(denops);
116+
await option.verbose.get(denops);
117+
await fn.bufnr(denops, "%");
118+
await fn.bufname(denops, "%");
119+
await vars.v.get(denops, "cmdarg");
120+
},
121+
) as [Record<string, string>, number, number, string, string, unknown];
129122
const [opts, _] = parseOpts(cmdarg.split(" "));
130123
validateOpts(opts, builtinOpts);
131124
const { expr, params, fragment } = bufname.parse(bname);

denops/gin/feat/patch/command.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ export async function exec(
7676
!!verbose,
7777
);
7878

79-
const infoIndex = await editExec(denops, filename, undefined, {
80-
"cached": "",
81-
}, {
79+
const infoIndex = await editExec(denops, filename, undefined, {}, {
8280
worktree,
81+
cached: true,
8382
opener: options.opener,
8483
cmdarg: options.cmdarg,
8584
mods: options.mods,

ftplugin/gin-diff.vim

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if exists('b:did_ftplugin')
2+
finish
3+
endif
4+
runtime ftplugin/diff.vim
5+
6+
if !get(g:, 'gin_diff_disable_default_mappings')
7+
nmap <buffer> g<CR> <Plug>(gin-diffjump-old)zv
8+
nmap <buffer> <CR> <Plug>(gin-diffjump-new)zv
9+
endif
10+
11+
let b:did_ftplugin = 1

syntax/gin-diff.vim

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if exists('b:current_syntax')
2+
finish
3+
endif
4+
runtime syntax/diff.vim
5+
6+
let b:current_syntax = 'gin-diff'

0 commit comments

Comments
 (0)