mirror of
https://github.com/Myzel394/jsonfly.nvim.git
synced 2025-06-18 12:15:25 +02:00
debug
This commit is contained in:
parent
acd899ce82
commit
c3350797f9
28
lua/jsonfly/languages.lua
Normal file
28
lua/jsonfly/languages.lua
Normal file
@ -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;
|
@ -124,6 +124,10 @@ function M:parse_lsp_value(result)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@class Range
|
||||||
|
---@field start Position
|
||||||
|
---@field ["end"] Position
|
||||||
|
--
|
||||||
---@class Symbol
|
---@class Symbol
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field kind number 2 = Object, 16 = Number, 15 = String, 18 = Array, 13 = Null, 17 = Boolean
|
---@field kind number 2 = Object, 16 = Number, 15 = String, 18 = Array, 13 = Null, 17 = Boolean
|
||||||
@ -132,10 +136,6 @@ end
|
|||||||
---@field detail string
|
---@field detail string
|
||||||
---@field children Symbol[]
|
---@field children Symbol[]
|
||||||
--
|
--
|
||||||
---@class Range
|
|
||||||
---@field start Position
|
|
||||||
---@field ["end"] Position
|
|
||||||
--
|
|
||||||
---@class Position
|
---@class Position
|
||||||
---@field line number
|
---@field line number
|
||||||
---@field character number
|
---@field character number
|
||||||
|
@ -28,6 +28,7 @@ local parsers = require"jsonfly.parsers"
|
|||||||
local utils = require"jsonfly.utils"
|
local utils = require"jsonfly.utils"
|
||||||
local cache = require"jsonfly.cache"
|
local cache = require"jsonfly.cache"
|
||||||
local insert = require"jsonfly.insert"
|
local insert = require"jsonfly.insert"
|
||||||
|
local languages = require"jsonfly.languages"
|
||||||
|
|
||||||
local json = require"jsonfly.json"
|
local json = require"jsonfly.json"
|
||||||
local finders = require "telescope.finders"
|
local finders = require "telescope.finders"
|
||||||
@ -196,6 +197,16 @@ return require"telescope".register_extension {
|
|||||||
"textDocument/documentSymbol",
|
"textDocument/documentSymbol",
|
||||||
params,
|
params,
|
||||||
function(error, lsp_response)
|
function(error, lsp_response)
|
||||||
|
print(vim.inspect(lsp_response))
|
||||||
|
|
||||||
|
languages:filter_lsp_symbol_by_position(
|
||||||
|
lsp_response[1],
|
||||||
|
params.position
|
||||||
|
)
|
||||||
|
|
||||||
|
print(vim.inspect(lsp_response))
|
||||||
|
|
||||||
|
|
||||||
if error then
|
if error then
|
||||||
run_lua_parser()
|
run_lua_parser()
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user