diff options
| author | DefaultGen <gravel.justness270@slmail.me> | 2024-06-09 15:33:37 -0400 |
|---|---|---|
| committer | DefaultGen <gravel.justness270@slmail.me> | 2024-06-09 15:33:37 -0400 |
| commit | 4396249bfd7b299b17d4c3e056803483fdcc039d (patch) | |
| tree | 9cadabe787a415cd3d417bf463093398a24c7daf /lua/simple-denote | |
| parent | 38738a6527d2d571d149bda36e74bdb9e2f0743c (diff) | |
| download | simple-denote.nvim-4396249bfd7b299b17d4c3e056803483fdcc039d.tar.gz | |
Removed cursed search function
Diffstat (limited to 'lua/simple-denote')
| -rw-r--r-- | lua/simple-denote/api.lua | 1 | ||||
| -rwxr-xr-x | lua/simple-denote/scripts/search.sh | 20 | ||||
| -rw-r--r-- | lua/simple-denote/search.lua | 40 |
3 files changed, 0 insertions, 61 deletions
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 |
