diff --git a/README.md b/README.md index 490a03f..0979d38 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Easy code navigation through LSP and 🌲🏡Treesitter symbols, diagnostic erro - LSP easy setup. Support some of the most commonly used lsp client setup - Unorthodox UI with floating windows +- Async request with lsp.buf_request for reference search +- Treesitter symbol search. It is handy for large file (Do you know sumneko_lua has 100kb size limitation?) - fzy search with Lua-JIT - Better navigation for diagnostic errors, Navigate through files that contain errors/warnings - Group references/implementation/incomming/outgoing based on file names. diff --git a/lua/navigator/lspwrapper.lua b/lua/navigator/lspwrapper.lua index e3ba05e..8139ca4 100644 --- a/lua/navigator/lspwrapper.lua +++ b/lua/navigator/lspwrapper.lua @@ -110,9 +110,8 @@ function M.call_async(method, params, handler) util.show(...) handler(...) end - local results_lsp, canceller = lsp.buf_request(0, method, params, callback) - return results_lsp, canceller - -- handler(err, method, extract_result(results_lsp), nil, nil) + return lsp.buf_request(0, method, params, callback) + -- results_lsp, canceller end function M.locations_to_items(locations) diff --git a/lua/navigator/reference.lua b/lua/navigator/reference.lua index bae3ae4..d440194 100644 --- a/lua/navigator/reference.lua +++ b/lua/navigator/reference.lua @@ -1,6 +1,8 @@ local util = require "navigator.util" +local log = util.log local lsphelper = require "navigator.lspwrapper" local gui = require "navigator.gui" +local lsp = require 'navigator.lspwrapper' local verbose = require "navigator.util".verbose -- local log = util.log -- local partial = util.partial @@ -14,12 +16,11 @@ local locations_to_items = lsphelper.locations_to_items local function ref_hdlr(arg1, api, locations, num, bufnr) local opts = {} - -- log("arg1", arg1) -- log(api) + -- log(locations) -- log("num", num) -- log("bfnr", bufnr) - if locations == nil or vim.tbl_isempty(locations) then print "References not found" return @@ -29,4 +30,14 @@ local function ref_hdlr(arg1, api, locations, num, bufnr) gui.new_list_view({items = items, api = 'Reference'}) end -return { reference_handler = ref_hdlr } +local async_reference_request = function() + local method = {"textDocument/references"} + local ref_params = vim.lsp.util.make_position_params() + ref_params.context = {includeDeclaration = true;} + return lsp.call_async(method[1], ref_params, ref_hdlr) -- return asyncresult, canceller +end + + +return { reference_handler = ref_hdlr, +show_reference = async_reference_request +}