stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.7k stars 32 forks source link

Telescope not focused when vim.ui.select is triggered by autocmd #59

Closed mehalter closed 1 year ago

mehalter commented 1 year ago

Describe the bug

When setting up an autocmd to automatically format the buffer on save with the LSP, if there are multiple formatting capable language servers vim.ui.select is called to select the correct one. The Telescope selection window appears but it not in focus

System information

require("dressing").setup({
  input = {
    enabled = ui_opts.nui_input,
    default_prompt = "➤ ",
    winhighlight = "Normal:Normal,NormalNC:Normal",
  },
  select = {
    enabled = ui_opts.telescope_select,
    backend = { "telescope", "builtin" },
    builtin = { winhighlight = "Normal:Normal,NormalNC:Normal" },
  },
})

To Reproduce Steps to reproduce the behavior:

  1. Set up dressing
  2. Add an autocmd to format synchronously on save (BufWritePre)
    on_attach = function(client, bufnr)
    if client.resolved_capabilities.document_formatting then
      vim.api.nvim_create_autocmd("BufWritePre", {
        desc = "Auto format before save",
        pattern = "<buffer>",
        callback = function() vim.lsp.buf.formatting_sync() end,
      })
    end
    end,
  3. Have multiple language servers with formatting capabilities. For example sumneko_lua and stylua (with null-ls)
  4. Open a file using at least 2 format capable language servers and save the file.

Screenshots

https://asciinema.org/a/86k1OuM0mj4hi8fQLTt7qz6B5

stevearc commented 1 year ago

I think this is because of a recent change I made for #58. I've reverted the vim.ui.select part of it. Can you give it another try?

mehalter commented 1 year ago

That worked perfectly! Thank you so much!