Skip to content

Commit

Permalink
feat(telescope): telescope flat style support (#521)
Browse files Browse the repository at this point in the history
* feat(telescope): flat style

* fix(docs): telescope integration

* mod(telescope): backwards compatibility & rename 'flat'

* fix(telescope): backwards compatibility

* fix: selene

* fix: stylua

---------

Co-authored-by: Egor Martynov <martynovegorOF@yandex.ru>
  • Loading branch information
nottyl and mrtnvgr committed Jun 24, 2023
1 parent 506a4aa commit fc73faa
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 25 deletions.
5 changes: 4 additions & 1 deletion doc/catppuccin.txt
Expand Up @@ -704,7 +704,10 @@ telekasten.nvim>lua
<

telescope.nvim>lua
telescope = true
telescope = {
enabled = true,
style = "classic" | "nvchad",
}
<

trouble.nvim>lua
Expand Down
65 changes: 44 additions & 21 deletions lua/catppuccin/groups/integrations/telescope.lua
@@ -1,27 +1,50 @@
local M = {}

function M.get()
return {
-- TelescopeNormal = { link = "NormalFloat" }, -- Respect telescope's default float bg
TelescopeBorder = { link = "FloatBorder" },
TelescopeSelectionCaret = { fg = C.flamingo },
TelescopeSelection = {
fg = O.transparent_background and C.flamingo or C.text,
bg = O.transparent_background and C.none or C.surface0,
style = { "bold" },
},
TelescopeMatching = { fg = C.blue },
-- TelescopePromptPrefix = { bg = C.crust },
-- TelescopePromptNormal = { bg = C.crust },
-- TelescopeResultsNormal = { bg = C.mantle },
-- TelescopePreviewNormal = { bg = C.crust },
-- TelescopePromptBorder = { bg = C.crust, fg = C.crust },
-- TelescopeResultsBorder = { bg = C.mantle, fg = C.crust },
-- TelescopePreviewBorder = { bg = C.crust, fg = C.crust },
-- TelescopePromptTitle = { fg = C.crust },
-- TelescopeResultsTitle = { fg = C.text },
-- TelescopePreviewTitle = { fg = C.crust },
}
-- Backwards compatibility
if type(O.integrations.telescope) == "boolean" then
return {
-- TelescopeNormal = { link = "NormalFloat" }, -- Respect telescope's default float bg
TelescopeBorder = { link = "FloatBorder" },
TelescopeSelectionCaret = { fg = C.flamingo },
TelescopeSelection = {
fg = O.transparent_background and C.flamingo or C.text,
bg = O.transparent_background and C.none or C.surface0,
style = { "bold" },
},
TelescopeMatching = { fg = C.blue },
}
end

if O.integrations.telescope.style == "classic" then
-- Classic look
return {
-- TelescopeNormal = { link = "NormalFloat" }, -- Respect telescope's default float bg
TelescopeBorder = { link = "FloatBorder" },
TelescopeSelectionCaret = { fg = C.flamingo },
TelescopeSelection = {
fg = O.transparent_background and C.flamingo or C.text,
bg = O.transparent_background and C.none or C.surface0,
style = { "bold" },
},
TelescopeMatching = { fg = C.blue },
}
elseif O.integrations.telescope.style == "nvchad" then
-- Flat look
return {
TelescopePromptPrefix = { bg = C.crust },
TelescopeSelectionCaret = { fg = C.rosewater, bg = C.surface1, bold = true },
TelescopePromptNormal = { bg = C.crust },
TelescopeResultsNormal = { bg = C.mantle },
TelescopePreviewNormal = { bg = C.mantle },
TelescopePromptBorder = { bg = C.crust, fg = C.crust },
TelescopeResultsBorder = { bg = C.mantle, fg = C.mantle },
TelescopePreviewBorder = { bg = C.mantle, fg = C.mantle },
TelescopePromptTitle = { bg = C.rosewater, fg = C.base, bold = true },
TelescopeResultsTitle = { bg = C.rosewater, fg = C.base, bold = true },
TelescopePreviewTitle = { bg = C.lavender, fg = C.base, bold = true },
}
end
end

return M
5 changes: 4 additions & 1 deletion lua/catppuccin/init.lua
Expand Up @@ -42,7 +42,10 @@ local M = {
markdown = true,
nvimtree = true,
semantic_tokens = not is_vim,
telescope = true,
telescope = {
enabled = true,
style = "classic",
},
treesitter = not is_vim,
ts_rainbow = true,
ts_rainbow2 = true,
Expand Down
6 changes: 5 additions & 1 deletion lua/catppuccin/types.lua
Expand Up @@ -58,7 +58,7 @@
---@field navic CtpIntegrationNavic
---@field nvimtree boolean
---@field semantic_tokens boolean
---@field telescope boolean
---@field telescope CtpIntegrationTelescope
---@field treesitter boolean
---@field ts_rainbow boolean
---@field ts_rainbow2 boolean
Expand Down Expand Up @@ -86,6 +86,10 @@
---@field enabled boolean? Whether to enable the navic integration.
---@field custom_bg string? Override the background color for navic.

---@class CtpIntegrationTelescope
---@field enabled boolean? Whether to enable the telescope integration
---@field style string? The style of Telescope "classic" | "nvchad"

---@alias CtpHighlightArgs "bold" | "underline" | "undercurl" | "underdouble" | "underdotted" | "underdashed" | "strikethrough" | "reverse" | "inverse" | "italic" | "standout" | "altfont" | "nocombine" | "NONE"
---@alias CtpHighlightOverrideFn fun(colors: CtpColors<string>): { [string]: CtpHighlight}
---@alias CtpHighlightOverrides CtpFlavors<CtpHighlightOverrideFn>
Expand Down
7 changes: 6 additions & 1 deletion vim.yml
Expand Up @@ -227,9 +227,14 @@ globals:
O.integrations.semantic_tokens:
type: bool
property: read-only
O.integrations.telescope:

O.integrations.telescope.enabled:
type: bool
property: read-only
O.integrations.telescope.style:
type: string
property: read-only

O.integrations.treesitter:
type: bool
property: read-only
Expand Down

0 comments on commit fc73faa

Please sign in to comment.