-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
local M = {}; | ||
|
||
---Only keep entries that are a parent of the child that is at the given position. | ||
---This is useful to remove all entries that are not relevant to the current cursor position for example. | ||
---Modifies the given `symbol` in place. | ||
---@param symbol Symbol | ||
---@param position Position | ||
function M:filter_lsp_symbol_by_position(symbol, position) | ||
if type(symbol.children) == "table" and #symbol.children > 0 then | ||
for index=1, #symbol.children do | ||
local child = symbol.children[index] | ||
|
||
print("child", vim.inspect(child)); | ||
self:filter_lsp_symbol_by_position(child, position) | ||
end | ||
end | ||
|
||
local r = symbol.selectionRange | ||
-- Let's just do a simple check | ||
if r.start.line >= position.line and r["end"].line <= position.line then | ||
return true | ||
end | ||
|
||
return false | ||
end | ||
|
||
|
||
return M; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters