Skip to content

Commit 0089f06

Browse files
committed
👍 Add Fall command completion
1 parent 71c3637 commit 0089f06

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

autoload/fall/command/Fall.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function! fall#command#Fall#call(args) abort
1111
try
1212
set laststatus=0
1313
call fall#internal#mapping#store()
14-
call denops#request('fall', 'picker:start:command', [a:args])
14+
call denops#request('fall', 'picker:command', [a:args])
1515
finally
1616
augroup fall_command_Fall
1717
autocmd!
@@ -23,10 +23,10 @@ function! fall#command#Fall#call(args) abort
2323
endfunction
2424

2525
function! fall#command#Fall#complete(arglead, cmdline, cursorpos) abort
26-
if denops#plugin#wait('fall') == 0
26+
if denops#plugin#wait('fall') isnot# 0
2727
return []
2828
endif
29-
return []
29+
return denops#request('fall', 'picker:command:complete', [a:arglead, a:cmdline, a:cursorpos])
3030
endfunction
3131

3232
function! s:hide() abort

denops/fall/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import {
99

1010
export { getGlobalConfig } from "./config/global_config.ts";
1111
export { getActionPickerParams } from "./config/action_picker.ts";
12-
export { getItemPickerParams } from "./config/item_picker.ts";
12+
export {
13+
getItemPickerParams,
14+
listItemPickerNames,
15+
} from "./config/item_picker.ts";
1316

1417
export async function loadUserConfig(
1518
denops: Denops,

denops/fall/config/item_picker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const itemPickerParamsMap = new Map<
1919
ItemPickerParams<unknown, string>
2020
>();
2121

22+
export function listItemPickerNames(): readonly string[] {
23+
return Array.from(itemPickerParamsMap.keys());
24+
}
25+
2226
export function getItemPickerParams(
2327
name: string,
2428
): Readonly<ItemPickerParams<unknown, string> & GlobalConfig> | undefined {

denops/fall/main/picker.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getActionPickerParams,
1717
getGlobalConfig,
1818
getItemPickerParams,
19+
listItemPickerNames,
1920
loadUserConfig,
2021
} from "../config.ts";
2122
import { Picker } from "../picker.ts";
@@ -26,7 +27,7 @@ let zindex = 50;
2627
export const main: Entrypoint = (denops) => {
2728
denops.dispatcher = {
2829
...denops.dispatcher,
29-
"picker:start:command": async (args) => {
30+
"picker:command": async (args) => {
3031
await init(denops);
3132
// Split the command arguments
3233
const [name, ...sourceArgs] = ensure(args, isArgs);
@@ -49,6 +50,13 @@ export const main: Entrypoint = (denops) => {
4950
{ signal: denops.interrupted },
5051
);
5152
},
53+
"picker:command:complete": async (arglead, cmdline, cursorpos) => {
54+
await init(denops);
55+
assert(arglead, is.String);
56+
assert(cmdline, is.String);
57+
assert(cursorpos, is.Number);
58+
return listItemPickerNames().filter((name) => name.startsWith(arglead));
59+
},
5260
"picker:start": async (args, screen, params, options) => {
5361
await init(denops);
5462
assert(args, isArgs);

plugin/fall.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ if exists('g:loaded_fall')
33
endif
44
let g:loaded_fall = 1
55

6-
command! -nargs=+ Fall call fall#command#Fall#call([<f-args>])
6+
command! -nargs=+ -complete=customlist,fall#command#Fall#complete
7+
\ Fall call fall#command#Fall#call([<f-args>])
8+
79
command! -nargs=0 FallConfig call fall#command#FallConfig#call()
810

911
augroup fall_plugin

0 commit comments

Comments
 (0)