From 600c9c7bb626c23938ffed1ab74492394f3e28df Mon Sep 17 00:00:00 2001 From: DefaultGen Date: Thu, 20 Jun 2024 19:56:55 -0400 Subject: Changed tags to keywords --- README.md | 14 +++++++------- lua/denote-fzf-lua.lua | 12 ++++++------ lua/denote-fzf-lua/config.lua | 14 +++++++------- lua/denote-fzf-lua/scripts/fallback_search_files.sh | 4 ++-- lua/denote-fzf-lua/scripts/search_files.sh | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 5c81dea..62422e6 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ Example config via [lazy.nvim](https://github.com/folke/lazy.nvim) -- Toggle which Denote fields are displayed in search search_fields = { - path = false, - date = true, - time = false, - sig = false, - title = true, - tags = true, - ext = false, + path = false, + date = true, + time = false, + sig = false, + title = true, + keywords = true, + ext = false, }, -- OPTIONAL: diff --git a/lua/denote-fzf-lua.lua b/lua/denote-fzf-lua.lua index 846361d..180de4a 100644 --- a/lua/denote-fzf-lua.lua +++ b/lua/denote-fzf-lua.lua @@ -63,7 +63,7 @@ end ---Format the --with-nth argument for fzf (which fields are shown) function M.format_fzf_with_nth(options) local fzf_with_nth = "" - local fields = {"path", "date", "time", "sig", "title", "tags", "ext" } + local fields = {"path", "date", "time", "sig", "title", "keywords", "ext" } for i, v in ipairs(fields) do if options.search_fields[v] then fzf_with_nth = fzf_with_nth .. i .. ',' @@ -88,12 +88,12 @@ function M.recombine_filename(filename) vim.print(filename) local t = {} filename = filename:gsub("%s%s+", "|") - t.path, t.year, t.month, t.day, t.hour, t.min, t.sec, t.sig, t.title, t.tags, t.ext = + t.path, t.year, t.month, t.day, t.hour, t.min, t.sec, t.sig, t.title, t.keywords, t.ext = filename:match("^(.*/)|(%d%d%d%d)%-(%d%d)%-(%d%d)|(%d%d):(%d%d):(%d%d)|([^|]+)|([^|]+)|([^|]+)|(%..+)") - t.sig = M.repopulate_field(t.sig,"=") - t.title = M.repopulate_field(t.title,"-") - t.tags = M.repopulate_field(t.tags,"_") - return t.path .. t.year .. t.month .. t.day .. "T" .. t.hour .. t.min .. t.sec .. t.sig .. t.title .. t.tags .. t.ext + t.sig = M.repopulate_field(t.sig,"=") + t.title = M.repopulate_field(t.title,"-") + t.keywords = M.repopulate_field(t.keywords,"_") + return t.path .. t.year .. t.month .. t.day .. "T" .. t.hour .. t.min .. t.sec .. t.sig .. t.title .. t.keywords .. t.ext end ---@param options table of user options diff --git a/lua/denote-fzf-lua/config.lua b/lua/denote-fzf-lua/config.lua index fa878ce..7fba4dc 100644 --- a/lua/denote-fzf-lua/config.lua +++ b/lua/denote-fzf-lua/config.lua @@ -6,13 +6,13 @@ M.defaults = { -- Choose which fields appear in search results search_fields = { - path = false, - date = true, - time = false, - sig = false, - title = true, - tags = true, - ext = false, + path = false, + date = true, + time = false, + sig = false, + title = true, + keywords = true, + ext = false, }, -- Settings for fzf-lua. See fzf-lua doc for full list of options diff --git a/lua/denote-fzf-lua/scripts/fallback_search_files.sh b/lua/denote-fzf-lua/scripts/fallback_search_files.sh index 430d058..0c07d87 100755 --- a/lua/denote-fzf-lua/scripts/fallback_search_files.sh +++ b/lua/denote-fzf-lua/scripts/fallback_search_files.sh @@ -5,12 +5,12 @@ 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] tr '\=\-_' ' ' |\ 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,Tags,Ext +column -t -s "," -N Path,Date,Time,Sig,Title,Keywords,Ext # 1. find everything in directory # 2. sed deletes every line that isn't a Denote note (can't do this with find alone because -regex can't match optional capture groups) # 3. sed splits the Denote filename into , delimited fields (pa -# 4. tr replaces sig, title, tags special characters with spaces +# 4. tr replaces sig, title, keywords special characters with spaces # 5. sed splits the date and time nicely # 6. sed replaces blank fields with a period # 7. column pretty prints the filenames in a table diff --git a/lua/denote-fzf-lua/scripts/search_files.sh b/lua/denote-fzf-lua/scripts/search_files.sh index 3b0379c..cc64eba 100755 --- a/lua/denote-fzf-lua/scripts/search_files.sh +++ b/lua/denote-fzf-lua/scripts/search_files.sh @@ -1,7 +1,7 @@ #/usr/bin/sh -(echo "Path,Date,Time,Sig,Title,Tags,Ext"; +(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\/.*\/)?(?P\d{8}T\d{6})(==(?P[a-z0-9=]+))?(--(?P[a-z0-9-]+))(__(?P<tags>[a-z0-9_]+))?(?P<ext>\.\w+)' '$path,$datetime,$sig,$title,$tags,$ext' |\ +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 '(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})' '$1-$2-$3,$4:$5:$6') |\ sd ',,' ',.,' |\ @@ -10,7 +10,7 @@ qsv table # 1. echo the table headers # 2. fd only Denote files in $1 directory (and subdirectories) # 3. sd chops the Denote filename fields into a CSV -# 4. tr replaces special characters in sig, title, and tags with spaces +# 4. tr replaces special characters in sig, title, and keywords with spaces # 5. sd formats the date and time as YYYY-MM-DD HH:MM:SS # 6. sd replaces blank fields with . (fzf can't handle blank fields) # 7. qsv to print the fields in tabular format -- cgit v1.2.3