From ae7fd0d27a72fa3088e84992eb5040853164dad6 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Tue, 29 Sep 2020 22:52:38 -0400 Subject: feat: Add status, better debug, and some associated refactors * [WIP]: Mon 28 Sep 2020 01:08:24 PM EDT * add much much better tracking. so much less hax * status updates, oneshot job updates, etc. * remove temp function * add status function * asdfasdfasdf --- scratch/how_long_does_time_take.lua | 8 ++++++++ scratch/new_index.lua | 9 +++++++++ scratch/old_perf_debug | 36 ++++++++++++++++++++++++++++++++++++ scratch/simple_rg.lua | 2 +- scratch/slow_proc.sh | 1 + scratch/temp_goals.txt | 17 +++++++++++++++++ 6 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 scratch/how_long_does_time_take.lua create mode 100644 scratch/new_index.lua create mode 100644 scratch/old_perf_debug create mode 100644 scratch/temp_goals.txt (limited to 'scratch') diff --git a/scratch/how_long_does_time_take.lua b/scratch/how_long_does_time_take.lua new file mode 100644 index 0000000..a77e47b --- /dev/null +++ b/scratch/how_long_does_time_take.lua @@ -0,0 +1,8 @@ +local start = vim.loop.hrtime() + +local counts = 1e6 +for _ = 1, counts do + local _ = vim.loop.hrtime() +end + +print(counts, ":", (vim.loop.hrtime() - start) / 1e9) diff --git a/scratch/new_index.lua b/scratch/new_index.lua new file mode 100644 index 0000000..3aa6a91 --- /dev/null +++ b/scratch/new_index.lua @@ -0,0 +1,9 @@ + +local t = setmetatable({}, { + __newindex = function(t, k, v) + print(t, k, v) + end +}) + +-- table.insert(t, "hello") +t[1] = "hello" diff --git a/scratch/old_perf_debug b/scratch/old_perf_debug new file mode 100644 index 0000000..3561a98 --- /dev/null +++ b/scratch/old_perf_debug @@ -0,0 +1,36 @@ + + +-- Until I have better profiling stuff, this will have to do. +PERF = function(...) end +PERF_DEBUG = PERF_DEBUG or nil +START = nil + +if PERF_DEBUG then + PERF = function(...) + local new_time = (vim.loop.hrtime() - START) / 1E9 + if select('#', ...) == 0 then + vim.schedule(function() + vim.api.nvim_buf_set_lines(PERF_DEBUG, -1, -1, false, { '' }) + end) + return + end + + local to_insert = '' + if START then + to_insert = tostring(new_time) .. ' | ' + end + + for _, v in ipairs({...}) do + if type(v) == 'table' then + to_insert = to_insert .. tostring(#v) .. ' | ' + else + to_insert = to_insert .. tostring(v) .. ' | ' + end + end + + vim.schedule(function() + vim.api.nvim_buf_set_lines(PERF_DEBUG, -1, -1, false, { to_insert }) + end) + end +end + diff --git a/scratch/simple_rg.lua b/scratch/simple_rg.lua index 5102611..8bd2586 100644 --- a/scratch/simple_rg.lua +++ b/scratch/simple_rg.lua @@ -5,7 +5,7 @@ local telescope = require('telescope') -- When updating the table, we should call filter on those items -- and then only display ones that pass the filter local rg_finder = telescope.finders.new { - fn_command = function(self, prompt) + fn_command = function(_, prompt) return string.format('rg --vimgrep %s', prompt) end, diff --git a/scratch/slow_proc.sh b/scratch/slow_proc.sh index 580e617..a43811d 100755 --- a/scratch/slow_proc.sh +++ b/scratch/slow_proc.sh @@ -8,3 +8,4 @@ sleep 1 echo "husband" sleep 1 echo "helper" + diff --git a/scratch/temp_goals.txt b/scratch/temp_goals.txt new file mode 100644 index 0000000..6827cad --- /dev/null +++ b/scratch/temp_goals.txt @@ -0,0 +1,17 @@ + +Goal: Implement scrolling + +So we want to start keeping track of more/all of the results + +We still want them sorted, so when you scroll past, + you still get the stuff you'd expect. + + +Notes: + +Probably want some X / Y count + + + +Options + -- cgit v1.2.3