summaryrefslogtreecommitdiff
path: root/scratch/simple_rg.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-07-17 00:03:20 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-07-17 00:03:20 -0400
commitababfbfd88334ca6d94d5d0a8b6324dd6600d602 (patch)
tree99dd820cca2d906175b9a645694cb778add58499 /scratch/simple_rg.lua
parentc6f0142fc651dcbd2431630956d034c046293e7e (diff)
Another stream
Diffstat (limited to 'scratch/simple_rg.lua')
-rw-r--r--scratch/simple_rg.lua32
1 files changed, 7 insertions, 25 deletions
diff --git a/scratch/simple_rg.lua b/scratch/simple_rg.lua
index c6a8481..5102611 100644
--- a/scratch/simple_rg.lua
+++ b/scratch/simple_rg.lua
@@ -5,37 +5,19 @@ 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(prompt)
+ fn_command = function(self, prompt)
return string.format('rg --vimgrep %s', prompt)
end,
responsive = false
}
-
local p = telescope.pickers.new {
- previewer = telescope.previewers.new(function(preview_win, preview_bufnr, results_bufnr, row)
- assert(preview_bufnr)
-
- local line = vim.api.nvim_buf_get_lines(results_bufnr, row, row + 1, false)[1]
- local file_name = vim.split(line, ":")[1]
-
- -- print(file_name)
- -- vim.fn.termopen(
- -- string.format("bat --color=always --style=grid %s"),
- -- vim.fn.fnamemodify(file_name, ":p")
- local bufnr = vim.fn.bufadd(file_name)
- vim.fn.bufload(bufnr)
-
- -- TODO: We should probably call something like this because we're not always getting highlight and all that stuff.
- -- api.nvim_command('doautocmd filetypedetect BufRead ' .. vim.fn.fnameescape(filename))
- vim.api.nvim_win_set_buf(preview_win, bufnr)
- vim.api.nvim_win_set_option(preview_win, 'wrap', false)
- vim.api.nvim_win_set_option(preview_win, 'winhl', 'Normal:Normal')
- vim.api.nvim_win_set_option(preview_win, 'winblend', 20)
- vim.api.nvim_win_set_option(preview_win, 'signcolumn', 'no')
- vim.api.nvim_win_set_option(preview_win, 'foldlevel', 100)
- end)
+ previewer = telescope.previewers.vim_buffer
+}
+p:find {
+ prompt = 'grep',
+ finder = rg_finder
}
-p:find(rg_finder)
+