Skip to content

Commit

Permalink
chore: readme corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmx committed Jan 8, 2023
1 parent c3da7a1 commit 775ce6b
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 395 deletions.
66 changes: 11 additions & 55 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,58 +90,13 @@ This extension should be configured using the `extensions` field inside Telescop
However, you could also pass a table into the extension call.

```lua
--- this is optional
require("telescope").setup({
---Dimensions of the preview ueberzug window.
geometry = {
---X-offset of the ueberzug window.
x = -2,
---Y-offset of the ueberzug window.
y = -2,
---Width of the ueberzug window.
width = 1,
---Height of the ueberzug window.
height = 1,
},
find_command = {
"rg",
"--no-config",
"--files",
".",
},
backend = "ueberzug",
dynamic_preview_title = true,
on_confirm = canned.open_path,
on_confirm_muliple = canned.bulk_copy,
cache_path = "/tmp/tele.media.cache",
preview = {
title = "Previews",
filesize = 35,
enable_colorizer = true,
treesitter = true,
check_mime_type = true,
window_options = {
wrap = false,
winhl = "Normal:TelescopePreviewNormal",
signcolumn = "no",
foldlevel = 100,
scrollbind = false,
},
mimeforce = {
"json",
"lua",
"xml",
},
filetype_detect = true,
fill = {
mime_disable = "",
not_text_mime = "",
permission_denied = "",
caching = "",
stat_nil = "",
file_limit = "ˆ",
},
},
extensions = {
backend = "viu", -- "ueberzug"|"viu"|"chafa"|"jp2a"|catimg
on_confirm = canned.single.copy_path,
on_confirm_muliple = canned.multiple.bulk_copy,
cache_path = "/tmp/tele.media.cache",
}
})
```

Expand Down Expand Up @@ -182,15 +137,16 @@ Some of these are optional.

<summary>This is getting out of hand.</summary>

- [ ] Add documentations, briefs and notes.
- [x] Add documentations, briefs and notes.
- [ ] Recalibrate preview size when window is moved.
- [x] Add default text preview.
- [ ] Render html files using elinks, pandoc, lynx and w3m.
- [ ] Render markdown files using glow and pandoc.
- [ ] Add [viu](https://github.com/atanunq/viu) backend.
- [ ] Add [jp2a](https://github.com/cslarsen/jp2a) backend.
- [ ] Add [chafa](https://github.com/hpjansson/chafa/) backend.
- [x] Add [viu](https://github.com/atanunq/viu) backend.
- [x] Add [jp2a](https://github.com/cslarsen/jp2a) backend.
- [x] Add [chafa](https://github.com/hpjansson/chafa/) backend.
- [x] Add support for ZIPs.
- [x] Add support for binaries.
- [x] Add default image preview.
- [x] Add support for ebooks.
- [x] Add support for Ai/EPS.
Expand Down
81 changes: 5 additions & 76 deletions lua/telescope/_extensions/media/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@ if not present then
return
end

local utils = require("telescope.utils")
local actions = require("telescope.actions")
local finders = require("telescope.finders")
local pickers = require("telescope.pickers")
local config = require("telescope.config")

local action_state = require("telescope.actions.state")
local actions_layout = require("telescope.actions.layout")
local make_entry = require("telescope.make_entry")

local Job = require("plenary.job")
local Path = require("plenary.path")

local scope = require("telescope._extensions.media.scope")
local canned = require("telescope._extensions.media.canned")
local media_previewer = require("telescope._extensions.media.preview")
Expand All @@ -50,79 +45,18 @@ local fn = vim.fn
-- The default configuration. {{{
---This is the default configuration.
local _TelescopeMediaConfig = {
---Dimensions of the preview ueberzug window.
geometry = {
---X-offset of the ueberzug window.
x = -2,
---Y-offset of the ueberzug window.
y = -2,
---Width of the ueberzug window.
width = 1,
---Height of the ueberzug window.
height = 1,
},
find_command = {
"rg",
"--no-config",
"--files",
".",
},
backend = "ueberzug",
backend = "viu",
on_confirm = canned.single.copy_path,
on_confirm_muliple = canned.multiple.bulk_copy,
cache_path = "/tmp/tele.media.cache",
mappings = {
{ "n", "p", actions_layout.toggle_preview },
{ "n", "v", canned.actions.multiple_vsplit },
{ "n", "s", canned.actions.multiple_split },
{ "n", "f", actions_layout.cycle_layout_next },
{ "n", "b", actions_layout.cycle_layout_prev },
},
preview_title = "",
results_title = "",
prompt_title = "",
previewer = nil,
theme = "ivy",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
preview_cutoff = 1,
width = function(_, max_columns, _) return math.min(max_columns, 120) end,
height = function(_, _, max_lines) return math.min(max_lines, 20) end,
},
border = true,
borderchars = {
prompt = { "", "", " ", "", "", "", "", "" },
results = { "", "", "", "", "", "", "", "" },
preview = { "", "", "", "", "", "", "", "" },
},
prompt_title = "Media",
preview = {
timeout = 250, -- TODO
all_binaries = true, -- TODO
title = "",
filesize = 35,
colorizer = true,
treesitter = true,
check_mime_type = true,
window_options = {
wrap = false,
winhl = "Normal:TelescopePreviewNormal",
signcolumn = "no",
foldlevel = 100,
scrollbind = false,
},
mimeforce = {
"json",
"lua",
"xml",
},
filetype_detect = true,
fill = {
mime_disable = "",
not_text_mime = "",
permission_denied = "",
mime = "",
permission = "",
caching = "",
file_limit = "ˆ",
timeout = "", -- TODO
},
},
}
Expand Down Expand Up @@ -170,10 +104,6 @@ end
local function media(options)
options = F.if_nil(options, {})
options.attach_mappings = function(buffer, map)
for _, mapping in ipairs(options.mappings) do
map(mapping[1], mapping[2], mapping[3])
end

actions.select_default:replace(function(prompt_buffer)
local current_picker = action_state.get_current_picker(prompt_buffer)
local selections = current_picker:get_multi_selection()
Expand All @@ -192,7 +122,6 @@ local function media(options)
-- we need to do this everytime because a new table might be passed
-- for example: one might want to run this through the cmdline or whatever
options = vim.tbl_deep_extend("keep", options, _TelescopeMediaConfig)
options.find_command = find_command(options)

-- Validate find_command {{{
---@see telescope.previewers.buffer_previewer
Expand Down
Loading

0 comments on commit 775ce6b

Please sign in to comment.