Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ jobs:
version: nightly

- name: luajit
uses: leafo/gh-actions-lua@v10
uses: leafo/gh-actions-lua@v11
with:
luaVersion: "luajit-2.1.0-beta3"

- name: luarocks
uses: leafo/gh-actions-luarocks@v4
uses: leafo/gh-actions-luarocks@v5
with:
luarocksVersion: "3.12.2"

- name: run test
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion doc/lspsaga.nvim.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*lspsaga.nvim.txt* For Nvim 0.8.0 Last change: 2025 June 25
*lspsaga.nvim.txt* For Nvim 0.8.0 Last change: 2025 September 10

==============================================================================
Table of Contents *lspsaga.nvim-table-of-contents*
Expand Down
32 changes: 21 additions & 11 deletions lua/lspsaga/finder/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,25 @@ function fd:new(args)
self.inexist = config.finder.sp_inexist
end
self.layout = layout or config.finder.layout

local curbuf = api.nvim_get_current_buf()
local params = lsp.util.make_position_params(0, util.get_offset_encoding({ bufnr = curbuf }))
params.context = {
includeDeclaration = true,
}
if type(config.finder.ref_opt) == 'boolean' then
params.context = {
includeDeclaration = config.finder.ref_opt,
}
end

if #meth == 0 then
meth = vim.split(config.finder.default, '+', { plain = true })
end
local methods = box.get_methods(meth)

methods = vim.tbl_filter(function(method)
return #util.get_client_by_method(method) > 0
end, methods)
local curbuf = api.nvim_get_current_buf()
self.ft = vim.bo[curbuf].filetype
if #methods == 0 then
vim.notify(
('[lspsaga] no servers of buffer %s makes these methods available %s'):format(
Expand All @@ -510,23 +519,24 @@ function fd:new(args)
return
end

local methods_with_params = vim.tbl_map(function(method)
return util.gen_param_by_config(method, params, config.finder.ref_opt)
end, methods)

self.ft = vim.bo[curbuf].filetype
self.list = slist.new()
local params = lsp.util.make_position_params(0, util.get_offset_encoding({ bufnr = curbuf }))
params.context = {
includeDeclaration = true,
}

local spin_close = box.spinner()
local count = 0
coroutine.resume(coroutine.create(function()
local retval = {}
local co = coroutine.running()
for _, method in ipairs(methods) do
lsp.buf_request_all(curbuf, method, params, function(results)
for _, item in ipairs(methods_with_params) do
lsp.buf_request_all(curbuf, item[1], item[2], function(results)
count = count + 1
results = box.filter(method, results)
results = box.filter(item[1], results)
if results and not util.res_isempty(results) then
retval[method] = results
retval[item[1]] = results
end
if count == #methods then
coroutine.resume(co)
Expand Down
1 change: 1 addition & 0 deletions lua/lspsaga/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ local default_config = {
ly_botright = false,
number = vim.o.number,
relativenumber = vim.o.relativenumber,
ref_opt = true,
keys = {
shuttle = '[w',
toggle_or_open = 'o',
Expand Down
27 changes: 27 additions & 0 deletions lua/lspsaga/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,33 @@ function M.get_client_by_method(method)
return supports
end

--- generate LSP RPC method `textDocument/references` parameters by configuration.
---@param method string LSP RPC method name
---@param params table parameters for LSP RPC method
---@param config table|boolean configuration for config.finder.ref_opt
---@return table
function M.gen_param_by_config(method, params, config)
if type(config) == 'table' and method == 'textDocument/references' then
local bufnr = vim.api.nvim_get_current_buf()
local clients = lsp.get_clients({ bufnr = bufnr })

for _, client in ipairs(clients or {}) do
-- Replace characters dash('-') to underscore('_') for LSP client name,
-- which is useful for some LSP client like `rust-analyzer`.
local client_name = string.gsub(client.name, '-', '_')
local v = vim.tbl_get(config, client_name)
if v ~= nil then
params.context = {
includeDeclaration = v,
}
return { method, params }
end
end
end

return { method, params }
end

function M.feedkeys(key)
local k = api.nvim_replace_termcodes(key, true, false, true)
api.nvim_feedkeys(k, 'nx', false)
Expand Down