aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorDefaultGen <gravel.justness270@slmail.me>2024-06-09 15:33:37 -0400
committerDefaultGen <gravel.justness270@slmail.me>2024-06-09 15:33:37 -0400
commit4396249bfd7b299b17d4c3e056803483fdcc039d (patch)
tree9cadabe787a415cd3d417bf463093398a24c7daf /lua
parent38738a6527d2d571d149bda36e74bdb9e2f0743c (diff)
downloadsimple-denote.nvim-4396249bfd7b299b17d4c3e056803483fdcc039d.tar.gz
Removed cursed search function
Diffstat (limited to 'lua')
-rw-r--r--lua/simple-denote.lua5
-rw-r--r--lua/simple-denote/api.lua1
-rwxr-xr-xlua/simple-denote/scripts/search.sh20
-rw-r--r--lua/simple-denote/search.lua40
4 files changed, 0 insertions, 66 deletions
diff --git a/lua/simple-denote.lua b/lua/simple-denote.lua
index 12ba1f6..403a5ac 100644
--- a/lua/simple-denote.lua
+++ b/lua/simple-denote.lua
@@ -2,7 +2,6 @@ local M = {}
local config = require("simple-denote.config")
local api = require("simple-denote.api")
-local search = require ("simple-denote.search")
function M.load_cmd(options)
vim.api.nvim_create_user_command("Denote", function(opts)
@@ -14,10 +13,6 @@ function M.load_cmd(options)
api.tag(options)
elseif opts.fargs[1] == "signature" then
api.signature(options)
- elseif opts.fargs[1] == "search" then
- search.search(options)
- elseif opts.fargs[1] == "test" then
- search.test()
else
error("Unsupported operation " .. opts.fargs[1])
end
diff --git a/lua/simple-denote/api.lua b/lua/simple-denote/api.lua
index 36ab8c8..05d645a 100644
--- a/lua/simple-denote/api.lua
+++ b/lua/simple-denote/api.lua
@@ -1,7 +1,6 @@
local M = {}
local internal = require("simple-denote.internal")
-local search = require ("simple-denote.search")
---@param options table
---@param title string|nil
diff --git a/lua/simple-denote/scripts/search.sh b/lua/simple-denote/scripts/search.sh
deleted file mode 100755
index 799e081..0000000
--- a/lua/simple-denote/scripts/search.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/sh
-fd . $1 |\
-sd '(?P<prefix>\/.*\/)?(?P<datetime>\d{8}T\d{6})(==(?P<sig>[a-z0-9=]+))?(--(?P<title>[a-z0-9-]+))(__(?P<tags>[a-z0-9_]+))?(?P<ext>\.\w+)' '$prefix|$datetime|$sig|$title|$tags|$ext' |\
-sd '[\=\-\_]' ' ' |\
-sd '(\d{4})(\d{2})(\d{2})(T\d{6})' '$1-$2-$3|$4' |\
-sd '\|\|' '|.|'|\
-column -t -s "|" -N Prefix,Date,Time,Sig,Title,Tags,Ext |\
-fzf --delimiter='\s{2,}' --nth=1..3 --with-nth=2,5,6 --header-lines=1 --reverse --info=hidden --no-separator --preview-window=bottom \
---preview='
-sig={4}; sig=$(echo $sig | sd "\W" "" | sd " " "="); if [ ! -z ${sig} ] ;then sig="==${sig}"; fi; \
-title={5}; title=$(echo $title | sd " " "-"); if [ ! -z ${title} ] ;then title="--${title}"; fi; \
-tags={6}; tags=$(echo $tags | sd " " "_" | sd "\." ""); if [ ! -z ${tags} ] ;then tags="__${tags}"; fi; \
-ext={7}; \
-echo {1}\|{2}\|{3}\|{4}\|{5}\|{6}\|{7} | sd "(?P<prefix>\/.*\/)?\|(?P<d1>\d\d\d\d)-(?P<d2>\d\d)-(?P<d3>\d\d)\|(?P<time>T\d\d\d\d\d\d)\|.*" "\$prefix\$d1\$d2\$d3\$time$sig$title$tags$ext" | xargs cat' \
---bind='enter:execute( \
-sig={4}; sig=$(echo $sig | sd "\W" "" | sd " " "="); if [ ! -z ${sig} ] ;then sig="==${sig}"; fi; \
-title={5}; title=$(echo $title | sd " " "-"); if [ ! -z ${title} ] ;then title="--${title}"; fi; \
-tags={6}; tags=$(echo $tags | sd " " "_" | sd "\." ""); if [ ! -z ${tags} ] ;then tags="__${tags}"; fi; \
-ext={7}; \
-echo {1}\|{2}\|{3}\|{4}\|{5}\|{6}\|{7} | sd "(?P<prefix>\/.*\/)?\|(?P<d1>\d\d\d\d)-(?P<d2>\d\d)-(?P<d3>\d\d)\|(?P<time>T\d\d\d\d\d\d)\|.*" "\$prefix\$d1\$d2\$d3\$time$sig$title$tags$ext" | cat)+abort'
diff --git a/lua/simple-denote/search.lua b/lua/simple-denote/search.lua
deleted file mode 100644
index eab25dd..0000000
--- a/lua/simple-denote/search.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-local M = {}
-
-function M.search(options)
- local width = vim.o.columns - 8
- local height = vim.o.lines - 8
-
- vim.api.nvim_open_win(
- vim.api.nvim_create_buf(false, true),
- true,
- {
- relative = 'editor',
- style = 'minimal',
- border = 'rounded',
- noautocmd = true,
- width = width,
- height = height,
- col = math.min((vim.o.columns - width) / 2),
- row = math.min((vim.o.lines - height) / 2 - 1),
- }
- )
- local file = vim.fn.tempname()
- -- This feels like the wrong way to call a script from a relative path
- local lua_file_path = debug.getinfo(1, "S").source:sub(2)
- local lua_file_dir = vim.fn.fnamemodify(lua_file_path, ":h")
- local script_path = lua_file_dir .. "/scripts/search.sh"
- if not script_path then
- error("Script not found")
- end
- vim.api.nvim_command('startinsert')
- vim.fn.termopen(script_path .. " " .. options.dir .. " > " .. file, {
- on_exit = function(jobid, data, event)
- vim.api.nvim_command('bdelete!')
- local f = io.open(file, 'r')
- local stdout = f:read('*all')
- f:close()
- os.remove(file)
- vim.api.nvim_command('edit ' .. stdout)
- end})
-end
-return M