aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-22 16:33:14 -0400
committerhistoria <[not public]>2026-06-22 16:33:14 -0400
commit49b1c88332b83b79b44bb790d439aa100179d9aa (patch)
tree99ac86de58e826d96e31700b1842d72a86a884bb
parentf7e92893e0bddcbff82e11784fd620886fa1297d (diff)
downloaddenote-fzf-lua-49b1c88332b83b79b44bb790d439aa100179d9aa.tar.gz
feat: supports searching multiple directories configured via simple-denote.nvim. existing config is backwards compatible and works the same.
-rw-r--r--README.md4
-rw-r--r--lua/denote-fzf-lua.lua4
-rwxr-xr-xlua/denote-fzf-lua/scripts/fallback_search_files.sh2
-rwxr-xr-xlua/denote-fzf-lua/scripts/search_files.sh4
4 files changed, 9 insertions, 5 deletions
diff --git a/README.md b/README.md
index 7aebe3d..606d426 100644
--- a/README.md
+++ b/README.md
@@ -83,6 +83,10 @@ If the optional dependencies are missing `denote-fzf-lua` falls back to standard
:DenoteSearch contents
```
+# Multi-Directory Support
+
+When used alongside [simple-denote.nvim](https://codeberg.org/historia/simple-denote.nvim) with multiple directories configured, `denote-fzf-lua` automatically follows the active directory set by `:Denote dir`. It reads from `vim.g.denote_dir` if set, falling back to the configured `dir` option. No additional configuration is needed.
+
# License
GNU AGPL
diff --git a/lua/denote-fzf-lua.lua b/lua/denote-fzf-lua.lua
index 167ecb3..977bb23 100644
--- a/lua/denote-fzf-lua.lua
+++ b/lua/denote-fzf-lua.lua
@@ -90,7 +90,7 @@ function M.search_files(options)
vim.api.nvim_command("edit " .. vim.fn.fnameescape(filename))
end,
}
- local dir = vim.fn.expand(options.dir)
+ local dir = vim.fn.expand(vim.g.denote_dir or options.dir)
fzflua.fzf_exec(script .. " " .. dir, opts)
end
@@ -100,7 +100,7 @@ function M.search_contents(options)
return
end
local opts = {}
- opts.cwd = vim.fn.expand(options.dir)
+ opts.cwd = vim.fn.expand(vim.g.denote_dir or options.dir)
opts.previewer = "builtin"
opts.fzf_opts = options.fzf_lua_opts.fzf_opts
opts.actions = fzflua.defaults.actions.files
diff --git a/lua/denote-fzf-lua/scripts/fallback_search_files.sh b/lua/denote-fzf-lua/scripts/fallback_search_files.sh
index f6ee4fc..34fc1b1 100755
--- a/lua/denote-fzf-lua/scripts/fallback_search_files.sh
+++ b/lua/denote-fzf-lua/scripts/fallback_search_files.sh
@@ -2,7 +2,7 @@
find "$1" -not -path '*/.*' |\
sed -E "/^(.*\/)?([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9])(==[^_\.\-]+)?(--[^_\.]+)?(__[^\.]+)?(\.[a-z0-9]+)$/!d" |\
sed -E "s/^(.*\/)?([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9])(==([^_\.\-]+))?(--([^_\.]+))?(__([^\.]+))?(\.[a-z0-9]+)$/\1,\2,\4,\6,\8,\9/" |\
-tr '\=\-_' ' ' |\
+awk 'BEGIN{FS=OFS=","}{for(i=2;i<=NF;i++)gsub(/[=_-]/," ",$i)}1' |\
sed -E 's/([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])T([0-9][0-9])([0-9][0-9])([0-9][0-9])/\1-\2-\3,\4:\5:\6/' |\
sed 's/,,/,.,/g' |\
column -t -s "," -N Path,Date,Time,Sig,Title,Keywords,Ext
diff --git a/lua/denote-fzf-lua/scripts/search_files.sh b/lua/denote-fzf-lua/scripts/search_files.sh
index 4367049..0050552 100755
--- a/lua/denote-fzf-lua/scripts/search_files.sh
+++ b/lua/denote-fzf-lua/scripts/search_files.sh
@@ -1,8 +1,8 @@
#!/bin/sh
(echo "Path,Date,Time,Sig,Title,Keywords,Ext";
fd '^\d{8}T\d{6}(==[a-z0-9=]+)?(\-\-[a-z0-9-]+)?(__[a-z0-9_]+)?\.\w+$' "$1" |\
-sd '(?P<path>\/.*\/)?(?P<datetime>\d{8}T\d{6})(==(?P<sig>[a-z0-9=]+))?(--(?P<title>[a-z0-9-]+))(__(?P<keywords>[a-z0-9_]+))?(?P<ext>\.\w+)' '$path,$datetime,$sig,$title,$keywords,$ext' |\
-tr '\=\-_' ' ' |\
+sd '(?P<path>\/.*\/)?(?P<datetime>\d{8}T\d{6})(==(?P<sig>[a-z0-9=]+))?(--(?P<title>[a-z0-9-]+))?(__(?P<keywords>[a-z0-9_]+))?(?P<ext>\.\w+)' '$path,$datetime,$sig,$title,$keywords,$ext' |\
+awk 'BEGIN{FS=OFS=","}{for(i=2;i<=NF;i++)gsub(/[=_-]/," ",$i)}1' |\
sd '(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})' '$1-$2-$3,$4:$5:$6') |\
sd ',,' ',.,' |\
qsv table