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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user