Skip to content

feat: Add theme options to select Telescope themes#710

Merged
deathbeam merged 3 commits intoCopilotC-Nvim:mainfrom
Kohei-Wada:main-add-telescope-theme-option
Jan 26, 2025
Merged

feat: Add theme options to select Telescope themes#710
deathbeam merged 3 commits intoCopilotC-Nvim:mainfrom
Kohei-Wada:main-add-telescope-theme-option

Conversation

@Kohei-Wada
Copy link
Copy Markdown
Contributor

Added theme options to the M.pick function to allow selection of dropdown, ivy, and cursor themes.

image image

@jellydn jellydn requested review from Copilot and deathbeam January 11, 2025 14:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Files not reviewed (1)
  • lua/CopilotChat/integrations/telescope.lua: Language not supported

@jellydn
Copy link
Copy Markdown
Contributor

jellydn commented Jan 26, 2025

Thank you @Kohei-Wada for this nice improvement. I like this idea, however, in terms of API (.pick()), I would like to hear @deathbeam thought on this.

@deathbeam
Copy link
Copy Markdown
Collaborator

deathbeam commented Jan 26, 2025

I think better way is to just check if .theme is present in opts or not and if present dont call themes.get_dropdown, see how the themes are impleented in telescope: https://github.com/nvim-telescope/telescope.nvim/blob/415af52339215926d705cccc08145f3782c4d132/lua/telescope/themes.lua

so you could call .pick(actions, telescope.themes.get_ivy(opts)) etc. This would also allow custom themes that telescope should support in their api

@Kohei-Wada
Copy link
Copy Markdown
Contributor Author

Kohei-Wada commented Jan 26, 2025

@jellydn @deathbeam
Thank you for your review! I have updated the implementation to allow calling the function as follows:

actions.prompt_actions({ selection = select.visual }, {
  theme = require("telescope.themes").get_cursor({ prompt_prefix = "copilot-chat>" }),
})

This change ensures that the theme can be passed directly in the opts parameter, supporting both default and custom themes provided by the Telescope API. Let me know if you have any further suggestions!

Added theme options to the M.pick function to allow selection of
dropdown, ivy, and cursor themes.
Simplified code by removing the theme argument and integrating it into opts.
@deathbeam
Copy link
Copy Markdown
Collaborator

I did not exactly meant it like that, I meant using theme just as a marker as the .get_cursor sets the .theme variable on the opts. So if the variable is set just use the whole opts otherwise use .get_dropdown, as the opts are extended, so you just pass the other opts to the theme function itself:

https://github.com/nvim-telescope/telescope.nvim/blob/415af52339215926d705cccc08145f3782c4d132/lua/telescope/themes.lua#L64

Fixed to apply the default theme when opts and opts.theme are not set.
@Kohei-Wada
Copy link
Copy Markdown
Contributor Author

@deathbeam
Thank you for the feedback! I think I understood your suggestion to use opts.theme if it is already set and avoid calling themes.get_dropdown. This approach makes sense, as it respects the custom theme provided by the user.

@deathbeam deathbeam added the enhancement New feature or request label Jan 26, 2025
@deathbeam deathbeam merged commit 9b8e944 into CopilotC-Nvim:main Jan 26, 2025
@deathbeam
Copy link
Copy Markdown
Collaborator

Looks good, thanks.

@all-contributors add @Kohei-Wada for code

@allcontributors
Copy link
Copy Markdown
Contributor

@deathbeam

I've put up a pull request to add @Kohei-Wada! 🎉

@Kohei-Wada Kohei-Wada deleted the main-add-telescope-theme-option branch January 26, 2025 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants