mirror of
https://github.com/Myzel394/jsonfly.nvim.git
synced 2025-06-18 04:05:26 +02:00
fix: Improve parser
This commit is contained in:
parent
ce0e163b8f
commit
31be7184ff
@ -19,6 +19,12 @@ local PRIMITIVE_TYPES = {
|
||||
number = true,
|
||||
boolean = true,
|
||||
}
|
||||
local CONTAINS_CHILDREN_TYPES = {
|
||||
[2] = true, -- Module / Javascript Object
|
||||
[8] = true, -- Field
|
||||
[18] = true, -- Array
|
||||
[19] = true, -- Object
|
||||
}
|
||||
|
||||
local M = {}
|
||||
|
||||
@ -91,7 +97,7 @@ end
|
||||
---@return string|number|table|boolean|nil
|
||||
function M:parse_lsp_value(result)
|
||||
-- Object
|
||||
if result.kind == 2 then
|
||||
if CONTAINS_CHILDREN_TYPES[result.kind] then
|
||||
local value = {}
|
||||
|
||||
for _, child in ipairs(result.children) do
|
||||
@ -165,7 +171,7 @@ function M:get_entries_from_lsp_symbols(symbols)
|
||||
}
|
||||
keys[#keys + 1] = entry
|
||||
|
||||
if symbol.kind == 2 or symbol.kind == 18 then
|
||||
if CONTAINS_CHILDREN_TYPES[symbol.kind] then
|
||||
local sub_keys = M:get_entries_from_lsp_symbols(symbol.children)
|
||||
|
||||
for jindex=1, #sub_keys do
|
||||
|
@ -56,7 +56,7 @@ local DEFAULT_CONFIG = {
|
||||
},
|
||||
jump_behavior = "key_start",
|
||||
subkeys_display = "normal",
|
||||
show_nested_child_preview = false,
|
||||
show_nested_child_preview = true,
|
||||
backend = "lsp",
|
||||
use_cache = 500,
|
||||
commands = {
|
||||
@ -196,17 +196,19 @@ return require("telescope").register_extension {
|
||||
if global_config.backend == "lsp" then
|
||||
local params = vim.lsp.util.make_position_params(xopts.winnr)
|
||||
|
||||
vim.lsp.buf_request(
|
||||
vim.lsp.buf_request_all(
|
||||
current_buf,
|
||||
"textDocument/documentSymbol",
|
||||
params,
|
||||
function(error, lsp_response)
|
||||
if error then
|
||||
function(response)
|
||||
if response == nil or #response == 0 then
|
||||
run_lua_parser()
|
||||
return
|
||||
end
|
||||
|
||||
local entries = parsers:get_entries_from_lsp_symbols(lsp_response)
|
||||
local result = response[1].result
|
||||
|
||||
local entries = parsers:get_entries_from_lsp_symbols(result)
|
||||
|
||||
if allow_cache then
|
||||
cache:cache_buffer(current_buf, entries)
|
||||
|
Loading…
x
Reference in New Issue
Block a user