mirror of
https://github.com/Myzel394/jsonfly.nvim.git
synced 2025-06-18 12:15:25 +02:00
fix: Bugfixes; improve performance
This commit is contained in:
parent
340bac1fd9
commit
e898c14369
@ -14,6 +14,11 @@
|
|||||||
---@field value_start number
|
---@field value_start number
|
||||||
---@field key_start number
|
---@field key_start number
|
||||||
|
|
||||||
|
local PRIMITIVE_TYPES = {
|
||||||
|
string = true,
|
||||||
|
number = true,
|
||||||
|
boolean = true,
|
||||||
|
}
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@ -35,9 +40,13 @@ local function get_contents_from_json_value(entry)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param t table
|
---@param t table|nil|string|number
|
||||||
---@return Entry[]
|
---@return Entry[]
|
||||||
function M:get_entries_from_lua_json(t)
|
function M:get_entries_from_lua_json(t)
|
||||||
|
if PRIMITIVE_TYPES[type(t)] or t == nil then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
local keys = {}
|
local keys = {}
|
||||||
|
|
||||||
for k, _raw_value in pairs(t) do
|
for k, _raw_value in pairs(t) do
|
||||||
@ -60,15 +69,17 @@ function M:get_entries_from_lua_json(t)
|
|||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
local sub_keys = M:get_entries_from_lua_json(v)
|
local sub_keys = M:get_entries_from_lua_json(v)
|
||||||
|
|
||||||
for _, sub_key in ipairs(sub_keys) do
|
for index=1, #sub_keys do
|
||||||
|
local sub_key = sub_keys[index]
|
||||||
|
|
||||||
---@type Entry
|
---@type Entry
|
||||||
local entry = {
|
local entry = {
|
||||||
key = k .. "." .. sub_key.key,
|
key = k .. "." .. sub_key.key,
|
||||||
value = get_contents_from_json_value(sub_key),
|
value = sub_key.value,
|
||||||
position = sub_key.position,
|
position = sub_key.position,
|
||||||
}
|
}
|
||||||
|
|
||||||
table.insert(keys, entry)
|
keys[#keys + 1] = entry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -63,12 +63,13 @@ local function show_picker(results, buffer)
|
|||||||
{ remaining = true },
|
{ remaining = true },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
---@type boolean
|
||||||
local conceal
|
local conceal
|
||||||
|
|
||||||
if opts.conceal == "auto" then
|
if opts.conceal == "auto" then
|
||||||
conceal = vim.o.conceallevel > 0
|
conceal = vim.o.conceallevel > 0
|
||||||
else
|
else
|
||||||
conceal = opts.conceal
|
conceal = opts.conceal == true
|
||||||
end
|
end
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user