summaryrefslogtreecommitdiff
path: root/lua/telescope/builtin/lsp.lua
diff options
context:
space:
mode:
authoroberblastmeister <61095988+oberblastmeister@users.noreply.github.com>2021-04-13 14:39:14 -0400
committerGitHub <noreply@github.com>2021-04-13 14:39:14 -0400
commit253d3aaa6b43eac6b11341b325e34d37dc459af3 (patch)
treef2e4c02ffcc6a6f6019d7fb1f605f08d31544a4d /lua/telescope/builtin/lsp.lua
parent5bd6f5ca9828ea02f2c54d616ad65c72a5cdd7fb (diff)
added a new DynamicFinder (which can be used with rust_analyzer) (#705)
* started tree finder * made tree more ergonmic * deleted unneeded comments * added stack root and node * added preprocessing * using staticfinder instead of separate finder, custom entry maker * added selections and remember * removed unused stuff * fixed warnings * fixed remember and selections pop * started branch * added go function * changed up test * removed root parameter from go function * changed back to not do_close * removed node and leaf classes * removed stack class instead for table.insert and table.remove * fixed warning * started branch * added better preprocessor and tree class * started some tests * finished making tests pass * cleaned up * fixed make entry and updated example * started * added some stuff * deleted uneeded stuff * added cancelable * changed workspace requester * use better cancellation mechanism * removed accidental stuff * removed useless print * delete more useless stuff * rename to dynamic * added request cancellation * CHECK IF NIL * removed unused * added trash global variable
Diffstat (limited to 'lua/telescope/builtin/lsp.lua')
-rw-r--r--lua/telescope/builtin/lsp.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua
index 741eb36..b2ab981 100644
--- a/lua/telescope/builtin/lsp.lua
+++ b/lua/telescope/builtin/lsp.lua
@@ -4,6 +4,9 @@ local finders = require('telescope.finders')
local make_entry = require('telescope.make_entry')
local pickers = require('telescope.pickers')
local utils = require('telescope.utils')
+local a = require('plenary.async_lib')
+local async, await = a.async, a.await
+local channel = a.util.channel
local conf = require('telescope.config').values
@@ -218,6 +221,36 @@ lsp.workspace_symbols = function(opts)
}):find()
end
+local function get_workspace_symbols_requester(bufnr)
+ local cancel = function() end
+
+ return async(function(prompt)
+ local tx, rx = channel.oneshot()
+ cancel()
+ _, cancel = vim.lsp.buf_request(bufnr, "workspace/symbol", {query = prompt}, tx)
+
+ local err, _, results_lsp = await(rx())
+ assert(not err, err)
+
+ local locations = vim.lsp.util.symbols_to_items(results_lsp or {}, bufnr) or {}
+ return locations
+ end)
+end
+
+lsp.dynamic_workspace_symbols = function(opts)
+ local curr_bufnr = vim.api.nvim_get_current_buf()
+
+ pickers.new(opts, {
+ prompt_title = 'LSP Dynamic Workspace Symbols',
+ finder = finders.new_dynamic {
+ entry_maker = opts.entry_maker or make_entry.gen_from_lsp_symbols(opts),
+ fn = get_workspace_symbols_requester(curr_bufnr),
+ },
+ previewer = conf.qflist_previewer(opts),
+ sorter = conf.generic_sorter()
+ }):find()
+end
+
lsp.diagnostics = function(opts)
local locations = utils.diagnostics_to_tbl(opts)