summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-08-27 22:28:04 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-08-27 22:28:04 -0400
commitbb446421c5e97310fc0823c157d94cef624688bb (patch)
tree5d54630e4b902651bb90cb1112af4a8c4bbd2eba /lua
parent02ff322242cb2a738f9df497a99d8632f363e0ad (diff)
feat: Add quickfix to builtin
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/lua/telescope/builtin.lua b/lua/telescope/builtin.lua
index fad98d1..9ff8f2b 100644
--- a/lua/telescope/builtin.lua
+++ b/lua/telescope/builtin.lua
@@ -150,6 +150,51 @@ builtin.lsp_references = function()
}
end
+builtin.quickfix = function()
+ local locations = vim.fn.getqflist()
+
+ local results = {}
+ for _, entry in ipairs(locations) do
+ if not entry.filename then
+ entry.filename = vim.api.nvim_buf_get_name(entry.bufnr)
+ end
+
+ local vimgrep_str = string.format(
+ "%s:%s:%s: %s",
+ vim.fn.fnamemodify(entry.filename, ":."),
+ entry.lnum,
+ entry.col,
+ entry.text
+ )
+
+ table.insert(results, {
+ valid = true,
+ value = entry,
+ ordinal = vimgrep_str,
+ display = vimgrep_str,
+ })
+ end
+
+ if vim.tbl_isempty(results) then
+ return
+ end
+
+ local lsp_reference_finder = finders.new {
+ results = results
+ }
+
+ local reference_previewer = previewers.qflist
+ local reference_picker = pickers.new {
+ previewer = reference_previewer
+ }
+
+ reference_picker:find {
+ prompt = 'LSP References',
+ finder = lsp_reference_finder,
+ sorter = sorters.get_norcalli_sorter(),
+ }
+end
+
return builtin