mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
feat: add custom media_extensions support (#306)
* Add custom media_extensions support Customize insert image and preview image files list. This is useful to add optional filetypes into filtered list (for example telescope-media-files optionally supporting svg preview) * Make media_extension option matching to default one
This commit is contained in:
@@ -136,6 +136,20 @@ telekasten.setup({opts})
|
|||||||
-- "viu-previewer" if you have viu installed
|
-- "viu-previewer" if you have viu installed
|
||||||
media_previewer = "telescope-media-files",
|
media_previewer = "telescope-media-files",
|
||||||
|
|
||||||
|
-- Customize insert image and preview image files list. This is useful
|
||||||
|
-- to add optional filetypes into filtered list (for example
|
||||||
|
-- telescope-media-files optionally supporting svg preview)
|
||||||
|
media_extensions = {
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".bmp",
|
||||||
|
".gif",
|
||||||
|
".pdf",
|
||||||
|
".mp4",
|
||||||
|
".webm",
|
||||||
|
".webp",
|
||||||
|
},
|
||||||
|
|
||||||
-- Calendar integration
|
-- Calendar integration
|
||||||
plug_into_calendar = true, -- use calendar integration
|
plug_into_calendar = true, -- use calendar integration
|
||||||
calendar_opts = {
|
calendar_opts = {
|
||||||
|
|||||||
@@ -148,6 +148,17 @@ local function defaultConfig(home)
|
|||||||
-- "catimg-previewer" if you have catimg installed
|
-- "catimg-previewer" if you have catimg installed
|
||||||
-- "viu-previewer" if you have viu installed
|
-- "viu-previewer" if you have viu installed
|
||||||
media_previewer = "telescope-media-files",
|
media_previewer = "telescope-media-files",
|
||||||
|
-- files which will be aviable in insert and preview images list
|
||||||
|
media_extensions = {
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".bmp",
|
||||||
|
".gif",
|
||||||
|
".pdf",
|
||||||
|
".mp4",
|
||||||
|
".webm",
|
||||||
|
".webp",
|
||||||
|
},
|
||||||
-- A customizable fallback handler for urls.
|
-- A customizable fallback handler for urls.
|
||||||
follow_url_fallback = nil,
|
follow_url_fallback = nil,
|
||||||
-- Enable creation new notes with Ctrl-n when finding notes
|
-- Enable creation new notes with Ctrl-n when finding notes
|
||||||
@@ -1395,15 +1406,7 @@ local function PreviewImg(opts)
|
|||||||
cwd = imageDir,
|
cwd = imageDir,
|
||||||
default_text = fname,
|
default_text = fname,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
filter_extensions = {
|
filter_extensions = M.Cfg.media_extensions,
|
||||||
".png",
|
|
||||||
".jpg",
|
|
||||||
".bmp",
|
|
||||||
".gif",
|
|
||||||
".pdf",
|
|
||||||
".mp4",
|
|
||||||
".webm",
|
|
||||||
},
|
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
@@ -1447,15 +1450,7 @@ local function BrowseImg(opts)
|
|||||||
prompt_title = "Preview image/media",
|
prompt_title = "Preview image/media",
|
||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
filter_extensions = {
|
filter_extensions = M.Cfg.media_extensions,
|
||||||
".png",
|
|
||||||
".jpg",
|
|
||||||
".bmp",
|
|
||||||
".gif",
|
|
||||||
".pdf",
|
|
||||||
".mp4",
|
|
||||||
".webm",
|
|
||||||
},
|
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
@@ -1784,15 +1779,7 @@ local function InsertImgLink(opts)
|
|||||||
prompt_title = "Find image/media",
|
prompt_title = "Find image/media",
|
||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
filter_extensions = {
|
filter_extensions = M.Cfg.media_extensions,
|
||||||
".png",
|
|
||||||
".jpg",
|
|
||||||
".bmp",
|
|
||||||
".gif",
|
|
||||||
".pdf",
|
|
||||||
".mp4",
|
|
||||||
".webm",
|
|
||||||
},
|
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
@@ -2943,6 +2930,7 @@ local function Setup(cfg)
|
|||||||
M.Cfg.rg_pcre = true
|
M.Cfg.rg_pcre = true
|
||||||
end
|
end
|
||||||
M.Cfg.media_previewer = M.Cfg.media_previewer
|
M.Cfg.media_previewer = M.Cfg.media_previewer
|
||||||
|
M.Cfg.media_extensions = M.Cfg.media_extensions
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _setup(cfg)
|
local function _setup(cfg)
|
||||||
|
|||||||
Reference in New Issue
Block a user