nvim-telescope / telescope-ui-select.nvim

MIT License
774 stars 18 forks source link

codeactions specific config #16

Open EricDriussi opened 1 year ago

EricDriussi commented 1 year ago

Hi there! Thanks for your work!

I'm trying to set a specific setup for codeactions while leaving the rest as default.

So withing Telescope's extensions table, the ui-select config looks like this:

["ui-select"] = {
      layout_strategy = "cursor",
      layout_config = { width = 0.4, height = 0.3 },
      on_complete = {
        function()
          vim.cmd("stopinsert")
        end
      }
    }

Is there any way I could use that config but only for codeactions, while leaving the rest of the popups as they are?

I've tried following the Readme but I can't quite figure it out :thinking:

antonk52 commented 1 year ago

There is no way for vim.ui.select to know that it has been called from a code actions function. A potential workaround could be to map your codeactions key map to a custom function that would be wrapping codeactions.

Something along these lines may work, I haven't tested.

local function setup_telescope() --[[ require('telescope').setup({ regular_config })

local function setup_custom_telescope() --[[ require('telescope').setup({ config_from_example + on_complete_call_setup_telescope })]] end

function custom_codeactions()
  setup_custom_telescope()
  vim.lsp.buf.code_action()
end