Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc616f72

Browse files
authored
feat: add sync ui select util (#345)
1 parent4d810a5 commitc616f72

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎lua/java/utils/ui.lua‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ function M.select(prompt, values, format_item, opts)
2626
end)
2727
end
2828

29+
--Sync vim.ui.select function
30+
---@genericT
31+
---@parampromptstring
32+
---@paramvaluesT[]
33+
---@paramformat_item?fun(item:T,index:number):string
34+
---@paramopts?{return_one:boolean}
35+
---@returnT|nil
36+
functionM.select_sync(prompt,values,format_item,opts)
37+
opts=optsor {prompt_single=false }
38+
39+
ifnotopts.prompt_singleand#values==1then
40+
returnvalues[1]
41+
end
42+
43+
locallabels= {prompt }
44+
forindex,valueinipairs(values)do
45+
table.insert(labels,format_itemandformat_item(value,index)orvalue)
46+
end
47+
48+
localselected_index=vim.fn.inputlist(labels)
49+
50+
returnvalues[selected_index]
51+
end
52+
2953
---Async vim.ui.select function
3054
---@genericT
3155
---@parampromptstring

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp