summaryrefslogtreecommitdiff
path: root/scratch
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-07-15 00:05:14 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-07-15 00:05:14 -0400
commit69d4cd3899845d84767fa0e2ff9c8234e9dcbf84 (patch)
tree4cdce2c77f17d9d79235c2ea64b2879e2c77d93e /scratch
Initial commit after stream
Diffstat (limited to 'scratch')
-rw-r--r--scratch/example.lua68
-rw-r--r--scratch/rg_lua_jobstart.lua21
-rwxr-xr-xscratch/slow_proc.sh6
3 files changed, 95 insertions, 0 deletions
diff --git a/scratch/example.lua b/scratch/example.lua
new file mode 100644
index 0000000..19952dc
--- /dev/null
+++ b/scratch/example.lua
@@ -0,0 +1,68 @@
+
+local finder = Finder:new {
+ 'rg %s -l',
+ pipeable = true,
+ ...
+}
+
+local filter = Filter:new {
+ "fzf --filter '%s'"
+}
+
+local lua_filter = Filter:new {
+ function(input, line)
+ if string.match(line, input) then
+ return true
+ end
+
+ return false
+ end
+}
+
+
+local picker_read = Picker:new {
+ filter = filter,
+
+ previewer = function(window, buffer, line)
+ local file = io.open(line, "r")
+
+ local filename = vim.split(line, ':')[1]
+ if vim.fn.bufexists(filename) then
+ vim.api.nvim_win_set_buf(window, vim.fn.bufnr(filename))
+ return
+ end
+
+ local lines = {}
+ for _ = 1, 100 do
+ table.insert(lines, file:read("l"))
+
+ -- TODO: Check if we're out of lines
+ end
+
+ -- optionally set the filetype or whatever...
+ vim.api.nvim_buf_set_lines(buffer, 0, -1, false, lines)
+ end,
+
+ mappings = {
+ ["<CR>"] = function(line)
+ vim.cmd(string.format('e ', vim.split(line, ':')))
+ end,
+ },
+}
+
+local picker = Picker:new {
+ filter = filter,
+
+ -- idk
+ previewer = function(window, line)
+ vim.api.nvim_win_set_current_window(window)
+
+ -- if is_file_loaded(line) then
+ -- lien_number = vim.api.nvim_...
+
+ vim.fn.termopen(string.format(
+ 'bat --color=always --style=grid %s',
+ vim.split(line, ':')[1]
+ ))
+ end
+}
diff --git a/scratch/rg_lua_jobstart.lua b/scratch/rg_lua_jobstart.lua
new file mode 100644
index 0000000..4b551d4
--- /dev/null
+++ b/scratch/rg_lua_jobstart.lua
@@ -0,0 +1,21 @@
+
+local function get_rg_results(bufnr, search_string)
+ local start_time = vim.fn.reltime()
+
+ vim.fn.jobstart(string.format('rg %s', search_string), {
+ cwd = '/home/tj/build/neovim',
+
+ on_stdout = function(job_id, data, event)
+ vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, data)
+ end,
+
+ on_exit = function()
+ print("Finished in: ", vim.fn.reltimestr(vim.fn.reltime(start_time)))
+ end,
+
+ stdout_buffer = true,
+ })
+end
+
+local bufnr = 14
+get_rg_results(bufnr, 'vim.api')
diff --git a/scratch/slow_proc.sh b/scratch/slow_proc.sh
new file mode 100755
index 0000000..6326991
--- /dev/null
+++ b/scratch/slow_proc.sh
@@ -0,0 +1,6 @@
+
+echo "hello"
+sleep 1
+echo "cool"
+sleep 1
+echo "world"