* wip: 2021-07-22 15:00 BST * wip: `horizontal` refactored * wip: `center` refactored * wip: `cursor` and `vertical` refactored * wip: `current_buffer` refactor - also changed `layout_config_defaults` as they gave errors when using `current_buffer` * wip: `bottom_pane` refactor * [docgen] Update doc/telescope.txt skip-checks: true * fix: put accidentally remove config option back * [docgen] Update doc/telescope.txt skip-checks: true * wip: standardise `height` calculation for `center` and `bottom_pane` * wip: improve comments * [docgen] Update doc/telescope.txt skip-checks: true * stylua - also fix a merge mistake * [docgen] Update doc/telescope.txt skip-checks: true * fix: attempt to fix bad merge * refactor: remove unused entry in `borderchars` table - also fix some typos * wip: tweak padding for `bottom_pane` * wip: add `tabline` checks to `bottom_pane` - also tweaked position so that `statusline` is not covered when borders are enabled * stylua * refactor: factor out size capping function * [docgen] Update doc/telescope.txt skip-checks: true * fix: adjust tests that relied on height being number of results * fix: forgot variable in calc_size_and_spacing * fix: maybe this fixes these tests? * test: try other plenary branch for ci * test: switch back to main plenary branch for ci * fix: actually define `max_results` in the test * fix: final tweaks for edge cases Co-authored-by: Github Actions <actions@github>
129 lines
3.1 KiB
Lua
129 lines
3.1 KiB
Lua
-- Prototype Theme System (WIP)
|
|
-- Currently certain designs need a number of parameters.
|
|
--
|
|
-- local opts = themes.get_dropdown { winblend = 3 }
|
|
|
|
---@tag telescope.themes
|
|
|
|
---@brief [[
|
|
--- Themes are ways to combine several elements of styling together.
|
|
---
|
|
--- They are helpful for managing the several differnt UI aspects for telescope and provide
|
|
--- a simple interface for users to get a particular "style" of picker.
|
|
---@brief ]]
|
|
|
|
local themes = {}
|
|
|
|
--- Dropdown style theme.
|
|
---
|
|
--- Usage:
|
|
--- <code>
|
|
--- `local builtin = require('telescope.builtin')`
|
|
--- `local themes = require('telescope.themes')`
|
|
--- `builtin.find_files(themes.get_dropdown())`
|
|
--- </code>
|
|
function themes.get_dropdown(opts)
|
|
opts = opts or {}
|
|
|
|
local theme_opts = {
|
|
theme = "dropdown",
|
|
|
|
results_title = false,
|
|
preview_title = "Preview",
|
|
|
|
sorting_strategy = "ascending",
|
|
layout_strategy = "center",
|
|
layout_config = {
|
|
preview_cutoff = 1, -- Preview should always show (unless previewer = false)
|
|
|
|
width = function(_, max_columns, _)
|
|
return math.min(max_columns - 3, 80)
|
|
end,
|
|
|
|
height = function(_, _, max_lines)
|
|
return math.min(max_lines - 4, 15)
|
|
end,
|
|
},
|
|
|
|
border = true,
|
|
borderchars = {
|
|
prompt = { "─", "│", " ", "│", "╭", "╮", "│", "│" },
|
|
results = { "─", "│", "─", "│", "├", "┤", "╯", "╰" },
|
|
preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
|
},
|
|
}
|
|
|
|
return vim.tbl_deep_extend("force", theme_opts, opts)
|
|
end
|
|
|
|
--- Cursor style theme.
|
|
---
|
|
--- Usage:
|
|
--- <code>
|
|
---
|
|
--- `local builtin = require('telescope.builtin')`
|
|
--- `local themes = require('telescope.themes')`
|
|
--- `builtin.lsp_code_actions(themes.get_cursor())`
|
|
--- </code>
|
|
function themes.get_cursor(opts)
|
|
opts = opts or {}
|
|
|
|
local theme_opts = {
|
|
theme = "cursor",
|
|
|
|
sorting_strategy = "ascending",
|
|
results_title = false,
|
|
layout_strategy = "cursor",
|
|
layout_config = {
|
|
width = function(_, _, _)
|
|
return 80
|
|
end,
|
|
|
|
height = function(_, _, _)
|
|
return 6
|
|
end,
|
|
},
|
|
borderchars = {
|
|
prompt = { "─", "│", " ", "│", "╭", "╮", "│", "│" },
|
|
results = { "─", "│", "─", "│", "├", "┤", "╯", "╰" },
|
|
preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
|
},
|
|
}
|
|
|
|
return vim.tbl_deep_extend("force", theme_opts, opts)
|
|
end
|
|
|
|
--- Ivy style theme.
|
|
---
|
|
--- Usage:
|
|
--- <code>
|
|
--- `local builtin = require('telescope.builtin')`
|
|
--- `local themes = require('telescope.themes')`
|
|
--- `builtin.find_files(themes.get_ivy())`
|
|
--- </code>
|
|
function themes.get_ivy(opts)
|
|
opts = opts or {}
|
|
|
|
return vim.tbl_deep_extend("force", {
|
|
theme = "ivy",
|
|
|
|
sorting_strategy = "ascending",
|
|
|
|
preview_title = "",
|
|
|
|
layout_strategy = "bottom_pane",
|
|
layout_config = {
|
|
height = 25,
|
|
},
|
|
|
|
border = true,
|
|
borderchars = {
|
|
prompt = { "─", " ", " ", " ", "─", "─", " ", " " },
|
|
results = { " " },
|
|
preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
|
},
|
|
}, opts)
|
|
end
|
|
|
|
return themes
|