mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 14:14:24 -05:00
preview images of markdown links
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
- [ ] yt video
|
- [ ] yt video
|
||||||
|
|
||||||
## Dones
|
## Dones
|
||||||
|
- [x] preview images
|
||||||
- [x] insert link to image, with preview
|
- [x] insert link to image, with preview
|
||||||
- [x] sorting file picker: devicons, ...
|
- [x] sorting file picker: devicons, ...
|
||||||
- [x] dailies and weeklies: don't display whole paths: fix entries: display values
|
- [x] dailies and weeklies: don't display whole paths: fix entries: display values
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ A Neovim (lua) plugin for working with a text-based, markdown [zettelkasten](htt
|
|||||||
- calendar support
|
- calendar support
|
||||||
- paste images from clipboard
|
- paste images from clipboard
|
||||||
- toggle [ ] todo status of line
|
- toggle [ ] todo status of line
|
||||||
- insert links to images, with **image previews**, via extension _(Linux only)_
|
- insert links to images
|
||||||
|
- **image previews**, via extension _(Linux only)_
|
||||||
|
|
||||||
##### New features are being announced in the [discussions](https://github.com/renerocksai/telekasten.nvim/discussions)!
|
##### New features are being announced in the [discussions](https://github.com/renerocksai/telekasten.nvim/discussions)!
|
||||||
|
|
||||||
@@ -302,6 +303,8 @@ The plugin defines the following functions.
|
|||||||
- if the `telescope-media-files.nvim` plugin is installed, **a preview of images / media files will be given** during the search.
|
- if the `telescope-media-files.nvim` plugin is installed, **a preview of images / media files will be given** during the search.
|
||||||
- this function accepts a parameter `{i}`. If `true`, it will enter input mode by pressing the 'A' key. This is useful for being able to continue to type after link insertion. See also: [Bind it](#4-bind-it).
|
- this function accepts a parameter `{i}`. If `true`, it will enter input mode by pressing the 'A' key. This is useful for being able to continue to type after link insertion. See also: [Bind it](#4-bind-it).
|
||||||
- example: `insert_link({ i=true })`
|
- example: `insert_link({ i=true })`
|
||||||
|
- `preview_img()` : uses the `telescope-media-files.nvim` extension to preview the image / media file under the cursor of a markdown image link: ``. The cursor must be between `(the two parenthesis)`.
|
||||||
|
- **note**: this requires the `telescope-media-files.nvim` plugin to be installed.
|
||||||
- `setup(opts)`: used for configuring paths, file extension, etc.
|
- `setup(opts)`: used for configuring paths, file extension, etc.
|
||||||
|
|
||||||
To use one of the functions above, just run them with the `:lua ...` command.
|
To use one of the functions above, just run them with the `:lua ...` command.
|
||||||
@@ -419,6 +422,7 @@ nnoremap <leader>zt :lua require('telekasten').toggle_todo()<CR>
|
|||||||
nnoremap <leader>zb :lua require('telekasten').show_backlinks()<CR>
|
nnoremap <leader>zb :lua require('telekasten').show_backlinks()<CR>
|
||||||
nnoremap <leader>zF :lua require('telekasten').find_friends()<CR>
|
nnoremap <leader>zF :lua require('telekasten').find_friends()<CR>
|
||||||
nnoremap <leader>zI :lua require('telekasten').insert_img_link({ i=true })<CR>
|
nnoremap <leader>zI :lua require('telekasten').insert_img_link({ i=true })<CR>
|
||||||
|
nnoremap <leader>zp :lua require('telekasten').preview_img()<CR>
|
||||||
|
|
||||||
" we could define [[ in **insert mode** to call insert link
|
" we could define [[ in **insert mode** to call insert link
|
||||||
" inoremap [[ <ESC>:lua require('telekasten').insert_link()<CR>
|
" inoremap [[ <ESC>:lua require('telekasten').insert_link()<CR>
|
||||||
|
|||||||
@@ -454,6 +454,15 @@ telekasten.insert_img_link({opts})~
|
|||||||
|
|
||||||
Default: `nil`
|
Default: `nil`
|
||||||
|
|
||||||
|
*telekasten.preview_img()*
|
||||||
|
telekasten.preview_img()~
|
||||||
|
Uses the `telescope-media-files.nvim` extension to preview the image / media
|
||||||
|
file under the cursor of a markdown image link: ``. The
|
||||||
|
cursor must be between `(the two parenthesis)`.
|
||||||
|
|
||||||
|
Note:~
|
||||||
|
This requires the `telescope-media-files.nvim` plugin to be installed.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
Section 3.1: Templates *telekasten.templates*
|
Section 3.1: Templates *telekasten.templates*
|
||||||
|
|
||||||
@@ -584,6 +593,7 @@ However, here are some suggestions:
|
|||||||
nnoremap <leader>zb :lua require('telekasten').show_backlinks()<CR>
|
nnoremap <leader>zb :lua require('telekasten').show_backlinks()<CR>
|
||||||
nnoremap <leader>zF :lua require('telekasten').find_friends()<CR>
|
nnoremap <leader>zF :lua require('telekasten').find_friends()<CR>
|
||||||
nnoremap <leader>zI :lua require('telekasten').insert_img_link({ i=true })<CR>
|
nnoremap <leader>zI :lua require('telekasten').insert_img_link({ i=true })<CR>
|
||||||
|
nnoremap <leader>zp :lua require('telekasten').preview_img()<CR>
|
||||||
|
|
||||||
" we could define [[ in **insert mode** to call insert link
|
" we could define [[ in **insert mode** to call insert link
|
||||||
" inoremap [[ <ESC>:lua require('telekasten').insert_link()<CR>
|
" inoremap [[ <ESC>:lua require('telekasten').insert_link()<CR>
|
||||||
|
|||||||
@@ -471,6 +471,40 @@ local function FollowLink(opts)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- PreviewImg:
|
||||||
|
-- -----------
|
||||||
|
--
|
||||||
|
-- preview media
|
||||||
|
--
|
||||||
|
local function PreviewImg(_)
|
||||||
|
vim.cmd("normal yi)")
|
||||||
|
local fname = vim.fn.getreg('"0')
|
||||||
|
|
||||||
|
-- check if fname exists anywhere
|
||||||
|
local fexists = file_exists(M.Cfg.home .. "/" .. fname)
|
||||||
|
|
||||||
|
if fexists == true then
|
||||||
|
find_files_sorted({
|
||||||
|
prompt_title = "Preview image/media",
|
||||||
|
cwd = M.Cfg.home,
|
||||||
|
default_text = fname,
|
||||||
|
find_command = M.Cfg.find_command,
|
||||||
|
filter_extensions = { ".png", ".jpg", ".bmp", ".gif", ".pdf", ".mp4", ".webm" },
|
||||||
|
preview_type = "media",
|
||||||
|
|
||||||
|
attach_mappings = function(prompt_bufnr, _)
|
||||||
|
actions.select_default:replace(function()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
print("File not found: " .. M.Cfg.home .. "/" .. fname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FindFriends:
|
-- FindFriends:
|
||||||
-- -----------
|
-- -----------
|
||||||
@@ -557,7 +591,7 @@ end
|
|||||||
-- InsertImgLink:
|
-- InsertImgLink:
|
||||||
-- --------------
|
-- --------------
|
||||||
--
|
--
|
||||||
-- Select from notes
|
-- Insert link to image / media, with optional preview
|
||||||
--
|
--
|
||||||
local function InsertImgLink(opts)
|
local function InsertImgLink(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
@@ -915,5 +949,6 @@ M.toggle_todo = ToggleTodo
|
|||||||
M.show_backlinks = ShowBacklinks
|
M.show_backlinks = ShowBacklinks
|
||||||
M.find_friends = FindFriends
|
M.find_friends = FindFriends
|
||||||
M.insert_img_link = InsertImgLink
|
M.insert_img_link = InsertImgLink
|
||||||
|
M.preview_img = PreviewImg
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user