mirror of
https://github.com/Myzel394/jsonfly.nvim.git
synced 2025-06-19 04:25:27 +02:00
Compare commits
No commits in common. "db4394d856059d99d82ea2c75d033721e9dcb1fc" and "d713d9ef38115ab09b4a2828dac67b2b3f7d35c4" have entirely different histories.
db4394d856
...
d713d9ef38
43
README.md
43
README.md
@ -1,5 +1,3 @@
|
|||||||
**NOTICE**: I'm slowly migrating my repositories to my own Git server. Please visit this repository at [https://git.myzel394.app/Myzel394/jsonfly.nvim](https://git.myzel394.app/Myzel394/jsonfly.nvim) for the latest updates.
|
|
||||||
|
|
||||||
# jsonfly.nvim
|
# jsonfly.nvim
|
||||||
|
|
||||||
Fly through your JSON, XML and YAML files with ease.
|
Fly through your JSON, XML and YAML files with ease.
|
||||||
@ -19,7 +17,6 @@ It's completely customizable and even supports highlighting of the values.
|
|||||||
* 🗑 Values automatically cached for faster navigation
|
* 🗑 Values automatically cached for faster navigation
|
||||||
* 🫣 Automatic concealment based on your configuration
|
* 🫣 Automatic concealment based on your configuration
|
||||||
* 📐 Everything completely customizable!
|
* 📐 Everything completely customizable!
|
||||||
* 📝 [JSONPath](https://github.com/phelipetls/jsonpath.nvim) support - copy JSON paths to your clipboard
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -29,30 +26,22 @@ Install with your favorite plugin manager, for example with [lazy.nvim](https://
|
|||||||
{
|
{
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- "https://git.myzel394.app/Myzel394/easytables.nvim",
|
-- "Myzel394/easytables.nvim",
|
||||||
-- "https://git.myzel394.app/Myzel394/telescope-last-positions",
|
-- "Myzel394/telescope-last-positions",
|
||||||
-- Other dependencies
|
-- Other dependencies
|
||||||
-- ..
|
-- ..
|
||||||
"https://git.myzel394.app/Myzel394/jsonfly.nvim",
|
"Myzel394/jsonfly.nvim",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Load the extension with:
|
|
||||||
|
|
||||||
```lua
|
|
||||||
require("telescope").load_extension("jsonfly")
|
|
||||||
```
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
Here's how I load it with lazy.nvim with lazy-loading and `<leader>j` as the keymap :)
|
Here's how I load it with lazy.nvim with lazy-loading and `<leader>j` as the keymap :)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"https://git.myzel394.app/Myzel394/jsonfly.nvim",
|
"Myzel394/jsonfly.nvim",
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
@ -66,6 +55,12 @@ Here's how I load it with lazy.nvim with lazy-loading and `<leader>j` as the key
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Load the extension with:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require("telescope").load_extension("jsonfly")
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Go to a JSON file and run:
|
Go to a JSON file and run:
|
||||||
@ -92,24 +87,6 @@ The following schemas are valid:
|
|||||||
|
|
||||||
Please note: JSON(fly) is intended to be used with **human-readable** JSON files. Inserting keys won't work with minified JSON files.
|
Please note: JSON(fly) is intended to be used with **human-readable** JSON files. Inserting keys won't work with minified JSON files.
|
||||||
|
|
||||||
## Integrating jsonpath.nvim
|
|
||||||
|
|
||||||
json(fly) has native support for [jsonpath.nvim](https://github.com/phelipetls/jsonpath.nvim).
|
|
||||||
|
|
||||||
Just make sure jsonpath is loaded when you call json(fly), and you can copy the currently selected path by pressing `<C-j>` (you can also change this keybinding of course).
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```lua
|
|
||||||
{
|
|
||||||
url = "https://git.myzel394.app/Myzel394/jsonfly.nvim",
|
|
||||||
dependencies = {
|
|
||||||
"phelipetls/jsonpath.nvim"
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
* [jsonpath.nvim](https://github.com/phelipetls/jsonpath.nvim) - Copy JSON paths to your clipboard
|
* [jsonpath.nvim](https://github.com/phelipetls/jsonpath.nvim) - Copy JSON paths to your clipboard
|
||||||
|
61
flake.lock
generated
61
flake.lock
generated
@ -1,61 +0,0 @@
|
|||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1748929857,
|
|
||||||
"narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"utils": "utils"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
44
flake.nix
44
flake.nix
@ -1,44 +0,0 @@
|
|||||||
{
|
|
||||||
description = "jsonfly";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
||||||
utils.url = "github:numtide/flake-utils";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { nixpkgs, utils, ... } @ inputs:
|
|
||||||
utils.lib.eachDefaultSystem(system:
|
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
logo = pkgs.writeText "logo.txt" ''
|
|
||||||
▄█ ▄████████ ▄██████▄ ███▄▄▄▄ ▄████████ ▄█ ▄██ ▄
|
|
||||||
███ ███ ███ ███ ███ ███▀▀▀██▄ ███ ███ ███ ███ ██▄
|
|
||||||
███ ███ █▀ ███ ███ ███ ███ ███ █▀ ███ ███▄▄▄███
|
|
||||||
███ ███ ███ ███ ███ ███ ▄███▄▄▄ ███ ▀▀▀▀▀▀███
|
|
||||||
███ ▀███████████ ███ ███ ███ ███ ▀▀███▀▀▀ ███ ▄██ ███
|
|
||||||
███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
||||||
███ ▄█ ███ ███ ███ ███ ███ ███ ███▌ ▄ ███ ███
|
|
||||||
█▄ ▄███ ▄████████▀ ▀██████▀ ▀█ █▀ ███ █████▄▄██ ▀█████▀
|
|
||||||
▀▀▀▀▀▀ ▀
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
just
|
|
||||||
stylua
|
|
||||||
|
|
||||||
# If this ever fails, just remove it. It's just for the logo.
|
|
||||||
lolcat
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
cat ${logo} | lolcat
|
|
||||||
echo "";
|
|
||||||
echo "Welcome to the jsonfly.nvim development environment!";
|
|
||||||
echo "";
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
10
justfile
10
justfile
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env just --justfile
|
|
||||||
|
|
||||||
set dotenv-load := true
|
|
||||||
|
|
||||||
_default:
|
|
||||||
just --list -u
|
|
||||||
|
|
||||||
lint:
|
|
||||||
stylua lua
|
|
||||||
|
|
@ -205,12 +205,4 @@ function M:extract_key_description(text)
|
|||||||
return keys
|
return keys
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param name string
|
|
||||||
---@return boolean
|
|
||||||
function M:is_module_available(name)
|
|
||||||
return pcall(function()
|
|
||||||
require(name)
|
|
||||||
end) == true
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
--
|
--
|
||||||
---@class Commands
|
---@class Commands
|
||||||
---@field add_key string[] - Add the currently entered key to the JSON. Must be of type [string, string] <mode, key>; Example: {"n", "a"} -> When in normal mode, press "a" to add the key; Example: {"i", "<C-a>"} -> When in insert mode, press <C-a> to add the key; Default: {"i", "<C-a>"}
|
---@field add_key string[] - Add the currently entered key to the JSON. Must be of type [string, string] <mode, key>; Example: {"n", "a"} -> When in normal mode, press "a" to add the key; Example: {"i", "<C-a>"} -> When in insert mode, press <C-a> to add the key; Default: {"i", "<C-a>"}
|
||||||
---@field copy_jsonpath [string, string, function] - Copy the JSONPath of the currently selected key. jsonpath must be installed. Must be of type [string, string, function] <mode, key, (path: string, bufnr: number) -> void> - Example: {"n", "<C-j>", function(path) vim.fn.setreg("+", path) end} -> When in normal mode, press <C-j> to copy the JSONPath to the clipboard; Default: {"i", "<C-j>", a function that will copy the JSONPath to the clipboard}
|
|
||||||
---
|
---
|
||||||
---@class Highlights
|
---@class Highlights
|
||||||
---@field number string - Highlight group for numbers, Default: "@number.json"
|
---@field number string - Highlight group for numbers, Default: "@number.json"
|
||||||
@ -62,20 +61,6 @@ local DEFAULT_CONFIG = {
|
|||||||
use_cache = 500,
|
use_cache = 500,
|
||||||
commands = {
|
commands = {
|
||||||
add_key = { "i", "<C-a>" },
|
add_key = { "i", "<C-a>" },
|
||||||
copy_jsonpath = {
|
|
||||||
"i",
|
|
||||||
"<C-j>",
|
|
||||||
---@param path string
|
|
||||||
---@param prompt_bufnr number
|
|
||||||
function(path, prompt_bufnr)
|
|
||||||
vim.fn.setreg("+", path)
|
|
||||||
|
|
||||||
vim.notify(
|
|
||||||
'copied JSONPath "' .. utils:truncate_overflow(path, 35, "…") .. '" to clipboard',
|
|
||||||
vim.log.levels.INFO
|
|
||||||
)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,34 +102,6 @@ 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
|
|
||||||
map(
|
|
||||||
global_config.commands.copy_jsonpath[1],
|
|
||||||
global_config.commands.copy_jsonpath[2],
|
|
||||||
function(prompt_bufnr)
|
|
||||||
local jsonpath = require("jsonpath")
|
|
||||||
|
|
||||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
|
||||||
local selection = current_picker:get_selection()
|
|
||||||
|
|
||||||
local path = jsonpath.get(
|
|
||||||
vim.treesitter.get_node({
|
|
||||||
bufnr = buffer,
|
|
||||||
pos = {
|
|
||||||
selection.lnum - 1,
|
|
||||||
selection.col,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
buffer
|
|
||||||
)
|
|
||||||
|
|
||||||
if path then
|
|
||||||
global_config.commands.copy_jsonpath[3](path, prompt_bufnr)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
finder = finders.new_table({
|
finder = finders.new_table({
|
||||||
@ -239,10 +196,7 @@ return require("telescope").register_extension({
|
|||||||
end
|
end
|
||||||
|
|
||||||
if global_config.backend == "lsp" then
|
if global_config.backend == "lsp" then
|
||||||
local params = vim.lsp.util.make_position_params(
|
local params = vim.lsp.util.make_position_params(xopts.winnr)
|
||||||
xopts.winnr,
|
|
||||||
"utf-8"
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Check i
|
-- Check i
|
||||||
local clients = vim.lsp.get_clients()
|
local clients = vim.lsp.get_clients()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user