aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/telescope/setup.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/alpha/telescope/setup.lua')
-rw-r--r--lua/alpha/telescope/setup.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/lua/alpha/telescope/setup.lua b/lua/alpha/telescope/setup.lua
index 5758746..0e368c7 100644
--- a/lua/alpha/telescope/setup.lua
+++ b/lua/alpha/telescope/setup.lua
@@ -11,8 +11,57 @@ local set_prompt_to_entry_value = function(prompt_bufnr)
action_state.get_current_picker(prompt_bufnr):reset_prompt(entry.ordinal)
end
+local filetype_hook = function(filepath, bufnr, opts)
+ -- Here for example you can say: if ft == "xyz" then this_regex_highlighing else nothing end
+ --
+ local is_image = function(filepath)
+ local image_extensions = { "png", "jpg" } -- Supported image formats
+ local split_path = vim.split(filepath:lower(), ".", { plain = true })
+ local extension = split_path[#split_path]
+ return vim.tbl_contains(image_extensions, extension)
+ end
+ if not is_image(filepath) then
+ return true
+ end
+ local ui = require "image.ui"
+ local options = require "image.options"
+ local dimensions = require "image.dimensions"
+ local api = require "image.api"
+ local config = require "image.config"
+ local user_opts = {
+ render = {
+ foreground_color = true,
+ background_color = true,
+ },
+ }
+ local global_opts = vim.tbl_deep_extend("force", config.DEFAULT_OPTS, user_opts)
+
+ local ascii_width, ascii_height, horizontal_padding, vertical_padding, img_width, img_height =
+ dimensions.calculate_ascii_width_height(opts.winid, filepath, global_opts)
+ options.set_options_before_render(bufnr)
+ ui.buf_clear(bufnr)
+ local label = ui.create_label(
+ filepath,
+ ascii_width,
+ horizontal_padding,
+ global_opts.render.show_image_dimensions,
+ img_width,
+ img_height
+ )
+
+ api.get_ascii_data_sync(filepath, ascii_width, ascii_height, global_opts, function(ascii_data)
+ ui.buf_insert_data_with_padding(bufnr, ascii_data, horizontal_padding, vertical_padding, label, global_opts)
+
+ options.set_options_after_render(bufnr)
+ end)
+ return false
+end
+
require("telescope").setup {
defaults = {
+ preview = {
+ filetype_hook = filetype_hook,
+ },
prompt_prefix = "❯ ",
selection_caret = "❯ ",
@@ -100,6 +149,7 @@ require("telescope").setup {
path = "~/.local/share/nvim/databases/telescope_history.sqlite3",
limit = 100,
},
+ -- buffer_previewer_maker = new_maker,
},
pickers = {