mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 14:14:24 -05:00
refactored! daily finder is gone!
This commit is contained in:
@@ -1,12 +1,10 @@
|
|||||||
# Backlog
|
# Backlog
|
||||||
|
|
||||||
- **!!!!!** recurse subdirs!!!!
|
|
||||||
|
|
||||||
- extend markdown syntax highlights for [[links]]
|
- extend markdown syntax highlights for [[links]]
|
||||||
- get rid of `daily_finder.sh`
|
|
||||||
- maybe choose template in create note
|
- maybe choose template in create note
|
||||||
|
|
||||||
## Dones
|
## Dones
|
||||||
|
- [x] get rid of `daily_finder.sh`
|
||||||
- [x] find weekly note
|
- [x] find weekly note
|
||||||
- [x] goto week
|
- [x] goto week
|
||||||
- [x] create note, use default template
|
- [x] create note, use default template
|
||||||
@@ -15,4 +13,3 @@
|
|||||||
- [x] shortcuts for todo and done in init.vim
|
- [x] shortcuts for todo and done in init.vim
|
||||||
- [x] Readme search based navigation
|
- [x] Readme search based navigation
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
37
README.md
37
README.md
@@ -15,15 +15,20 @@ I find that pressing the enter key to confirm the search does not interrupt my f
|
|||||||
|
|
||||||
## Install and setup
|
## Install and setup
|
||||||
|
|
||||||
**MS Windows note:** At the moment, telekasten.nvim is unlikely to be able to run on Windows, because it relies on a bash script. Just sayin. Since telekasten.nvim is a project that scratches my own itch, I am not sure if I will add Windows support any time soon. Should anyone read this: Pull requests are welcome 😄! Replacing the daily finder by a proper lua version should do the trick.
|
|
||||||
|
|
||||||
|
|
||||||
### 0. Prerequisites
|
### 0. Prerequisites
|
||||||
|
|
||||||
|
#### Telescope
|
||||||
Since this plugin uses [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim), you need to install it first.
|
Since this plugin uses [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim), you need to install it first.
|
||||||
|
|
||||||
[Neovim (v0.5.1)](https://github.com/neovim/neovim/releases/tag/v0.5.1) or the latest neovim nighly commit is required for `telescope.nvim` to work.
|
[Neovim (v0.5.1)](https://github.com/neovim/neovim/releases/tag/v0.5.1) or the latest neovim nighly commit is required for `telescope.nvim` to work.
|
||||||
|
|
||||||
|
#### Ripgrep
|
||||||
|
For proper sort order of daily notes, the `rg` executable ([Ripgrep](https://github.com/BurntSushi/ripgrep)) is required and needs to be installed so that nvim can find it. So make sure, it's in your path.
|
||||||
|
|
||||||
|
If rg isn't found at `setup()` time, it will not be used. In that case, the sort order of daily and weekly notes are likely to be reversed. I do accept pull requests, though, for a lua implementation 😁!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 1. Install the plugin
|
### 1. Install the plugin
|
||||||
Install with your plugin manager of choice. Mine is [Vundle](https://github.com/VundleVim/Vundle.vim).
|
Install with your plugin manager of choice. Mine is [Vundle](https://github.com/VundleVim/Vundle.vim).
|
||||||
@@ -32,6 +37,7 @@ Install with your plugin manager of choice. Mine is [Vundle](https://github.com
|
|||||||
Plugin 'renerocksai/telekasten.nvim'
|
Plugin 'renerocksai/telekasten.nvim'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### 2. Configure telekasten.nvim
|
### 2. Configure telekasten.nvim
|
||||||
Somewhere in your vim config, put a snippet like this:
|
Somewhere in your vim config, put a snippet like this:
|
||||||
|
|
||||||
@@ -43,15 +49,6 @@ require('telekasten').setup({
|
|||||||
dailies = home .. '/' .. 'daily',
|
dailies = home .. '/' .. 'daily',
|
||||||
weeklies = home .. '/' .. 'weekly',
|
weeklies = home .. '/' .. 'weekly',
|
||||||
extension = ".md",
|
extension = ".md",
|
||||||
daily_finder = "daily_finder.sh",
|
|
||||||
|
|
||||||
-- where to install the daily_finder,
|
|
||||||
-- (must be a dir in your PATH)
|
|
||||||
my_bin = vim.fn.expand('~/bin'),
|
|
||||||
|
|
||||||
-- download tool for daily_finder installation: curl or wget
|
|
||||||
downloader = 'curl',
|
|
||||||
-- downloader = 'wget', -- wget is supported, too
|
|
||||||
|
|
||||||
-- following a link to a non-existing note will create it
|
-- following a link to a non-existing note will create it
|
||||||
follow_creates_nonexisting = true,
|
follow_creates_nonexisting = true,
|
||||||
@@ -70,16 +67,6 @@ require('telekasten').setup({
|
|||||||
END
|
END
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Install the daily finder
|
|
||||||
Before using telekasten.nvim, a shell script needs to be installed. It finds and sorts notes the way we want. As long as I don't have a lua version for this functionality (this is literally the first time I use lua), we will have to stick with `daily_finder.sh`.
|
|
||||||
|
|
||||||
Luckily, the plugin can install the daily finder for you, directly from [GitHub](https://raw.githubusercontent.com/renerocksai/telekasten.nvim/main/ext_commands/daily_finder.sh):
|
|
||||||
|
|
||||||
```
|
|
||||||
:lua require('telekasten.nvim').install_daily_finder()
|
|
||||||
```
|
|
||||||
|
|
||||||
This will download the daily finder into the `bin/` folder of your home directory - or the directory you specified as `my_bin` in the step above.
|
|
||||||
|
|
||||||
## Use it
|
## Use it
|
||||||
|
|
||||||
@@ -94,7 +81,6 @@ The plugin defines the following functions.
|
|||||||
- `search_notes()`: live grep for word under cursor in all notes (search in notes), via Telescope
|
- `search_notes()`: live grep for word under cursor in all notes (search in notes), via Telescope
|
||||||
- `insert_link()` : select a note by name, via Telescope, and place a `[[link]]` at the current cursor position
|
- `insert_link()` : select a note by name, via Telescope, and place a `[[link]]` at the current cursor position
|
||||||
- `follow_link()`: take text between brackets (linked note) and open a Telescope file finder with it: selects note to open (incl. preview) - with optional note creation for non-existing notes, honoring the configured template
|
- `follow_link()`: take text between brackets (linked note) and open a Telescope file finder with it: selects note to open (incl. preview) - with optional note creation for non-existing notes, honoring the configured template
|
||||||
- `install_daily_finder()` : installs the daily finder tool used by the plugin
|
|
||||||
- `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.
|
||||||
@@ -200,10 +186,3 @@ Currently, the following things are hardcoded:
|
|||||||
- the file naming format for daily note files: YYYY-MM-DD.ext (e.g. 2021-11-21.md)
|
- the file naming format for daily note files: YYYY-MM-DD.ext (e.g. 2021-11-21.md)
|
||||||
- the file naming format for weekly note files: YYYY-Www.ext (e.g. 2021-W46.md)
|
- the file naming format for weekly note files: YYYY-Www.ext (e.g. 2021-W46.md)
|
||||||
|
|
||||||
Finding and sorting notes is contained in the `daily_finder.sh` script - which you can edit to your liking. I recommend making a copy, though. Otherwise your changes get lost with every plugin update. Don't forget to set `daily_finder = "my_edited_daily_finder.sh"` in the `setup()`, provided you named your copy `my_edited_daily_finder.sh`.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# daily_finder for telekasten.nvim
|
|
||||||
#
|
|
||||||
# actually, this is now the standard finder in telekasten
|
|
||||||
|
|
||||||
if [ "$1" == "check" ] ; then
|
|
||||||
echo OK
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if called by the plugin, no args are provided, and the current working
|
|
||||||
# directory is set instead
|
|
||||||
if [ "$1" == "" ] ; then
|
|
||||||
the_dir=$(pwd)
|
|
||||||
else
|
|
||||||
the_dir=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# sort reversed numerical
|
|
||||||
find $the_dir -type f | sort -rn
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
local builtin = require "telescope.builtin"
|
local builtin = require "telescope.builtin"
|
||||||
|
|
||||||
local actions = require("telescope.actions")
|
local actions = require("telescope.actions") local action_state = require "telescope.actions.state"
|
||||||
local action_state = require "telescope.actions.state"
|
|
||||||
|
|
||||||
-- 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
|
||||||
|
|
||||||
|
-- TODO : check if rg exists: vim.fn.executable('rg') - if it isn't, don't set the find_command
|
||||||
|
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
-- DEFAULT CONFIG
|
-- DEFAULT CONFIG
|
||||||
@@ -17,15 +17,7 @@ ZkCfg = {
|
|||||||
dailies = home .. '/' .. 'daily',
|
dailies = home .. '/' .. 'daily',
|
||||||
weeklies = home .. '/' .. 'weekly',
|
weeklies = home .. '/' .. 'weekly',
|
||||||
extension = ".md",
|
extension = ".md",
|
||||||
daily_finder = "daily_finder.sh",
|
|
||||||
|
|
||||||
-- where to install the daily_finder,
|
|
||||||
-- (must be a dir in your PATH)
|
|
||||||
my_bin = vim.fn.expand('~/bin'),
|
|
||||||
|
|
||||||
-- download tool for daily_finder installation: curl or wget
|
|
||||||
downloader = 'curl',
|
|
||||||
-- downloader = 'wget', -- wget is supported, too
|
|
||||||
|
|
||||||
-- following a link to a non-existing note will create it
|
-- following a link to a non-existing note will create it
|
||||||
follow_creates_nonexisting = true,
|
follow_creates_nonexisting = true,
|
||||||
@@ -40,26 +32,17 @@ ZkCfg = {
|
|||||||
|
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local downloader2cmd = {
|
|
||||||
curl = 'curl -o',
|
|
||||||
wget = 'wget -O',
|
|
||||||
}
|
|
||||||
|
|
||||||
local note_type_templates = {
|
local note_type_templates = {
|
||||||
normal = ZkCfg.template_new_note,
|
normal = ZkCfg.template_new_note,
|
||||||
daily = ZkCfg.template_new_daily,
|
daily = ZkCfg.template_new_daily,
|
||||||
weekly = ZkCfg.template_new_weekly,
|
weekly = ZkCfg.template_new_weekly,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local function file_exists(fname)
|
local function file_exists(fname)
|
||||||
local f=io.open(fname,"r")
|
local f=io.open(fname,"r")
|
||||||
if f~=nil then io.close(f) return true else return false end
|
if f~=nil then io.close(f) return true else return false end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function daysuffix(day)
|
local function daysuffix(day)
|
||||||
if((day == '1') or (day == '21') or (day == '31')) then return 'st' end
|
if((day == '1') or (day == '21') or (day == '31')) then return 'st' end
|
||||||
if((day == '2') or (day == '22')) then return 'nd' end
|
if((day == '2') or (day == '22')) then return 'nd' end
|
||||||
@@ -67,7 +50,6 @@ local function daysuffix(day)
|
|||||||
return 'th'
|
return 'th'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function linesubst(line, title)
|
local function linesubst(line, title)
|
||||||
local substs = {
|
local substs = {
|
||||||
date = os.date('%Y-%m-%d'),
|
date = os.date('%Y-%m-%d'),
|
||||||
@@ -83,7 +65,6 @@ local function linesubst(line, title)
|
|||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local create_note_from_template = function (title, filepath, templatefn)
|
local create_note_from_template = function (title, filepath, templatefn)
|
||||||
-- first, read the template file
|
-- first, read the template file
|
||||||
local lines = {}
|
local lines = {}
|
||||||
@@ -100,7 +81,6 @@ local create_note_from_template = function (title, filepath, templatefn)
|
|||||||
ofile:close()
|
ofile:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local path_to_linkname = function(p)
|
local path_to_linkname = function(p)
|
||||||
local fn = vim.split(p, "/")
|
local fn = vim.split(p, "/")
|
||||||
fn = fn[#fn]
|
fn = fn[#fn]
|
||||||
@@ -110,38 +90,6 @@ local path_to_linkname = function(p)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local zk_entry_maker = function(entry)
|
|
||||||
return {
|
|
||||||
value = entry,
|
|
||||||
display = path_to_linkname(entry),
|
|
||||||
ordinal = entry,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local check_local_finder = function()
|
|
||||||
local ret = vim.fn.system(ZkCfg.daily_finder .. ' check')
|
|
||||||
return ret == "OK\n"
|
|
||||||
-- return vim.fn.executable(ZkCfg.daily_finder) == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- InstallDailyFinder:
|
|
||||||
-- -------------------
|
|
||||||
--
|
|
||||||
-- downloads the daily finder scripts to the configured `my_bin` directory
|
|
||||||
-- and makes it executable
|
|
||||||
--
|
|
||||||
InstallDailyFinder = function()
|
|
||||||
local destpath = ZkCfg.my_bin .. '/' .. ZkCfg.daily_finder
|
|
||||||
local cmd = downloader2cmd[ZkCfg.downloader]
|
|
||||||
vim.api.nvim_command('!'.. cmd .. ' ' .. destpath .. ' https://raw.githubusercontent.com/renerocksai/telekasten.nvim/main/ext_commands/daily_finder.sh')
|
|
||||||
vim.api.nvim_command('!chmod +x ' .. destpath)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FindDailyNotes:
|
-- FindDailyNotes:
|
||||||
-- ---------------
|
-- ---------------
|
||||||
@@ -158,20 +106,14 @@ FindDailyNotes = function(opts)
|
|||||||
create_note_from_template(today, fname, note_type_templates.daily)
|
create_note_from_template(today, fname, note_type_templates.daily)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (check_local_finder() == true) then
|
|
||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
prompt_title = "Find daily note",
|
prompt_title = "Find daily note",
|
||||||
cwd = ZkCfg.dailies,
|
cwd = ZkCfg.dailies,
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
entry_maker = zk_entry_maker,
|
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print("Daily finder not found. Try :lua require('telekasten').install_daily_finder()")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FindWeeklyNotes:
|
-- FindWeeklyNotes:
|
||||||
-- ---------------
|
-- ---------------
|
||||||
@@ -188,20 +130,14 @@ FindWeeklyNotes = function(opts)
|
|||||||
create_note_from_template(title, fname, note_type_templates.weekly)
|
create_note_from_template(title, fname, note_type_templates.weekly)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (check_local_finder() == true) then
|
|
||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
prompt_title = "Find weekly note",
|
prompt_title = "Find weekly note",
|
||||||
cwd = ZkCfg.weeklies,
|
cwd = ZkCfg.weeklies,
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
entry_maker = zk_entry_maker,
|
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print("Daily finder not found. Try :lua require('telekasten').install_daily_finder()")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- InsertLink:
|
-- InsertLink:
|
||||||
-- -----------
|
-- -----------
|
||||||
@@ -210,7 +146,6 @@ end
|
|||||||
--
|
--
|
||||||
InsertLink = function(opts)
|
InsertLink = function(opts)
|
||||||
opts = {} or opts
|
opts = {} or opts
|
||||||
if (check_local_finder() == true) then
|
|
||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
prompt_title = "Insert link to note",
|
prompt_title = "Insert link to note",
|
||||||
cwd = ZkCfg.home,
|
cwd = ZkCfg.home,
|
||||||
@@ -224,16 +159,11 @@ InsertLink = function(opts)
|
|||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
entry_maker = zk_entry_maker,
|
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print("Daily finder not found. Try :lua require('telekasten').install_daily_finder()")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FollowLink:
|
-- FollowLink:
|
||||||
-- -----------
|
-- -----------
|
||||||
@@ -251,21 +181,15 @@ FollowLink = function(opts)
|
|||||||
create_note_from_template(title, fname, note_type_templates.normal)
|
create_note_from_template(title, fname, note_type_templates.normal)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (check_local_finder() == true) then
|
|
||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
prompt_title = "Follow link to note...",
|
prompt_title = "Follow link to note...",
|
||||||
cwd = ZkCfg.home,
|
cwd = ZkCfg.home,
|
||||||
default_text = title,
|
default_text = title,
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
entry_maker = zk_entry_maker,
|
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print("Daily finder not found. Try :lua require('telekasten').install_daily_finder()")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- GotoToday:
|
-- GotoToday:
|
||||||
-- ----------
|
-- ----------
|
||||||
@@ -282,21 +206,15 @@ GotoToday = function(opts)
|
|||||||
create_note_from_template(word, fname, note_type_templates.daily)
|
create_note_from_template(word, fname, note_type_templates.daily)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (check_local_finder() == true) then
|
|
||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
prompt_title = "Goto today",
|
prompt_title = "Goto today",
|
||||||
cwd = ZkCfg.home,
|
cwd = ZkCfg.home,
|
||||||
default_text = word,
|
default_text = word,
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
entry_maker = zk_entry_maker,
|
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print("Daily finder not found. Try :lua require('telekasten').install_daily_finder()")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FindNotes:
|
-- FindNotes:
|
||||||
-- ----------
|
-- ----------
|
||||||
@@ -308,13 +226,11 @@ FindNotes = function(opts)
|
|||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
prompt_title = "Find notes by name",
|
prompt_title = "Find notes by name",
|
||||||
cwd = ZkCfg.home,
|
cwd = ZkCfg.home,
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
entry_maker = zk_entry_maker,
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- SearchNotes:
|
-- SearchNotes:
|
||||||
-- ------------
|
-- ------------
|
||||||
@@ -324,21 +240,16 @@ end
|
|||||||
SearchNotes = function(opts)
|
SearchNotes = function(opts)
|
||||||
opts = {} or opts
|
opts = {} or opts
|
||||||
|
|
||||||
if (check_local_finder() == true) then
|
|
||||||
builtin.live_grep({
|
builtin.live_grep({
|
||||||
prompt_title = "Search in notes",
|
prompt_title = "Search in notes",
|
||||||
cwd = ZkCfg.home,
|
cwd = ZkCfg.home,
|
||||||
search_dirs = { ZkCfg.home },
|
search_dirs = { ZkCfg.home },
|
||||||
default_text = vim.fn.expand("<cword>"),
|
default_text = vim.fn.expand("<cword>"),
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print("Daily finder not found. Try :lua require('telekasten').install_daily_finder()")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- CreateNote:
|
-- CreateNote:
|
||||||
-- ------------
|
-- ------------
|
||||||
@@ -354,18 +265,12 @@ local function on_create(title)
|
|||||||
create_note_from_template(title, fname, note_type_templates.normal)
|
create_note_from_template(title, fname, note_type_templates.normal)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (check_local_finder() == true) then
|
|
||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
prompt_title = "Created note...",
|
prompt_title = "Created note...",
|
||||||
cwd = ZkCfg.home,
|
cwd = ZkCfg.home,
|
||||||
default_text = title,
|
default_text = title,
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
entry_maker = zk_entry_maker,
|
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print("Daily finder not found. Try :lua require('telekasten').install_daily_finder()")
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
CreateNote = function(opts)
|
CreateNote = function(opts)
|
||||||
@@ -374,7 +279,6 @@ CreateNote = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- GotoThisWeek:
|
-- GotoThisWeek:
|
||||||
-- ----------
|
-- ----------
|
||||||
@@ -391,36 +295,29 @@ GotoThisWeek = function(opts)
|
|||||||
create_note_from_template(title, fname, note_type_templates.weekly)
|
create_note_from_template(title, fname, note_type_templates.weekly)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (check_local_finder() == true) then
|
|
||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
prompt_title = "Goto this week:",
|
prompt_title = "Goto this week:",
|
||||||
cwd = ZkCfg.weeklies,
|
cwd = ZkCfg.weeklies,
|
||||||
default_text = title,
|
default_text = title,
|
||||||
find_command = { ZkCfg.daily_finder },
|
find_command = ZkCfg.find_command,
|
||||||
entry_maker = zk_entry_maker,
|
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print("Daily finder not found. Try :lua require('telekasten').install_daily_finder()")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Setup(cfg)
|
-- Setup(cfg)
|
||||||
--
|
--
|
||||||
-- Overrides config with elements from cfg
|
-- Overrides config with elements from cfg. See top of file for defaults.
|
||||||
-- Valid keys are:
|
|
||||||
-- - home : path to zettelkasten folder
|
|
||||||
-- - dailies : path to folder of daily notes
|
|
||||||
-- - extension : extension of note files (.md)
|
|
||||||
-- - daily_finder: executable that finds daily notes and sorts them by date
|
|
||||||
-- as long as we have no lua equivalent, this will be necessary
|
|
||||||
--
|
--
|
||||||
Setup = function(cfg)
|
Setup = function(cfg)
|
||||||
cfg = cfg or {}
|
cfg = cfg or {}
|
||||||
for k, v in pairs(cfg) do
|
for k, v in pairs(cfg) do
|
||||||
ZkCfg[k] = v
|
ZkCfg[k] = v
|
||||||
end
|
end
|
||||||
|
if vim.fn.executable('rg') then
|
||||||
|
ZkCfg.find_command = { 'rg', '--files', '--sortr', 'created', }
|
||||||
|
else
|
||||||
|
ZkCfg.find_command = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local M = {
|
local M = {
|
||||||
@@ -431,7 +328,6 @@ local M = {
|
|||||||
insert_link = InsertLink,
|
insert_link = InsertLink,
|
||||||
follow_link = FollowLink,
|
follow_link = FollowLink,
|
||||||
setup = Setup,
|
setup = Setup,
|
||||||
install_daily_finder = InstallDailyFinder,
|
|
||||||
goto_today = GotoToday,
|
goto_today = GotoToday,
|
||||||
new_note = CreateNote,
|
new_note = CreateNote,
|
||||||
goto_thisweek = GotoThisWeek,
|
goto_thisweek = GotoThisWeek,
|
||||||
|
|||||||
Reference in New Issue
Block a user