echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
5.19k stars 187 forks source link

mini.sessions get error when use nui instead of vim.ui.select #1153

Closed liuhq closed 2 months ago

liuhq commented 2 months ago

Contributing guidelines

Module(s)

mini.sessions

Description

when using nui to take over vim.ui.select (code like below 👇)

https://github.com/MunifTanjim/nui.nvim/wiki/vim.ui#vimuiselect

require('mini.sessions').select('read') will get a error 👇

image

I read the mini.sessions source code and find the error maybe happen in 👇

image

nui the error-related code maybe as follows 👇

image and image

But I don't know the bug which is from nui code or mini.sessions

Neovim version

0.10

Steps to reproduce

  1. configure nui code (from https://github.com/MunifTanjim/nui.nvim/wiki/vim.ui#vimuiselect)
  2. configure mini.sessions to bind a keymap to require('mini.sessions').select('read')

Expected behavior

No response

Actual behavior

An error occurred

echasnovski commented 2 months ago

Thanks for the detailed question!

This doesn't look like an issue with 'mini.sessions', but rather a code snippet from 'nui.nvim'. The reason is that input items to vim.ui.select() are plain strings. The 'nui.nvim' code has the line of local format_item = opts.format_item or function(item) return tostring(item.__raw_item or item) end (meaning format_item is equal to opts.format_item if it is supplied) which later is used with the transformed item (after if type(item) ~= 'table' then item = { __raw_item = item } end) and not with the original item. This is not according to the specification, see :h vim.ui.select().