mirror of
https://github.com/Myzel394/jsonfly.nvim.git
synced 2025-06-18 12:15:25 +02:00
chore: apply stylua
This commit is contained in:
parent
895e9adfdf
commit
0e5158a8d4
@ -208,7 +208,9 @@ end
|
|||||||
---@param name string
|
---@param name string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function M:is_module_available(name)
|
function M:is_module_available(name)
|
||||||
return pcall(function() require(name) end) == true
|
return pcall(function()
|
||||||
|
require(name)
|
||||||
|
end) == true
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -61,7 +61,7 @@ local DEFAULT_CONFIG = {
|
|||||||
backend = "lsp",
|
backend = "lsp",
|
||||||
use_cache = 500,
|
use_cache = 500,
|
||||||
commands = {
|
commands = {
|
||||||
add_key = {"i", "<C-a>"},
|
add_key = { "i", "<C-a>" },
|
||||||
copy_jsonpath = {
|
copy_jsonpath = {
|
||||||
"i",
|
"i",
|
||||||
"<C-j>",
|
"<C-j>",
|
||||||
@ -69,9 +69,9 @@ local DEFAULT_CONFIG = {
|
|||||||
---@param prompt_bufnr number
|
---@param prompt_bufnr number
|
||||||
function(path, prompt_bufnr)
|
function(path, prompt_bufnr)
|
||||||
vim.fn.setreg("+", path)
|
vim.fn.setreg("+", path)
|
||||||
end
|
end,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local global_config = {}
|
local global_config = {}
|
||||||
@ -112,7 +112,7 @@ local function show_picker(entries, buffer, xopts)
|
|||||||
insert:insert_new_key(entries, key_descriptor, buffer)
|
insert:insert_new_key(entries, key_descriptor, buffer)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if global_config.commands.copy_jsonpath and utils:is_module_available("jsonpath") then
|
if global_config.commands.copy_jsonpath and utils:is_module_available("jsonpath") then
|
||||||
map(
|
map(
|
||||||
global_config.commands.copy_jsonpath[1],
|
global_config.commands.copy_jsonpath[1],
|
||||||
global_config.commands.copy_jsonpath[2],
|
global_config.commands.copy_jsonpath[2],
|
||||||
@ -122,13 +122,16 @@ if global_config.commands.copy_jsonpath and utils:is_module_available("jsonpath"
|
|||||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
local selection = current_picker:get_selection()
|
local selection = current_picker:get_selection()
|
||||||
|
|
||||||
local path = jsonpath.get(vim.treesitter.get_node({
|
local path = jsonpath.get(
|
||||||
|
vim.treesitter.get_node({
|
||||||
bufnr = buffer,
|
bufnr = buffer,
|
||||||
pos = {
|
pos = {
|
||||||
selection.lnum - 1,
|
selection.lnum - 1,
|
||||||
selection.index,
|
selection.index,
|
||||||
}
|
},
|
||||||
}), buffer)
|
}),
|
||||||
|
buffer
|
||||||
|
)
|
||||||
|
|
||||||
if path then
|
if path then
|
||||||
global_config.commands.copy_jsonpath[3](path, prompt_bufnr)
|
global_config.commands.copy_jsonpath[3](path, prompt_bufnr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user