Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(pickers): Add telescope picker for codecompanion actions #250

Closed
wants to merge 5 commits into from

Conversation

Ajaymamtora
Copy link

Description

As described here: #248 -- I would prefer the ability to configure the layout of the telescope picker, which cant be done currently. The current implementation seems to use vim.ui.select which I've overriden with Telescope using dressing.nvim.

If we create a telescope picker and export it as an extension, you can pass opts directly to the picker and configure the layout/bindings etc.

My default telescope layout takes up most of the screen, but for pickers with not many options like codecompanion actions, I want to reduce the size.

Related Issue(s)

#248

Screenshots

image

As you can see the layout is now as I wanted when compared to the discussion above, using:

local small_no_preview = {
  layout_strategy = "vertical",
  previewer = false,
  layout_config = {
    vertical = {
      size = {
        height = "40%",
        width = "40%",
      },
    },
  },
}

Checklist

WIP

WIP

WIP

WIP

WIP

WIP

ts top level -> select

WIP

WIP

WIP

WIP
@olimorris
Copy link
Owner

Thanks @Ajaymamtora this looks epic!

I'll test this out tonight and my thinking is that perhaps this should be the default behaviour. If a user runs CodeCompanionActions and they have Telescope installed, then use the extension...otherwise default to the current one.

@S1M0N38
Copy link
Contributor

S1M0N38 commented Sep 23, 2024

I think registering a proper extension for Telescope would be a nice touch.

However, I'm not sure about cluttering the CodeCompanion command namespace with the command CodeCompanionTelescope.

It might be better to avoid creating user commands tied to specific dependencies because, following that logic, we would need to implement separate commands for different pickers (e.g., fzf-lua, mini.pick, etc.).

@olimorris
Copy link
Owner

@S1M0N38 is Telescope best practice to still manually register the extension?

@S1M0N38
Copy link
Contributor

S1M0N38 commented Sep 23, 2024

@S1M0N38 is Telescope best practice to still manually register the extension?

I don't know. I was only point out some design choice about user commands.

@olimorris
Copy link
Owner

Sorry I've only got around to reviewing this now.

I agree with @S1M0N38's point that I'd like to keep the command at just :CodeCompanionActions. I've noticed that this PR doesn't show any prompts that are bound to visual mode.

An easier way to obtain all of the actions is with:

local context_utils = require("codecompanion.utils.context")

local actions = require("codecompanion.actions")
local context = context_utils.get()
actions.add_default_prompt_library(context)

I notice that in CopilotChat.nvim they pass the actions to a telescope function:

require("CopilotChat.integrations.telescope").pick(actions.prompt_actions({
    selection = select.visual,
}))

I consider that advantageous as a user doesn't need to register an extension.

@olimorris
Copy link
Owner

This has made me realise that I should probably refactor the whole actions and prompts anyway...

@olimorris
Copy link
Owner

@Ajaymamtora I'm in the process of massively refactoring the actions / prompts.

Should be done tomorrow (hopefully) and I'll make sure I add Telescope support.

I forgot how horrible and hacky my default pickers were...this was before I expected anyone to ever use the plugin 😂.

@Ajaymamtora
Copy link
Author

@Ajaymamtora I'm in the process of massively refactoring the actions / prompts.

Should be done tomorrow (hopefully) and I'll make sure I add Telescope support.

I forgot how horrible and hacky my default pickers were...this was before I expected anyone to ever use the plugin 😂.

Nice one thank you! Haha all good

@olimorris
Copy link
Owner

This should now be in v4.0.0. If you run :CodeCompanionActions Telescope it should open.

@Ajaymamtora
Copy link
Author

This should now be in v4.0.0. If you run :CodeCompanionActions Telescope it should open.

The picker isn't exposed so my original issue is back :(

@olimorris
Copy link
Owner

I'm wondering if it's because I didn't register the extension. Can you check #267 ? I'll also move all the conversation over there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants