mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
browse_media() and picker actions
This commit is contained in:
@@ -6,12 +6,12 @@
|
|||||||
- these buffers / this buffer should keep its size even when resizing other
|
- these buffers / this buffer should keep its size even when resizing other
|
||||||
splits (like the calendar)
|
splits (like the calendar)
|
||||||
- [ ] really good support for special links: inserting, yanking, ...
|
- [ ] really good support for special links: inserting, yanking, ...
|
||||||
- can we add image pre-viewing capabilities from `telescope-media-files` to the standard previewer or a self-written
|
|
||||||
pre-viewer (config)?
|
|
||||||
|
|
||||||
- [ ] yt video
|
- [ ] yt video
|
||||||
|
|
||||||
## Dones
|
## Dones
|
||||||
|
- [x] browse_media()
|
||||||
|
- [x] action mappings for notes: yanking and link inserting
|
||||||
- [x] document and suggest colors for Calendar nav buttons, they look weird in gruvbox
|
- [x] document and suggest colors for Calendar nav buttons, they look weird in gruvbox
|
||||||
- [x] initial support for special links
|
- [x] initial support for special links
|
||||||
- links to headings
|
- links to headings
|
||||||
|
|||||||
30
README.md
30
README.md
@@ -84,6 +84,7 @@ of being able to edit it.
|
|||||||
* [2.1 Note templates](#21-note-templates)
|
* [2.1 Note templates](#21-note-templates)
|
||||||
* [2.1.1 Template files](#211-template-files)
|
* [2.1.1 Template files](#211-template-files)
|
||||||
* [2.2 Using the calendar](#22-using-the-calendar)
|
* [2.2 Using the calendar](#22-using-the-calendar)
|
||||||
|
* [2.3 Using the telescope pickers](#23-using-the-telescope-pickers)
|
||||||
* [3. Bind it](#3-bind-it)
|
* [3. Bind it](#3-bind-it)
|
||||||
* [4. The hardcoded stuff](#4-the-hardcoded-stuff)
|
* [4. The hardcoded stuff](#4-the-hardcoded-stuff)
|
||||||
|
|
||||||
@@ -219,7 +220,12 @@ require('telekasten').setup({
|
|||||||
calendar_monday = 1,
|
calendar_monday = 1,
|
||||||
-- calendar mark: where to put mark for marked days: 'left', 'right', 'left-fit'
|
-- calendar mark: where to put mark for marked days: 'left', 'right', 'left-fit'
|
||||||
calendar_mark = 'left-fit',
|
calendar_mark = 'left-fit',
|
||||||
}
|
},
|
||||||
|
|
||||||
|
-- telescope actions behavior
|
||||||
|
close_after_yanking = false,
|
||||||
|
insert_after_inserting = true,
|
||||||
|
|
||||||
})
|
})
|
||||||
END
|
END
|
||||||
```
|
```
|
||||||
@@ -246,6 +252,8 @@ END
|
|||||||
| | set to `nil` if you want none | |
|
| | set to `nil` if you want none | |
|
||||||
| `plug_into_calendar` | activate calendar support if true (needs calendar-vim plugin) | true |
|
| `plug_into_calendar` | activate calendar support if true (needs calendar-vim plugin) | true |
|
||||||
| `calendar_opts` | options for calendar, see below | see below |
|
| `calendar_opts` | options for calendar, see below | see below |
|
||||||
|
| `close_after_yanking` | close telescope preview after yanking via <ctrl><y>| false |
|
||||||
|
| `insert_after_inserting` | enter insert mode after inserting a link from a telescope picker via <ctrl><i>| true |
|
||||||
|
|
||||||
**Please note:** If you do not want to use a template, set its associated option to `nil` or remove it from your config.
|
**Please note:** If you do not want to use a template, set its associated option to `nil` or remove it from your config.
|
||||||
```lua
|
```lua
|
||||||
@@ -363,6 +371,8 @@ The plugin defines the following functions:
|
|||||||
- `preview_img()` : uses the `telescope-media-files.nvim` extension to preview the image / media file under the cursor
|
- `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)`.
|
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.
|
- **note**: this requires the `telescope-media-files.nvim` plugin to be installed.
|
||||||
|
- `browse_media()` : uses the `telescope-media-files.nvim` extension to preview the image / media files
|
||||||
|
- **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.
|
||||||
@@ -523,6 +533,22 @@ command in vim:
|
|||||||
:CalendarT
|
:CalendarT
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 2.3 Using the telescope pickers
|
||||||
|
|
||||||
|
When you are prompted with a telescope picker to select a note or media file, the following mappings apply:
|
||||||
|
|
||||||
|
- <kbd>CTRL</kbd> + <kbd>i</kbd> : inserts a link to the selected note / image
|
||||||
|
- the option `insert_after_inserting` defines if insert mode will be entered after the link is pasted into your
|
||||||
|
current buffer
|
||||||
|
- <kbd>CTRL</kbd> + <kbd>y</kbd> : yanks a link to the selected note / image, ready for <kbd>p</kbd>asting
|
||||||
|
- the option `close_after_yanking` defines whether the telescope window should be closed when the link has been
|
||||||
|
yanked
|
||||||
|
- <kbd>RETURN / ENTER</kbd> : usually opens the selected note or performs the action defined by the called function
|
||||||
|
- e.g. `insert_img_link()`'s action is to insert a link to the selected image.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3. Bind it
|
## 3. Bind it
|
||||||
Usually, you would set up some key bindings, though:
|
Usually, you would set up some key bindings, though:
|
||||||
|
|
||||||
@@ -532,6 +558,7 @@ nnoremap <leader>zd :lua require('telekasten').find_daily_notes()<CR>
|
|||||||
nnoremap <leader>zg :lua require('telekasten').search_notes()<CR>
|
nnoremap <leader>zg :lua require('telekasten').search_notes()<CR>
|
||||||
nnoremap <leader>zz :lua require('telekasten').follow_link()<CR>
|
nnoremap <leader>zz :lua require('telekasten').follow_link()<CR>
|
||||||
nnoremap <leader>zT :lua require('telekasten').goto_today()<CR>
|
nnoremap <leader>zT :lua require('telekasten').goto_today()<CR>
|
||||||
|
nnoremap <leader>zW :lua require('telekasten').goto_thisweek()<CR>
|
||||||
nnoremap <leader>zw :lua require('telekasten').find_weekly_notes()<CR>
|
nnoremap <leader>zw :lua require('telekasten').find_weekly_notes()<CR>
|
||||||
nnoremap <leader>zn :lua require('telekasten').new_note()<CR>
|
nnoremap <leader>zn :lua require('telekasten').new_note()<CR>
|
||||||
nnoremap <leader>zN :lua require('telekasten').new_templated_note()<CR>
|
nnoremap <leader>zN :lua require('telekasten').new_templated_note()<CR>
|
||||||
@@ -544,6 +571,7 @@ 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>
|
nnoremap <leader>zp :lua require('telekasten').preview_img()<CR>
|
||||||
|
nnoremap <leader>zm :lua require('telekasten').browse_media()<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>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ CONTENTS
|
|||||||
3.1 Link Notation ............ |telekasten.link_notation|
|
3.1 Link Notation ............ |telekasten.link_notation|
|
||||||
3.2 Templates ................ |telekasten.templates|
|
3.2 Templates ................ |telekasten.templates|
|
||||||
3.3 Calendar ................. |telekasten.calendar|
|
3.3 Calendar ................. |telekasten.calendar|
|
||||||
|
3.4 Picker mappings .......... |telekasten.picker_mappings|
|
||||||
4. Suggested mappings ............ |telekasten.mappings|
|
4. Suggested mappings ............ |telekasten.mappings|
|
||||||
5. Credits ....................... |telekasten.credits|
|
5. Credits ....................... |telekasten.credits|
|
||||||
|
|
||||||
@@ -621,6 +622,27 @@ Note:~
|
|||||||
Calendar functions are only available if you have the plugin `calendar-vim`
|
Calendar functions are only available if you have the plugin `calendar-vim`
|
||||||
installed, which you can find at https://github.com/renerocksai/calendar-vim
|
installed, which you can find at https://github.com/renerocksai/calendar-vim
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Section 3.4: Picker mappings *telekasten.picker_mappings*
|
||||||
|
|
||||||
|
When you are prompted with a telescope picker to select a note or media file,
|
||||||
|
the following mappings apply:
|
||||||
|
|
||||||
|
<CTRL> + <i>
|
||||||
|
Inserts a link to the selected note / image.
|
||||||
|
The option `insert_after_inserting` defines if insert mode will be entered
|
||||||
|
after the link is pasted into your current buffer.
|
||||||
|
|
||||||
|
<CTRL> + <y>
|
||||||
|
Yanks a link to the selected note / image, ready for <p>asting.
|
||||||
|
The option `close_after_yanking` defines whether the telescope window should
|
||||||
|
be closed when the link has been yanked.
|
||||||
|
|
||||||
|
<RETURN> / <ENTER>
|
||||||
|
Usually opens the selected note or performs the action defined by the called
|
||||||
|
function. E.g. `insert_img_link()`'s action is to insert a link to the
|
||||||
|
selected image.
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Section 4: Suggested Mappings *telekasten.mappings*
|
Section 4: Suggested Mappings *telekasten.mappings*
|
||||||
|
|
||||||
@@ -633,6 +655,7 @@ However, here are some suggestions:
|
|||||||
nnoremap <leader>zg :lua require('telekasten').search_notes()<CR>
|
nnoremap <leader>zg :lua require('telekasten').search_notes()<CR>
|
||||||
nnoremap <leader>zz :lua require('telekasten').follow_link()<CR>
|
nnoremap <leader>zz :lua require('telekasten').follow_link()<CR>
|
||||||
nnoremap <leader>zT :lua require('telekasten').goto_today()<CR>
|
nnoremap <leader>zT :lua require('telekasten').goto_today()<CR>
|
||||||
|
nnoremap <leader>zW :lua require('telekasten').goto_thisweek()<CR>
|
||||||
nnoremap <leader>zw :lua require('telekasten').find_weekly_notes()<CR>
|
nnoremap <leader>zw :lua require('telekasten').find_weekly_notes()<CR>
|
||||||
nnoremap <leader>zn :lua require('telekasten').new_note()<CR>
|
nnoremap <leader>zn :lua require('telekasten').new_note()<CR>
|
||||||
nnoremap <leader>zN :lua require('telekasten').new_templated_note()<CR>
|
nnoremap <leader>zN :lua require('telekasten').new_templated_note()<CR>
|
||||||
@@ -645,6 +668,7 @@ However, here are some suggestions:
|
|||||||
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>
|
nnoremap <leader>zp :lua require('telekasten').preview_img()<CR>
|
||||||
|
nnoremap <leader>zm :lua require('telekasten').browse_media()<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>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local scan = require("plenary.scandir")
|
|||||||
local utils = require("telescope.utils")
|
local utils = require("telescope.utils")
|
||||||
local previewers = require("telescope.previewers")
|
local previewers = require("telescope.previewers")
|
||||||
local make_entry = require("telescope.make_entry")
|
local make_entry = require("telescope.make_entry")
|
||||||
local debug_utils = require('plenary.debug_utils')
|
local debug_utils = require("plenary.debug_utils")
|
||||||
|
|
||||||
-- declare locals for the nvim api stuff to avoid more lsp warnings
|
-- declare locals for the nvim api stuff to avoid more lsp warnings
|
||||||
local vim = vim
|
local vim = vim
|
||||||
@@ -58,6 +58,8 @@ M.Cfg = {
|
|||||||
-- calendar mark: where to put mark for marked days: 'left', 'right', 'left-fit'
|
-- calendar mark: where to put mark for marked days: 'left', 'right', 'left-fit'
|
||||||
calendar_mark = "left-fit",
|
calendar_mark = "left-fit",
|
||||||
},
|
},
|
||||||
|
close_after_yanking = false,
|
||||||
|
insert_after_inserting = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function file_exists(fname)
|
local function file_exists(fname)
|
||||||
@@ -295,12 +297,13 @@ end
|
|||||||
|
|
||||||
local sourced_file = debug_utils.sourced_filepath()
|
local sourced_file = debug_utils.sourced_filepath()
|
||||||
M.base_directory = vim.fn.fnamemodify(sourced_file, ":h:h:h")
|
M.base_directory = vim.fn.fnamemodify(sourced_file, ":h:h:h")
|
||||||
local media_files_base_directory = M.base_directory .. "/telescope-media-files.nvim"
|
local media_files_base_directory = M.base_directory
|
||||||
|
.. "/telescope-media-files.nvim"
|
||||||
local defaulter = utils.make_default_callable
|
local defaulter = utils.make_default_callable
|
||||||
local media_preview = defaulter(function(opts)
|
local media_preview = defaulter(function(opts)
|
||||||
local preview_cmd = media_files_base_directory .. "/scripts/vimg"
|
local preview_cmd = media_files_base_directory .. "/scripts/vimg"
|
||||||
if vim.fn.executable(preview_cmd) == 0 then
|
if vim.fn.executable(preview_cmd) == 0 then
|
||||||
print('Previewer not found: ' .. preview_cmd)
|
print("Previewer not found: " .. preview_cmd)
|
||||||
return conf.file_previewer(opts)
|
return conf.file_previewer(opts)
|
||||||
end
|
end
|
||||||
return previewers.new_termopen_previewer({
|
return previewers.new_termopen_previewer({
|
||||||
@@ -405,6 +408,65 @@ local function find_files_sorted(opts)
|
|||||||
picker:find()
|
picker:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- note picker actions
|
||||||
|
local picker_actions = {}
|
||||||
|
|
||||||
|
function picker_actions.paste_link(opts)
|
||||||
|
return function(prompt_bufnr)
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
local fn = path_to_linkname(selection.value)
|
||||||
|
local title = "[[" .. fn .. "]]"
|
||||||
|
vim.api.nvim_put({ title }, "", true, true)
|
||||||
|
if opts.insert_after_inserting then
|
||||||
|
vim.api.nvim_feedkeys("A", "m", false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function picker_actions.yank_link(opts)
|
||||||
|
return function(prompt_bufnr)
|
||||||
|
opts = opts or {}
|
||||||
|
if opts.close_after_yanking then
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
end
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
local fn = path_to_linkname(selection.value)
|
||||||
|
local title = "[[" .. fn .. "]]"
|
||||||
|
vim.fn.setreg('"', title)
|
||||||
|
print("yanked " .. title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function picker_actions.paste_img_link(opts)
|
||||||
|
return function(prompt_bufnr)
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
local fn = selection.value
|
||||||
|
fn = fn:gsub(M.Cfg.home .. "/", "")
|
||||||
|
local imglink = ""
|
||||||
|
vim.api.nvim_put({ imglink }, "", true, true)
|
||||||
|
if opts.insert_after_inserting then
|
||||||
|
vim.api.nvim_feedkeys("A", "m", false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function picker_actions.yank_img_link(opts)
|
||||||
|
return function(prompt_bufnr)
|
||||||
|
opts = opts or {}
|
||||||
|
if opts.close_after_yanking then
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
end
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
local fn = selection.value
|
||||||
|
fn = fn:gsub(M.Cfg.home .. "/", "")
|
||||||
|
local imglink = ""
|
||||||
|
vim.fn.setreg('"', imglink)
|
||||||
|
print("yanked " .. imglink)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FindDailyNotes:
|
-- FindDailyNotes:
|
||||||
-- ---------------
|
-- ---------------
|
||||||
@@ -413,6 +475,10 @@ end
|
|||||||
--
|
--
|
||||||
local function FindDailyNotes(opts)
|
local function FindDailyNotes(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
local today = os.date("%Y-%m-%d")
|
local today = os.date("%Y-%m-%d")
|
||||||
local fname = M.Cfg.dailies .. "/" .. today .. M.Cfg.extension
|
local fname = M.Cfg.dailies .. "/" .. today .. M.Cfg.extension
|
||||||
@@ -431,6 +497,15 @@ local function FindDailyNotes(opts)
|
|||||||
prompt_title = "Find daily note",
|
prompt_title = "Find daily note",
|
||||||
cwd = M.Cfg.dailies,
|
cwd = M.Cfg.dailies,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -442,6 +517,10 @@ end
|
|||||||
--
|
--
|
||||||
local function FindWeeklyNotes(opts)
|
local function FindWeeklyNotes(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
local title = os.date("%Y-W%V")
|
local title = os.date("%Y-W%V")
|
||||||
local fname = M.Cfg.weeklies .. "/" .. title .. M.Cfg.extension
|
local fname = M.Cfg.weeklies .. "/" .. title .. M.Cfg.extension
|
||||||
@@ -460,6 +539,15 @@ local function FindWeeklyNotes(opts)
|
|||||||
prompt_title = "Find weekly note",
|
prompt_title = "Find weekly note",
|
||||||
cwd = M.Cfg.weeklies,
|
cwd = M.Cfg.weeklies,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -471,10 +559,14 @@ end
|
|||||||
--
|
--
|
||||||
local function InsertLink(opts)
|
local function InsertLink(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
find_files_sorted({
|
find_files_sorted({
|
||||||
prompt_title = "Insert link to note",
|
prompt_title = "Insert link to note",
|
||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
@@ -484,6 +576,12 @@ local function InsertLink(opts)
|
|||||||
vim.api.nvim_feedkeys("A", "m", false)
|
vim.api.nvim_feedkeys("A", "m", false)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
@@ -498,6 +596,11 @@ end
|
|||||||
--
|
--
|
||||||
local function FollowLink(opts)
|
local function FollowLink(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
vim.cmd("normal yi]")
|
vim.cmd("normal yi]")
|
||||||
local title = vim.fn.getreg('"0')
|
local title = vim.fn.getreg('"0')
|
||||||
title = title:gsub("^(%[)(.+)(%])$", "%2")
|
title = title:gsub("^(%[)(.+)(%])$", "%2")
|
||||||
@@ -571,6 +674,15 @@ local function FollowLink(opts)
|
|||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
default_text = title,
|
default_text = title,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -622,6 +734,15 @@ local function FollowLink(opts)
|
|||||||
-- link to heading in specific file (a daily file): [[The cool note#^xAcSh-xxr]]
|
-- link to heading in specific file (a daily file): [[The cool note#^xAcSh-xxr]]
|
||||||
-- link to paragraph globally [[#^xAcSh-xxr]]
|
-- link to paragraph globally [[#^xAcSh-xxr]]
|
||||||
finder = live_grepper,
|
finder = live_grepper,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -632,7 +753,13 @@ end
|
|||||||
--
|
--
|
||||||
-- preview media
|
-- preview media
|
||||||
--
|
--
|
||||||
local function PreviewImg(_)
|
local function PreviewImg(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
vim.cmd("normal yi)")
|
vim.cmd("normal yi)")
|
||||||
local fname = vim.fn.getreg('"0')
|
local fname = vim.fn.getreg('"0')
|
||||||
|
|
||||||
@@ -656,10 +783,16 @@ local function PreviewImg(_)
|
|||||||
},
|
},
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
|
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
end)
|
end)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_img_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_img_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_img_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_img_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_img_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_img_link(opts))
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@@ -668,13 +801,62 @@ local function PreviewImg(_)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- BrowseImg:
|
||||||
|
-- -----------
|
||||||
|
--
|
||||||
|
-- preview media
|
||||||
|
--
|
||||||
|
local function BrowseImg(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
|
find_files_sorted({
|
||||||
|
prompt_title = "Preview image/media",
|
||||||
|
cwd = M.Cfg.home,
|
||||||
|
find_command = M.Cfg.find_command,
|
||||||
|
filter_extensions = {
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".bmp",
|
||||||
|
".gif",
|
||||||
|
".pdf",
|
||||||
|
".mp4",
|
||||||
|
".webm",
|
||||||
|
},
|
||||||
|
preview_type = "media",
|
||||||
|
|
||||||
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
|
actions.select_default:replace(function()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
end)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_img_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_img_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_img_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_img_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_img_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_img_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FindFriends:
|
-- FindFriends:
|
||||||
-- -----------
|
-- -----------
|
||||||
--
|
--
|
||||||
-- Find notes also linking to the link under cursor
|
-- Find notes also linking to the link under cursor
|
||||||
--
|
--
|
||||||
local function FindFriends()
|
local function FindFriends(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
vim.cmd("normal yi]")
|
vim.cmd("normal yi]")
|
||||||
local title = vim.fn.getreg('"0')
|
local title = vim.fn.getreg('"0')
|
||||||
title = title:gsub("^(%[)(.+)(%])$", "%2")
|
title = title:gsub("^(%[)(.+)(%])$", "%2")
|
||||||
@@ -684,6 +866,15 @@ local function FindFriends()
|
|||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
default_text = "\\[\\[" .. title .. "\\]\\]",
|
default_text = "\\[\\[" .. title .. "\\]\\]",
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -707,6 +898,11 @@ end
|
|||||||
--
|
--
|
||||||
local function GotoToday(opts)
|
local function GotoToday(opts)
|
||||||
opts = opts or calenderinfo_today()
|
opts = opts or calenderinfo_today()
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
local word = opts.date or os.date("%Y-%m-%d")
|
local word = opts.date or os.date("%Y-%m-%d")
|
||||||
|
|
||||||
local fname = M.Cfg.dailies .. "/" .. word .. M.Cfg.extension
|
local fname = M.Cfg.dailies .. "/" .. word .. M.Cfg.extension
|
||||||
@@ -731,7 +927,7 @@ local function GotoToday(opts)
|
|||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
default_text = word,
|
default_text = word,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
|
|
||||||
@@ -741,6 +937,12 @@ local function GotoToday(opts)
|
|||||||
end
|
end
|
||||||
vim.cmd("e " .. fname)
|
vim.cmd("e " .. fname)
|
||||||
end)
|
end)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@@ -752,11 +954,26 @@ end
|
|||||||
--
|
--
|
||||||
-- Select from notes
|
-- Select from notes
|
||||||
--
|
--
|
||||||
local function FindNotes(_)
|
local function FindNotes(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
find_files_sorted({
|
find_files_sorted({
|
||||||
prompt_title = "Find notes by name",
|
prompt_title = "Find notes by name",
|
||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -783,7 +1000,7 @@ local function InsertImgLink(opts)
|
|||||||
},
|
},
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
|
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
@@ -794,6 +1011,12 @@ local function InsertImgLink(opts)
|
|||||||
vim.api.nvim_feedkeys("A", "m", false)
|
vim.api.nvim_feedkeys("A", "m", false)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_img_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_img_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_img_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_img_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_img_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_img_link(opts))
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@@ -805,13 +1028,28 @@ end
|
|||||||
--
|
--
|
||||||
-- find the file linked to by the word under the cursor
|
-- find the file linked to by the word under the cursor
|
||||||
--
|
--
|
||||||
local function SearchNotes(_)
|
local function SearchNotes(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
builtin.live_grep({
|
builtin.live_grep({
|
||||||
prompt_title = "Search in notes",
|
prompt_title = "Search in notes",
|
||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
search_dirs = { M.Cfg.home },
|
search_dirs = { M.Cfg.home },
|
||||||
default_text = vim.fn.expand("<cword>"),
|
default_text = vim.fn.expand("<cword>"),
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -821,7 +1059,13 @@ end
|
|||||||
--
|
--
|
||||||
-- Find all notes linking to this one
|
-- Find all notes linking to this one
|
||||||
--
|
--
|
||||||
local function ShowBacklinks(_)
|
local function ShowBacklinks(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
local title = path_to_linkname(vim.fn.expand("%"))
|
local title = path_to_linkname(vim.fn.expand("%"))
|
||||||
-- or vim.api.nvim_buf_get_name(0)
|
-- or vim.api.nvim_buf_get_name(0)
|
||||||
builtin.live_grep({
|
builtin.live_grep({
|
||||||
@@ -831,6 +1075,15 @@ local function ShowBacklinks(_)
|
|||||||
search_dirs = { M.Cfg.home },
|
search_dirs = { M.Cfg.home },
|
||||||
default_text = "\\[\\[" .. title .. "\\]\\]",
|
default_text = "\\[\\[" .. title .. "\\]\\]",
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -840,7 +1093,13 @@ end
|
|||||||
--
|
--
|
||||||
-- Prompts for title and creates note with default template
|
-- Prompts for title and creates note with default template
|
||||||
--
|
--
|
||||||
local function on_create(title)
|
local function on_create(opts, title)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
if title == nil then
|
if title == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -856,16 +1115,24 @@ local function on_create(title)
|
|||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
default_text = title,
|
default_text = title,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CreateNote(_)
|
local function CreateNote(opts)
|
||||||
|
opts = opts or {}
|
||||||
-- vim.ui.input causes ppl problems - see issue #4
|
-- vim.ui.input causes ppl problems - see issue #4
|
||||||
-- vim.ui.input({ prompt = "Title: " }, on_create)
|
-- vim.ui.input({ prompt = "Title: " }, on_create)
|
||||||
local title = vim.fn.input("Title: ")
|
local title = vim.fn.input("Title: ")
|
||||||
title = title:gsub("[" .. M.Cfg.extension .. "]+$", "")
|
title = title:gsub("[" .. M.Cfg.extension .. "]+$", "")
|
||||||
if #title > 0 then
|
if #title > 0 then
|
||||||
on_create(title)
|
on_create(opts, title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -876,11 +1143,17 @@ end
|
|||||||
-- Prompts for title, then pops up telescope for template selection,
|
-- Prompts for title, then pops up telescope for template selection,
|
||||||
-- creates the new note by template and opens it
|
-- creates the new note by template and opens it
|
||||||
|
|
||||||
local function on_create_with_template(title)
|
local function on_create_with_template(opts, title)
|
||||||
if title == nil then
|
if title == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
local fname = M.Cfg.home .. "/" .. title .. M.Cfg.extension
|
local fname = M.Cfg.home .. "/" .. title .. M.Cfg.extension
|
||||||
local fexists = file_exists(fname)
|
local fexists = file_exists(fname)
|
||||||
if fexists == true then
|
if fexists == true then
|
||||||
@@ -893,7 +1166,7 @@ local function on_create_with_template(title)
|
|||||||
prompt_title = "Select template...",
|
prompt_title = "Select template...",
|
||||||
cwd = M.Cfg.templates,
|
cwd = M.Cfg.templates,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
-- local template = M.Cfg.templates .. "/" .. action_state.get_selected_entry().value
|
-- local template = M.Cfg.templates .. "/" .. action_state.get_selected_entry().value
|
||||||
@@ -902,18 +1175,23 @@ local function on_create_with_template(title)
|
|||||||
-- open the new note
|
-- open the new note
|
||||||
vim.cmd("e " .. fname)
|
vim.cmd("e " .. fname)
|
||||||
end)
|
end)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CreateNoteSelectTemplate(_)
|
local function CreateNoteSelectTemplate(opts)
|
||||||
|
opts = opts or {}
|
||||||
-- vim.ui.input causes ppl problems - see issue #4
|
-- vim.ui.input causes ppl problems - see issue #4
|
||||||
-- vim.ui.input({ prompt = "Title: " }, on_create_with_template)
|
-- vim.ui.input({ prompt = "Title: " }, on_create_with_template)
|
||||||
local title = vim.fn.input("Title: ")
|
local title = vim.fn.input("Title: ")
|
||||||
title = title:gsub("[" .. M.Cfg.extension .. "]+$", "")
|
title = title:gsub("[" .. M.Cfg.extension .. "]+$", "")
|
||||||
if #title > 0 then
|
if #title > 0 then
|
||||||
on_create_with_template(title)
|
on_create_with_template(opts, title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -925,6 +1203,10 @@ end
|
|||||||
--
|
--
|
||||||
local function GotoThisWeek(opts)
|
local function GotoThisWeek(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
opts.insert_after_inserting = opts.insert_after_inserting
|
||||||
|
or M.Cfg.insert_after_inserting
|
||||||
|
opts.close_after_yanking = opts.close_after_yanking
|
||||||
|
or M.Cfg.close_after_yanking
|
||||||
|
|
||||||
local title = os.date("%Y-W%V")
|
local title = os.date("%Y-W%V")
|
||||||
local fname = M.Cfg.weeklies .. "/" .. title .. M.Cfg.extension
|
local fname = M.Cfg.weeklies .. "/" .. title .. M.Cfg.extension
|
||||||
@@ -944,6 +1226,13 @@ local function GotoThisWeek(opts)
|
|||||||
cwd = M.Cfg.weeklies,
|
cwd = M.Cfg.weeklies,
|
||||||
default_text = title,
|
default_text = title,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("i", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
map("n", "<c-y>", picker_actions.yank_link(opts))
|
||||||
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1161,5 +1450,6 @@ 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
|
M.preview_img = PreviewImg
|
||||||
|
M.browse_media = BrowseImg
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user