Skip to content

Commit 6bb4c41

Browse files
committed
feat: support vim.ui.select in Neovim 0.6
1 parent e725e2e commit 6bb4c41

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

autoload/arduino/chooser.vim

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ function! arduino#chooser#Choose(title, raw_items, callback) abort
1313
endif
1414
endfor
1515

16-
if get(g:, 'arduino_telescope_enabled', 0)
16+
if get(g:, 'arduino_nvim_select_enabled', 0)
17+
call luaeval("require('arduino').select_shim(_A[1], _A[2], _A[3])", [a:title, items, a:callback])
18+
elseif get(g:, 'arduino_telescope_enabled', 0)
1719
call luaeval("require('arduino.telescope').choose('".a:title."', _A, '".a:callback."')", items)
1820
elseif g:arduino_ctrlp_enabled
1921
let ext_data = get(g:ctrlp_ext_vars, s:ctrlp_idx)
@@ -125,4 +127,9 @@ if !exists('g:arduino_telescope_enabled') && exists('*luaeval')
125127
let g:arduino_telescope_enabled = luaeval("pcall(require, 'telescope')")
126128
endif
127129

130+
" neovim vim.ui.select {{{1
131+
if !exists('g:arduino_nvim_select_enabled') && exists('*luaeval')
132+
let g:arduino_nvim_select_enabled = luaeval('(vim.ui and vim.ui.select) ~= nil')
133+
endif
134+
128135
" vim:fen:fdm=marker:fmr={{{,}}}

lua/arduino/init.lua

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
local M = {}
2+
3+
M.select_shim = function(title, items, callback)
4+
local opts = {
5+
prompt = title,
6+
format_item = function(item) return item.label or item.value end
7+
}
8+
vim.ui.select(items, opts, function(item)
9+
if item then
10+
vim.call(callback, item.value)
11+
end
12+
end)
13+
end
14+
15+
return M

0 commit comments

Comments
 (0)