nvim-telescope / telescope-ui-select.nvim

MIT License
774 stars 18 forks source link

Code action: `expected string, got function` #44

Open hejops opened 6 months ago

hejops commented 6 months ago

Minimal config (as per README):

local telescope = require("telescope")
telescope.setup({
    extensions = {
        ["ui-select"] = {
            require("telescope.themes").get_dropdown(
                -- { initial_mode = "normal" } -- optional
            ),

        },
    },
})
telescope.load_extension("ui-select")

Then, in some language/file/line with support for code actions (e.g. Go), call:

:lua vim.lsp.buf.code_action()

The following error is produced, regardless of initial_mode value:

E5108: Error executing lua: vim/shared.lua:0: s: expected string, got function
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'gsplit'
        vim/shared.lua: in function 'split'
        ...e/nvim/lazy/telescope.nvim/lua/telescope/actions/set.lua:162: in function 'run_replace_or_original'
        ...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'run_replace_or_original'
        ...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'run_replace_or_original'
        ...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:262: in function <...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:261>
mikew commented 1 week ago

Also seeing this on nvim 0.10.1. Curious what you mean when you say "from insert mode". Do you mean insert mode of the file, or Telescope's input field? Because I'm seeing it regardless of either.

https://github.com/user-attachments/assets/8ea9a327-5ed7-4788-a04b-3f505cd7d07f

hejops commented 3 days ago

Thanks for confirming. I forgot I had filed this issue since it was so long ago, and I stopped using this plugin since I never found a compelling use case for it, outside of code actions (which I'm not a regular user of).

In any case, after checking it out again, the previously observed error still occurs, regardless of which mode vim.lsp.buf.code_action was invoked in (normal/insert), and the value of initial_mode.

From grokking the source of code_action, I think it returns a table of vim.lsp.CodeActionResultEntry, but ui-select expects a table of string, resulting in the error.